diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-02-27 17:47:18 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-02-27 17:47:18 -0500 |
| commit | d24345386274e3abcbcc676fe65bda127c06ce8e (patch) | |
| tree | b5945c207d3ce6dff2631af9c30f35d2e72c6c55 | |
| parent | 138d6f909321fb4fddeaa172357336c384c64eda (diff) | |
| download | zig-d24345386274e3abcbcc676fe65bda127c06ce8e.tar.gz zig-d24345386274e3abcbcc676fe65bda127c06ce8e.zip | |
Revert "llvm coroutine workaround: sret functions return sret pointer"
This reverts commit 132e604aa399a3bcb91996e550cf8972bd88422c.
this workaround didn't work either
| -rw-r--r-- | src/analyze.cpp | 5 | ||||
| -rw-r--r-- | src/codegen.cpp | 13 |
2 files changed, 4 insertions, 14 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index f95c9396cb..ce9e99f8fa 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -1026,10 +1026,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) { gen_param_index += 1; // after the gen_param_index += 1 because 0 is the return type param_di_types[gen_param_index] = gen_type->di_type; - - // as a workaround for LLVM coroutines not understanding instruction dependencies, - // we return the sret pointer argument instead of returning void - gen_return_type = gen_type; + gen_return_type = g->builtin_types.entry_void; } else { gen_return_type = fn_type_id->return_type; } diff --git a/src/codegen.cpp b/src/codegen.cpp index 7fda1eaa3f..d650daa6cb 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -547,10 +547,7 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) { } else if (handle_is_ptr(return_type) && calling_convention_does_first_arg_return(fn_type->data.fn.fn_type_id.cc)) { - // We do not add the sret attribute, because it would require the return type to be void, - // and we want the return value to return the sret pointer, to work around LLVM Coroutine - // transformation passes not understanding the data dependency. - //addLLVMArgAttr(fn_table_entry->llvm_value, 0, "sret"); + addLLVMArgAttr(fn_table_entry->llvm_value, 0, "sret"); addLLVMArgAttr(fn_table_entry->llvm_value, 0, "nonnull"); } @@ -1619,9 +1616,7 @@ static LLVMValueRef ir_render_return(CodeGen *g, IrExecutable *executable, IrIns if (calling_convention_does_first_arg_return(g->cur_fn->type_entry->data.fn.fn_type_id.cc)) { assert(g->cur_ret_ptr); gen_assign_raw(g, g->cur_ret_ptr, get_pointer_to_type(g, return_type, false), value); - // as a workaround for LLVM coroutines not understanding instruction dependencies, - // we return the sret pointer argument instead of returning void - LLVMBuildRet(g->builder, g->cur_ret_ptr); + LLVMBuildRetVoid(g->builder); } else { LLVMValueRef by_val_value = gen_load_untyped(g, value, 0, false, ""); LLVMBuildRet(g->builder, by_val_value); @@ -2774,9 +2769,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr } else if (!ret_has_bits) { return nullptr; } else if (first_arg_ret) { - // instead of returning instruction->tmp_ptr here, we trust that the function returned the first arg. - // this is a workaround for llvm coroutines not understanding the data dependency - return result; + return instruction->tmp_ptr; } else { return result; } |
