From: Wei Mi Date: Tue, 8 Nov 2016 18:19:36 +0000 (+0000) Subject: [RegAllocGreedy] Another fix about NewVRegs for last chance recoloring after r281783. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=85bacc4129256e99c0f414c88b10c5e9387832ed;p=llvm [RegAllocGreedy] Another fix about NewVRegs for last chance recoloring after r281783. About when we should move a vreg from CurrentNewVRegs to NewVRegs, if the vreg in CurrentNewVRegs was added into RecoloringCandidate and was evicted, it shouldn't be added to NewVRegs because its physical register will be restored at the end of tryLastChanceRecoloring after the recoloring failed. If the vreg in CurrentNewVRegs was not in RecoloringCandidate, i.e. it was evicted in selectOrSplitImpl inside tryRecoloringCandidates, its physical register will not be restored even if the recoloring failed. In that case, we need to add the vreg to NewVRegs. Same as r281783, the problem was seen on out-of-tree target and we didn't have a test case that reproduce the problem with in-tree targets. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286259 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/RegAllocGreedy.cpp b/lib/CodeGen/RegAllocGreedy.cpp index 188021c2832..469ea67f0ac 100644 --- a/lib/CodeGen/RegAllocGreedy.cpp +++ b/lib/CodeGen/RegAllocGreedy.cpp @@ -2105,9 +2105,6 @@ unsigned RAGreedy::tryLastChanceRecoloring(LiveInterval &VirtReg, // Mark VirtReg as fixed, i.e., it will not be recolored pass this point in // this recoloring "session". FixedRegisters.insert(VirtReg.reg); - // Remember the ID of the last vreg in case the recoloring fails. - unsigned LastVReg = - TargetRegisterInfo::index2VirtReg(MRI->getNumVirtRegs() - 1); SmallVector CurrentNewVRegs; Order.rewind(); @@ -2179,14 +2176,14 @@ unsigned RAGreedy::tryLastChanceRecoloring(LiveInterval &VirtReg, FixedRegisters = SaveFixedRegisters; Matrix->unassign(VirtReg); - // When we move a register from RS_Assign to RS_Split, we do not - // actually do anything with it. I.e., it should not end up in NewVRegs. - // For the other cases, since we created new live-ranges, we need to - // process them. + // For a newly created vreg which is also in RecoloringCandidates, + // don't add it to NewVRegs because its physical register will be restored + // below. Other vregs in CurrentNewVRegs are created by calling + // selectOrSplit and should be added into NewVRegs. for (SmallVectorImpl::iterator Next = CurrentNewVRegs.begin(), End = CurrentNewVRegs.end(); Next != End; ++Next) { - if (*Next <= LastVReg && getStage(LIS->getInterval(*Next)) == RS_Split) + if (RecoloringCandidates.count(&LIS->getInterval(*Next))) continue; NewVRegs.push_back(*Next); }