[llvm-commits] [llvm] r157174 - in /llvm/trunk: include/llvm/CodeGen/EdgeBundles.h lib/CodeGen/SpillPlacement.cpp

Jakob Stoklund Olesen stoklund at 2pi.dk
Sun May 20 20:11:24 PDT 2012


Author: stoklund
Date: Sun May 20 22:11:23 2012
New Revision: 157174

URL: http://llvm.org/viewvc/llvm-project?rev=157174&view=rev
Log:
Give a small negative bias to giant edge bundles.

This helps compile time when the greedy register allocator splits live
ranges in giant functions. Without the bias, we would try to grow
regions through the giant edge bundles, usually to find out that the
region became too big and expensive.

If a live range has many uses in blocks near the giant bundle, the small
negative bias doesn't make a big difference, and we still consider
regions including the giant edge bundle.

Giant edge bundles are usually connected to landing pads or indirect
branches.

Modified:
    llvm/trunk/include/llvm/CodeGen/EdgeBundles.h
    llvm/trunk/lib/CodeGen/SpillPlacement.cpp

Modified: llvm/trunk/include/llvm/CodeGen/EdgeBundles.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/EdgeBundles.h?rev=157174&r1=157173&r2=157174&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/EdgeBundles.h (original)
+++ llvm/trunk/include/llvm/CodeGen/EdgeBundles.h Sun May 20 22:11:23 2012
@@ -46,7 +46,7 @@
   unsigned getNumBundles() const { return EC.getNumClasses(); }
 
   /// getBlocks - Return an array of blocks that are connected to Bundle.
-  ArrayRef<unsigned> getBlocks(unsigned Bundle) { return Blocks[Bundle]; }
+  ArrayRef<unsigned> getBlocks(unsigned Bundle) const { return Blocks[Bundle]; }
 
   /// getMachineFunction - Return the last machine function computed.
   const MachineFunction *getMachineFunction() const { return MF; }

Modified: llvm/trunk/lib/CodeGen/SpillPlacement.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SpillPlacement.cpp?rev=157174&r1=157173&r2=157174&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SpillPlacement.cpp (original)
+++ llvm/trunk/lib/CodeGen/SpillPlacement.cpp Sun May 20 22:11:23 2012
@@ -207,6 +207,17 @@
     return;
   ActiveNodes->set(n);
   nodes[n].clear();
+
+  // Very large bundles usually come from big switches, indirect branches,
+  // landing pads, or loops with many 'continue' statements. It is difficult to
+  // allocate registers when so many different blocks are involved.
+  //
+  // Give a small negative bias to large bundles such that 1/32 of the
+  // connected blocks need to be interested before we consider expanding the
+  // region through the bundle. This helps compile time by limiting the number
+  // of blocks visited and the number of links in the Hopfield network.
+  if (bundles->getBlocks(n).size() > 100)
+    nodes[n].Bias = -0.0625f;
 }
 
 





More information about the llvm-commits mailing list