/// register.
VarInfo &getVarInfo(unsigned RegIdx);
- void MarkVirtRegAliveInBlock(unsigned reg, MachineBasicBlock *BB);
- void MarkVirtRegAliveInBlock(unsigned reg, MachineBasicBlock *BB,
+ void MarkVirtRegAliveInBlock(VarInfo& VRInfo, MachineBasicBlock* DefBlock,
+ MachineBasicBlock *BB);
+ void MarkVirtRegAliveInBlock(VarInfo& VRInfo, MachineBasicBlock* DefBlock,
+ MachineBasicBlock *BB,
std::vector<MachineBasicBlock*> &WorkList);
void HandleVirtRegUse(unsigned reg, MachineBasicBlock *MBB,
MachineInstr *MI);
return false;
}
-void LiveVariables::MarkVirtRegAliveInBlock(unsigned reg,
+void LiveVariables::MarkVirtRegAliveInBlock(VarInfo& VRInfo,
+ MachineBasicBlock *DefBlock,
MachineBasicBlock *MBB,
std::vector<MachineBasicBlock*> &WorkList) {
unsigned BBNum = MBB->getNumber();
-
- VarInfo& VRInfo = getVarInfo(reg);
// Check to see if this basic block is one of the killing blocks. If so,
// remove it...
break;
}
- MachineRegisterInfo& MRI = MBB->getParent()->getRegInfo();
- if (MBB == MRI.getVRegDef(reg)->getParent()) return; // Terminate recursion
+ if (MBB == DefBlock) return; // Terminate recursion
if (VRInfo.AliveBlocks[BBNum])
return; // We already know the block is live
WorkList.push_back(*PI);
}
-void LiveVariables::MarkVirtRegAliveInBlock(unsigned reg,
+void LiveVariables::MarkVirtRegAliveInBlock(VarInfo& VRInfo,
+ MachineBasicBlock *DefBlock,
MachineBasicBlock *MBB) {
std::vector<MachineBasicBlock*> WorkList;
- MarkVirtRegAliveInBlock(reg, MBB, WorkList);
+ MarkVirtRegAliveInBlock(VRInfo, DefBlock, MBB, WorkList);
while (!WorkList.empty()) {
MachineBasicBlock *Pred = WorkList.back();
WorkList.pop_back();
- MarkVirtRegAliveInBlock(reg, Pred, WorkList);
+ MarkVirtRegAliveInBlock(VRInfo, DefBlock, Pred, WorkList);
}
}
// Update all dominating blocks to mark them known live.
for (MachineBasicBlock::const_pred_iterator PI = MBB->pred_begin(),
E = MBB->pred_end(); PI != E; ++PI)
- MarkVirtRegAliveInBlock(reg, *PI);
+ MarkVirtRegAliveInBlock(VRInfo, MRI.getVRegDef(reg)->getParent(), *PI);
}
bool LiveVariables::addRegisterKilled(unsigned IncomingReg, MachineInstr *MI,
bool LiveVariables::runOnMachineFunction(MachineFunction &mf) {
MF = &mf;
RegInfo = MF->getTarget().getRegisterInfo();
+ MachineRegisterInfo& MRI = mf.getRegInfo();
assert(RegInfo && "Target doesn't have register information?");
ReservedRegisters = RegInfo->getReservedRegs(mf);
for (SmallVector<unsigned, 4>::iterator I = VarInfoVec.begin(),
E = VarInfoVec.end(); I != E; ++I) {
// Only mark it alive only in the block we are representing.
- MarkVirtRegAliveInBlock(*I, MBB);
+ MarkVirtRegAliveInBlock(getVarInfo(*I), MRI.getVRegDef(*I)->getParent(),
+ MBB);
}
}
// Convert and transfer the dead / killed information we have gathered into
// VirtRegInfo onto MI's.
//
- MachineRegisterInfo& MRI = mf.getRegInfo();
for (unsigned i = 0, e1 = VirtRegInfo.size(); i != e1; ++i)
for (unsigned j = 0, e2 = VirtRegInfo[i].Kills.size(); j != e2; ++j) {
if (VirtRegInfo[i].Kills[j] == MRI.getVRegDef(i +