BasicBlock::BasicBlock(const std::string &Name, Function *NewParent,
- BasicBlock *InsertBefore, BasicBlock *Dest)
- : User(Type::LabelTy, Value::BasicBlockVal, &unwindDest, 0/*FIXME*/), Parent(0) {
+ BasicBlock *InsertBefore)
+ : Value(Type::LabelTy, Value::BasicBlockVal), Parent(0) {
// Make sure that we get added to a function
LeakDetector::addGarbageObject(this);
}
setName(Name);
- unwindDest.init(NULL, this);
- setUnwindDest(Dest);
}
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) {
}
void BasicBlock::dropAllReferences() {
- setUnwindDest(NULL);
for(iterator I = begin(), E = end(); I != E; ++I)
I->dropAllReferences();
}
/// called while the predecessor still refers to this block.
///
void BasicBlock::removePredecessor(BasicBlock *Pred,
- bool DontDeleteUselessPHIs,
- bool OnlyDeleteOne) {
+ bool DontDeleteUselessPHIs) {
assert((hasNUsesOrMore(16)||// Reduce cost of this assertion for complex CFGs.
find(pred_begin(this), pred_end(this), Pred) != pred_end(this)) &&
"removePredecessor: BB is not a predecessor!");
// Yup, loop through and nuke the PHI nodes
while (PHINode *PN = dyn_cast<PHINode>(&front())) {
// Remove the predecessor first.
- if (OnlyDeleteOne) {
- int idx = PN->getBasicBlockIndex(Pred);
- PN->removeIncomingValue(idx, !DontDeleteUselessPHIs);
- } else
- PN->removeIncomingValue(Pred, !DontDeleteUselessPHIs);
+ PN->removeIncomingValue(Pred, !DontDeleteUselessPHIs);
// If the PHI _HAD_ two uses, replace PHI node with its now *single* value
if (max_idx == 2) {
PHINode *PN;
for (iterator II = begin(); (PN = dyn_cast<PHINode>(II)); ) {
++II;
- if (OnlyDeleteOne) {
- int idx = PN->getBasicBlockIndex(Pred);
- PN->removeIncomingValue(idx, false);
- } else
- PN->removeIncomingValue(Pred, false);
-
+ PN->removeIncomingValue(Pred, false);
// If all incoming values to the Phi are the same, we can replace the Phi
// with that value.
Value* PNV = 0;
assert(I != InstList.end() &&
"Trying to get me to create degenerate basic block!");
- BasicBlock *New = new(0/*FIXME*/) BasicBlock(BBName, getParent(), getNext());
+ BasicBlock *New = BasicBlock::Create(BBName, getParent(), getNext());
// Move all of the specified instructions from the original basic block into
// the new basic block.