diff options
Diffstat (limited to 'contrib/llvm-project/llvm/lib/CodeGen/LiveInterval.cpp')
| -rw-r--r-- | contrib/llvm-project/llvm/lib/CodeGen/LiveInterval.cpp | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/contrib/llvm-project/llvm/lib/CodeGen/LiveInterval.cpp b/contrib/llvm-project/llvm/lib/CodeGen/LiveInterval.cpp index 1eed0ec5bbbe..9ded0fb6ae0a 100644 --- a/contrib/llvm-project/llvm/lib/CodeGen/LiveInterval.cpp +++ b/contrib/llvm-project/llvm/lib/CodeGen/LiveInterval.cpp @@ -592,21 +592,10 @@ void LiveRange::removeSegment(SlotIndex Start, SlotIndex End, VNInfo *ValNo = I->valno; if (I->start == Start) { if (I->end == End) { - if (RemoveDeadValNo) { - // Check if val# is dead. - bool isDead = true; - for (const_iterator II = begin(), EE = end(); II != EE; ++II) - if (II != I && II->valno == ValNo) { - isDead = false; - break; - } - if (isDead) { - // Now that ValNo is dead, remove it. - markValNoForDeletion(ValNo); - } - } - segments.erase(I); // Removed the whole Segment. + + if (RemoveDeadValNo) + removeValNoIfDead(ValNo); } else I->start = End; return; @@ -627,13 +616,25 @@ void LiveRange::removeSegment(SlotIndex Start, SlotIndex End, segments.insert(std::next(I), Segment(End, OldEnd, ValNo)); } +LiveRange::iterator LiveRange::removeSegment(iterator I, bool RemoveDeadValNo) { + VNInfo *ValNo = I->valno; + I = segments.erase(I); + if (RemoveDeadValNo) + removeValNoIfDead(ValNo); + return I; +} + +void LiveRange::removeValNoIfDead(VNInfo *ValNo) { + if (none_of(*this, [=](const Segment &S) { return S.valno == ValNo; })) + markValNoForDeletion(ValNo); +} + /// removeValNo - Remove all the segments defined by the specified value#. /// Also remove the value# from value# list. void LiveRange::removeValNo(VNInfo *ValNo) { if (empty()) return; - segments.erase(remove_if(*this, [ValNo](const Segment &S) { - return S.valno == ValNo; - }), end()); + llvm::erase_if(segments, + [ValNo](const Segment &S) { return S.valno == ValNo; }); // Now that ValNo is dead, remove it. markValNoForDeletion(ValNo); } @@ -1019,7 +1020,7 @@ void LiveRange::print(raw_ostream &OS) const { // Print value number info. if (getNumValNums()) { - OS << " "; + OS << ' '; unsigned vnum = 0; for (const_vni_iterator i = vni_begin(), e = vni_end(); i != e; ++i, ++vnum) { @@ -1038,8 +1039,8 @@ void LiveRange::print(raw_ostream &OS) const { } void LiveInterval::SubRange::print(raw_ostream &OS) const { - OS << " L" << PrintLaneMask(LaneMask) << ' ' - << static_cast<const LiveRange&>(*this); + OS << " L" << PrintLaneMask(LaneMask) << ' ' + << static_cast<const LiveRange &>(*this); } void LiveInterval::print(raw_ostream &OS) const { @@ -1048,7 +1049,7 @@ void LiveInterval::print(raw_ostream &OS) const { // Print subranges for (const SubRange &SR : subranges()) OS << SR; - OS << " weight:" << Weight; + OS << " weight:" << Weight; } #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) |
