Skip to content

Commit f33f66b

Browse files
committed
[NFC][RemoveDIs] Always use iterators for inserting PHIs
It's becoming potentially unsafe to insert a PHI instruction using a plain Instruction pointer. Switch all the remaining sites that create and insert PHIs to use iterators instead. For example, the code in ComplexDeinterleavingPass.cpp is definitely at-risk of mixing PHIs and debug-info.
1 parent 1e828f8 commit f33f66b

File tree

7 files changed

+8
-8
lines changed

7 files changed

+8
-8
lines changed

llvm/lib/CodeGen/CodeGenPrepare.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4130,7 +4130,7 @@ class AddressingModeCombiner {
41304130
PHINode *CurrentPhi = cast<PHINode>(Current);
41314131
unsigned PredCount = CurrentPhi->getNumIncomingValues();
41324132
PHINode *PHI =
4133-
PHINode::Create(CommonType, PredCount, "sunk_phi", CurrentPhi);
4133+
PHINode::Create(CommonType, PredCount, "sunk_phi", CurrentPhi->getIterator());
41344134
Map[Current] = PHI;
41354135
ST.insertNewPhi(PHI);
41364136
append_range(Worklist, CurrentPhi->incoming_values());
@@ -6436,7 +6436,7 @@ bool CodeGenPrepare::optimizePhiType(
64366436
}
64376437
for (PHINode *Phi : PhiNodes)
64386438
ValMap[Phi] = PHINode::Create(ConvertTy, Phi->getNumIncomingValues(),
6439-
Phi->getName() + ".tc", Phi);
6439+
Phi->getName() + ".tc", Phi->getIterator());
64406440
// Pipe together all the PhiNodes.
64416441
for (PHINode *Phi : PhiNodes) {
64426442
PHINode *NewPhi = cast<PHINode>(ValMap[Phi]);

llvm/lib/CodeGen/ComplexDeinterleavingPass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1975,7 +1975,7 @@ Value *ComplexDeinterleavingGraph::replaceNode(IRBuilderBase &Builder,
19751975
// It is filled later when the ReductionOperation is processed.
19761976
auto *VTy = cast<VectorType>(Node->Real->getType());
19771977
auto *NewVTy = VectorType::getDoubleElementsVectorType(VTy);
1978-
auto *NewPHI = PHINode::Create(NewVTy, 0, "", BackEdge->getFirstNonPHI());
1978+
auto *NewPHI = PHINode::Create(NewVTy, 0, "", BackEdge->getFirstNonPHIIt());
19791979
OldToNewPHI[dyn_cast<PHINode>(Node->Real)] = NewPHI;
19801980
ReplacementNode = NewPHI;
19811981
break;

llvm/lib/Target/ARM/MVEGatherScatterLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@ bool MVEGatherScatterLowering::optimiseOffsets(Value *Offsets, BasicBlock *BB,
10601060
NewPhi = Phi;
10611061
} else {
10621062
// There are other users -> create a new phi
1063-
NewPhi = PHINode::Create(Phi->getType(), 2, "NewPhi", Phi);
1063+
NewPhi = PHINode::Create(Phi->getType(), 2, "NewPhi", Phi->getIterator());
10641064
// Copy the incoming values of the old phi
10651065
NewPhi->addIncoming(Phi->getIncomingValue(IncrementingBlock == 1 ? 0 : 1),
10661066
Phi->getIncomingBlock(IncrementingBlock == 1 ? 0 : 1));

llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class PPCBoolRetToInt : public FunctionPass {
101101
// runOnUse.
102102
Value *Zero = Constant::getNullValue(IntTy);
103103
PHINode *Q =
104-
PHINode::Create(IntTy, P->getNumIncomingValues(), P->getName(), P);
104+
PHINode::Create(IntTy, P->getNumIncomingValues(), P->getName(), P->getIterator());
105105
for (unsigned i = 0; i < P->getNumOperands(); ++i)
106106
Q->addIncoming(Zero, P->getIncomingBlock(i));
107107
return Q;

llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ bool RISCVGatherScatterLowering::matchStridedRecurrence(Value *Index, Loop *L,
229229

230230
// Build scalar phi and increment.
231231
BasePtr =
232-
PHINode::Create(Start->getType(), 2, Phi->getName() + ".scalar", Phi);
232+
PHINode::Create(Start->getType(), 2, Phi->getName() + ".scalar", Phi->getIterator());
233233
Inc = BinaryOperator::CreateAdd(BasePtr, Step, Inc->getName() + ".scalar",
234234
Inc);
235235
BasePtr->addIncoming(Start, Phi->getIncomingBlock(1 - IncrementingBlock));

llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ BasicBlock *X86LowerAMXIntrinsics::createLoop(BasicBlock *Preheader,
116116
BranchInst::Create(Body, Header);
117117
BranchInst::Create(Latch, Body);
118118
PHINode *IV =
119-
PHINode::Create(I16Ty, 2, Name + ".iv", Header->getTerminator());
119+
PHINode::Create(I16Ty, 2, Name + ".iv", Header->getTerminator()->getIterator());
120120
IV->addIncoming(ConstantInt::get(I16Ty, 0), Preheader);
121121

122122
B.SetInsertPoint(Latch);

polly/lib/CodeGen/BlockGenerators.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,7 @@ PHINode *RegionGenerator::buildExitPHI(MemoryAccess *MA, LoopToScevMapT &LTS,
12341234

12351235
PHINode *NewPHI = PHINode::Create(OrigPHI->getType(), Incoming.size(),
12361236
"polly." + OrigPHI->getName(),
1237-
NewSubregionExit->getFirstNonPHI());
1237+
NewSubregionExit->getFirstNonPHIIt());
12381238

12391239
// Add the incoming values to the PHI.
12401240
for (auto &Pair : Incoming) {

0 commit comments

Comments
 (0)