[llvm] f33f66b - [NFC][RemoveDIs] Always use iterators for inserting PHIs
Jeremy Morse via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 5 09:01:50 PST 2024
Author: Jeremy Morse
Date: 2024-03-05T17:00:12Z
New Revision: f33f66be7dc586a597437d7ce7619d87e8637209
URL: https://github.com/llvm/llvm-project/commit/f33f66be7dc586a597437d7ce7619d87e8637209
DIFF: https://github.com/llvm/llvm-project/commit/f33f66be7dc586a597437d7ce7619d87e8637209.diff
LOG: [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.
Added:
Modified:
llvm/lib/CodeGen/CodeGenPrepare.cpp
llvm/lib/CodeGen/ComplexDeinterleavingPass.cpp
llvm/lib/Target/ARM/MVEGatherScatterLowering.cpp
llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp
llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp
llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp
polly/lib/CodeGen/BlockGenerators.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index feefe87f406365..36f6cc83be2c3f 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -4130,7 +4130,7 @@ class AddressingModeCombiner {
PHINode *CurrentPhi = cast<PHINode>(Current);
unsigned PredCount = CurrentPhi->getNumIncomingValues();
PHINode *PHI =
- PHINode::Create(CommonType, PredCount, "sunk_phi", CurrentPhi);
+ PHINode::Create(CommonType, PredCount, "sunk_phi", CurrentPhi->getIterator());
Map[Current] = PHI;
ST.insertNewPhi(PHI);
append_range(Worklist, CurrentPhi->incoming_values());
@@ -6436,7 +6436,7 @@ bool CodeGenPrepare::optimizePhiType(
}
for (PHINode *Phi : PhiNodes)
ValMap[Phi] = PHINode::Create(ConvertTy, Phi->getNumIncomingValues(),
- Phi->getName() + ".tc", Phi);
+ Phi->getName() + ".tc", Phi->getIterator());
// Pipe together all the PhiNodes.
for (PHINode *Phi : PhiNodes) {
PHINode *NewPhi = cast<PHINode>(ValMap[Phi]);
diff --git a/llvm/lib/CodeGen/ComplexDeinterleavingPass.cpp b/llvm/lib/CodeGen/ComplexDeinterleavingPass.cpp
index a6cacf874bdcd3..031a271de5bd75 100644
--- a/llvm/lib/CodeGen/ComplexDeinterleavingPass.cpp
+++ b/llvm/lib/CodeGen/ComplexDeinterleavingPass.cpp
@@ -1975,7 +1975,7 @@ Value *ComplexDeinterleavingGraph::replaceNode(IRBuilderBase &Builder,
// It is filled later when the ReductionOperation is processed.
auto *VTy = cast<VectorType>(Node->Real->getType());
auto *NewVTy = VectorType::getDoubleElementsVectorType(VTy);
- auto *NewPHI = PHINode::Create(NewVTy, 0, "", BackEdge->getFirstNonPHI());
+ auto *NewPHI = PHINode::Create(NewVTy, 0, "", BackEdge->getFirstNonPHIIt());
OldToNewPHI[dyn_cast<PHINode>(Node->Real)] = NewPHI;
ReplacementNode = NewPHI;
break;
diff --git a/llvm/lib/Target/ARM/MVEGatherScatterLowering.cpp b/llvm/lib/Target/ARM/MVEGatherScatterLowering.cpp
index bcfedd3414253e..404c280ab97991 100644
--- a/llvm/lib/Target/ARM/MVEGatherScatterLowering.cpp
+++ b/llvm/lib/Target/ARM/MVEGatherScatterLowering.cpp
@@ -1060,7 +1060,7 @@ bool MVEGatherScatterLowering::optimiseOffsets(Value *Offsets, BasicBlock *BB,
NewPhi = Phi;
} else {
// There are other users -> create a new phi
- NewPhi = PHINode::Create(Phi->getType(), 2, "NewPhi", Phi);
+ NewPhi = PHINode::Create(Phi->getType(), 2, "NewPhi", Phi->getIterator());
// Copy the incoming values of the old phi
NewPhi->addIncoming(Phi->getIncomingValue(IncrementingBlock == 1 ? 0 : 1),
Phi->getIncomingBlock(IncrementingBlock == 1 ? 0 : 1));
diff --git a/llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp b/llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp
index 20f53bd4badf1d..f1abb78d4dd343 100644
--- a/llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp
+++ b/llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp
@@ -101,7 +101,7 @@ class PPCBoolRetToInt : public FunctionPass {
// runOnUse.
Value *Zero = Constant::getNullValue(IntTy);
PHINode *Q =
- PHINode::Create(IntTy, P->getNumIncomingValues(), P->getName(), P);
+ PHINode::Create(IntTy, P->getNumIncomingValues(), P->getName(), P->getIterator());
for (unsigned i = 0; i < P->getNumOperands(); ++i)
Q->addIncoming(Zero, P->getIncomingBlock(i));
return Q;
diff --git a/llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp b/llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp
index 1dcb83a6078ed7..0530e3d08be821 100644
--- a/llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp
@@ -229,7 +229,7 @@ bool RISCVGatherScatterLowering::matchStridedRecurrence(Value *Index, Loop *L,
// Build scalar phi and increment.
BasePtr =
- PHINode::Create(Start->getType(), 2, Phi->getName() + ".scalar", Phi);
+ PHINode::Create(Start->getType(), 2, Phi->getName() + ".scalar", Phi->getIterator());
Inc = BinaryOperator::CreateAdd(BasePtr, Step, Inc->getName() + ".scalar",
Inc);
BasePtr->addIncoming(Start, Phi->getIncomingBlock(1 - IncrementingBlock));
diff --git a/llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp b/llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp
index 591a76e6fd6cc7..e355a4b9d35b91 100644
--- a/llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp
+++ b/llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp
@@ -116,7 +116,7 @@ BasicBlock *X86LowerAMXIntrinsics::createLoop(BasicBlock *Preheader,
BranchInst::Create(Body, Header);
BranchInst::Create(Latch, Body);
PHINode *IV =
- PHINode::Create(I16Ty, 2, Name + ".iv", Header->getTerminator());
+ PHINode::Create(I16Ty, 2, Name + ".iv", Header->getTerminator()->getIterator());
IV->addIncoming(ConstantInt::get(I16Ty, 0), Preheader);
B.SetInsertPoint(Latch);
diff --git a/polly/lib/CodeGen/BlockGenerators.cpp b/polly/lib/CodeGen/BlockGenerators.cpp
index 3de1781a27a834..da0e503b23efc1 100644
--- a/polly/lib/CodeGen/BlockGenerators.cpp
+++ b/polly/lib/CodeGen/BlockGenerators.cpp
@@ -1234,7 +1234,7 @@ PHINode *RegionGenerator::buildExitPHI(MemoryAccess *MA, LoopToScevMapT <S,
PHINode *NewPHI = PHINode::Create(OrigPHI->getType(), Incoming.size(),
"polly." + OrigPHI->getName(),
- NewSubregionExit->getFirstNonPHI());
+ NewSubregionExit->getFirstNonPHIIt());
// Add the incoming values to the PHI.
for (auto &Pair : Incoming) {
More information about the llvm-commits
mailing list