Skip to content
Snippets Groups Projects
Commit 331e6880 authored by Jakob Stoklund Olesen's avatar Jakob Stoklund Olesen
Browse files

Place new basic blocks immediately after their predecessor when splitting

critical edges in PHIElimination.

This has a huge impact on regalloc performance, and we recover almost all of
the 10% compile time regression that edge splitting introduced.

llvm-svn: 89381
parent 31c74dbb
No related branches found
No related tags found
No related merge requests found
...@@ -439,21 +439,21 @@ MachineBasicBlock *PHIElimination::SplitCriticalEdge(MachineBasicBlock *A, ...@@ -439,21 +439,21 @@ MachineBasicBlock *PHIElimination::SplitCriticalEdge(MachineBasicBlock *A,
++NumSplits; ++NumSplits;
MachineBasicBlock *NMBB = MF->CreateMachineBasicBlock(); MachineBasicBlock *NMBB = MF->CreateMachineBasicBlock();
MF->push_back(NMBB); MF->insert(next(MachineFunction::iterator(A)), NMBB);
DEBUG(errs() << "PHIElimination splitting critical edge:" DEBUG(errs() << "PHIElimination splitting critical edge:"
" BB#" << A->getNumber() " BB#" << A->getNumber()
<< " -- BB#" << NMBB->getNumber() << " -- BB#" << NMBB->getNumber()
<< " -- BB#" << B->getNumber() << '\n'); << " -- BB#" << B->getNumber() << '\n');
A->ReplaceUsesOfBlockWith(B, NMBB); A->ReplaceUsesOfBlockWith(B, NMBB);
// If A may fall through to B, we may have to insert a branch. A->updateTerminator();
if (A->isLayoutSuccessor(B))
A->updateTerminator();
// Insert unconditional "jump B" instruction in NMBB. // Insert unconditional "jump B" instruction in NMBB if necessary.
NMBB->addSuccessor(B); NMBB->addSuccessor(B);
Cond.clear(); if (!NMBB->isLayoutSuccessor(B)) {
MF->getTarget().getInstrInfo()->InsertBranch(*NMBB, B, NULL, Cond); Cond.clear();
MF->getTarget().getInstrInfo()->InsertBranch(*NMBB, B, NULL, Cond);
}
// Fix PHI nodes in B so they refer to NMBB instead of A // Fix PHI nodes in B so they refer to NMBB instead of A
for (MachineBasicBlock::iterator i = B->begin(), e = B->end(); for (MachineBasicBlock::iterator i = B->begin(), e = B->end();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment