diff options
Diffstat (limited to 'llvm/lib/IR/BasicBlock.cpp')
-rw-r--r-- | llvm/lib/IR/BasicBlock.cpp | 40 |
1 files changed, 1 insertions, 39 deletions
diff --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp index 7f34565..95b8602b 100644 --- a/llvm/lib/IR/BasicBlock.cpp +++ b/llvm/lib/IR/BasicBlock.cpp @@ -372,11 +372,7 @@ bool BasicBlock::isLegalToHoistInto() const { return !Term->isExceptionalTerminator(); } -BasicBlock *BasicBlock::splitBasicBlock(iterator I, const Twine &BBName, - bool Before) { - if (Before) - return splitBasicBlockBefore(I, BBName); - +BasicBlock *BasicBlock::splitBasicBlock(iterator I, const Twine &BBName) { assert(getTerminator() && "Can't use splitBasicBlock on degenerate BB!"); assert(I != InstList.end() && "Trying to get me to create degenerate basic block!"); @@ -403,40 +399,6 @@ BasicBlock *BasicBlock::splitBasicBlock(iterator I, const Twine &BBName, return New; } -BasicBlock *BasicBlock::splitBasicBlockBefore(iterator I, const Twine &BBName) { - assert(getTerminator() && - "Can't use splitBasicBlockBefore on degenerate BB!"); - assert(I != InstList.end() && - "Trying to get me to create degenerate basic block!"); - - assert((!isa<PHINode>(*I) || getSinglePredecessor()) && - "cannot split on multi incoming phis"); - - BasicBlock *New = BasicBlock::Create(getContext(), BBName, getParent(), this); - // Save DebugLoc of split point before invalidating iterator. - DebugLoc Loc = I->getDebugLoc(); - // Move all of the specified instructions from the original basic block into - // the new basic block. - New->getInstList().splice(New->end(), this->getInstList(), begin(), I); - - // Loop through all of the predecessors of the 'this' block (which will be the - // predecessors of the New block), replace the specified successor 'this' - // block to point at the New block and update any PHI nodes in 'this' block. - // If there were PHI nodes in 'this' block, the PHI nodes are updated - // to reflect that the incoming branches will be from the New block and not - // from predecessors of the 'this' block. - for (BasicBlock *Pred : predecessors(this)) { - Instruction *TI = Pred->getTerminator(); - TI->replaceSuccessorWith(this, New); - this->replacePhiUsesWith(Pred, New); - } - // Add a branch instruction from "New" to "this" Block. - BranchInst *BI = BranchInst::Create(this, New); - BI->setDebugLoc(Loc); - - return New; -} - void BasicBlock::replacePhiUsesWith(BasicBlock *Old, BasicBlock *New) { // N.B. This might not be a complete BasicBlock, so don't assume // that it ends with a non-phi instruction. |