1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00

MachineInstr can change. Store indexes instead.

llvm-svn: 44612
This commit is contained in:
Evan Cheng 2007-12-05 10:24:35 +00:00
parent 33ac3dd05f
commit abc6ab4765
3 changed files with 23 additions and 14 deletions

View File

@ -1165,6 +1165,15 @@ addIntervalsForSpills(const LiveInterval &li,
// it's also guaranteed to be a single val# / range interval.
if (vrm.getPreSplitReg(li.reg)) {
vrm.setIsSplitFromReg(li.reg, 0);
// Unset the split kill marker on the last use.
unsigned KillIdx = vrm.getKillPoint(li.reg);
if (KillIdx) {
MachineInstr *KillMI = getInstructionFromIndex(KillIdx);
assert(KillMI && "Last use disappeared?");
int KillOp = KillMI->findRegisterUseOperandIdx(li.reg, true);
assert(KillOp != -1 && "Last use disappeared?");
KillMI->getOperand(KillOp).unsetIsKill();
}
vrm.removeKillPoint(li.reg);
bool DefIsReMat = vrm.isReMaterialized(li.reg);
Slot = vrm.getStackSlot(li.reg);
@ -1395,13 +1404,14 @@ addIntervalsForSpills(const LiveInterval &li,
LI->weight /= LI->getSize();
if (!AddedKill.count(LI)) {
LiveRange *LR = &LI->ranges[LI->ranges.size()-1];
MachineInstr *LastUse = getInstructionFromIndex(getBaseIndex(LR->end));
unsigned LastUseIdx = getBaseIndex(LR->end);
MachineInstr *LastUse = getInstructionFromIndex(LastUseIdx);
int UseIdx = LastUse->findRegisterUseOperandIdx(LI->reg);
assert(UseIdx != -1);
if (LastUse->getInstrDescriptor()->
getOperandConstraint(UseIdx, TOI::TIED_TO) == -1) {
LastUse->getOperand(UseIdx).setIsKill();
vrm.addKillPoint(LI->reg, &LastUse->getOperand(UseIdx));
vrm.addKillPoint(LI->reg, LastUseIdx);
}
}
RetNewLIs.push_back(LI);

View File

@ -64,7 +64,7 @@ VirtRegMap::VirtRegMap(MachineFunction &mf)
: TII(*mf.getTarget().getInstrInfo()), MF(mf),
Virt2PhysMap(NO_PHYS_REG), Virt2StackSlotMap(NO_STACK_SLOT),
Virt2ReMatIdMap(NO_STACK_SLOT), Virt2SplitMap(0),
Virt2SplitKillMap(NULL), ReMatMap(NULL), ReMatId(MAX_STACK_SLOT+1) {
Virt2SplitKillMap(0), ReMatMap(NULL), ReMatId(MAX_STACK_SLOT+1) {
grow();
}

View File

@ -67,8 +67,8 @@ namespace llvm {
IndexedMap<unsigned, VirtReg2IndexFunctor> Virt2SplitMap;
/// Virt2SplitKillMap - This is splitted virtual register to its last use
/// (kill) mapping.
IndexedMap<MachineOperand*> Virt2SplitKillMap;
/// (kill) index mapping.
IndexedMap<unsigned> Virt2SplitKillMap;
/// ReMatMap - This is virtual register to re-materialized instruction
/// mapping. Each virtual register whose definition is going to be
@ -215,18 +215,17 @@ namespace llvm {
}
/// @brief record the last use (kill) of a split virtual register.
void addKillPoint(unsigned virtReg, MachineOperand *Op) {
Virt2SplitKillMap[virtReg] = Op;
void addKillPoint(unsigned virtReg, unsigned index) {
Virt2SplitKillMap[virtReg] = index;
}
/// @brief reset and remove the last use (kill) of a split virtual register.
void removeKillPoint(unsigned virtReg) {
MachineOperand *MO = Virt2SplitKillMap[virtReg];
if (MO) {
assert(MO->isKill() && "Split last use is not marked kill?");
MO->unsetIsKill();
Virt2SplitKillMap[virtReg] = NULL;
unsigned getKillPoint(unsigned virtReg) const {
return Virt2SplitKillMap[virtReg];
}
/// @brief remove the last use (kill) of a split virtual register.
void removeKillPoint(unsigned virtReg) {
Virt2SplitKillMap[virtReg] = 0;
}
/// @brief returns true if the specified MachineInstr is a spill point.