From 846b31d74aa673a178f57f9d47f366d8ddb756d3 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Fri, 30 Aug 2013 17:58:49 +0000 Subject: [PATCH] Use LiveRangeQuery for instruction-level liveness queries. Remove redundant or bug-prone LiveInterval APIs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189685 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveInterval.h | 15 --------------- lib/CodeGen/LiveRangeEdit.cpp | 2 +- lib/CodeGen/RegisterPressure.cpp | 14 ++++++++------ 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/include/llvm/CodeGen/LiveInterval.h b/include/llvm/CodeGen/LiveInterval.h index 38d07e4612b..84323deef83 100644 --- a/include/llvm/CodeGen/LiveInterval.h +++ b/include/llvm/CodeGen/LiveInterval.h @@ -287,21 +287,6 @@ namespace llvm { return r != end() && r->start <= index; } - /// Return true if a live range ends at the instruction at this index. Note - /// that the kill point is not contained in the half-open live range. It is - /// usually the EarlyClobber or Register slot following its last use. - bool isKilledAtInstr(SlotIndex index) const { - SlotIndex BaseIdx = index.getBaseIndex(); - const_iterator r = find(BaseIdx); - return r != end() && r->end.getBaseIndex() == BaseIdx; - } - - /// Return true if a live range starts at the instruction at this index. - bool isDefinedByInstr(SlotIndex index) const { - const_iterator r = find(index.getDeadSlot()); - return r != end() && r->end.getBaseIndex() == index.getBaseIndex(); - } - /// getLiveRangeContaining - Return the live range that contains the /// specified index, or null if there is none. const LiveRange *getLiveRangeContaining(SlotIndex Idx) const { diff --git a/lib/CodeGen/LiveRangeEdit.cpp b/lib/CodeGen/LiveRangeEdit.cpp index 86271116f4e..9c374b15019 100644 --- a/lib/CodeGen/LiveRangeEdit.cpp +++ b/lib/CodeGen/LiveRangeEdit.cpp @@ -278,7 +278,7 @@ void LiveRangeEdit::eliminateDeadDef(MachineInstr *MI, ToShrinkSet &ToShrink) { // Always shrink COPY uses that probably come from live range splitting. if (MI->readsVirtualRegister(Reg) && (MI->isCopy() || MOI->isDef() || MRI.hasOneNonDBGUse(Reg) || - LI.isKilledAtInstr(Idx))) + LiveRangeQuery(LI, Idx).isKill())) ToShrink.insert(&LI); // Remove defined value. diff --git a/lib/CodeGen/RegisterPressure.cpp b/lib/CodeGen/RegisterPressure.cpp index 1be203f36dd..27da370c961 100644 --- a/lib/CodeGen/RegisterPressure.cpp +++ b/lib/CodeGen/RegisterPressure.cpp @@ -500,8 +500,9 @@ bool RegPressureTracker::recede(SmallVectorImpl *LiveUses, if (RequireIntervals) { const LiveInterval *LI = getInterval(Reg); // Check if this LR is killed and not redefined here. - if (LI && !LI->isKilledAtInstr(SlotIdx) - && !LI->isDefinedByInstr(SlotIdx)) { + if (LI) { + LiveRangeQuery LRQ(*LI, SlotIdx); + if (!LRQ.isKill() && !LRQ.valueDefined()) discoverLiveOut(Reg); } } @@ -558,7 +559,7 @@ bool RegPressureTracker::advance() { bool lastUse = false; if (RequireIntervals) { const LiveInterval *LI = getInterval(Reg); - lastUse = LI && LI->isKilledAtInstr(SlotIdx); + lastUse = LI && LiveRangeQuery(*LI, SlotIdx).isKill(); } else { // Allocatable physregs are always single-use before register rewriting. @@ -882,9 +883,10 @@ void RegPressureTracker::bumpDownwardPressure(const MachineInstr *MI) { // to be bottom-scheduled to avoid searching uses at each query. SlotIndex CurrIdx = getCurrSlot(); const LiveInterval *LI = getInterval(Reg); - if (LI && LI->isKilledAtInstr(SlotIdx) - && !findUseBetween(Reg, CurrIdx, SlotIdx, MRI, LIS)) { - decreaseRegPressure(Reg); + if (LI) { + LiveRangeQuery LRQ(*LI, SlotIdx); + if (LRQ.isKill() && !findUseBetween(Reg, CurrIdx, SlotIdx, MRI, LIS)) + decreaseRegPressure(Reg); } } else if (!TargetRegisterInfo::isVirtualRegister(Reg)) { -- 2.34.1