Skip to content

Commit

Permalink
Defensively fix patterns similar to #29983
Browse files Browse the repository at this point in the history
I don't have concrete tests for these, but it looks like
they all need the `is_old` predicate for what they're doing,
so switch those over also while we're at it.
  • Loading branch information
Keno authored and KristofferC committed Apr 20, 2019
1 parent fd1f187 commit 8ec20f4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions base/compiler/ssair/passes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function simple_walk(compact::IncrementalCompact, @nospecialize(defssa#=::AnySSA
return defssa
end
if isa(def.val, SSAValue)
if isa(defssa, OldSSAValue) && !already_inserted(compact, defssa)
if is_old(compact, defssa)
defssa = OldSSAValue(def.val.id)
else
defssa = def.val
Expand Down Expand Up @@ -281,7 +281,7 @@ function lift_leaves(compact::IncrementalCompact, @nospecialize(stmt),
end
if is_tuple_call(compact.ir, def) && isa(field, Int) && 1 <= field < length(def.args)
lifted = def.args[1+field]
if isa(leaf, OldSSAValue) && isa(lifted, SSAValue)
if is_old(compact, leaf) && isa(lifted, SSAValue)
lifted = OldSSAValue(lifted.id)
end
if isa(lifted, GlobalRef) || isa(lifted, Expr)
Expand Down Expand Up @@ -320,7 +320,7 @@ function lift_leaves(compact::IncrementalCompact, @nospecialize(stmt),
compact[leaf] = def
end
lifted = def.args[1+field]
if isa(leaf, OldSSAValue) && isa(lifted, SSAValue)
if is_old(compact, leaf) && isa(lifted, SSAValue)
lifted = OldSSAValue(lifted.id)
end
if isa(lifted, GlobalRef) || isa(lifted, Expr)
Expand All @@ -339,7 +339,7 @@ function lift_leaves(compact::IncrementalCompact, @nospecialize(stmt),
# N.B.: This can be a bit dangerous because it can lead to
# infinite loops if we accidentally insert a node just ahead
# of where we are
if isa(leaf, OldSSAValue) && (isa(field, Int) || isa(field, Symbol))
if is_old(compact, leaf) && (isa(field, Int) || isa(field, Symbol))
(isa(typ, DataType) && (!typ.abstract)) || return nothing
@assert !typ.mutable
# If there's the potential for an undefref error on access, we cannot insert a getfield
Expand Down

0 comments on commit 8ec20f4

Please sign in to comment.