mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-11 11:34:02 +00:00
Fixes <rdar://problem/8612856>: During postRAsched, the antidependence
breaker needs to check all definitions of the antidepenent register to avoid multiple defs of the same new register. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118032 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ec6f096c36
commit
4638852696
@ -325,8 +325,25 @@ void CriticalAntiDepBreaker::ScanInstruction(MachineInstr *MI,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check all machine instructions that define the antidependent register.
|
||||||
|
// Return true if any of these instructions define the new register.
|
||||||
|
bool
|
||||||
|
CriticalAntiDepBreaker::isNewRegModifiedByRefs(RegRefIter RegRefBegin,
|
||||||
|
RegRefIter RegRefEnd,
|
||||||
|
unsigned NewReg)
|
||||||
|
{
|
||||||
|
for (RegRefIter I = RegRefBegin; I != RegRefEnd; ++I ) {
|
||||||
|
MachineOperand *MO = I->second;
|
||||||
|
if (MO->isDef()) continue;
|
||||||
|
if (MO->getParent()->modifiesRegister(NewReg, TRI))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned
|
unsigned
|
||||||
CriticalAntiDepBreaker::findSuitableFreeRegister(MachineInstr *MI,
|
CriticalAntiDepBreaker::findSuitableFreeRegister(RegRefIter RegRefBegin,
|
||||||
|
RegRefIter RegRefEnd,
|
||||||
unsigned AntiDepReg,
|
unsigned AntiDepReg,
|
||||||
unsigned LastNewReg,
|
unsigned LastNewReg,
|
||||||
const TargetRegisterClass *RC)
|
const TargetRegisterClass *RC)
|
||||||
@ -342,10 +359,10 @@ CriticalAntiDepBreaker::findSuitableFreeRegister(MachineInstr *MI,
|
|||||||
// an anti-dependence with this AntiDepReg, because that would
|
// an anti-dependence with this AntiDepReg, because that would
|
||||||
// re-introduce that anti-dependence.
|
// re-introduce that anti-dependence.
|
||||||
if (NewReg == LastNewReg) continue;
|
if (NewReg == LastNewReg) continue;
|
||||||
// If the instruction already has a def of the NewReg, it's not suitable.
|
// If any instructions that define AntiDepReg also define the NewReg, it's
|
||||||
// For example, Instruction with multiple definitions can result in this
|
// not suitable. For example, Instruction with multiple definitions can
|
||||||
// condition.
|
// result in this condition.
|
||||||
if (MI->modifiesRegister(NewReg, TRI)) continue;
|
if (isNewRegModifiedByRefs(RegRefBegin, RegRefEnd, NewReg)) continue;
|
||||||
// If NewReg is dead and NewReg's most recent def is not before
|
// If NewReg is dead and NewReg's most recent def is not before
|
||||||
// AntiDepReg's kill, it's safe to replace AntiDepReg with NewReg.
|
// AntiDepReg's kill, it's safe to replace AntiDepReg with NewReg.
|
||||||
assert(((KillIndices[AntiDepReg] == ~0u) != (DefIndices[AntiDepReg] == ~0u))
|
assert(((KillIndices[AntiDepReg] == ~0u) != (DefIndices[AntiDepReg] == ~0u))
|
||||||
@ -552,7 +569,11 @@ BreakAntiDependencies(const std::vector<SUnit>& SUnits,
|
|||||||
// TODO: Instead of picking the first free register, consider which might
|
// TODO: Instead of picking the first free register, consider which might
|
||||||
// be the best.
|
// be the best.
|
||||||
if (AntiDepReg != 0) {
|
if (AntiDepReg != 0) {
|
||||||
if (unsigned NewReg = findSuitableFreeRegister(MI, AntiDepReg,
|
std::pair<std::multimap<unsigned, MachineOperand *>::iterator,
|
||||||
|
std::multimap<unsigned, MachineOperand *>::iterator>
|
||||||
|
Range = RegRefs.equal_range(AntiDepReg);
|
||||||
|
if (unsigned NewReg = findSuitableFreeRegister(Range.first, Range.second,
|
||||||
|
AntiDepReg,
|
||||||
LastNewReg[AntiDepReg],
|
LastNewReg[AntiDepReg],
|
||||||
RC)) {
|
RC)) {
|
||||||
DEBUG(dbgs() << "Breaking anti-dependence edge on "
|
DEBUG(dbgs() << "Breaking anti-dependence edge on "
|
||||||
@ -562,9 +583,6 @@ BreakAntiDependencies(const std::vector<SUnit>& SUnits,
|
|||||||
|
|
||||||
// Update the references to the old register to refer to the new
|
// Update the references to the old register to refer to the new
|
||||||
// register.
|
// register.
|
||||||
std::pair<std::multimap<unsigned, MachineOperand *>::iterator,
|
|
||||||
std::multimap<unsigned, MachineOperand *>::iterator>
|
|
||||||
Range = RegRefs.equal_range(AntiDepReg);
|
|
||||||
for (std::multimap<unsigned, MachineOperand *>::iterator
|
for (std::multimap<unsigned, MachineOperand *>::iterator
|
||||||
Q = Range.first, QE = Range.second; Q != QE; ++Q) {
|
Q = Range.first, QE = Range.second; Q != QE; ++Q) {
|
||||||
Q->second->setReg(NewReg);
|
Q->second->setReg(NewReg);
|
||||||
|
@ -50,6 +50,8 @@ class TargetRegisterInfo;
|
|||||||
|
|
||||||
/// RegRegs - Map registers to all their references within a live range.
|
/// RegRegs - Map registers to all their references within a live range.
|
||||||
std::multimap<unsigned, MachineOperand *> RegRefs;
|
std::multimap<unsigned, MachineOperand *> RegRefs;
|
||||||
|
typedef std::multimap<unsigned, MachineOperand *>::const_iterator
|
||||||
|
RegRefIter;
|
||||||
|
|
||||||
/// KillIndices - The index of the most recent kill (proceding bottom-up),
|
/// KillIndices - The index of the most recent kill (proceding bottom-up),
|
||||||
/// or ~0u if the register is not live.
|
/// or ~0u if the register is not live.
|
||||||
@ -90,10 +92,14 @@ class TargetRegisterInfo;
|
|||||||
private:
|
private:
|
||||||
void PrescanInstruction(MachineInstr *MI);
|
void PrescanInstruction(MachineInstr *MI);
|
||||||
void ScanInstruction(MachineInstr *MI, unsigned Count);
|
void ScanInstruction(MachineInstr *MI, unsigned Count);
|
||||||
unsigned findSuitableFreeRegister(MachineInstr *MI,
|
bool isNewRegModifiedByRefs(RegRefIter RegRefBegin,
|
||||||
|
RegRefIter RegRefEnd,
|
||||||
|
unsigned NewReg);
|
||||||
|
unsigned findSuitableFreeRegister(RegRefIter RegRefBegin,
|
||||||
|
RegRefIter RegRefEnd,
|
||||||
unsigned AntiDepReg,
|
unsigned AntiDepReg,
|
||||||
unsigned LastNewReg,
|
unsigned LastNewReg,
|
||||||
const TargetRegisterClass *);
|
const TargetRegisterClass *RC);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user