Skip to content

Commit cf1f006

Browse files
authored
Enforce only capturing function parent scope (#2694)
1 parent 438de4e commit cf1f006

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/errors.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,10 +382,14 @@ function julia_error(
382382
bt = GPUCompiler.backtrace(val)
383383
end
384384
end
385+
elseif val isa LLVM.Function
386+
# Need to convert function to string, since when the error is going to be printed
387+
# the module might have been destroyed
388+
ir = string(val)
385389
else
386390
# Need to convert function to string, since when the error is going to be printed
387391
# the module might have been destroyed
388-
ir = string(parent_scope(val))
392+
ir = string(parent_scope(val)::LLVM.Function)
389393
end
390394
end
391395

@@ -426,7 +430,7 @@ function julia_error(
426430

427431
msgN = sprint() do io::IO
428432
if isa(val, LLVM.Argument)
429-
fn = parent_scope(val)
433+
fn = parent_scope(val)::LLVM.Function
430434
ir = string(LLVM.name(fn)) * string(function_type(fn))
431435
print(io, "Current scope: \n")
432436
print(io, ir)
@@ -496,7 +500,7 @@ function julia_error(
496500
Base.show_backtrace(io, bt)
497501
println(io)
498502
end
499-
pscope = parent_scope(val)
503+
pscope = parent_scope(val)::LLVM.Function
500504
mi, rt = enzyme_custom_extract_mi(pscope, false) #=error=#
501505
if mi !== nothing
502506
println(io, "within ", mi)

0 commit comments

Comments
 (0)