[llvm] 294be6b - [CalcSpillWeights] Propagate the fact that a live-interval is not spillable

Quentin Colombet via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 15 17:57:53 PDT 2020


Author: Quentin Colombet
Date: 2020-07-15T17:57:36-07:00
New Revision: 294be6b5d32e1fe44d0b36cd46b2931c5f0634c4

URL: https://github.com/llvm/llvm-project/commit/294be6b5d32e1fe44d0b36cd46b2931c5f0634c4
DIFF: https://github.com/llvm/llvm-project/commit/294be6b5d32e1fe44d0b36cd46b2931c5f0634c4.diff

LOG: [CalcSpillWeights] Propagate the fact that a live-interval is not spillable

When we calculate the weight of a live-interval, add some code to
check if the original live-interval was markied as not spillable and
if so, progagate that information down to the new interval.

Previously we would just recompute a weight for the new interval,
thus, we could in theory just spill live-intervals marked as not
spillable by just splitting them. That goes against the spirit of
a non-spillable live-interval.

E.g., previously we could do:
v1 =  // v1 must not be spilled
...
= v1

Split:
v1 = // v1 must not be spilled
...
v2 = v1 // v2 can be spilled
...
v3 = v2 // v3 can be spilled
= v3

There's no test case for that one as we would need to split a
non-spillable live-interval without using LiveRangeEdit to see this
happening.
RegAlloc inserts non-spillable intervals only as part of the spilling
mechanism, thus at this point the intervals are not splittable anymore.
On top of that, RegAlloc uses the LiveRangeEdit API, which already
properly propagate that information.

In other words, this could only happen if a target was to mark
a live-interval as not spillable before register allocation and
split it without using LRE, e.g., through
LiveIntervals::splitSeparateComponent.

Added: 
    

Modified: 
    llvm/lib/CodeGen/CalcSpillWeights.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/CalcSpillWeights.cpp b/llvm/lib/CodeGen/CalcSpillWeights.cpp
index 5d6ee09c8438..254503673fd2 100644
--- a/llvm/lib/CodeGen/CalcSpillWeights.cpp
+++ b/llvm/lib/CodeGen/CalcSpillWeights.cpp
@@ -161,6 +161,17 @@ float VirtRegAuxInfo::weightCalcHelper(LiveInterval &li, SlotIndex *start,
 
   std::pair<unsigned, unsigned> TargetHint = mri.getRegAllocationHint(li.reg);
 
+  if (li.isSpillable() && VRM) {
+    Register Reg = li.reg;
+    Register Original = VRM->getOriginal(Reg);
+    const LiveInterval &OrigInt = LIS.getInterval(Original);
+    // li comes from a split of OrigInt. If OrigInt was marked
+    // as not spillable, make sure the new interval is marked
+    // as not spillable as well.
+    if (!OrigInt.isSpillable())
+      li.markNotSpillable();
+  }
+
   // Don't recompute spill weight for an unspillable register.
   bool Spillable = li.isSpillable();
 


        


More information about the llvm-commits mailing list