|
1 | 1 | # This file is a part of Julia. License is MIT: https://julialang.org/license
|
2 | 2 |
|
| 3 | +irshow_was_loaded() = invokelatest(isdefined, Compiler.IRShow, :debuginfo_firstline) |
3 | 4 | function maybe_show_ir(ir::IRCode)
|
4 |
| - if isdefined(Core, :Main) && isdefined(Core.Main, :Base) |
| 5 | + if irshow_was_loaded() |
5 | 6 | # ensure we use I/O that does not yield, as this gets called during compilation
|
6 | 7 | invokelatest(Core.Main.Base.show, Core.stdout, "text/plain", ir)
|
7 | 8 | else
|
@@ -104,15 +105,16 @@ function count_int(val::Int, arr::Vector{Int})
|
104 | 105 | n
|
105 | 106 | end
|
106 | 107 |
|
| 108 | +_debuginfo_firstline(debuginfo::Union{DebugInfo,DebugInfoStream}) = IRShow.debuginfo_firstline(debuginfo) |
107 | 109 | function verify_ir(ir::IRCode, print::Bool=true,
|
108 | 110 | allow_frontend_forms::Bool=false,
|
109 | 111 | 𝕃ₒ::AbstractLattice = SimpleInferenceLattice.instance,
|
110 | 112 | mi::Union{Nothing,MethodInstance}=nothing)
|
111 | 113 | function raise_error()
|
112 | 114 | error_args = Any["IR verification failed."]
|
113 |
| - if isdefined(Core, :Main) && isdefined(Core.Main, :Base) |
| 115 | + if irshow_was_loaded() |
114 | 116 | # 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) |
116 | 118 | else
|
117 | 119 | firstline = nothing
|
118 | 120 | end
|
|
0 commit comments