mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-13 22:24:07 +00:00
Teach PHIElimination to split critical edges when -split-phi-edges is enabled.
Critical edges leading to a PHI node are split when the PHI source variable is live out from the predecessor block. This help the coalescer eliminate more PHI joins. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86725 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -50,6 +50,14 @@ void LiveVariables::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
MachineFunctionPass::getAnalysisUsage(AU);
|
||||
}
|
||||
|
||||
MachineInstr *
|
||||
LiveVariables::VarInfo::findKill(const MachineBasicBlock *MBB) const {
|
||||
for (unsigned i = 0, e = Kills.size(); i != e; ++i)
|
||||
if (Kills[i]->getParent() == MBB)
|
||||
return Kills[i];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void LiveVariables::VarInfo::dump() const {
|
||||
errs() << " Alive in blocks: ";
|
||||
for (SparseBitVector<>::iterator I = AliveBlocks.begin(),
|
||||
@ -641,3 +649,35 @@ void LiveVariables::analyzePHINodes(const MachineFunction& Fn) {
|
||||
PHIVarInfo[BBI->getOperand(i + 1).getMBB()->getNumber()]
|
||||
.push_back(BBI->getOperand(i).getReg());
|
||||
}
|
||||
|
||||
void LiveVariables::addNewBlock(MachineBasicBlock *A, MachineBasicBlock *B) {
|
||||
unsigned NumA = A->getNumber();
|
||||
unsigned NumB = B->getNumber();
|
||||
|
||||
// Update info for all live variables
|
||||
for (unsigned i = 0, e = VirtRegInfo.size(); i != e; ++i) {
|
||||
VarInfo &VI = VirtRegInfo[i];
|
||||
|
||||
// Anything live through B is also live through A.
|
||||
if (VI.AliveBlocks.test(NumB)) {
|
||||
VI.AliveBlocks.set(NumA);
|
||||
continue;
|
||||
}
|
||||
|
||||
// If we're not killed in B, we are not live in
|
||||
if (!VI.findKill(B))
|
||||
continue;
|
||||
|
||||
unsigned Reg = i+TargetRegisterInfo::FirstVirtualRegister;
|
||||
|
||||
// Find a def outside B
|
||||
for (MachineRegisterInfo::def_iterator di = MRI->def_begin(Reg),
|
||||
de=MRI->def_end(); di != de; ++di) {
|
||||
if (di->getParent() != B) {
|
||||
// Reg was defined outside B and killed in B - it must be live in.
|
||||
VI.AliveBlocks.set(NumA);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user