aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-06-20 18:15:27 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-06-20 18:27:04 -0400
commit237233b04bdbbb82a5ce881a074fdd4ca55fe58f (patch)
treefad7ac5a1a052d1f9b12f94a45ed1a0154dda2c8 /src
parent057b105fadb1b60d0927cb878e795c9e7ac9bdb1 (diff)
downloadzig-237233b04bdbbb82a5ce881a074fdd4ca55fe58f.tar.gz
zig-237233b04bdbbb82a5ce881a074fdd4ca55fe58f.zip
fix coroutines
Diffstat (limited to 'src')
-rw-r--r--src/codegen.cpp2
-rw-r--r--src/ir.cpp8
2 files changed, 8 insertions, 2 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp
index 5cb65b38f3..79c92964f6 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -3755,7 +3755,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
bool prefix_arg_err_ret_stack = get_prefix_arg_err_ret_stack(g, fn_type_id);
bool is_var_args = fn_type_id->is_var_args;
ZigList<LLVMValueRef> gen_param_values = {};
- LLVMValueRef result_loc = first_arg_ret ? ir_llvm_value(g, instruction->result_loc) : nullptr;
+ LLVMValueRef result_loc = (first_arg_ret || instruction->is_async) ? ir_llvm_value(g, instruction->result_loc) : nullptr;
if (first_arg_ret) {
gen_param_values.append(result_loc);
}
diff --git a/src/ir.cpp b/src/ir.cpp
index 4dbc20cf48..c3ed14770f 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -15252,8 +15252,14 @@ static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCallSrc
ZigType *promise_type = get_promise_type(ira->codegen, return_type);
ZigType *async_return_type = get_error_union_type(ira->codegen, alloc_fn_error_set_type, promise_type);
+ IrInstruction *result_loc = ir_resolve_result(ira, &call_instruction->base, no_result_loc(),
+ async_return_type, nullptr, true, true);
+ if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) {
+ return result_loc;
+ }
+
return ir_build_call_gen(ira, &call_instruction->base, fn_entry, fn_ref, arg_count,
- casted_args, FnInlineAuto, true, async_allocator_inst, nullptr, nullptr,
+ casted_args, FnInlineAuto, true, async_allocator_inst, nullptr, result_loc,
async_return_type);
}