aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-02-28 18:22:43 -0500
committerAndrew Kelley <superjoe30@gmail.com>2018-02-28 18:22:43 -0500
commit58dc2b719c8e5a13c91ebbbbf476998c7f3e925b (patch)
tree34ae2eb4d0624b69045ae79f23716357d0b2393b /src
parentad2a29ccf25af189fc180cba6843c20b9dd029d1 (diff)
downloadzig-58dc2b719c8e5a13c91ebbbbf476998c7f3e925b.tar.gz
zig-58dc2b719c8e5a13c91ebbbbf476998c7f3e925b.zip
better coroutine codegen, now passing first coro test
we have to use the Suspend block with llvm.coro.end to return from the coro
Diffstat (limited to 'src')
-rw-r--r--src/ir.cpp9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index e9f29d1caa..06a23af07c 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -6225,19 +6225,14 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec
ir_build_call(irb, scope, node, nullptr, free_fn, arg_count, args, false, FnInlineAuto, false, nullptr);
IrBasicBlock *resume_block = ir_create_basic_block(irb, scope, "Resume");
- IrBasicBlock *return_block = ir_create_basic_block(irb, scope, "Return");
- ir_build_cond_br(irb, scope, node, resume_awaiter, resume_block, return_block, const_bool_false);
+ ir_build_cond_br(irb, scope, node, resume_awaiter, resume_block, irb->exec->coro_suspend_block, const_bool_false);
ir_set_cursor_at_end_and_append_block(irb, resume_block);
IrInstruction *unwrapped_await_handle_ptr = ir_build_unwrap_maybe(irb, scope, node,
irb->exec->coro_awaiter_field_ptr, false);
IrInstruction *awaiter_handle = ir_build_load_ptr(irb, scope, node, unwrapped_await_handle_ptr);
ir_build_coro_resume(irb, scope, node, awaiter_handle);
- ir_build_br(irb, scope, node, return_block, const_bool_false);
-
- ir_set_cursor_at_end_and_append_block(irb, return_block);
- IrInstruction *undef = ir_build_const_undefined(irb, scope, node);
- ir_build_return(irb, scope, node, undef);
+ ir_build_br(irb, scope, node, irb->exec->coro_suspend_block, const_bool_false);
}
return true;