diff --git a/llvm/include/llvm/Analysis/ScalarEvolution.h b/llvm/include/llvm/Analysis/ScalarEvolution.h --- a/llvm/include/llvm/Analysis/ScalarEvolution.h +++ b/llvm/include/llvm/Analysis/ScalarEvolution.h @@ -542,8 +542,8 @@ /// Notify this ScalarEvolution that \p User directly uses SCEVs in \p Ops. void registerUser(const SCEV *User, ArrayRef Ops); - /// Return true if the SCEV expression contains an undef value. - bool containsUndefs(const SCEV *S) const; + /// Return true if the SCEV expression contains a poison value. + bool containsPoison(const SCEV *S) const; /// Return true if the SCEV expression contains a Value that has been /// optimised out and is now a nullptr. diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -7196,7 +7196,7 @@ // to obey basic rules for definitions dominating uses which this // analysis depends on. if (!DT.isReachableFromEntry(I->getParent())) - return getUnknown(UndefValue::get(V->getType())); + return getUnknown(PoisonValue::get(V->getType())); } else if (ConstantInt *CI = dyn_cast(V)) return getConstant(CI); else if (GlobalAlias *GA = dyn_cast(V)) @@ -12813,10 +12813,10 @@ } // Return true when S contains at least an undef value. -bool ScalarEvolution::containsUndefs(const SCEV *S) const { +bool ScalarEvolution::containsPoison(const SCEV *S) const { return SCEVExprContains(S, [](const SCEV *S) { if (const auto *SU = dyn_cast(S)) - return isa(SU->getValue()); + return isa(SU->getValue()); return false; }); } @@ -13516,7 +13516,7 @@ SE2.getReachableBlocks(ReachableBlocks, F); auto GetDelta = [&](const SCEV *Old, const SCEV *New) -> const SCEV * { - if (containsUndefs(Old) || containsUndefs(New)) { + if (containsPoison(Old) || containsPoison(New)) { // SCEV treats "undef" as an unknown but consistent value (i.e. it does // not propagate undef aggressively). This means we can (and do) fail // verification in cases where a transform makes a value go from "undef" diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp --- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -6389,7 +6389,7 @@ // It's possible that a value referred to in the SCEV may have been // optimised out by LSR. if (SE.containsErasedValue(DVIRec.SCEVs[i]) || - SE.containsUndefs(DVIRec.SCEVs[i])) { + SE.containsPoison(DVIRec.SCEVs[i])) { LLVM_DEBUG(dbgs() << "scev-salvage: SCEV for location at index: " << i << " refers to a location that is now undef or erased. " "Salvage abandoned.\n"); @@ -6522,7 +6522,7 @@ return false; const SCEV *S = SE.getSCEV(LocOp); - if (SE.containsUndefs(S)) + if (SE.containsPoison(S)) return false; } return true; @@ -6558,7 +6558,7 @@ if (!SE.isSCEVable(P->getType())) return false; if (const SCEVAddRecExpr *Rec = dyn_cast(SE.getSCEV(P))) - return Rec->isAffine() && !SE.containsUndefs(SE.getSCEV(P)); + return Rec->isAffine() && !SE.containsPoison(SE.getSCEV(P)); return false; }; diff --git a/llvm/test/Analysis/ScalarEvolution/shift-recurrences.ll b/llvm/test/Analysis/ScalarEvolution/shift-recurrences.ll --- a/llvm/test/Analysis/ScalarEvolution/shift-recurrences.ll +++ b/llvm/test/Analysis/ScalarEvolution/shift-recurrences.ll @@ -389,9 +389,9 @@ ; CHECK-LABEL: 'unreachable_phi' ; CHECK-NEXT: Classifying expressions for: @unreachable_phi ; CHECK-NEXT: %p_58.addr.1 = phi i32 [ undef, %unreachable1 ], [ %sub2629, %unreachable2 ] -; CHECK-NEXT: --> undef U: full-set S: full-set +; CHECK-NEXT: --> poison U: full-set S: full-set ; CHECK-NEXT: %sub2629 = sub i32 %p_58.addr.1, 1 -; CHECK-NEXT: --> undef U: full-set S: full-set +; CHECK-NEXT: --> poison U: full-set S: full-set ; CHECK-NEXT: Determining loop execution counts for: @unreachable_phi ; entry: @@ -415,7 +415,7 @@ ; CHECK-NEXT: %p_58.addr.1 = phi i32 [ undef, %header ], [ %sub2629, %unreachable ] ; CHECK-NEXT: --> %p_58.addr.1 U: full-set S: full-set Exits: <> LoopDispositions: { %header: Variant } ; CHECK-NEXT: %sub2629 = sub i32 %p_58.addr.1, 1 -; CHECK-NEXT: --> undef U: full-set S: full-set +; CHECK-NEXT: --> poison U: full-set S: full-set ; CHECK-NEXT: Determining loop execution counts for: @unreachable_binop ; CHECK-NEXT: Loop %header: Unpredictable backedge-taken count. ; CHECK-NEXT: Loop %header: Unpredictable max backedge-taken count. diff --git a/llvm/test/Analysis/ScalarEvolution/unreachable-code.ll b/llvm/test/Analysis/ScalarEvolution/unreachable-code.ll --- a/llvm/test/Analysis/ScalarEvolution/unreachable-code.ll +++ b/llvm/test/Analysis/ScalarEvolution/unreachable-code.ll @@ -1,7 +1,7 @@ ; RUN: opt < %s -disable-output "-passes=print" 2>&1 | FileCheck %s ; CHECK: %t = add i64 %t, 1 -; CHECK: --> undef +; CHECK: --> poison define void @foo() { entry: