summaryrefslogtreecommitdiff
path: root/lib/VMCore/BasicBlock.cpp
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2008-03-02 02:48:09 +0000
committerNick Lewycky <nicholas@mxc.ca>2008-03-02 02:48:09 +0000
commitfc82fabe00b0b820e3c0d7fc9e289bace0295f11 (patch)
tree963a736756189f58a4bd042ddf745b895e40cbac /lib/VMCore/BasicBlock.cpp
parentfe0753efbac4e15d5e1b8a58b06788a86d7e2545 (diff)
downloadllvm-fc82fabe00b0b820e3c0d7fc9e289bace0295f11.tar.gz
llvm-fc82fabe00b0b820e3c0d7fc9e289bace0295f11.tar.bz2
llvm-fc82fabe00b0b820e3c0d7fc9e289bace0295f11.tar.xz
Add an unwind_to field to basic blocks, making them Users instead of Values.
This is the first checkin for PR1269, the new EH infrastructure. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47802 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/BasicBlock.cpp')
-rw-r--r--lib/VMCore/BasicBlock.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/lib/VMCore/BasicBlock.cpp b/lib/VMCore/BasicBlock.cpp
index 3ab5e96157..f9bead74d2 100644
--- a/lib/VMCore/BasicBlock.cpp
+++ b/lib/VMCore/BasicBlock.cpp
@@ -70,8 +70,8 @@ template class SymbolTableListTraits<Instruction, BasicBlock>;
BasicBlock::BasicBlock(const std::string &Name, Function *NewParent,
- BasicBlock *InsertBefore)
- : Value(Type::LabelTy, Value::BasicBlockVal), Parent(0) {
+ BasicBlock *InsertBefore, BasicBlock *Dest)
+ : User(Type::LabelTy, Value::BasicBlockVal, &unwindDest, 0), Parent(0) {
// Make sure that we get added to a function
LeakDetector::addGarbageObject(this);
@@ -85,6 +85,8 @@ BasicBlock::BasicBlock(const std::string &Name, Function *NewParent,
}
setName(Name);
+ unwindDest.init(NULL, this);
+ setUnwindDest(Dest);
}
@@ -113,6 +115,19 @@ void BasicBlock::eraseFromParent() {
getParent()->getBasicBlockList().erase(this);
}
+const BasicBlock *BasicBlock::getUnwindDest() const {
+ return cast_or_null<const BasicBlock>(unwindDest.get());
+}
+
+BasicBlock *BasicBlock::getUnwindDest() {
+ return cast_or_null<BasicBlock>(unwindDest.get());
+}
+
+void BasicBlock::setUnwindDest(BasicBlock *dest) {
+ NumOperands = unwindDest ? 1 : 0;
+ unwindDest.set(dest);
+}
+
/// moveBefore - Unlink this basic block from its current function and
/// insert it into the function that MovePos lives in, right before MovePos.
void BasicBlock::moveBefore(BasicBlock *MovePos) {
@@ -151,6 +166,7 @@ Instruction* BasicBlock::getFirstNonPHI()
}
void BasicBlock::dropAllReferences() {
+ setUnwindDest(NULL);
for(iterator I = begin(), E = end(); I != E; ++I)
I->dropAllReferences();
}
@@ -177,6 +193,9 @@ void BasicBlock::removePredecessor(BasicBlock *Pred,
find(pred_begin(this), pred_end(this), Pred) != pred_end(this)) &&
"removePredecessor: BB is not a predecessor!");
+ if (Pred == getUnwindDest())
+ setUnwindDest(NULL);
+
if (InstList.empty()) return;
PHINode *APN = dyn_cast<PHINode>(&front());
if (!APN) return; // Quick exit.