diff --git a/src/irgen.jl b/src/irgen.jl index 919d9793..c8e2d75d 100644 --- a/src/irgen.jl +++ b/src/irgen.jl @@ -265,11 +265,14 @@ function emit_exception!(builder, name, inst) # report the exception if Base.JLOptions().debug_level >= 1 name = globalstring_ptr!(builder, name, "exception") - if Base.JLOptions().debug_level == 1 + c = if Base.JLOptions().debug_level == 1 call!(builder, Runtime.get(:report_exception), [name]) else call!(builder, Runtime.get(:report_exception_name), [name]) end + callsite_attribute!(c, ( + LLVM.EnumAttribute("inaccessiblememonly", 0; ctx), + LLVM.EnumAttribute("writeonly", 0; ctx))) end # report each frame @@ -287,7 +290,10 @@ function emit_exception!(builder, name, inst) end # signal the exception - call!(builder, Runtime.get(:signal_exception)) + c = call!(builder, Runtime.get(:signal_exception)) + callsite_attribute!(c, ( + LLVM.EnumAttribute("inaccessiblememonly", 0; ctx), + LLVM.EnumAttribute("writeonly", 0; ctx))) emit_trap!(job, builder, mod, inst) end diff --git a/src/utils.jl b/src/utils.jl index f3190440..bbed9836 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -113,3 +113,10 @@ macro unlocked(ex) end esc(combinedef(def)) end + +function callsite_attribute!(call, attributes) + # TODO: Make a nice API for this in LLVM.jl + for attribute in attributes + LLVM.API.LLVMAddCallSiteAttribute(call, LLVM.API.LLVMAttributeFunctionIndex, attribute) + end +end