Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/irgen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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