[llvm-branch-commits] [llvm] 76f6b12 - Revert "[llvm] Use BasicBlock::phis() (NFC)"
Oliver Stannard via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Jan 7 01:49:27 PST 2021
Author: Oliver Stannard
Date: 2021-01-07T09:43:33Z
New Revision: 76f6b125cef1f5d949cd8f4049b14f572ecd9ee6
URL: https://github.com/llvm/llvm-project/commit/76f6b125cef1f5d949cd8f4049b14f572ecd9ee6
DIFF: https://github.com/llvm/llvm-project/commit/76f6b125cef1f5d949cd8f4049b14f572ecd9ee6.diff
LOG: Revert "[llvm] Use BasicBlock::phis() (NFC)"
Reverting because this causes crashes on the 2-stage buildbots, for
example http://lab.llvm.org:8011/#/builders/7/builds/1140.
This reverts commit 9b228f107d43341ef73af92865f73a9a076c5a76.
Added:
Modified:
llvm/lib/IR/BasicBlock.cpp
llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
llvm/lib/Transforms/Utils/InlineFunction.cpp
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp
index 688211877d18..7f34565f5cd8 100644
--- a/llvm/lib/IR/BasicBlock.cpp
+++ b/llvm/lib/IR/BasicBlock.cpp
@@ -440,8 +440,12 @@ BasicBlock *BasicBlock::splitBasicBlockBefore(iterator I, const Twine &BBName) {
void BasicBlock::replacePhiUsesWith(BasicBlock *Old, BasicBlock *New) {
// N.B. This might not be a complete BasicBlock, so don't assume
// that it ends with a non-phi instruction.
- for (PHINode &PN : phis())
- PN.replaceIncomingBlockWith(Old, New);
+ for (iterator II = begin(), IE = end(); II != IE; ++II) {
+ PHINode *PN = dyn_cast<PHINode>(II);
+ if (!PN)
+ break;
+ PN->replaceIncomingBlockWith(Old, New);
+ }
}
void BasicBlock::replaceSuccessorsPhiUsesWith(BasicBlock *Old,
diff --git a/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp b/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
index 273d3ab97c7b..68c79d2a113f 100644
--- a/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
@@ -2199,10 +2199,13 @@ bool HexagonLoopIdiomRecognize::processCopyingStore(Loop *CurLoop,
if (ParentL)
ParentL->addBasicBlockToLoop(NewPreheader, *LF);
IRBuilder<>(NewPreheader).CreateBr(Header);
- for (PHINode &PN : Header->phis()) {
- int bx = PN.getBasicBlockIndex(Preheader);
+ for (auto &In : *Header) {
+ PHINode *PN = dyn_cast<PHINode>(&In);
+ if (!PN)
+ break;
+ int bx = PN->getBasicBlockIndex(Preheader);
if (bx >= 0)
- PN.setIncomingBlock(bx, NewPreheader);
+ PN->setIncomingBlock(bx, NewPreheader);
}
DT->addNewBlock(NewPreheader, Preheader);
DT->changeImmediateDominator(Header, NewPreheader);
diff --git a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
index 060ca4bcd8ee..4cce05d595a8 100644
--- a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
@@ -483,20 +483,24 @@ static Optional<EstimatedUnrollCost> analyzeLoopUnrollCost(
// Prepare for the iteration by collecting any simplified entry or backedge
// inputs.
- for (PHINode &PHI : L->getHeader()->phis()) {
+ for (Instruction &I : *L->getHeader()) {
+ auto *PHI = dyn_cast<PHINode>(&I);
+ if (!PHI)
+ break;
+
// The loop header PHI nodes must have exactly two input: one from the
// loop preheader and one from the loop latch.
assert(
- PHI.getNumIncomingValues() == 2 &&
+ PHI->getNumIncomingValues() == 2 &&
"Must have an incoming value only for the preheader and the latch.");
- Value *V = PHI.getIncomingValueForBlock(
+ Value *V = PHI->getIncomingValueForBlock(
Iteration == 0 ? L->getLoopPreheader() : L->getLoopLatch());
Constant *C = dyn_cast<Constant>(V);
if (Iteration != 0 && !C)
C = SimplifiedValues.lookup(V);
if (C)
- SimplifiedInputValues.push_back({&PHI, C});
+ SimplifiedInputValues.push_back({PHI, C});
}
// Now clear and re-populate the map for the next iteration.
@@ -621,8 +625,12 @@ static Optional<EstimatedUnrollCost> analyzeLoopUnrollCost(
BasicBlock *ExitingBB, *ExitBB;
std::tie(ExitingBB, ExitBB) = ExitWorklist.pop_back_val();
- for (PHINode &PN : ExitBB->phis()) {
- Value *Op = PN.getIncomingValueForBlock(ExitingBB);
+ for (Instruction &I : *ExitBB) {
+ auto *PN = dyn_cast<PHINode>(&I);
+ if (!PN)
+ break;
+
+ Value *Op = PN->getIncomingValueForBlock(ExitingBB);
if (auto *OpI = dyn_cast<Instruction>(Op))
if (L->contains(OpI))
AddCostRecursively(*OpI, TripCount - 1);
diff --git a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
index ed3f87a7d0e7..68ddebf113d1 100644
--- a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
+++ b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
@@ -2843,8 +2843,12 @@ static void computeLiveInValues(BasicBlock::reverse_iterator Begin,
static void computeLiveOutSeed(BasicBlock *BB, SetVector<Value *> &LiveTmp) {
for (BasicBlock *Succ : successors(BB)) {
- for (PHINode &PN : Succ->phis()) {
- Value *V = PN.getIncomingValueForBlock(BB);
+ for (auto &I : *Succ) {
+ PHINode *PN = dyn_cast<PHINode>(&I);
+ if (!PN)
+ break;
+
+ Value *V = PN->getIncomingValueForBlock(BB);
assert(!isUnhandledGCPointerType(V->getType()) &&
"support for FCA unimplemented");
if (isHandledGCPointerType(V->getType()) && !isa<Constant>(V))
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index 521b2b2e5f49..e480d7b8d61f 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -657,9 +657,13 @@ static void HandleInlinedEHPad(InvokeInst *II, BasicBlock *FirstNewBlock,
// edge from this block.
SmallVector<Value *, 8> UnwindDestPHIValues;
BasicBlock *InvokeBB = II->getParent();
- for (PHINode &PHI : UnwindDest->phis())
+ for (Instruction &I : *UnwindDest) {
// Save the value to use for this edge.
- UnwindDestPHIValues.push_back(PHI.getIncomingValueForBlock(InvokeBB));
+ PHINode *PHI = dyn_cast<PHINode>(&I);
+ if (!PHI)
+ break;
+ UnwindDestPHIValues.push_back(PHI->getIncomingValueForBlock(InvokeBB));
+ }
// Add incoming-PHI values to the unwind destination block for the given basic
// block, using the values for the original invoke's source block.
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 6b7f107e89ef..abd0470270d5 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -7529,9 +7529,14 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
// Collect the incoming values from the PHIs.
Incoming.clear();
- for (PHINode &P : BB->phis())
- if (!VisitedInstrs.count(&P) && !R.isDeleted(&P))
- Incoming.push_back(&P);
+ for (Instruction &I : *BB) {
+ PHINode *P = dyn_cast<PHINode>(&I);
+ if (!P)
+ break;
+
+ if (!VisitedInstrs.count(P) && !R.isDeleted(P))
+ Incoming.push_back(P);
+ }
// Sort by type.
llvm::stable_sort(Incoming, PhiTypeSorterFunc);
More information about the llvm-branch-commits
mailing list