summaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/LiveVariables.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2021-07-29 20:15:26 +0000
committerDimitry Andric <dim@FreeBSD.org>2021-07-29 20:15:26 +0000
commit344a3780b2e33f6ca763666c380202b18aab72a3 (patch)
treef0b203ee6eb71d7fdd792373e3c81eb18d6934dd /llvm/lib/CodeGen/LiveVariables.cpp
parentb60736ec1405bb0a8dd40989f67ef4c93da068ab (diff)
Diffstat (limited to 'llvm/lib/CodeGen/LiveVariables.cpp')
-rw-r--r--llvm/lib/CodeGen/LiveVariables.cpp44
1 files changed, 19 insertions, 25 deletions
diff --git a/llvm/lib/CodeGen/LiveVariables.cpp b/llvm/lib/CodeGen/LiveVariables.cpp
index 49b880c30936..7181dbc9c870 100644
--- a/llvm/lib/CodeGen/LiveVariables.cpp
+++ b/llvm/lib/CodeGen/LiveVariables.cpp
@@ -67,9 +67,8 @@ LiveVariables::VarInfo::findKill(const MachineBasicBlock *MBB) const {
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void LiveVariables::VarInfo::dump() const {
dbgs() << " Alive in blocks: ";
- for (SparseBitVector<>::iterator I = AliveBlocks.begin(),
- E = AliveBlocks.end(); I != E; ++I)
- dbgs() << *I << ", ";
+ for (unsigned AB : AliveBlocks)
+ dbgs() << AB << ", ";
dbgs() << "\n Killed by:";
if (Kills.empty())
dbgs() << " No instructions.\n";
@@ -173,9 +172,8 @@ void LiveVariables::HandleVirtRegUse(Register Reg, MachineBasicBlock *MBB,
VRInfo.Kills.push_back(&MI);
// Update all dominating blocks to mark them as "known live".
- for (MachineBasicBlock::const_pred_iterator PI = MBB->pred_begin(),
- E = MBB->pred_end(); PI != E; ++PI)
- MarkVirtRegAliveInBlock(VRInfo, MRI->getVRegDef(Reg)->getParent(), *PI);
+ for (MachineBasicBlock *Pred : MBB->predecessors())
+ MarkVirtRegAliveInBlock(VRInfo, MRI->getVRegDef(Reg)->getParent(), Pred);
}
void LiveVariables::HandleVirtRegDef(Register Reg, MachineInstr &MI) {
@@ -499,7 +497,7 @@ void LiveVariables::UpdatePhysRegDefs(MachineInstr &MI,
void LiveVariables::runOnInstr(MachineInstr &MI,
SmallVectorImpl<unsigned> &Defs) {
- assert(!MI.isDebugInstr());
+ assert(!MI.isDebugOrPseudoInstr());
// Process all of the operands of the instruction...
unsigned NumOperandsToProcess = MI.getNumOperands();
@@ -574,7 +572,7 @@ void LiveVariables::runOnBlock(MachineBasicBlock *MBB, const unsigned NumRegs) {
DistanceMap.clear();
unsigned Dist = 0;
for (MachineInstr &MI : *MBB) {
- if (MI.isDebugInstr())
+ if (MI.isDebugOrPseudoInstr())
continue;
DistanceMap.insert(std::make_pair(&MI, Dist++));
@@ -588,19 +586,16 @@ void LiveVariables::runOnBlock(MachineBasicBlock *MBB, const unsigned NumRegs) {
if (!PHIVarInfo[MBB->getNumber()].empty()) {
SmallVectorImpl<unsigned> &VarInfoVec = PHIVarInfo[MBB->getNumber()];
- for (SmallVectorImpl<unsigned>::iterator I = VarInfoVec.begin(),
- E = VarInfoVec.end(); I != E; ++I)
+ for (unsigned I : VarInfoVec)
// Mark it alive only in the block we are representing.
- MarkVirtRegAliveInBlock(getVarInfo(*I),MRI->getVRegDef(*I)->getParent(),
+ MarkVirtRegAliveInBlock(getVarInfo(I), MRI->getVRegDef(I)->getParent(),
MBB);
}
// MachineCSE may CSE instructions which write to non-allocatable physical
// registers across MBBs. Remember if any reserved register is liveout.
SmallSet<unsigned, 4> LiveOuts;
- for (MachineBasicBlock::const_succ_iterator SI = MBB->succ_begin(),
- SE = MBB->succ_end(); SI != SE; ++SI) {
- MachineBasicBlock *SuccMBB = *SI;
+ for (const MachineBasicBlock *SuccMBB : MBB->successors()) {
if (SuccMBB->isEHPad())
continue;
for (const auto &LI : SuccMBB->liveins()) {
@@ -665,8 +660,8 @@ bool LiveVariables::runOnMachineFunction(MachineFunction &mf) {
// function. If so, it is due to a bug in the instruction selector or some
// other part of the code generator if this happens.
#ifndef NDEBUG
- for(MachineFunction::iterator i = MF->begin(), e = MF->end(); i != e; ++i)
- assert(Visited.contains(&*i) && "unreachable basic block found");
+ for (const MachineBasicBlock &MBB : *MF)
+ assert(Visited.contains(&MBB) && "unreachable basic block found");
#endif
PhysRegDef.clear();
@@ -779,13 +774,12 @@ void LiveVariables::addNewBlock(MachineBasicBlock *BB,
// Record all vreg defs and kills of all instructions in SuccBB.
for (; BBI != BBE; ++BBI) {
- for (MachineInstr::mop_iterator I = BBI->operands_begin(),
- E = BBI->operands_end(); I != E; ++I) {
- if (I->isReg() && Register::isVirtualRegister(I->getReg())) {
- if (I->isDef())
- Defs.insert(I->getReg());
- else if (I->isKill())
- Kills.insert(I->getReg());
+ for (const MachineOperand &Op : BBI->operands()) {
+ if (Op.isReg() && Register::isVirtualRegister(Op.getReg())) {
+ if (Op.isDef())
+ Defs.insert(Op.getReg());
+ else if (Op.isKill())
+ Kills.insert(Op.getReg());
}
}
}
@@ -817,8 +811,8 @@ void LiveVariables::addNewBlock(MachineBasicBlock *BB,
const unsigned NumNew = BB->getNumber();
SparseBitVector<> &BV = LiveInSets[SuccBB->getNumber()];
- for (auto R = BV.begin(), E = BV.end(); R != E; R++) {
- Register VirtReg = Register::index2VirtReg(*R);
+ for (unsigned R : BV) {
+ Register VirtReg = Register::index2VirtReg(R);
LiveVariables::VarInfo &VI = getVarInfo(VirtReg);
VI.AliveBlocks.set(NumNew);
}