diff options
author | Chris Lattner <sabre@nondot.org> | 2008-11-27 07:43:12 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-11-27 07:43:12 +0000 |
commit | 99d6809ac1e5c158b4d74276fd452ca6cfc2a3d4 (patch) | |
tree | 161772dee2e555c2926284a7482d4fc6afbf4bad /llvm/lib/Transforms/Scalar/JumpThreading.cpp | |
parent | 077eb6fcc2ac538676d5ac2444fe3cf967301164 (diff) | |
download | bcm5719-llvm-99d6809ac1e5c158b4d74276fd452ca6cfc2a3d4.tar.gz bcm5719-llvm-99d6809ac1e5c158b4d74276fd452ca6cfc2a3d4.zip |
move MergeBasicBlockIntoOnlyPred to Transforms/Utils.
llvm-svn: 60162
Diffstat (limited to 'llvm/lib/Transforms/Scalar/JumpThreading.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/JumpThreading.cpp | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp index b6d8ff6b35e..eb4a873a464 100644 --- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp +++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp @@ -156,37 +156,6 @@ static unsigned getJumpThreadDuplicationCost(const BasicBlock *BB) { return Size; } -/// MergeBasicBlockIntoOnlyPred - DestBB is a block with one predecessor and its -/// predecessor is known to have one successor (DestBB!). Eliminate the edge -/// between them, moving the instructions in the predecessor into DestBB and -/// deleting the predecessor block. -/// -/// FIXME: Move to TransformUtils to share with simplifycfg and codegenprepare. -static void MergeBasicBlockIntoOnlyPred(BasicBlock *DestBB) { - // If BB has single-entry PHI nodes, fold them. - while (PHINode *PN = dyn_cast<PHINode>(DestBB->begin())) { - Value *NewVal = PN->getIncomingValue(0); - // Replace self referencing PHI with undef, it must be dead. - if (NewVal == PN) NewVal = UndefValue::get(PN->getType()); - PN->replaceAllUsesWith(NewVal); - PN->eraseFromParent(); - } - - BasicBlock *PredBB = DestBB->getSinglePredecessor(); - assert(PredBB && "Block doesn't have a single predecessor!"); - - // Splice all the instructions from PredBB to DestBB. - PredBB->getTerminator()->eraseFromParent(); - DestBB->getInstList().splice(DestBB->begin(), PredBB->getInstList()); - - // Anything that branched to PredBB now branches to DestBB. - PredBB->replaceAllUsesWith(DestBB); - - // Nuke BB. - PredBB->eraseFromParent(); -} - - /// ProcessBlock - If there are any predecessors whose control can be threaded /// through to a successor, transform them now. bool JumpThreading::ProcessBlock(BasicBlock *BB) { |