aboutsummaryrefslogtreecommitdiffstats
path: root/lib/IR/BasicBlock.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/IR/BasicBlock.cpp')
-rw-r--r--lib/IR/BasicBlock.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/lib/IR/BasicBlock.cpp b/lib/IR/BasicBlock.cpp
index 5ed9bed..b3b3cbf 100644
--- a/lib/IR/BasicBlock.cpp
+++ b/lib/IR/BasicBlock.cpp
@@ -19,7 +19,6 @@
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/LLVMContext.h"
-#include "llvm/IR/LeakDetector.h"
#include "llvm/IR/Type.h"
#include <algorithm>
using namespace llvm;
@@ -47,9 +46,6 @@ BasicBlock::BasicBlock(LLVMContext &C, const Twine &Name, Function *NewParent,
BasicBlock *InsertBefore)
: Value(Type::getLabelTy(C), Value::BasicBlockVal), Parent(nullptr) {
- // Make sure that we get added to a function
- LeakDetector::addGarbageObject(this);
-
if (NewParent)
insertInto(NewParent, InsertBefore);
else
@@ -94,14 +90,8 @@ BasicBlock::~BasicBlock() {
}
void BasicBlock::setParent(Function *parent) {
- if (getParent())
- LeakDetector::addGarbageObject(this);
-
// Set Parent=parent, updating instruction symtab entries as appropriate.
InstList.setSymTabObject(&Parent, parent);
-
- if (getParent())
- LeakDetector::removeGarbageObject(this);
}
void BasicBlock::removeFromParent() {
@@ -249,6 +239,20 @@ BasicBlock *BasicBlock::getUniquePredecessor() {
return PredBB;
}
+BasicBlock *BasicBlock::getUniqueSuccessor() {
+ succ_iterator SI = succ_begin(this), E = succ_end(this);
+ if (SI == E) return NULL; // No successors
+ BasicBlock *SuccBB = *SI;
+ ++SI;
+ for (;SI != E; ++SI) {
+ if (*SI != SuccBB)
+ return NULL;
+ // The same successor appears multiple times in the successor list.
+ // This is OK.
+ }
+ return SuccBB;
+}
+
/// removePredecessor - This method is used to notify a BasicBlock that the
/// specified Predecessor of the block is no longer able to reach it. This is
/// actually not used to update the Predecessor list, but is actually used to