Skip to content

Commit 6205aa2

Browse files
committed
irinterp: Add handling for :throw_undef_if_not
This addresses an existing TODO to terminate irinterp on discovering a :throw_undef_if_not that is dead. The underlying infrastructure to do this was added in #49692, so this just needed to be wired up properly.
1 parent 76c906e commit 6205aa2

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

base/compiler/ssair/irinterp.jl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,16 @@ function reprocess_instruction!(interp::AbstractInterpreter, idx::Int, bb::Union
130130
if nothrow
131131
ir.stmts[idx][:flag] |= IR_FLAG_NOTHROW
132132
end
133-
elseif head === :throw_undef_if_not || # TODO: Terminate interpretation early if known false?
134-
head === :gc_preserve_begin ||
133+
elseif head === :throw_undef_if_not
134+
condval = maybe_extract_const_bool(argextype(inst.args[2], ir))
135+
condval isa Bool || return false
136+
if condval
137+
ir.stmts[idx][:inst] = nothing
138+
# We simplified the IR, but we did not update the type
139+
return false
140+
end
141+
rt = Union{}
142+
elseif head === :gc_preserve_begin ||
135143
head === :gc_preserve_end
136144
return false
137145
else

0 commit comments

Comments
 (0)