diff options
author | Owen Anderson <resistor@mac.com> | 2008-08-06 22:08:58 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2008-08-06 22:08:58 +0000 |
commit | 883771f86a111c43ce7c30085a1f4820b66f5712 (patch) | |
tree | dd475fef5e77438d5d2c5c98f418c82819f3b3a6 /lib/CodeGen/StrongPHIElimination.cpp | |
parent | aa111080dfb161054255c9c367779f1ea2581849 (diff) | |
download | external_llvm-883771f86a111c43ce7c30085a1f4820b66f5712.zip external_llvm-883771f86a111c43ce7c30085a1f4820b66f5712.tar.gz external_llvm-883771f86a111c43ce7c30085a1f4820b66f5712.tar.bz2 |
Correct handle cases where two phis are coalesced together, and correct break up the case where two different
phis want to coalesce with the same vreg.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54426 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/StrongPHIElimination.cpp')
-rw-r--r-- | lib/CodeGen/StrongPHIElimination.cpp | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/lib/CodeGen/StrongPHIElimination.cpp b/lib/CodeGen/StrongPHIElimination.cpp index 11b8ca3..1df453c 100644 --- a/lib/CodeGen/StrongPHIElimination.cpp +++ b/lib/CodeGen/StrongPHIElimination.cpp @@ -860,20 +860,52 @@ bool StrongPHIElimination::runOnMachineFunction(MachineFunction &Fn) { I->begin()->getOpcode() == TargetInstrInfo::PHI) processBlock(I); + // Break interferences where two different phis want to coalesce + // in the same register. + std::set<unsigned> seen; + typedef std::map<unsigned, std::map<unsigned, MachineBasicBlock*> > + RenameSetType; + for (RenameSetType::iterator I = RenameSets.begin(), E = RenameSets.end(); + I != E; ++I) { + for (std::map<unsigned, MachineBasicBlock*>::iterator + OI = I->second.begin(), OE = I->second.end(); OI != OE; ) { + if (!seen.count(OI->first)) { + seen.insert(OI->first); + ++OI; + } else { + Waiting[OI->second].insert(std::make_pair(OI->first, I->first)); + unsigned reg = OI->first; + ++OI; + I->second.erase(reg); + } + } + } + // Insert copies // FIXME: This process should probably preserve LiveIntervals SmallPtrSet<MachineBasicBlock*, 16> visited; InsertCopies(Fn.begin(), visited); // Perform renaming - typedef std::map<unsigned, std::map<unsigned, MachineBasicBlock*> > - RenameSetType; for (RenameSetType::iterator I = RenameSets.begin(), E = RenameSets.end(); I != E; ++I) - for (std::map<unsigned, MachineBasicBlock*>::iterator SI = - I->second.begin(), SE = I->second.end(); SI != SE; ++SI) { - mergeLiveIntervals(I->first, SI->first, SI->second); - Fn.getRegInfo().replaceRegWith(SI->first, I->first); + while (I->second.size()) { + std::map<unsigned, MachineBasicBlock*>::iterator SI = I->second.begin(); + + if (SI->first != I->first) { + mergeLiveIntervals(I->first, SI->first, SI->second); + Fn.getRegInfo().replaceRegWith(SI->first, I->first); + + if (RenameSets.count(SI->first)) { + I->second.insert(RenameSets[SI->first].begin(), + RenameSets[SI->first].end()); + RenameSets.erase(SI->first); + } + + + } + + I->second.erase(SI->first); } // FIXME: Insert last-minute copies @@ -907,6 +939,7 @@ bool StrongPHIElimination::runOnMachineFunction(MachineFunction &Fn) { // trim them because they might have other legitimate uses. for (unsigned i = 1; i < PInstr->getNumOperands(); i += 2) { unsigned reg = PInstr->getOperand(i).getReg(); + MachineBasicBlock* MBB = PInstr->getOperand(i+1).getMBB(); LiveInterval& InputI = LI.getInterval(reg); if (MBB != PInstr->getParent() && |