Skip to content

Commit 7ffeb8e

Browse files
committed
PromoteMem2Reg: use poison instead of undef as placeholder in phi entries from unreachable predecessors [NFC]
1 parent 25d9fde commit 7ffeb8e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ void PromoteMem2Reg::run() {
835835
// code. Unfortunately, there may be unreachable blocks which the renamer
836836
// hasn't traversed. If this is the case, the PHI nodes may not
837837
// have incoming values for all predecessors. Loop over all PHI nodes we have
838-
// created, inserting undef values if they are missing any incoming values.
838+
// created, inserting poison values if they are missing any incoming values.
839839
for (DenseMap<std::pair<unsigned, unsigned>, PHINode *>::iterator
840840
I = NewPhiNodes.begin(),
841841
E = NewPhiNodes.end();
@@ -885,9 +885,9 @@ void PromoteMem2Reg::run() {
885885
BasicBlock::iterator BBI = BB->begin();
886886
while ((SomePHI = dyn_cast<PHINode>(BBI++)) &&
887887
SomePHI->getNumIncomingValues() == NumBadPreds) {
888-
Value *UndefVal = UndefValue::get(SomePHI->getType());
888+
Value *PoisonVal = PoisonValue::get(SomePHI->getType());
889889
for (BasicBlock *Pred : Preds)
890-
SomePHI->addIncoming(UndefVal, Pred);
890+
SomePHI->addIncoming(PoisonVal, Pred);
891891
}
892892
}
893893

llvm/test/Transforms/Mem2Reg/undef-order.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ define i32 @foo() {
4545
; CHECK: Block16:
4646
; CHECK-NEXT: br label [[JOIN]]
4747
; CHECK: Join:
48-
; CHECK-NEXT: [[VAL_0:%.*]] = phi i32 [ 1, [[STORE1]] ], [ 2, [[STORE2]] ], [ undef, [[BLOCK1:%.*]] ], [ undef, [[BLOCK2:%.*]] ], [ undef, [[BLOCK3:%.*]] ], [ undef, [[BLOCK4:%.*]] ], [ undef, [[BLOCK5:%.*]] ], [ undef, [[BLOCK6:%.*]] ], [ undef, [[BLOCK7:%.*]] ], [ undef, [[BLOCK8:%.*]] ], [ undef, [[BLOCK9:%.*]] ], [ undef, [[BLOCK10:%.*]] ], [ undef, [[BLOCK11:%.*]] ], [ undef, [[BLOCK12:%.*]] ], [ undef, [[BLOCK13:%.*]] ], [ undef, [[BLOCK14:%.*]] ], [ undef, [[BLOCK15:%.*]] ], [ undef, [[BLOCK16:%.*]] ]
48+
; CHECK-NEXT: [[VAL_0:%.*]] = phi i32 [ 1, [[STORE1]] ], [ 2, [[STORE2]] ], [ poison, [[BLOCK1:%.*]] ], [ poison, [[BLOCK2:%.*]] ], [ poison, [[BLOCK3:%.*]] ], [ poison, [[BLOCK4:%.*]] ], [ poison, [[BLOCK5:%.*]] ], [ poison, [[BLOCK6:%.*]] ], [ poison, [[BLOCK7:%.*]] ], [ poison, [[BLOCK8:%.*]] ], [ poison, [[BLOCK9:%.*]] ], [ poison, [[BLOCK10:%.*]] ], [ poison, [[BLOCK11:%.*]] ], [ poison, [[BLOCK12:%.*]] ], [ poison, [[BLOCK13:%.*]] ], [ poison, [[BLOCK14:%.*]] ], [ poison, [[BLOCK15:%.*]] ], [ poison, [[BLOCK16:%.*]] ]
4949
; CHECK-NEXT: ret i32 [[VAL_0]]
5050
;
5151
Entry:

0 commit comments

Comments
 (0)