-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[llvm] Replace UndefValue placeholders with PoisonValue
#116453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
9be09bb to
8553393
Compare
8553393 to
e1552a6
Compare
|
@llvm/pr-subscribers-llvm-analysis @llvm/pr-subscribers-llvm-ir Author: Lee Wei (leewei05) ChangesThis PR replaces all @nunoplopes @regehr Full diff: https://github.com/llvm/llvm-project/pull/116453.diff 5 Files Affected:
diff --git a/llvm/unittests/Analysis/BranchProbabilityInfoTest.cpp b/llvm/unittests/Analysis/BranchProbabilityInfoTest.cpp
index 898dfef83a6e39..38dec6bd41c085 100644
--- a/llvm/unittests/Analysis/BranchProbabilityInfoTest.cpp
+++ b/llvm/unittests/Analysis/BranchProbabilityInfoTest.cpp
@@ -50,7 +50,7 @@ TEST_F(BranchProbabilityInfoTest, StressUnreachableHeuristic) {
// define void @f() {
// entry:
- // switch i32 undef, label %exit, [
+ // switch i32 poison, label %exit, [
// i32 0, label %preexit
// ... ;;< Add lots of cases to stress the heuristic.
// ]
@@ -69,8 +69,8 @@ TEST_F(BranchProbabilityInfoTest, StressUnreachableHeuristic) {
unsigned NumCases = 4096;
auto *I32 = IntegerType::get(C, 32);
- auto *Undef = UndefValue::get(I32);
- auto *Switch = SwitchInst::Create(Undef, ExitBB, NumCases, EntryBB);
+ auto *Poison = PoisonValue::get(I32);
+ auto *Switch = SwitchInst::Create(Poison, ExitBB, NumCases, EntryBB);
for (unsigned I = 0; I < NumCases; ++I)
Switch->addCase(ConstantInt::get(I32, I), PreExitBB);
diff --git a/llvm/unittests/Analysis/MemorySSATest.cpp b/llvm/unittests/Analysis/MemorySSATest.cpp
index 81784bb2360975..0ebbc881d26ab3 100644
--- a/llvm/unittests/Analysis/MemorySSATest.cpp
+++ b/llvm/unittests/Analysis/MemorySSATest.cpp
@@ -705,7 +705,7 @@ TEST_F(MemorySSATest, PartialWalkerCacheWithPhis) {
BasicBlock *IfThen = BasicBlock::Create(C, "B", F);
BasicBlock *IfEnd = BasicBlock::Create(C, "C", F);
- B.CreateCondBr(UndefValue::get(Type::getInt1Ty(C)), IfThen, IfEnd);
+ B.CreateCondBr(PoisonValue::get(Type::getInt1Ty(C)), IfThen, IfEnd);
B.SetInsertPoint(IfThen);
Instruction *FirstStore = B.CreateStore(Zero, AllocA);
diff --git a/llvm/unittests/Analysis/ScalarEvolutionTest.cpp b/llvm/unittests/Analysis/ScalarEvolutionTest.cpp
index 3450302f36f617..c72cecbba3cb8c 100644
--- a/llvm/unittests/Analysis/ScalarEvolutionTest.cpp
+++ b/llvm/unittests/Analysis/ScalarEvolutionTest.cpp
@@ -133,7 +133,7 @@ TEST_F(ScalarEvolutionsTest, SimplifiedPHI) {
BasicBlock *LoopBB = BasicBlock::Create(Context, "loop", F);
BasicBlock *ExitBB = BasicBlock::Create(Context, "exit", F);
BranchInst::Create(LoopBB, EntryBB);
- BranchInst::Create(LoopBB, ExitBB, UndefValue::get(Type::getInt1Ty(Context)),
+ BranchInst::Create(LoopBB, ExitBB, PoisonValue::get(Type::getInt1Ty(Context)),
LoopBB);
ReturnInst::Create(Context, nullptr, ExitBB);
auto *Ty = Type::getInt32Ty(Context);
@@ -328,11 +328,11 @@ TEST_F(ScalarEvolutionsTest, CompareSCEVComplexity) {
for (int i = 0; i < 8; i++) {
PHINode *Phi = cast<PHINode>(&*II++);
Phi->addIncoming(Acc[i], LoopBB);
- Phi->addIncoming(UndefValue::get(Ty), EntryBB);
+ Phi->addIncoming(PoisonValue::get(Ty), EntryBB);
}
BasicBlock *ExitBB = BasicBlock::Create(Context, "bb2", F);
- BranchInst::Create(LoopBB, ExitBB, UndefValue::get(Type::getInt1Ty(Context)),
+ BranchInst::Create(LoopBB, ExitBB, PoisonValue::get(Type::getInt1Ty(Context)),
LoopBB);
Acc[0] = BinaryOperator::CreateAdd(Acc[0], Acc[1], "", ExitBB);
@@ -491,7 +491,7 @@ TEST_F(ScalarEvolutionsTest, SCEVNormalization) {
" %iv1 = phi i32 [ %iv1.inc, %loop ], [ -2147483648, %loop.ph ] "
" %iv0.inc = add i32 %iv0, 1 "
" %iv1.inc = add i32 %iv1, 3 "
- " br i1 undef, label %for.end.loopexit, label %loop "
+ " br i1 poison, label %for.end.loopexit, label %loop "
" "
"for.end.loopexit: "
" ret void "
@@ -503,19 +503,18 @@ TEST_F(ScalarEvolutionsTest, SCEVNormalization) {
" br label %loop_0 "
" "
"loop_0: "
- " br i1 undef, label %loop_0, label %loop_1 "
+ " br i1 poison, label %loop_0, label %loop_1 "
" "
"loop_1: "
- " br i1 undef, label %loop_2, label %loop_1 "
+ " br i1 poison, label %loop_2, label %loop_1 "
" "
" "
"loop_2: "
- " br i1 undef, label %end, label %loop_2 "
+ " br i1 poison, label %end, label %loop_2 "
" "
"end: "
" ret void "
- "} "
- ,
+ "} ",
Err, C);
assert(M && "Could not parse module?");
@@ -914,7 +913,7 @@ TEST_F(ScalarEvolutionsTest, SCEVAddRecFromPHIwithLargeConstants) {
%1 = shl i64 %0, 32
%2 = ashr exact i64 %1, 32
%3 = add i64 %2, -9223372036854775808
- br i1 undef, label %exit, label %loop
+ br i1 poison, label %exit, label %loop
exit:
ret void
*/
@@ -929,7 +928,7 @@ TEST_F(ScalarEvolutionsTest, SCEVAddRecFromPHIwithLargeConstants) {
ConstantInt::get(Context, APInt(64, 0x8000000000000000U, true));
auto *Int64_32 = ConstantInt::get(Context, APInt(64, 32));
auto *Br = BranchInst::Create(
- LoopBB, ExitBB, UndefValue::get(Type::getInt1Ty(Context)), LoopBB);
+ LoopBB, ExitBB, PoisonValue::get(Type::getInt1Ty(Context)), LoopBB);
auto *Phi =
PHINode::Create(Type::getInt64Ty(Context), 2, "", Br->getIterator());
auto *Shl = BinaryOperator::CreateShl(Phi, Int64_32, "", Br->getIterator());
@@ -973,7 +972,7 @@ TEST_F(ScalarEvolutionsTest, SCEVAddRecFromPHIwithLargeConstantAccum) {
%2 = shl i32 %1, 16
%3 = ashr exact i32 %2, 16
%4 = add i32 %3, -2147483648
- br i1 undef, label %exit, label %loop
+ br i1 poison, label %exit, label %loop
exit:
ret void
*/
@@ -987,7 +986,7 @@ TEST_F(ScalarEvolutionsTest, SCEVAddRecFromPHIwithLargeConstantAccum) {
auto *MinInt32 = ConstantInt::get(Context, APInt(32, 0x80000000U));
auto *Int32_16 = ConstantInt::get(Context, APInt(32, 16));
auto *Br = BranchInst::Create(
- LoopBB, ExitBB, UndefValue::get(Type::getInt1Ty(Context)), LoopBB);
+ LoopBB, ExitBB, PoisonValue::get(Type::getInt1Ty(Context)), LoopBB);
auto *Phi = PHINode::Create(Int32Ty, 2, "", Br->getIterator());
auto *Shl = BinaryOperator::CreateShl(Phi, Int32_16, "", Br->getIterator());
auto *AShr =
diff --git a/llvm/unittests/IR/BasicBlockTest.cpp b/llvm/unittests/IR/BasicBlockTest.cpp
index 88ac6611742ce9..36e849471d1ed8 100644
--- a/llvm/unittests/IR/BasicBlockTest.cpp
+++ b/llvm/unittests/IR/BasicBlockTest.cpp
@@ -67,8 +67,8 @@ TEST(BasicBlockTest, PhiRange) {
// Finally, let's iterate them, which is the thing we're trying to test.
// We'll use this to wire up the rest of the incoming values.
for (auto &PN : BB->phis()) {
- PN.addIncoming(UndefValue::get(Int32Ty), BB1.get());
- PN.addIncoming(UndefValue::get(Int32Ty), BB2.get());
+ PN.addIncoming(PoisonValue::get(Int32Ty), BB1.get());
+ PN.addIncoming(PoisonValue::get(Int32Ty), BB2.get());
}
// Test that we can use const iterators and generally that the iterators
diff --git a/llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp b/llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp
index 13bd69624867e9..6aff8406790d3b 100644
--- a/llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp
+++ b/llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp
@@ -95,7 +95,7 @@ TEST_F(ScalarEvolutionExpanderTest, ExpandPtrTypeSCEV) {
const DataLayout &DL = F->getDataLayout();
BranchInst *Br = BranchInst::Create(
- LoopBB, ExitBB, UndefValue::get(Type::getInt1Ty(Context)), LoopBB);
+ LoopBB, ExitBB, PoisonValue::get(Type::getInt1Ty(Context)), LoopBB);
AllocaInst *Alloca = new AllocaInst(I32Ty, DL.getAllocaAddrSpace(), "alloca",
Br->getIterator());
ConstantInt *Ci32 = ConstantInt::get(Context, APInt(32, 1));
@@ -172,7 +172,7 @@ TEST_F(ScalarEvolutionExpanderTest, SCEVZeroExtendExprNonIntegral) {
Builder.SetInsertPoint(L);
PHINode *Phi = Builder.CreatePHI(T_int64, 2);
Value *Add = Builder.CreateAdd(Phi, ConstantInt::get(T_int64, 1), "add");
- Builder.CreateCondBr(UndefValue::get(T_int1), L, Post);
+ Builder.CreateCondBr(PoisonValue::get(T_int1), L, Post);
Phi->addIncoming(ConstantInt::get(T_int64, 0), LPh);
Phi->addIncoming(Add, L);
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR replaces all
UndefValueact as placeholders withPoisonValueinllvm/unittests.@nunoplopes @regehr