LiveIntervalAnalysis: Factor out code to update liveness on vreg def removal
[oota-llvm.git] / lib / CodeGen / LiveIntervalAnalysis.cpp
index 48daf2ccd06939d1d251f83d933599562c532a81..c03773f80370bb8f6261c98926bba48764764ca7 100644 (file)
@@ -1375,3 +1375,17 @@ void LiveIntervals::removePhysRegDefAt(unsigned Reg, SlotIndex Pos) {
         LR->removeValNo(VNI);
   }
 }
+
+void LiveIntervals::removeVRegDefAt(LiveInterval &LI, SlotIndex Pos) {
+  VNInfo *VNI = LI.getVNInfoAt(Pos);
+  if (VNI == nullptr)
+    return;
+  LI.removeValNo(VNI);
+
+  // Also remove the value in subranges.
+  for (LiveInterval::SubRange &S : LI.subranges()) {
+    if (VNInfo *SVNI = S.getVNInfoAt(Pos))
+      S.removeValNo(SVNI);
+  }
+  LI.removeEmptySubRanges();
+}