[llvm-commits] [llvm] r69606 - /llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp

Evan Cheng evan.cheng at apple.com
Mon Apr 20 10:23:49 PDT 2009


Author: evancheng
Date: Mon Apr 20 12:23:48 2009
New Revision: 69606

URL: http://llvm.org/viewvc/llvm-project?rev=69606&view=rev
Log:
- Remove an arbitrary spill weight tweak that should not have been there.
- Find more reloads from SS.

Modified:
    llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp

Modified: llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp?rev=69606&r1=69605&r2=69606&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp Mon Apr 20 12:23:48 2009
@@ -554,9 +554,6 @@
   SmallSet<unsigned, 4> Processed;
   SmallSet<unsigned, 4> SuperAdded;
   SmallVector<unsigned, 4> Supers;
-  // Unfavor downgraded registers for spilling.
-  if (DowngradedRegs.count(reg))
-    weight *= 2.0f;
   Weights[reg] += weight;
   Processed.insert(reg);
   for (const unsigned* as = tri_->getAliasSet(reg); *as; ++as) {
@@ -1015,8 +1012,32 @@
     // Merge added with unhandled.  Note that we have already sorted
     // intervals returned by addIntervalsForSpills by their starting
     // point.
-    for (unsigned i = 0, e = added.size(); i != e; ++i)
-      unhandled_.push(added[i]);
+    // This also update the NextReloadMap. That is, it adds mapping from a
+    // register defined by a reload from SS to the next reload from SS in the
+    // same basic block.
+    MachineBasicBlock *LastReloadMBB = 0;
+    LiveInterval *LastReload = 0;
+    int LastReloadSS = VirtRegMap::NO_STACK_SLOT;
+    for (unsigned i = 0, e = added.size(); i != e; ++i) {
+      LiveInterval *ReloadLi = added[i];
+      if (ReloadLi->weight == HUGE_VALF &&
+          li_->getApproximateInstructionCount(*ReloadLi) == 0) {
+        unsigned ReloadIdx = ReloadLi->beginNumber();
+        MachineBasicBlock *ReloadMBB = li_->getMBBFromIndex(ReloadIdx);
+        int ReloadSS = vrm_->getStackSlot(ReloadLi->reg);
+        if (LastReloadMBB == ReloadMBB && LastReloadSS == ReloadSS) {
+          // Last reload of same SS is in the same MBB. We want to try to
+          // allocate both reloads the same register and make sure the reg
+          // isn't clobbered in between if at all possible.
+          assert(LastReload->beginNumber() < ReloadIdx);
+          NextReloadMap.insert(std::make_pair(LastReload->reg, ReloadLi->reg));
+        }
+        LastReloadMBB = ReloadMBB;
+        LastReload = ReloadLi;
+        LastReloadSS = ReloadSS;
+      }
+      unhandled_.push(ReloadLi);
+    }
     return;
   }
 





More information about the llvm-commits mailing list