diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-03-02 13:40:03 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-03-02 13:40:03 -0500 |
| commit | 101b7745c4da1fdf0ebe723710fe8b195013fc0e (patch) | |
| tree | 4a56c931cb3eb5620c84fb4bbfe95ec0c73d24f8 | |
| parent | 7d494b3e7b09403358232dc61f45374d6c26905f (diff) | |
| download | zig-101b7745c4da1fdf0ebe723710fe8b195013fc0e.tar.gz zig-101b7745c4da1fdf0ebe723710fe8b195013fc0e.zip | |
add optnone noinline to async functions
this works around LLVM optimization assertion failures.
https://bugs.llvm.org/show_bug.cgi?id=36578
closes #800
| -rw-r--r-- | src/codegen.cpp | 4 | ||||
| -rw-r--r-- | test/behavior.zig | 12 |
2 files changed, 5 insertions, 11 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp index 0cfd27322f..3aa8f63100 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -489,6 +489,10 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) { } else { LLVMSetFunctionCallConv(fn_table_entry->llvm_value, get_llvm_cc(g, fn_type->data.fn.fn_type_id.cc)); } + if (fn_type->data.fn.fn_type_id.cc == CallingConventionAsync) { + addLLVMFnAttr(fn_table_entry->llvm_value, "optnone"); + addLLVMFnAttr(fn_table_entry->llvm_value, "noinline"); + } bool want_cold = fn_table_entry->is_cold || fn_type->data.fn.fn_type_id.cc == CallingConventionCold; if (want_cold) { diff --git a/test/behavior.zig b/test/behavior.zig index b9cfeb8e0b..a8ff7958cf 100644 --- a/test/behavior.zig +++ b/test/behavior.zig @@ -13,6 +13,7 @@ comptime { _ = @import("cases/bugs/656.zig"); _ = @import("cases/cast.zig"); _ = @import("cases/const_slice_child.zig"); + _ = @import("cases/coroutines.zig"); _ = @import("cases/defer.zig"); _ = @import("cases/enum.zig"); _ = @import("cases/enum_with_members.zig"); @@ -49,15 +50,4 @@ comptime { _ = @import("cases/var_args.zig"); _ = @import("cases/void.zig"); _ = @import("cases/while.zig"); - - - // LLVM 5.0.1, 6.0.0, and trunk crash when attempting to optimize coroutine code. - // So, Zig does not support ReleaseFast or ReleaseSafe for coroutines yet. - // Luckily, Clang users are running into the same crashes, so folks from the LLVM - // community are working on fixes. If we're really lucky they'll be fixed in 6.0.1. - // Otherwise we can hope for 7.0.0. - if (builtin.mode == builtin.Mode.Debug) { - _ = @import("cases/coroutines.zig"); - } - } |
