Skip to content

Commit

Permalink
Replace UndefValue as placeholders with PoisonValue
Browse files Browse the repository at this point in the history
  • Loading branch information
leewei05 committed Nov 16, 2024
1 parent 131d73e commit e1552a6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 21 deletions.
6 changes: 3 additions & 3 deletions llvm/unittests/Analysis/BranchProbabilityInfoTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
// ]
Expand All @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion llvm/unittests/Analysis/MemorySSATest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
25 changes: 12 additions & 13 deletions llvm/unittests/Analysis/ScalarEvolutionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 "
Expand All @@ -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?");
Expand Down Expand Up @@ -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
*/
Expand All @@ -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());
Expand Down Expand Up @@ -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
*/
Expand All @@ -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 =
Expand Down
4 changes: 2 additions & 2 deletions llvm/unittests/IR/BasicBlockTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit e1552a6

Please sign in to comment.