mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-22 13:29:44 +00:00
Fix kill info for split intervals.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44609 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
60fb5ecccc
commit
b50bb8cf19
@ -1267,6 +1267,7 @@ addIntervalsForSpills(const LiveInterval &li,
|
|||||||
if (!TrySplit)
|
if (!TrySplit)
|
||||||
return NewLIs;
|
return NewLIs;
|
||||||
|
|
||||||
|
SmallPtrSet<LiveInterval*, 4> AddedKill;
|
||||||
SmallVector<unsigned, 2> Ops;
|
SmallVector<unsigned, 2> Ops;
|
||||||
if (NeedStackSlot) {
|
if (NeedStackSlot) {
|
||||||
int Id = SpillMBBs.find_first();
|
int Id = SpillMBBs.find_first();
|
||||||
@ -1316,8 +1317,13 @@ addIntervalsForSpills(const LiveInterval &li,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Else tell the spiller to issue a spill.
|
// Else tell the spiller to issue a spill.
|
||||||
if (!Folded)
|
if (!Folded) {
|
||||||
vrm.addSpillPoint(VReg, MI);
|
LiveRange *LR = &nI.ranges[nI.ranges.size()-1];
|
||||||
|
bool isKill = LR->end == getStoreIndex(index);
|
||||||
|
vrm.addSpillPoint(VReg, isKill, MI);
|
||||||
|
if (isKill)
|
||||||
|
AddedKill.insert(&nI);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Id = SpillMBBs.find_next(Id);
|
Id = SpillMBBs.find_next(Id);
|
||||||
}
|
}
|
||||||
@ -1372,24 +1378,28 @@ addIntervalsForSpills(const LiveInterval &li,
|
|||||||
// load / rematerialization for us.
|
// load / rematerialization for us.
|
||||||
if (Folded)
|
if (Folded)
|
||||||
nI.removeRange(getLoadIndex(index), getUseIndex(index)+1);
|
nI.removeRange(getLoadIndex(index), getUseIndex(index)+1);
|
||||||
else {
|
else
|
||||||
vrm.addRestorePoint(VReg, MI);
|
vrm.addRestorePoint(VReg, MI);
|
||||||
LiveRange *LR = &nI.ranges[nI.ranges.size()-1];
|
|
||||||
MachineInstr *LastUse = getInstructionFromIndex(getBaseIndex(LR->end));
|
|
||||||
int UseIdx = LastUse->findRegisterUseOperandIdx(VReg);
|
|
||||||
assert(UseIdx != -1);
|
|
||||||
LastUse->getOperand(UseIdx).setIsKill();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Id = RestoreMBBs.find_next(Id);
|
Id = RestoreMBBs.find_next(Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finalize spill weights and filter out dead intervals.
|
// Finalize intervals: add kills, finalize spill weights, and filter out
|
||||||
|
// dead intervals.
|
||||||
std::vector<LiveInterval*> RetNewLIs;
|
std::vector<LiveInterval*> RetNewLIs;
|
||||||
for (unsigned i = 0, e = NewLIs.size(); i != e; ++i) {
|
for (unsigned i = 0, e = NewLIs.size(); i != e; ++i) {
|
||||||
LiveInterval *LI = NewLIs[i];
|
LiveInterval *LI = NewLIs[i];
|
||||||
if (!LI->empty()) {
|
if (!LI->empty()) {
|
||||||
LI->weight /= LI->getSize();
|
LI->weight /= LI->getSize();
|
||||||
|
if (!AddedKill.count(LI)) {
|
||||||
|
LiveRange *LR = &LI->ranges[LI->ranges.size()-1];
|
||||||
|
MachineInstr *LastUse = getInstructionFromIndex(getBaseIndex(LR->end));
|
||||||
|
int UseIdx = LastUse->findRegisterUseOperandIdx(LI->reg);
|
||||||
|
assert(UseIdx != -1);
|
||||||
|
if (LastUse->getInstrDescriptor()->
|
||||||
|
getOperandConstraint(UseIdx, TOI::TIED_TO) == -1)
|
||||||
|
LastUse->getOperand(UseIdx).setIsKill();
|
||||||
|
}
|
||||||
RetNewLIs.push_back(LI);
|
RetNewLIs.push_back(LI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -977,15 +977,17 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM) {
|
|||||||
|
|
||||||
// Insert spills here if asked to.
|
// Insert spills here if asked to.
|
||||||
if (VRM.isSpillPt(&MI)) {
|
if (VRM.isSpillPt(&MI)) {
|
||||||
std::vector<unsigned> &SpillRegs = VRM.getSpillPtSpills(&MI);
|
std::vector<std::pair<unsigned,bool> > &SpillRegs =
|
||||||
|
VRM.getSpillPtSpills(&MI);
|
||||||
for (unsigned i = 0, e = SpillRegs.size(); i != e; ++i) {
|
for (unsigned i = 0, e = SpillRegs.size(); i != e; ++i) {
|
||||||
unsigned VirtReg = SpillRegs[i];
|
unsigned VirtReg = SpillRegs[i].first;
|
||||||
|
bool isKill = SpillRegs[i].second;
|
||||||
if (!VRM.getPreSplitReg(VirtReg))
|
if (!VRM.getPreSplitReg(VirtReg))
|
||||||
continue; // Split interval spilled again.
|
continue; // Split interval spilled again.
|
||||||
const TargetRegisterClass *RC = RegMap->getRegClass(VirtReg);
|
const TargetRegisterClass *RC = RegMap->getRegClass(VirtReg);
|
||||||
unsigned Phys = VRM.getPhys(VirtReg);
|
unsigned Phys = VRM.getPhys(VirtReg);
|
||||||
int StackSlot = VRM.getStackSlot(VirtReg);
|
int StackSlot = VRM.getStackSlot(VirtReg);
|
||||||
MRI->storeRegToStackSlot(MBB, next(MII), Phys, false, StackSlot, RC);
|
MRI->storeRegToStackSlot(MBB, next(MII), Phys, isKill, StackSlot, RC);
|
||||||
MachineInstr *StoreMI = next(MII);
|
MachineInstr *StoreMI = next(MII);
|
||||||
DOUT << "Store:\t" << StoreMI;
|
DOUT << "Store:\t" << StoreMI;
|
||||||
VRM.virtFolded(VirtReg, StoreMI, VirtRegMap::isMod);
|
VRM.virtFolded(VirtReg, StoreMI, VirtRegMap::isMod);
|
||||||
|
@ -80,7 +80,8 @@ namespace llvm {
|
|||||||
/// SpillPt2VirtMap - This records the virtual registers which should
|
/// SpillPt2VirtMap - This records the virtual registers which should
|
||||||
/// be spilled right after the MachineInstr due to live interval
|
/// be spilled right after the MachineInstr due to live interval
|
||||||
/// splitting.
|
/// splitting.
|
||||||
std::map<MachineInstr*, std::vector<unsigned> > SpillPt2VirtMap;
|
std::map<MachineInstr*, std::vector<std::pair<unsigned,bool> > >
|
||||||
|
SpillPt2VirtMap;
|
||||||
|
|
||||||
/// RestorePt2VirtMap - This records the virtual registers which should
|
/// RestorePt2VirtMap - This records the virtual registers which should
|
||||||
/// be restored right before the MachineInstr due to live interval
|
/// be restored right before the MachineInstr due to live interval
|
||||||
@ -216,30 +217,31 @@ namespace llvm {
|
|||||||
|
|
||||||
/// @brief returns the virtual registers that should be spilled due to
|
/// @brief returns the virtual registers that should be spilled due to
|
||||||
/// splitting right after the specified MachineInstr.
|
/// splitting right after the specified MachineInstr.
|
||||||
std::vector<unsigned> &getSpillPtSpills(MachineInstr *Pt) {
|
std::vector<std::pair<unsigned,bool> > &getSpillPtSpills(MachineInstr *Pt) {
|
||||||
return SpillPt2VirtMap[Pt];
|
return SpillPt2VirtMap[Pt];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief records the specified MachineInstr as a spill point for virtReg.
|
/// @brief records the specified MachineInstr as a spill point for virtReg.
|
||||||
void addSpillPoint(unsigned virtReg, MachineInstr *Pt) {
|
void addSpillPoint(unsigned virtReg, bool isKill, MachineInstr *Pt) {
|
||||||
if (SpillPt2VirtMap.find(Pt) != SpillPt2VirtMap.end())
|
if (SpillPt2VirtMap.find(Pt) != SpillPt2VirtMap.end())
|
||||||
SpillPt2VirtMap[Pt].push_back(virtReg);
|
SpillPt2VirtMap[Pt].push_back(std::make_pair(virtReg, isKill));
|
||||||
else {
|
else {
|
||||||
std::vector<unsigned> Virts;
|
std::vector<std::pair<unsigned,bool> > Virts;
|
||||||
Virts.push_back(virtReg);
|
Virts.push_back(std::make_pair(virtReg, isKill));
|
||||||
SpillPt2VirtMap.insert(std::make_pair(Pt, Virts));
|
SpillPt2VirtMap.insert(std::make_pair(Pt, Virts));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void transferSpillPts(MachineInstr *Old, MachineInstr *New) {
|
void transferSpillPts(MachineInstr *Old, MachineInstr *New) {
|
||||||
std::map<MachineInstr*,std::vector<unsigned> >::iterator I =
|
std::map<MachineInstr*,std::vector<std::pair<unsigned,bool> > >::iterator
|
||||||
SpillPt2VirtMap.find(Old);
|
I = SpillPt2VirtMap.find(Old);
|
||||||
if (I == SpillPt2VirtMap.end())
|
if (I == SpillPt2VirtMap.end())
|
||||||
return;
|
return;
|
||||||
while (!I->second.empty()) {
|
while (!I->second.empty()) {
|
||||||
unsigned virtReg = I->second.back();
|
unsigned virtReg = I->second.back().first;
|
||||||
|
bool isKill = I->second.back().second;
|
||||||
I->second.pop_back();
|
I->second.pop_back();
|
||||||
addSpillPoint(virtReg, New);
|
addSpillPoint(virtReg, isKill, New);
|
||||||
}
|
}
|
||||||
SpillPt2VirtMap.erase(I);
|
SpillPt2VirtMap.erase(I);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user