Add regunit liveness support to LiveIntervals::handleMove().
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Tue, 19 Jun 2012 23:50:18 +0000 (23:50 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Tue, 19 Jun 2012 23:50:18 +0000 (23:50 +0000)
When LiveIntervals is tracking fixed interference in regunits, make sure
to update those intervals as well. Currently guarded by -live-regunits.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158766 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/LiveIntervalAnalysis.cpp

index d7348d4efa6ba83ea26e23ffc89db86baab16482..7308f0f50e75d2a2aed6c4ed50df5015c0633ac1 100644 (file)
@@ -1193,36 +1193,34 @@ private:
       // TODO: Currently we're skipping uses that are reserved or have no
       // interval, but we're not updating their kills. This should be
       // fixed.
-      if (!LIS.hasInterval(Reg) ||
-          (TargetRegisterInfo::isPhysicalRegister(Reg) && LIS.isReserved(Reg)))
+      if (TargetRegisterInfo::isPhysicalRegister(Reg) && LIS.isReserved(Reg))
         continue;
 
-      LiveInterval* LI = &LIS.getInterval(Reg);
+      if (TargetRegisterInfo::isPhysicalRegister(Reg) && LIS.trackingRegUnits())
+          for (MCRegUnitIterator Units(Reg, &TRI); Units.isValid(); ++Units)
+            collectRanges(MO, &LIS.getRegUnit(*Units),
+                          Entering, Internal, Exiting, OldIdx);
+      else if (LIS.hasInterval(Reg))
+        collectRanges(MO, &LIS.getInterval(Reg),
+                      Entering, Internal, Exiting, OldIdx);
+    }
+  }
 
-      if (MO.readsReg()) {
-        LiveRange* LR = LI->getLiveRangeContaining(OldIdx);
-        if (LR != 0)
-          Entering.insert(std::make_pair(LI, LR));
-      }
-      if (MO.isDef()) {
-        if (MO.isEarlyClobber()) {
-          LiveRange* LR = LI->getLiveRangeContaining(OldIdx.getRegSlot(true));
-          assert(LR != 0 && "No EC range?");
-          if (LR->end > OldIdx.getDeadSlot())
-            Exiting.insert(std::make_pair(LI, LR));
-          else
-            Internal.insert(std::make_pair(LI, LR));
-        } else if (MO.isDead()) {
-          LiveRange* LR = LI->getLiveRangeContaining(OldIdx.getRegSlot());
-          assert(LR != 0 && "No dead-def range?");
-          Internal.insert(std::make_pair(LI, LR));
-        } else {
-          LiveRange* LR = LI->getLiveRangeContaining(OldIdx.getDeadSlot());
-          assert(LR && LR->end > OldIdx.getDeadSlot() &&
-                 "Non-dead-def should have live range exiting.");
-          Exiting.insert(std::make_pair(LI, LR));
-        }
-      }
+  void collectRanges(const MachineOperand &MO, LiveInterval *LI,
+                     RangeSet &Entering, RangeSet &Internal, RangeSet &Exiting,
+                     SlotIndex OldIdx) {
+    if (MO.readsReg()) {
+      LiveRange* LR = LI->getLiveRangeContaining(OldIdx);
+      if (LR != 0)
+        Entering.insert(std::make_pair(LI, LR));
+    }
+    if (MO.isDef()) {
+      LiveRange* LR = LI->getLiveRangeContaining(OldIdx.getRegSlot());
+      assert(LR != 0 && "No live range for def?");
+      if (LR->end > OldIdx.getDeadSlot())
+        Exiting.insert(std::make_pair(LI, LR));
+      else
+        Internal.insert(std::make_pair(LI, LR));
     }
   }
 
@@ -1243,25 +1241,34 @@ private:
       // TODO: Currently we're skipping uses that are reserved or have no
       // interval, but we're not updating their kills. This should be
       // fixed.
-      if (!LIS.hasInterval(Reg) ||
-          (TargetRegisterInfo::isPhysicalRegister(Reg) && LIS.isReserved(Reg)))
+      if (TargetRegisterInfo::isPhysicalRegister(Reg) && LIS.isReserved(Reg))
         continue;
 
-      LiveInterval* LI = &LIS.getInterval(Reg);
+      if (TargetRegisterInfo::isPhysicalRegister(Reg) && LIS.trackingRegUnits())
+          for (MCRegUnitIterator Units(Reg, &TRI); Units.isValid(); ++Units)
+            collectRangesInBundle(MO, &LIS.getRegUnit(*Units),
+                                  Entering, Exiting, MIStartIdx, MIEndIdx);
+      else if (LIS.hasInterval(Reg))
+        collectRangesInBundle(MO, &LIS.getInterval(Reg),
+                              Entering, Exiting, MIStartIdx, MIEndIdx);
+    }
+  }
 
-      if (MO.readsReg()) {
-        LiveRange* LR = LI->getLiveRangeContaining(MIStartIdx);
-        if (LR != 0)
-          Entering.insert(std::make_pair(LI, LR));
-      }
-      if (MO.isDef()) {
-        assert(!MO.isEarlyClobber() &&
-               "Early clobbers not allowed in bundles.");
-        assert(!MO.isDead() && "Dead-defs not allowed in bundles.");
-        LiveRange* LR = LI->getLiveRangeContaining(MIEndIdx.getDeadSlot());
-        assert(LR != 0 && "Internal ranges not allowed in bundles.");
-        Exiting.insert(std::make_pair(LI, LR));
-      }
+  void collectRangesInBundle(const MachineOperand &MO, LiveInterval *LI,
+                             RangeSet &Entering, RangeSet &Exiting,
+                             SlotIndex MIStartIdx, SlotIndex MIEndIdx) {
+    if (MO.readsReg()) {
+      LiveRange* LR = LI->getLiveRangeContaining(MIStartIdx);
+      if (LR != 0)
+        Entering.insert(std::make_pair(LI, LR));
+    }
+    if (MO.isDef()) {
+      assert(!MO.isEarlyClobber() &&
+             "Early clobbers not allowed in bundles.");
+      assert(!MO.isDead() && "Dead-defs not allowed in bundles.");
+      LiveRange* LR = LI->getLiveRangeContaining(MIEndIdx.getDeadSlot());
+      assert(LR != 0 && "Internal ranges not allowed in bundles.");
+      Exiting.insert(std::make_pair(LI, LR));
     }
   }