authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-02-27 17:47:18-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-02-27 17:47:18-05:00
logd24345386274e3abcbcc676fe65bda127c06ce8e
treeb5945c207d3ce6dff2631af9c30f35d2e72c6c55
parent138d6f909321fb4fddeaa172357336c384c64eda

Revert "llvm coroutine workaround: sret functions return sret pointer"

This reverts commit 132e604aa399a3bcb91996e550cf8972bd88422c. this workaround didn't work either

2 files changed, 4 insertions(+), 14 deletions(-)

src/analyze.cpp+1-4
......@@ -1026,10 +1026,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
10261026 gen_param_index += 1;
10271027 // after the gen_param_index += 1 because 0 is the return type
10281028 param_di_types[gen_param_index] = gen_type->di_type;
1029
1030 // as a workaround for LLVM coroutines not understanding instruction dependencies,
1031 // we return the sret pointer argument instead of returning void
1032 gen_return_type = gen_type;
1029 gen_return_type = g->builtin_types.entry_void;
10331030 } else {
10341031 gen_return_type = fn_type_id->return_type;
10351032 }
src/codegen.cpp+3-10
......@@ -547,10 +547,7 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) {
547547 } else if (handle_is_ptr(return_type) &&
548548 calling_convention_does_first_arg_return(fn_type->data.fn.fn_type_id.cc))
549549 {
550 // We do not add the sret attribute, because it would require the return type to be void,
551 // and we want the return value to return the sret pointer, to work around LLVM Coroutine
552 // transformation passes not understanding the data dependency.
553 //addLLVMArgAttr(fn_table_entry->llvm_value, 0, "sret");
550 addLLVMArgAttr(fn_table_entry->llvm_value, 0, "sret");
554551 addLLVMArgAttr(fn_table_entry->llvm_value, 0, "nonnull");
555552 }
556553
......@@ -1619,9 +1616,7 @@ static LLVMValueRef ir_render_return(CodeGen *g, IrExecutable *executable, IrIns
16191616 if (calling_convention_does_first_arg_return(g->cur_fn->type_entry->data.fn.fn_type_id.cc)) {
16201617 assert(g->cur_ret_ptr);
16211618 gen_assign_raw(g, g->cur_ret_ptr, get_pointer_to_type(g, return_type, false), value);
1622 // as a workaround for LLVM coroutines not understanding instruction dependencies,
1623 // we return the sret pointer argument instead of returning void
1624 LLVMBuildRet(g->builder, g->cur_ret_ptr);
1619 LLVMBuildRetVoid(g->builder);
16251620 } else {
16261621 LLVMValueRef by_val_value = gen_load_untyped(g, value, 0, false, "");
16271622 LLVMBuildRet(g->builder, by_val_value);
......@@ -2774,9 +2769,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
27742769 } else if (!ret_has_bits) {
27752770 return nullptr;
27762771 } else if (first_arg_ret) {
2777 // instead of returning instruction->tmp_ptr here, we trust that the function returned the first arg.
2778 // this is a workaround for llvm coroutines not understanding the data dependency
2779 return result;
2772 return instruction->tmp_ptr;
27802773 } else {
27812774 return result;
27822775 }