[llvm] r241602 - Revert r241570, it caused PR24053
Nico Weber
nicolasweber at gmx.de
Tue Jul 7 09:42:51 PDT 2015
Author: nico
Date: Tue Jul 7 11:42:50 2015
New Revision: 241602
URL: http://llvm.org/viewvc/llvm-project?rev=241602&view=rev
Log:
Revert r241570, it caused PR24053
Modified:
llvm/trunk/lib/IR/BasicBlock.cpp
Modified: llvm/trunk/lib/IR/BasicBlock.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/BasicBlock.cpp?rev=241602&r1=241601&r2=241602&view=diff
==============================================================================
--- llvm/trunk/lib/IR/BasicBlock.cpp (original)
+++ llvm/trunk/lib/IR/BasicBlock.cpp Tue Jul 7 11:42:50 2015
@@ -163,40 +163,47 @@ CallInst *BasicBlock::getTerminatingMust
}
Instruction* BasicBlock::getFirstNonPHI() {
- for (Instruction &I : *this)
- if (!isa<PHINode>(I))
- return &I;
- return nullptr;
+ BasicBlock::iterator i = begin();
+ // All valid basic blocks should have a terminator,
+ // which is not a PHINode. If we have an invalid basic
+ // block we'll get an assertion failure when dereferencing
+ // a past-the-end iterator.
+ while (isa<PHINode>(i)) ++i;
+ return &*i;
}
Instruction* BasicBlock::getFirstNonPHIOrDbg() {
- for (Instruction &I : *this)
- if (!isa<PHINode>(I) && !isa<DbgInfoIntrinsic>(I))
- return &I;
- return nullptr;
+ BasicBlock::iterator i = begin();
+ // All valid basic blocks should have a terminator,
+ // which is not a PHINode. If we have an invalid basic
+ // block we'll get an assertion failure when dereferencing
+ // a past-the-end iterator.
+ while (isa<PHINode>(i) || isa<DbgInfoIntrinsic>(i)) ++i;
+ return &*i;
}
Instruction* BasicBlock::getFirstNonPHIOrDbgOrLifetime() {
- for (Instruction &I : *this) {
- if (isa<PHINode>(I) || isa<DbgInfoIntrinsic>(I))
+ // All valid basic blocks should have a terminator,
+ // which is not a PHINode. If we have an invalid basic
+ // block we'll get an assertion failure when dereferencing
+ // a past-the-end iterator.
+ BasicBlock::iterator i = begin();
+ for (;; ++i) {
+ if (isa<PHINode>(i) || isa<DbgInfoIntrinsic>(i))
continue;
- if (auto *II = dyn_cast<IntrinsicInst>(&I))
- if (II->getIntrinsicID() == Intrinsic::lifetime_start ||
- II->getIntrinsicID() == Intrinsic::lifetime_end)
- continue;
-
- return &I;
+ const IntrinsicInst *II = dyn_cast<IntrinsicInst>(i);
+ if (!II)
+ break;
+ if (II->getIntrinsicID() != Intrinsic::lifetime_start &&
+ II->getIntrinsicID() != Intrinsic::lifetime_end)
+ break;
}
- return nullptr;
+ return &*i;
}
BasicBlock::iterator BasicBlock::getFirstInsertionPt() {
- Instruction *FirstNonPHI = getFirstNonPHI();
- if (!FirstNonPHI)
- return end();
-
- iterator InsertPt = FirstNonPHI;
+ iterator InsertPt = getFirstNonPHI();
if (isa<LandingPadInst>(InsertPt)) ++InsertPt;
return InsertPt;
}
More information about the llvm-commits
mailing list