Prepare RAGreedy::growRegion for compact regions.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Sat, 23 Jul 2011 03:22:33 +0000 (03:22 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Sat, 23 Jul 2011 03:22:33 +0000 (03:22 +0000)
A split candidate can have a null PhysReg which means that it doesn't
map to a real interference pattern. Instead, pretend that all through
blocks have interference.

This makes it possible to generate compact regions where the live range
doesn't go through blocks that don't use it. The live range will still
be live between directly connected blocks with uses.

Splitting around a compact region tends to produce a live range with a
high spill weight, so it may evict a less dense live range.

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

lib/CodeGen/RegAllocGreedy.cpp

index 570a832303ae5043de1f69c452e9b7f8978a2abc..0267717b8435a2870f58d4d4b2ae36b0ddccc5cb 100644 (file)
@@ -749,7 +749,14 @@ void RAGreedy::growRegion(GlobalSplitCandidate &Cand) {
     // Any new blocks to add?
     if (ActiveBlocks.size() == AddedTo)
       break;
-    addThroughConstraints(Cand.Intf, makeArrayRef(ActiveBlocks).slice(AddedTo));
+
+    // Compute through constraints from the interference, or assume that all
+    // through blocks prefer spilling when forming compact regions.
+    ArrayRef<unsigned> NewBlocks = makeArrayRef(ActiveBlocks).slice(AddedTo);
+    if (Cand.PhysReg)
+      addThroughConstraints(Cand.Intf, NewBlocks);
+    else
+      SpillPlacer->addPrefSpill(NewBlocks);
     AddedTo = ActiveBlocks.size();
 
     // Perhaps iterating can enable more bundles?