[llvm] r189685 - Use LiveRangeQuery for instruction-level liveness queries.

Andrew Trick atrick at apple.com
Fri Aug 30 10:58:49 PDT 2013


Author: atrick
Date: Fri Aug 30 12:58:49 2013
New Revision: 189685

URL: http://llvm.org/viewvc/llvm-project?rev=189685&view=rev
Log:
Use LiveRangeQuery for instruction-level liveness queries.

Remove redundant or bug-prone LiveInterval APIs.

Modified:
    llvm/trunk/include/llvm/CodeGen/LiveInterval.h
    llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp
    llvm/trunk/lib/CodeGen/RegisterPressure.cpp

Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveInterval.h?rev=189685&r1=189684&r2=189685&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/LiveInterval.h (original)
+++ llvm/trunk/include/llvm/CodeGen/LiveInterval.h Fri Aug 30 12:58:49 2013
@@ -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 {

Modified: llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp?rev=189685&r1=189684&r2=189685&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp Fri Aug 30 12:58:49 2013
@@ -278,7 +278,7 @@ void LiveRangeEdit::eliminateDeadDef(Mac
     // 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.

Modified: llvm/trunk/lib/CodeGen/RegisterPressure.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegisterPressure.cpp?rev=189685&r1=189684&r2=189685&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegisterPressure.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegisterPressure.cpp Fri Aug 30 12:58:49 2013
@@ -500,8 +500,9 @@ bool RegPressureTracker::recede(SmallVec
       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::bumpDownwardPre
       // 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)) {





More information about the llvm-commits mailing list