diff options
author | Matthias Braun <matze@braunis.de> | 2014-12-20 01:54:48 +0000 |
---|---|---|
committer | Matthias Braun <matze@braunis.de> | 2014-12-20 01:54:48 +0000 |
commit | 7f8dece1d783418dfead89844c827be2f34dc5c8 (patch) | |
tree | 1b99bb4e606daa354aba85a4177c20d9172faa4c /llvm/lib | |
parent | a7a715698a3675a3db20d090dcbeff86445ee7e8 (diff) | |
download | bcm5719-llvm-7f8dece1d783418dfead89844c827be2f34dc5c8.tar.gz bcm5719-llvm-7f8dece1d783418dfead89844c827be2f34dc5c8.zip |
LiveIntervalAnalysis: cleanup addKills(), NFC
- Use more const modifiers
- Use references for things that can't be nullptr
- Improve some variable names
llvm-svn: 224663
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/CodeGen/LiveIntervalAnalysis.cpp | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp b/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp index 88fd7bf66e9..0d24075f026 100644 --- a/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp +++ b/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp @@ -624,14 +624,14 @@ void LiveIntervals::pruneValue(LiveInterval &LI, SlotIndex Kill, void LiveIntervals::addKillFlags(const VirtRegMap *VRM) { // Keep track of regunit ranges. - SmallVector<std::pair<LiveRange*, LiveRange::iterator>, 8> RU; + SmallVector<std::pair<const LiveRange*, LiveRange::const_iterator>, 8> RU; for (unsigned i = 0, e = MRI->getNumVirtRegs(); i != e; ++i) { unsigned Reg = TargetRegisterInfo::index2VirtReg(i); if (MRI->reg_nodbg_empty(Reg)) continue; - LiveInterval *LI = &getInterval(Reg); - if (LI->empty()) + const LiveInterval &LI = getInterval(Reg); + if (LI.empty()) continue; // Find the regunit intervals for the assigned register. They may overlap @@ -639,15 +639,15 @@ void LiveIntervals::addKillFlags(const VirtRegMap *VRM) { RU.clear(); for (MCRegUnitIterator Units(VRM->getPhys(Reg), TRI); Units.isValid(); ++Units) { - LiveRange &RURanges = getRegUnit(*Units); - if (RURanges.empty()) + const LiveRange &RURange = getRegUnit(*Units); + if (RURange.empty()) continue; - RU.push_back(std::make_pair(&RURanges, RURanges.find(LI->begin()->end))); + RU.push_back(std::make_pair(&RURange, RURange.find(LI.begin()->end))); } // Every instruction that kills Reg corresponds to a segment range end // point. - for (LiveInterval::iterator RI = LI->begin(), RE = LI->end(); RI != RE; + for (LiveInterval::const_iterator RI = LI.begin(), RE = LI.end(); RI != RE; ++RI) { // A block index indicates an MBB edge. if (RI->end.isBlock()) @@ -665,13 +665,13 @@ void LiveIntervals::addKillFlags(const VirtRegMap *VRM) { // // There should be no kill flag on FOO when %vreg5 is rewritten as %EAX. bool CancelKill = false; - for (unsigned u = 0, e = RU.size(); u != e; ++u) { - LiveRange &RRanges = *RU[u].first; - LiveRange::iterator &I = RU[u].second; - if (I == RRanges.end()) + for (auto &RUP : RU) { + const LiveRange &RURange = *RUP.first; + LiveRange::const_iterator I = RUP.second; + if (I == RURange.end()) continue; - I = RRanges.advanceTo(I, RI->end); - if (I == RRanges.end() || I->start >= RI->end) + I = RURange.advanceTo(I, RI->end); + if (I == RURange.end() || I->start >= RI->end) continue; // I is overlapping RI. CancelKill = true; @@ -684,14 +684,13 @@ void LiveIntervals::addKillFlags(const VirtRegMap *VRM) { // what we do when subregister liveness tracking is enabled. if (MRI->tracksSubRegLiveness()) { // Next segment has to be adjacent in the subregister write case. - LiveRange::iterator N = std::next(RI); - if (N != LI->end() && N->start == RI->end) { + LiveRange::const_iterator N = std::next(RI); + if (N != LI.end() && N->start == RI->end) { // See if we have a partial write operand bool IsFullWrite = false; - for (MachineInstr::const_mop_iterator MOp = MI->operands_begin(), - MOpE = MI->operands_end(); MOp != MOpE; ++MOp) { - if (MOp->isReg() && !MOp->isDef() && MOp->getReg() == Reg - && MOp->getSubReg() == 0) { + for (const MachineOperand &MO : MI->operands()) { + if (MO.isReg() && MO.isUse() && MO.getReg() == Reg + && MO.getSubReg() == 0) { IsFullWrite = true; break; } |