mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-28 22:43:29 +00:00
Use the new MergeBasicBlockIntoOnlyPred function.
llvm-svn: 60163
This commit is contained in:
parent
bb86dff3fe
commit
e1ed3a2962
@ -205,25 +205,7 @@ void CodeGenPrepare::EliminateMostlyEmptyBlock(BasicBlock *BB) {
|
||||
// If the destination block has a single pred, then this is a trivial edge,
|
||||
// just collapse it.
|
||||
if (DestBB->getSinglePredecessor()) {
|
||||
// If DestBB 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();
|
||||
}
|
||||
|
||||
// Splice all the PHI nodes from BB over to DestBB.
|
||||
DestBB->getInstList().splice(DestBB->begin(), BB->getInstList(),
|
||||
BB->begin(), BI);
|
||||
|
||||
// Anything that branched to BB now branches to DestBB.
|
||||
BB->replaceAllUsesWith(DestBB);
|
||||
|
||||
// Nuke BB.
|
||||
BB->eraseFromParent();
|
||||
|
||||
MergeBasicBlockIntoOnlyPred(DestBB);
|
||||
DOUT << "AFTER:\n" << *DestBB << "\n\n\n";
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user