Skip to content

Commit 64b9753

Browse files
authored
[llvm] Replace UndefValue placeholders with PoisonValue in unit tests [NFC] (#116453)
This PR replaces all `UndefValue` act as placeholders with `PoisonValue` in `llvm/unittests`.
1 parent 58a971f commit 64b9753

File tree

5 files changed

+20
-21
lines changed

5 files changed

+20
-21
lines changed

llvm/unittests/Analysis/BranchProbabilityInfoTest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ TEST_F(BranchProbabilityInfoTest, StressUnreachableHeuristic) {
5050

5151
// define void @f() {
5252
// entry:
53-
// switch i32 undef, label %exit, [
53+
// switch i32 poison, label %exit, [
5454
// i32 0, label %preexit
5555
// ... ;;< Add lots of cases to stress the heuristic.
5656
// ]
@@ -69,8 +69,8 @@ TEST_F(BranchProbabilityInfoTest, StressUnreachableHeuristic) {
6969

7070
unsigned NumCases = 4096;
7171
auto *I32 = IntegerType::get(C, 32);
72-
auto *Undef = UndefValue::get(I32);
73-
auto *Switch = SwitchInst::Create(Undef, ExitBB, NumCases, EntryBB);
72+
auto *Poison = PoisonValue::get(I32);
73+
auto *Switch = SwitchInst::Create(Poison, ExitBB, NumCases, EntryBB);
7474
for (unsigned I = 0; I < NumCases; ++I)
7575
Switch->addCase(ConstantInt::get(I32, I), PreExitBB);
7676

llvm/unittests/Analysis/MemorySSATest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ TEST_F(MemorySSATest, PartialWalkerCacheWithPhis) {
705705
BasicBlock *IfThen = BasicBlock::Create(C, "B", F);
706706
BasicBlock *IfEnd = BasicBlock::Create(C, "C", F);
707707

708-
B.CreateCondBr(UndefValue::get(Type::getInt1Ty(C)), IfThen, IfEnd);
708+
B.CreateCondBr(PoisonValue::get(Type::getInt1Ty(C)), IfThen, IfEnd);
709709

710710
B.SetInsertPoint(IfThen);
711711
Instruction *FirstStore = B.CreateStore(Zero, AllocA);

llvm/unittests/Analysis/ScalarEvolutionTest.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ TEST_F(ScalarEvolutionsTest, SimplifiedPHI) {
133133
BasicBlock *LoopBB = BasicBlock::Create(Context, "loop", F);
134134
BasicBlock *ExitBB = BasicBlock::Create(Context, "exit", F);
135135
BranchInst::Create(LoopBB, EntryBB);
136-
BranchInst::Create(LoopBB, ExitBB, UndefValue::get(Type::getInt1Ty(Context)),
136+
BranchInst::Create(LoopBB, ExitBB, PoisonValue::get(Type::getInt1Ty(Context)),
137137
LoopBB);
138138
ReturnInst::Create(Context, nullptr, ExitBB);
139139
auto *Ty = Type::getInt32Ty(Context);
@@ -328,11 +328,11 @@ TEST_F(ScalarEvolutionsTest, CompareSCEVComplexity) {
328328
for (int i = 0; i < 8; i++) {
329329
PHINode *Phi = cast<PHINode>(&*II++);
330330
Phi->addIncoming(Acc[i], LoopBB);
331-
Phi->addIncoming(UndefValue::get(Ty), EntryBB);
331+
Phi->addIncoming(PoisonValue::get(Ty), EntryBB);
332332
}
333333

334334
BasicBlock *ExitBB = BasicBlock::Create(Context, "bb2", F);
335-
BranchInst::Create(LoopBB, ExitBB, UndefValue::get(Type::getInt1Ty(Context)),
335+
BranchInst::Create(LoopBB, ExitBB, PoisonValue::get(Type::getInt1Ty(Context)),
336336
LoopBB);
337337

338338
Acc[0] = BinaryOperator::CreateAdd(Acc[0], Acc[1], "", ExitBB);
@@ -491,7 +491,7 @@ TEST_F(ScalarEvolutionsTest, SCEVNormalization) {
491491
" %iv1 = phi i32 [ %iv1.inc, %loop ], [ -2147483648, %loop.ph ] "
492492
" %iv0.inc = add i32 %iv0, 1 "
493493
" %iv1.inc = add i32 %iv1, 3 "
494-
" br i1 undef, label %for.end.loopexit, label %loop "
494+
" br i1 poison, label %for.end.loopexit, label %loop "
495495
" "
496496
"for.end.loopexit: "
497497
" ret void "
@@ -503,19 +503,18 @@ TEST_F(ScalarEvolutionsTest, SCEVNormalization) {
503503
" br label %loop_0 "
504504
" "
505505
"loop_0: "
506-
" br i1 undef, label %loop_0, label %loop_1 "
506+
" br i1 poison, label %loop_0, label %loop_1 "
507507
" "
508508
"loop_1: "
509-
" br i1 undef, label %loop_2, label %loop_1 "
509+
" br i1 poison, label %loop_2, label %loop_1 "
510510
" "
511511
" "
512512
"loop_2: "
513-
" br i1 undef, label %end, label %loop_2 "
513+
" br i1 poison, label %end, label %loop_2 "
514514
" "
515515
"end: "
516516
" ret void "
517-
"} "
518-
,
517+
"} ",
519518
Err, C);
520519

521520
assert(M && "Could not parse module?");
@@ -914,7 +913,7 @@ TEST_F(ScalarEvolutionsTest, SCEVAddRecFromPHIwithLargeConstants) {
914913
%1 = shl i64 %0, 32
915914
%2 = ashr exact i64 %1, 32
916915
%3 = add i64 %2, -9223372036854775808
917-
br i1 undef, label %exit, label %loop
916+
br i1 poison, label %exit, label %loop
918917
exit:
919918
ret void
920919
*/
@@ -929,7 +928,7 @@ TEST_F(ScalarEvolutionsTest, SCEVAddRecFromPHIwithLargeConstants) {
929928
ConstantInt::get(Context, APInt(64, 0x8000000000000000U, true));
930929
auto *Int64_32 = ConstantInt::get(Context, APInt(64, 32));
931930
auto *Br = BranchInst::Create(
932-
LoopBB, ExitBB, UndefValue::get(Type::getInt1Ty(Context)), LoopBB);
931+
LoopBB, ExitBB, PoisonValue::get(Type::getInt1Ty(Context)), LoopBB);
933932
auto *Phi =
934933
PHINode::Create(Type::getInt64Ty(Context), 2, "", Br->getIterator());
935934
auto *Shl = BinaryOperator::CreateShl(Phi, Int64_32, "", Br->getIterator());
@@ -973,7 +972,7 @@ TEST_F(ScalarEvolutionsTest, SCEVAddRecFromPHIwithLargeConstantAccum) {
973972
%2 = shl i32 %1, 16
974973
%3 = ashr exact i32 %2, 16
975974
%4 = add i32 %3, -2147483648
976-
br i1 undef, label %exit, label %loop
975+
br i1 poison, label %exit, label %loop
977976
exit:
978977
ret void
979978
*/
@@ -987,7 +986,7 @@ TEST_F(ScalarEvolutionsTest, SCEVAddRecFromPHIwithLargeConstantAccum) {
987986
auto *MinInt32 = ConstantInt::get(Context, APInt(32, 0x80000000U));
988987
auto *Int32_16 = ConstantInt::get(Context, APInt(32, 16));
989988
auto *Br = BranchInst::Create(
990-
LoopBB, ExitBB, UndefValue::get(Type::getInt1Ty(Context)), LoopBB);
989+
LoopBB, ExitBB, PoisonValue::get(Type::getInt1Ty(Context)), LoopBB);
991990
auto *Phi = PHINode::Create(Int32Ty, 2, "", Br->getIterator());
992991
auto *Shl = BinaryOperator::CreateShl(Phi, Int32_16, "", Br->getIterator());
993992
auto *AShr =

llvm/unittests/IR/BasicBlockTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ TEST(BasicBlockTest, PhiRange) {
6767
// Finally, let's iterate them, which is the thing we're trying to test.
6868
// We'll use this to wire up the rest of the incoming values.
6969
for (auto &PN : BB->phis()) {
70-
PN.addIncoming(UndefValue::get(Int32Ty), BB1.get());
71-
PN.addIncoming(UndefValue::get(Int32Ty), BB2.get());
70+
PN.addIncoming(PoisonValue::get(Int32Ty), BB1.get());
71+
PN.addIncoming(PoisonValue::get(Int32Ty), BB2.get());
7272
}
7373

7474
// Test that we can use const iterators and generally that the iterators

llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ TEST_F(ScalarEvolutionExpanderTest, ExpandPtrTypeSCEV) {
9595

9696
const DataLayout &DL = F->getDataLayout();
9797
BranchInst *Br = BranchInst::Create(
98-
LoopBB, ExitBB, UndefValue::get(Type::getInt1Ty(Context)), LoopBB);
98+
LoopBB, ExitBB, PoisonValue::get(Type::getInt1Ty(Context)), LoopBB);
9999
AllocaInst *Alloca = new AllocaInst(I32Ty, DL.getAllocaAddrSpace(), "alloca",
100100
Br->getIterator());
101101
ConstantInt *Ci32 = ConstantInt::get(Context, APInt(32, 1));
@@ -172,7 +172,7 @@ TEST_F(ScalarEvolutionExpanderTest, SCEVZeroExtendExprNonIntegral) {
172172
Builder.SetInsertPoint(L);
173173
PHINode *Phi = Builder.CreatePHI(T_int64, 2);
174174
Value *Add = Builder.CreateAdd(Phi, ConstantInt::get(T_int64, 1), "add");
175-
Builder.CreateCondBr(UndefValue::get(T_int1), L, Post);
175+
Builder.CreateCondBr(PoisonValue::get(T_int1), L, Post);
176176
Phi->addIncoming(ConstantInt::get(T_int64, 0), LPh);
177177
Phi->addIncoming(Add, L);
178178

0 commit comments

Comments
 (0)