From 8440e60e084123f9ed85ab0282348b86ad86bca5 Mon Sep 17 00:00:00 2001 From: Keno Fischer Date: Fri, 4 Jan 2019 22:08:17 -0500 Subject: [PATCH] Defensively fix patterns similar to #29983 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. --- base/compiler/ssair/passes.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/base/compiler/ssair/passes.jl b/base/compiler/ssair/passes.jl index 67d8f92f9fe1a9..12cd0cd582f8c0 100644 --- a/base/compiler/ssair/passes.jl +++ b/base/compiler/ssair/passes.jl @@ -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 @@ -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) @@ -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) @@ -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