[llvm-branch-commits] [llvm-branch] r105262 - in /llvm/branches/wendling/eh: include/llvm/Instructions.h lib/AsmParser/LLParser.cpp lib/VMCore/Instructions.cpp
Bill Wendling
isanbard at gmail.com
Mon May 31 17:29:31 PDT 2010
Author: void
Date: Mon May 31 19:29:31 2010
New Revision: 105262
URL: http://llvm.org/viewvc/llvm-project?rev=105262&view=rev
Log:
Add support to allocate and store the catch Value/BasicBlock pairs in the
InvokeInst.
Modified:
llvm/branches/wendling/eh/include/llvm/Instructions.h
llvm/branches/wendling/eh/lib/AsmParser/LLParser.cpp
llvm/branches/wendling/eh/lib/VMCore/Instructions.cpp
Modified: llvm/branches/wendling/eh/include/llvm/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/wendling/eh/include/llvm/Instructions.h?rev=105262&r1=105261&r2=105262&view=diff
==============================================================================
--- llvm/branches/wendling/eh/include/llvm/Instructions.h (original)
+++ llvm/branches/wendling/eh/include/llvm/Instructions.h Mon May 31 19:29:31 2010
@@ -2363,6 +2363,7 @@
class InvokeInst : public TerminatorInst {
/// CatchList - This is a pointer to the array of catches.
Use *CatchList;
+ unsigned ReservedSpace;
unsigned NumCatches;
AttrListPtr AttributeList;
@@ -2586,12 +2587,34 @@
Op<-1>() = reinterpret_cast<Value*>(B);
}
+ /// getNumCatches - Return the number of catch blocks for this invoke
+ /// instruction.
unsigned getNumCatches() const {
- return NumCatches; // EH-FIXME: Correct value?
+ return NumCatches / 2;
}
- /// addCatch - Add a catch to the invoke instruction.
- void addCatch(ConstantInt *, BasicBlock *) {} // EH-FIXME: Implement.
+ /// getCatchType - Return the specified catch type.
+ Value *getCatchType(unsigned I) {
+ assert(I && I < getNumCatches() && "Illegal catch type to get!");
+ return CatchList[I * 2];
+ }
+ const Value *getCatchType(unsigned I) const {
+ assert(I && I < getNumCatches() && "Illegal catch type to get!");
+ return CatchList[I * 2];
+ }
+
+ /// getCatchDest - Return the specified catch's landing pad.
+ BasicBlock *getCatchDest(unsigned I) {
+ assert(I && I < getNumCatches() && "Illegal catch type to get!");
+ return cast<BasicBlock>(CatchList[I * 2 + 1]);
+ }
+ const BasicBlock *getCatchDest(unsigned I) const {
+ assert(I && I < getNumCatches() && "Illegal catch type to get!");
+ return cast<BasicBlock>(CatchList[I * 2 + 1]);
+ }
+
+ /// addCatch - Add a catch block to the invoke instruction.
+ void addCatch(Value *V, BasicBlock *BB);
// Successor accessors.
BasicBlock *getSuccessor(unsigned i) const {
Modified: llvm/branches/wendling/eh/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/wendling/eh/lib/AsmParser/LLParser.cpp?rev=105262&r1=105261&r2=105262&view=diff
==============================================================================
--- llvm/branches/wendling/eh/lib/AsmParser/LLParser.cpp (original)
+++ llvm/branches/wendling/eh/lib/AsmParser/LLParser.cpp Mon May 31 19:29:31 2010
@@ -3489,6 +3489,13 @@
InvokeInst *II = InvokeInst::Create(Callee, NormalBB, UnwindBB, PersFn,
CatchAllVal, CatchAllBB, Catches.size(),
Args.begin(), Args.end());
+
+ // Now add the catch blockes.
+ for (SmallVectorImpl<ValueBBPair>::iterator
+ CI = Catches.begin(), CE = Catches.end(); CI != CE; ++CI)
+ II->addCatch(CI->first, CI->second);
+
+ // Lastly, set the CC and attributes.
II->setCallingConv(CC);
II->setAttributes(PAL);
Inst = II;
Modified: llvm/branches/wendling/eh/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/wendling/eh/lib/VMCore/Instructions.cpp?rev=105262&r1=105261&r2=105262&view=diff
==============================================================================
--- llvm/branches/wendling/eh/lib/VMCore/Instructions.cpp (original)
+++ llvm/branches/wendling/eh/lib/VMCore/Instructions.cpp Mon May 31 19:29:31 2010
@@ -563,6 +563,11 @@
(FTy->isVarArg() && NumArgs > FTy->getNumParams())) &&
"Invoking a function with bad signature");
+ // Allocate space for the catches.
+ ReservedSpace = NumCatches * 2;
+ this->NumCatches = 0;
+ CatchList = allocHungoffUses(ReservedSpace);
+
Use *OL = OperandList;
for (unsigned i = 0, e = NumArgs; i != e; i++) {
assert((i >= FTy->getNumParams() ||
@@ -620,6 +625,14 @@
setAttributes(PAL);
}
+void InvokeInst::addCatch(Value *V, BasicBlock *BB) {
+ unsigned OpNo = NumCatches;
+ assert(OpNo + 1 < ReservedSpace &&
+ "Adding too many catches to invoke instruction!");
+ NumCatches += 2;
+ CatchList[OpNo ] = V;
+ CatchList[OpNo + 1] = BB;
+}
//===----------------------------------------------------------------------===//
// ReturnInst Implementation
More information about the llvm-branch-commits
mailing list