[llvm-commits] [llvm] r44609 - in /llvm/trunk/lib/CodeGen: LiveIntervalAnalysis.cpp VirtRegMap.cpp VirtRegMap.h
Evan Cheng
evan.cheng at apple.com
Wed Dec 5 00:16:32 PST 2007
Author: evancheng
Date: Wed Dec 5 02:16:32 2007
New Revision: 44609
URL: http://llvm.org/viewvc/llvm-project?rev=44609&view=rev
Log:
Fix kill info for split intervals.
Modified:
llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp
llvm/trunk/lib/CodeGen/VirtRegMap.cpp
llvm/trunk/lib/CodeGen/VirtRegMap.h
Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=44609&r1=44608&r2=44609&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Wed Dec 5 02:16:32 2007
@@ -1267,6 +1267,7 @@
if (!TrySplit)
return NewLIs;
+ SmallPtrSet<LiveInterval*, 4> AddedKill;
SmallVector<unsigned, 2> Ops;
if (NeedStackSlot) {
int Id = SpillMBBs.find_first();
@@ -1316,8 +1317,13 @@
}
// Else tell the spiller to issue a spill.
- if (!Folded)
- vrm.addSpillPoint(VReg, MI);
+ if (!Folded) {
+ 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);
}
@@ -1372,24 +1378,28 @@
// load / rematerialization for us.
if (Folded)
nI.removeRange(getLoadIndex(index), getUseIndex(index)+1);
- else {
+ else
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);
}
- // Finalize spill weights and filter out dead intervals.
+ // Finalize intervals: add kills, finalize spill weights, and filter out
+ // dead intervals.
std::vector<LiveInterval*> RetNewLIs;
for (unsigned i = 0, e = NewLIs.size(); i != e; ++i) {
LiveInterval *LI = NewLIs[i];
if (!LI->empty()) {
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);
}
}
Modified: llvm/trunk/lib/CodeGen/VirtRegMap.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegMap.cpp?rev=44609&r1=44608&r2=44609&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/VirtRegMap.cpp (original)
+++ llvm/trunk/lib/CodeGen/VirtRegMap.cpp Wed Dec 5 02:16:32 2007
@@ -977,15 +977,17 @@
// Insert spills here if asked to.
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) {
- unsigned VirtReg = SpillRegs[i];
+ unsigned VirtReg = SpillRegs[i].first;
+ bool isKill = SpillRegs[i].second;
if (!VRM.getPreSplitReg(VirtReg))
continue; // Split interval spilled again.
const TargetRegisterClass *RC = RegMap->getRegClass(VirtReg);
unsigned Phys = VRM.getPhys(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);
DOUT << "Store:\t" << StoreMI;
VRM.virtFolded(VirtReg, StoreMI, VirtRegMap::isMod);
Modified: llvm/trunk/lib/CodeGen/VirtRegMap.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegMap.h?rev=44609&r1=44608&r2=44609&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/VirtRegMap.h (original)
+++ llvm/trunk/lib/CodeGen/VirtRegMap.h Wed Dec 5 02:16:32 2007
@@ -80,7 +80,8 @@
/// SpillPt2VirtMap - This records the virtual registers which should
/// be spilled right after the MachineInstr due to live interval
/// 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
/// be restored right before the MachineInstr due to live interval
@@ -216,30 +217,31 @@
/// @brief returns the virtual registers that should be spilled due to
/// splitting right after the specified MachineInstr.
- std::vector<unsigned> &getSpillPtSpills(MachineInstr *Pt) {
+ std::vector<std::pair<unsigned,bool> > &getSpillPtSpills(MachineInstr *Pt) {
return SpillPt2VirtMap[Pt];
}
/// @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())
- SpillPt2VirtMap[Pt].push_back(virtReg);
+ SpillPt2VirtMap[Pt].push_back(std::make_pair(virtReg, isKill));
else {
- std::vector<unsigned> Virts;
- Virts.push_back(virtReg);
+ std::vector<std::pair<unsigned,bool> > Virts;
+ Virts.push_back(std::make_pair(virtReg, isKill));
SpillPt2VirtMap.insert(std::make_pair(Pt, Virts));
}
}
void transferSpillPts(MachineInstr *Old, MachineInstr *New) {
- std::map<MachineInstr*,std::vector<unsigned> >::iterator I =
- SpillPt2VirtMap.find(Old);
+ std::map<MachineInstr*,std::vector<std::pair<unsigned,bool> > >::iterator
+ I = SpillPt2VirtMap.find(Old);
if (I == SpillPt2VirtMap.end())
return;
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();
- addSpillPoint(virtReg, New);
+ addSpillPoint(virtReg, isKill, New);
}
SpillPt2VirtMap.erase(I);
}
More information about the llvm-commits
mailing list