Skip to content

Commit 0a7da08

Browse files
KenoKristofferC
authored andcommitted
Compiler: Fix check for IRShow definedness (#57420)
Should fix the error part of #57329. I also cannot reproduce the underlying assertion error on master, so that was likely fixed in one of the other PRs. Closes #57329 as a result, but of course there could be other issues with the same symptoms, which can get their own issues. (cherry picked from commit 88b292d)
1 parent 67eb453 commit 0a7da08

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Compiler/src/ssair/verify.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

3+
irshow_was_loaded() = invokelatest(isdefined, Compiler.IRShow, :debuginfo_firstline)
34
function maybe_show_ir(ir::IRCode)
4-
if isdefined(Core, :Main) && isdefined(Core.Main, :Base)
5+
if irshow_was_loaded()
56
# ensure we use I/O that does not yield, as this gets called during compilation
67
invokelatest(Core.Main.Base.show, Core.stdout, "text/plain", ir)
78
else
@@ -104,15 +105,16 @@ function count_int(val::Int, arr::Vector{Int})
104105
n
105106
end
106107

108+
_debuginfo_firstline(debuginfo::Union{DebugInfo,DebugInfoStream}) = IRShow.debuginfo_firstline(debuginfo)
107109
function verify_ir(ir::IRCode, print::Bool=true,
108110
allow_frontend_forms::Bool=false,
109111
𝕃ₒ::AbstractLattice = SimpleInferenceLattice.instance,
110112
mi::Union{Nothing,MethodInstance}=nothing)
111113
function raise_error()
112114
error_args = Any["IR verification failed."]
113-
if isdefined(Core, :Main) && isdefined(Core.Main, :Base)
115+
if irshow_was_loaded()
114116
# ensure we use I/O that does not yield, as this gets called during compilation
115-
firstline = invokelatest(IRShow.debuginfo_firstline, ir.debuginfo)
117+
firstline = invokelatest(_debuginfo_firstline, ir.debuginfo)
116118
else
117119
firstline = nothing
118120
end

0 commit comments

Comments
 (0)