[llvm-commits] [llvm] r137744 - in /llvm/trunk: include/llvm/BasicBlock.h lib/VMCore/BasicBlock.cpp

Chris Lattner clattner at apple.com
Wed Aug 17 11:43:52 PDT 2011


On Aug 16, 2011, at 1:42 PM, Bill Wendling wrote:

> 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).

Cool

> +++ 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.

The last sentence doesn't make sense.

-Chris

> +  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();
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list