authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-03-02 13:40:03-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-03-02 13:40:03-05:00
log101b7745c4da1fdf0ebe723710fe8b195013fc0e
tree4a56c931cb3eb5620c84fb4bbfe95ec0c73d24f8
parent7d494b3e7b09403358232dc61f45374d6c26905f

add optnone noinline to async functions

this works around LLVM optimization assertion failures. https://bugs.llvm.org/show_bug.cgi?id=36578 closes #800

2 files changed, 5 insertions(+), 11 deletions(-)

src/codegen.cpp+4
......@@ -489,6 +489,10 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) {
489489 } else {
490490 LLVMSetFunctionCallConv(fn_table_entry->llvm_value, get_llvm_cc(g, fn_type->data.fn.fn_type_id.cc));
491491 }
492 if (fn_type->data.fn.fn_type_id.cc == CallingConventionAsync) {
493 addLLVMFnAttr(fn_table_entry->llvm_value, "optnone");
494 addLLVMFnAttr(fn_table_entry->llvm_value, "noinline");
495 }
492496
493497 bool want_cold = fn_table_entry->is_cold || fn_type->data.fn.fn_type_id.cc == CallingConventionCold;
494498 if (want_cold) {
test/behavior.zig+1-11
......@@ -13,6 +13,7 @@ comptime {
1313 _ = @import("cases/bugs/656.zig");
1414 _ = @import("cases/cast.zig");
1515 _ = @import("cases/const_slice_child.zig");
16 _ = @import("cases/coroutines.zig");
1617 _ = @import("cases/defer.zig");
1718 _ = @import("cases/enum.zig");
1819 _ = @import("cases/enum_with_members.zig");
......@@ -49,15 +50,4 @@ comptime {
4950 _ = @import("cases/var_args.zig");
5051 _ = @import("cases/void.zig");
5152 _ = @import("cases/while.zig");
52
53
54 // LLVM 5.0.1, 6.0.0, and trunk crash when attempting to optimize coroutine code.
55 // So, Zig does not support ReleaseFast or ReleaseSafe for coroutines yet.
56 // Luckily, Clang users are running into the same crashes, so folks from the LLVM
57 // community are working on fixes. If we're really lucky they'll be fixed in 6.0.1.
58 // Otherwise we can hope for 7.0.0.
59 if (builtin.mode == builtin.Mode.Debug) {
60 _ = @import("cases/coroutines.zig");
61 }
62
6353}