From: Bill Wendling Date: Thu, 28 Jul 2011 02:15:52 +0000 (+0000) Subject: Add a couple of convenience functions: X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=7f66c45f35bdfc69c41f2e1b3b9891a4eca0c0b0;p=oota-llvm.git Add a couple of convenience functions: * InvokeInst: Get the landingpad instruction associated with this invoke. * LandingPadInst: A method to reserve extra space for clauses. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136325 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index d337002e0bb..82d58162f68 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -1870,6 +1870,10 @@ public: /// 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 @@ public: Op<-1>() = reinterpret_cast(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(); diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index e7dd40d0599..9398c7f872c 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -214,6 +214,20 @@ void LandingPadInst::growOperands() { 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 @@ void InvokeInst::removeAttribute(unsigned i, Attributes attr) { setAttributes(PAL); } +LandingPadInst *InvokeInst::getLandingPad() const { + return cast(getUnwindDest()->getFirstNonPHI()); +} //===----------------------------------------------------------------------===// // ReturnInst Implementation