[llvm-commits] CVS: llvm/lib/VMCore/BasicBlock.cpp

Vladimir Prus ghost at cs.msu.su
Thu Jun 8 08:46:43 PDT 2006



Changes in directory llvm/lib/VMCore:

BasicBlock.cpp updated: 1.68 -> 1.69
---
Log message:

New method BasicBlock::getFirstNonPHI.


---
Diffs of the changes:  (+11 -0)

 BasicBlock.cpp |   11 +++++++++++
 1 files changed, 11 insertions(+)


Index: llvm/lib/VMCore/BasicBlock.cpp
diff -u llvm/lib/VMCore/BasicBlock.cpp:1.68 llvm/lib/VMCore/BasicBlock.cpp:1.69
--- llvm/lib/VMCore/BasicBlock.cpp:1.68	Fri Aug 12 17:14:06 2005
+++ llvm/lib/VMCore/BasicBlock.cpp	Thu Jun  8 10:46:18 2006
@@ -121,6 +121,17 @@
   return dyn_cast<TerminatorInst>(&InstList.back());
 }
 
+Instruction* BasicBlock::getFirstNonPHI()
+{
+    BasicBlock::iterator i = begin(), e = end();
+    // All valid basic blocks should have a terminator,
+    // which is not a PHINode. If we have invalid basic
+    // block we'll get assert when dereferencing past-the-end
+    // iterator.
+    while (isa<PHINode>(i)) ++i;
+    return &*i;
+}
+
 void BasicBlock::dropAllReferences() {
   for(iterator I = begin(), E = end(); I != E; ++I)
     I->dropAllReferences();






More information about the llvm-commits mailing list