Rename registers that do not need copies.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45759 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Owen Anderson 2008-01-08 21:54:52 +00:00
parent 2815cbb9c7
commit 0c5714bb99

View File

@ -44,6 +44,7 @@ namespace {
std::map<unsigned, std::vector<unsigned> > Stacks;
std::set<unsigned> UsedByAnother;
std::map<unsigned, std::set<unsigned> > RenameSets;
bool runOnMachineFunction(MachineFunction &Fn);
@ -442,7 +443,8 @@ void StrongPHIElimination::processBlock(MachineBasicBlock* MBB) {
}
}
// FIXME: Cache renaming information
// Cache renaming information
RenameSets.insert(std::make_pair(P->getOperand(0).getReg(), PHIUnion));
ProcessedNames.insert(PHIUnion.begin(), PHIUnion.end());
++P;
@ -649,8 +651,22 @@ bool StrongPHIElimination::runOnMachineFunction(MachineFunction &Fn) {
// FIXME: This process should probably preserve LiveVariables
InsertCopies(Fn.begin());
// FIXME: Perform renaming
// FIXME: Remove Phi instrs
// Perform renaming
typedef std::map<unsigned, std::set<unsigned> > RenameSetType;
for (RenameSetType::iterator I = RenameSets.begin(), E = RenameSets.end();
I != E; ++I)
for (std::set<unsigned>::iterator SI = I->second.begin(),
SE = I->second.end(); SI != SE; ++SI)
Fn.getRegInfo().replaceRegWith(*SI, I->first);
// FIXME: Insert last-minute copies
// Remove PHIs
for (MachineFunction::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I)
for (MachineBasicBlock::iterator BI = I->begin(), BE = I->end();
BI != BE; ++BI)
if (BI->getOpcode() == TargetInstrInfo::PHI)
BI->eraseFromParent();
return false;
}