[llvm-commits] [llvm] r137744 - in /llvm/trunk: include/llvm/BasicBlock.h lib/VMCore/BasicBlock.cpp
Bill Wendling
isanbard at gmail.com
Tue Aug 16 13:42:53 PDT 2011
Author: void
Date: Tue Aug 16 15:42:52 2011
New Revision: 137744
URL: http://llvm.org/viewvc/llvm-project?rev=137744&view=rev
Log:
Add getFirstInsertionPt() method.
getFirstInsertionPt() returns an iterator to the first insertion point in a
basic block. This is after all PHIs and any other instruction which is required
to be at the top of the basic block (like LandingPadInst).
Modified:
llvm/trunk/include/llvm/BasicBlock.h
llvm/trunk/lib/VMCore/BasicBlock.cpp
Modified: llvm/trunk/include/llvm/BasicBlock.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/BasicBlock.h?rev=137744&r1=137743&r2=137744&view=diff
==============================================================================
--- llvm/trunk/include/llvm/BasicBlock.h (original)
+++ llvm/trunk/include/llvm/BasicBlock.h Tue Aug 16 15:42:52 2011
@@ -145,6 +145,15 @@
return const_cast<BasicBlock*>(this)->getFirstNonPHIOrDbgOrLifetime();
}
+ /// getFirstInsertionPt - Returns an iterator to the first instruction in this
+ /// block that is suitable for inserting a non-PHI instruction. In particular,
+ /// it skips all PHIs and LandingPad instructions. Returns 0 if there are no
+ /// non-PHI instructions.
+ iterator getFirstInsertionPt();
+ const_iterator getFirstInsertionPt() const {
+ return const_cast<BasicBlock*>(this)->getFirstInsertionPt();
+ }
+
/// removeFromParent - This method unlinks 'this' from the containing
/// function, but does not delete it.
///
Modified: llvm/trunk/lib/VMCore/BasicBlock.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/BasicBlock.cpp?rev=137744&r1=137743&r2=137744&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/BasicBlock.cpp (original)
+++ llvm/trunk/lib/VMCore/BasicBlock.cpp Tue Aug 16 15:42:52 2011
@@ -167,6 +167,12 @@
return &*i;
}
+BasicBlock::iterator BasicBlock::getFirstInsertionPt() {
+ iterator InsertPt = getFirstNonPHI();
+ if (isa<LandingPadInst>(InsertPt)) ++InsertPt;
+ return InsertPt;
+}
+
void BasicBlock::dropAllReferences() {
for(iterator I = begin(), E = end(); I != E; ++I)
I->dropAllReferences();
More information about the llvm-commits
mailing list