Skip to content

Commit

Permalink
irinterp: Add handling for :throw_undef_if_not (JuliaLang#50303)
Browse files Browse the repository at this point in the history
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 JuliaLang#49692, so this just needed to be wired up
properly.
  • Loading branch information
Keno authored Jun 27, 2023
1 parent 6f26e4f commit 0e147eb
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions base/compiler/ssair/irinterp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,16 @@ function reprocess_instruction!(interp::AbstractInterpreter, idx::Int, bb::Union
if nothrow
ir.stmts[idx][:flag] |= IR_FLAG_NOTHROW
end
elseif head === :throw_undef_if_not || # TODO: Terminate interpretation early if known false?
head === :gc_preserve_begin ||
elseif head === :throw_undef_if_not
condval = maybe_extract_const_bool(argextype(inst.args[2], ir))
condval isa Bool || return false
if condval
ir.stmts[idx][:inst] = nothing
# We simplified the IR, but we did not update the type
return false
end
rt = Union{}
elseif head === :gc_preserve_begin ||
head === :gc_preserve_end
return false
else
Expand Down

0 comments on commit 0e147eb

Please sign in to comment.