There is no need to store the MBB along with the MI any more, we can now

ask instructions for their parent.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14998 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2004-07-19 07:04:55 +00:00
parent 472405e0dc
commit 74de8b1b26
4 changed files with 24 additions and 26 deletions

View File

@@ -48,11 +48,10 @@ public:
/// ///
std::vector<bool> AliveBlocks; std::vector<bool> AliveBlocks;
/// Kills - List of MachineBasicblock's which contain the last use of this /// Kills - List of MachineInstruction's which are the last use of this
/// virtual register (kill it). This also includes the specific instruction /// virtual register (kill it) in their basic block.
/// which kills the value.
/// ///
std::vector<std::pair<MachineBasicBlock*, MachineInstr*> > Kills; std::vector<MachineInstr*> Kills;
VarInfo() : DefInst(0) {} VarInfo() : DefInst(0) {}
@@ -60,13 +59,12 @@ public:
/// machine instruction. Returns true if there was a kill /// machine instruction. Returns true if there was a kill
/// corresponding to this instruction, false otherwise. /// corresponding to this instruction, false otherwise.
bool removeKill(MachineInstr *MI) { bool removeKill(MachineInstr *MI) {
for (std::vector<std::pair<MachineBasicBlock*, MachineInstr*> >::iterator for (std::vector<MachineInstr*>::iterator i = Kills.begin(),
i = Kills.begin(); i != Kills.end(); ++i) { e = Kills.end(); i != e; ++i)
if (i->second == MI) { if (*i == MI) {
Kills.erase(i); Kills.erase(i);
return true; return true;
} }
}
return false; return false;
} }
}; };
@@ -153,7 +151,7 @@ public:
/// ///
void addVirtualRegisterKilled(unsigned IncomingReg, MachineInstr *MI) { void addVirtualRegisterKilled(unsigned IncomingReg, MachineInstr *MI) {
RegistersKilled.insert(std::make_pair(MI, IncomingReg)); RegistersKilled.insert(std::make_pair(MI, IncomingReg));
getVarInfo(IncomingReg).Kills.push_back(std::make_pair(MI->getParent(),MI)); getVarInfo(IncomingReg).Kills.push_back(MI);
} }
/// removeVirtualRegisterKilled - Remove the specified virtual /// removeVirtualRegisterKilled - Remove the specified virtual
@@ -189,7 +187,7 @@ public:
/// ///
void addVirtualRegisterDead(unsigned IncomingReg, MachineInstr *MI) { void addVirtualRegisterDead(unsigned IncomingReg, MachineInstr *MI) {
RegistersDead.insert(std::make_pair(MI, IncomingReg)); RegistersDead.insert(std::make_pair(MI, IncomingReg));
getVarInfo(IncomingReg).Kills.push_back(std::make_pair(MI->getParent(),MI)); getVarInfo(IncomingReg).Kills.push_back(MI);
} }
/// removeVirtualRegisterDead - Remove the specified virtual /// removeVirtualRegisterDead - Remove the specified virtual

View File

@@ -311,11 +311,11 @@ void LiveIntervals::handleVirtualRegisterDef(MachineBasicBlock* mbb,
// two cases we have to handle here. The most common case is a vreg // two cases we have to handle here. The most common case is a vreg
// whose lifetime is contained within a basic block. In this case there // whose lifetime is contained within a basic block. In this case there
// will be a single kill, in MBB, which comes after the definition. // will be a single kill, in MBB, which comes after the definition.
if (vi.Kills.size() == 1 && vi.Kills[0].first == mbb) { if (vi.Kills.size() == 1 && vi.Kills[0]->getParent() == mbb) {
// FIXME: what about dead vars? // FIXME: what about dead vars?
unsigned killIdx; unsigned killIdx;
if (vi.Kills[0].second != mi) if (vi.Kills[0] != mi)
killIdx = getUseIndex(getInstructionIndex(vi.Kills[0].second))+1; killIdx = getUseIndex(getInstructionIndex(vi.Kills[0]))+1;
else else
killIdx = defIndex+1; killIdx = defIndex+1;
@@ -353,9 +353,9 @@ void LiveIntervals::handleVirtualRegisterDef(MachineBasicBlock* mbb,
// Finally, this virtual register is live from the start of any killing // Finally, this virtual register is live from the start of any killing
// block to the 'use' slot of the killing instruction. // block to the 'use' slot of the killing instruction.
for (unsigned i = 0, e = vi.Kills.size(); i != e; ++i) { for (unsigned i = 0, e = vi.Kills.size(); i != e; ++i) {
std::pair<MachineBasicBlock*, MachineInstr*> &Kill = vi.Kills[i]; MachineInstr *Kill = vi.Kills[i];
interval.addRange(getInstructionIndex(Kill.first->begin()), interval.addRange(getInstructionIndex(Kill->getParent()->begin()),
getUseIndex(getInstructionIndex(Kill.second))+1); getUseIndex(getInstructionIndex(Kill))+1);
} }
} else { } else {

View File

@@ -59,7 +59,7 @@ void LiveVariables::MarkVirtRegAliveInBlock(VarInfo &VRInfo,
// Check to see if this basic block is one of the killing blocks. If so, // Check to see if this basic block is one of the killing blocks. If so,
// remove it... // remove it...
for (unsigned i = 0, e = VRInfo.Kills.size(); i != e; ++i) for (unsigned i = 0, e = VRInfo.Kills.size(); i != e; ++i)
if (VRInfo.Kills[i].first == MBB) { if (VRInfo.Kills[i]->getParent() == MBB) {
VRInfo.Kills.erase(VRInfo.Kills.begin()+i); // Erase entry VRInfo.Kills.erase(VRInfo.Kills.begin()+i); // Erase entry
break; break;
} }
@@ -83,23 +83,23 @@ void LiveVariables::MarkVirtRegAliveInBlock(VarInfo &VRInfo,
void LiveVariables::HandleVirtRegUse(VarInfo &VRInfo, MachineBasicBlock *MBB, void LiveVariables::HandleVirtRegUse(VarInfo &VRInfo, MachineBasicBlock *MBB,
MachineInstr *MI) { MachineInstr *MI) {
// Check to see if this basic block is already a kill block... // Check to see if this basic block is already a kill block...
if (!VRInfo.Kills.empty() && VRInfo.Kills.back().first == MBB) { if (!VRInfo.Kills.empty() && VRInfo.Kills.back()->getParent() == MBB) {
// Yes, this register is killed in this basic block already. Increase the // Yes, this register is killed in this basic block already. Increase the
// live range by updating the kill instruction. // live range by updating the kill instruction.
VRInfo.Kills.back().second = MI; VRInfo.Kills.back() = MI;
return; return;
} }
#ifndef NDEBUG #ifndef NDEBUG
for (unsigned i = 0, e = VRInfo.Kills.size(); i != e; ++i) for (unsigned i = 0, e = VRInfo.Kills.size(); i != e; ++i)
assert(VRInfo.Kills[i].first != MBB && "entry should be at end!"); assert(VRInfo.Kills[i]->getParent() != MBB && "entry should be at end!");
#endif #endif
assert(MBB != VRInfo.DefInst->getParent() && assert(MBB != VRInfo.DefInst->getParent() &&
"Should have kill for defblock!"); "Should have kill for defblock!");
// Add a new kill entry for this basic block. // Add a new kill entry for this basic block.
VRInfo.Kills.push_back(std::make_pair(MI->getParent(), MI)); VRInfo.Kills.push_back(MI);
// Update all dominating blocks to mark them known live. // Update all dominating blocks to mark them known live.
const BasicBlock *BB = MBB->getBasicBlock(); const BasicBlock *BB = MBB->getBasicBlock();
@@ -234,7 +234,7 @@ bool LiveVariables::runOnMachineFunction(MachineFunction &MF) {
assert(VRInfo.DefInst == 0 && "Variable multiply defined!"); assert(VRInfo.DefInst == 0 && "Variable multiply defined!");
VRInfo.DefInst = MI; VRInfo.DefInst = MI;
// Defaults to dead // Defaults to dead
VRInfo.Kills.push_back(std::make_pair(MI->getParent(), MI)); VRInfo.Kills.push_back(MI);
} else if (MRegisterInfo::isPhysicalRegister(MO.getReg()) && } else if (MRegisterInfo::isPhysicalRegister(MO.getReg()) &&
AllocatablePhysicalRegisters[MO.getReg()]) { AllocatablePhysicalRegisters[MO.getReg()]) {
HandlePhysRegDef(MO.getReg(), MI); HandlePhysRegDef(MO.getReg(), MI);
@@ -283,12 +283,12 @@ bool LiveVariables::runOnMachineFunction(MachineFunction &MF) {
// //
for (unsigned i = 0, e = VirtRegInfo.size(); i != e; ++i) for (unsigned i = 0, e = VirtRegInfo.size(); i != e; ++i)
for (unsigned j = 0, e = VirtRegInfo[i].Kills.size(); j != e; ++j) { for (unsigned j = 0, e = VirtRegInfo[i].Kills.size(); j != e; ++j) {
if (VirtRegInfo[i].Kills[j].second == VirtRegInfo[i].DefInst) if (VirtRegInfo[i].Kills[j] == VirtRegInfo[i].DefInst)
RegistersDead.insert(std::make_pair(VirtRegInfo[i].Kills[j].second, RegistersDead.insert(std::make_pair(VirtRegInfo[i].Kills[j],
i + MRegisterInfo::FirstVirtualRegister)); i + MRegisterInfo::FirstVirtualRegister));
else else
RegistersKilled.insert(std::make_pair(VirtRegInfo[i].Kills[j].second, RegistersKilled.insert(std::make_pair(VirtRegInfo[i].Kills[j],
i + MRegisterInfo::FirstVirtualRegister)); i + MRegisterInfo::FirstVirtualRegister));
} }

View File

@@ -235,7 +235,7 @@ bool PNE::EliminatePHINodes(MachineFunction &MF, MachineBasicBlock &MBB) {
// Is it killed in this successor? // Is it killed in this successor?
for (unsigned i = 0, e = InRegVI.Kills.size(); i != e; ++i) for (unsigned i = 0, e = InRegVI.Kills.size(); i != e; ++i)
if (InRegVI.Kills[i].first == SuccMBB) { if (InRegVI.Kills[i]->getParent() == SuccMBB) {
ValueIsLive = true; ValueIsLive = true;
break; break;
} }