Skip to content

Commit

Permalink
don't look for SLOT_USEDUNDEF when folding :isdefined expr
Browse files Browse the repository at this point in the history
`SLOT_USEDUNDEF` is such a flag that has the following meaning:
> slot has uses that might raise UndefVarError

Since `Expr(:isdefined, slot)` doesn't raise `UndefVarError`, it sounds
incorrect conceptually to look for it when folding a `:isdefined`
expression to `true`.
  • Loading branch information
aviatesk committed May 7, 2022
1 parent 3e9cecd commit 4bc7ffc
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions base/compiler/ssair/slot2ssa.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,11 @@ function fixemup!(cond, rename, ir::IRCode, ci::CodeInfo, idx::Int, @nospecializ
if isexpr(stmt, :isdefined)
val = stmt.args[1]
if isa(val, Union{SlotNumber, TypedSlot})
slot = slot_id(val)
if (ci.slotflags[slot] & SLOT_USEDUNDEF) == 0
ssa = rename(val)
if ssa === UNDEF_TOKEN
return false
elseif !isa(ssa, SSAValue) && !isa(ssa, NewSSAValue)
return true
else
ssa = rename(val)
if ssa === UNDEF_TOKEN
return false
elseif !isa(ssa, SSAValue) && !isa(ssa, NewSSAValue)
return true
end
end
# temporarily corrupt the isdefined node. type_lift_pass! will fix it
stmt.args[1] = ssa
Expand Down

0 comments on commit 4bc7ffc

Please sign in to comment.