[llvm-commits] [llvm] r136325 - in /llvm/trunk: include/llvm/Instructions.h lib/VMCore/Instructions.cpp

Bill Wendling isanbard at gmail.com
Wed Jul 27 19:15:52 PDT 2011


Author: void
Date: Wed Jul 27 21:15:52 2011
New Revision: 136325

URL: http://llvm.org/viewvc/llvm-project?rev=136325&view=rev
Log:
Add a couple of convenience functions:

* InvokeInst: Get the landingpad instruction associated with this invoke.
* LandingPadInst: A method to reserve extra space for clauses.

Modified:
    llvm/trunk/include/llvm/Instructions.h
    llvm/trunk/lib/VMCore/Instructions.cpp

Modified: llvm/trunk/include/llvm/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=136325&r1=136324&r2=136325&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Instructions.h (original)
+++ llvm/trunk/include/llvm/Instructions.h Wed Jul 27 21:15:52 2011
@@ -1870,6 +1870,10 @@
   /// getNumClauses - Get the number of clauses for this landing pad.
   unsigned getNumClauses() const { return getNumOperands() - 1; }
 
+  /// reserveClauses - Grow the size of the operand list to accomodate the new
+  /// number of clauses.
+  void reserveClauses(unsigned Size);
+
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const LandingPadInst *) { return true; }
   static inline bool classof(const Instruction *I) {
@@ -2474,6 +2478,10 @@
     Op<-1>() = reinterpret_cast<Value*>(B);
   }
 
+  // getLandingPad - Get the landingpad instruction from the landing pad block
+  // (the unwind destination).
+  LandingPadInst *getLandingPad() const;
+
   BasicBlock *getSuccessor(unsigned i) const {
     assert(i < 2 && "Successor # out of range for invoke!");
     return i == 0 ? getNormalDest() : getUnwindDest();

Modified: llvm/trunk/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=136325&r1=136324&r2=136325&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Instructions.cpp (original)
+++ llvm/trunk/lib/VMCore/Instructions.cpp Wed Jul 27 21:15:52 2011
@@ -214,6 +214,20 @@
   Use::zap(OldOps, OldOps + e, true);
 }
 
+void LandingPadInst::reserveClauses(unsigned Size) {
+  unsigned e = getNumOperands() + Size;
+  if (ReservedSpace >= e) return;
+  ReservedSpace = e;
+
+  Use *NewOps = allocHungoffUses(ReservedSpace);
+  Use *OldOps = OperandList;
+  for (unsigned i = 0; i != e; ++i)
+      NewOps[i] = OldOps[i];
+
+  OperandList = NewOps;
+  Use::zap(OldOps, OldOps + e, true);
+}
+
 void LandingPadInst::addClause(ClauseType CT, Value *ClauseVal) {
   unsigned OpNo = getNumOperands();
   if (OpNo + 1 > ReservedSpace)
@@ -551,6 +565,9 @@
   setAttributes(PAL);
 }
 
+LandingPadInst *InvokeInst::getLandingPad() const {
+  return cast<LandingPadInst>(getUnwindDest()->getFirstNonPHI());
+}
 
 //===----------------------------------------------------------------------===//
 //                        ReturnInst Implementation





More information about the llvm-commits mailing list