[llvm] r212099 - [RegAllocGreedy] Provide a flag to disable the local reassignment heuristic.

Quentin Colombet qcolombet at apple.com
Tue Jul 1 07:08:37 PDT 2014


Author: qcolombet
Date: Tue Jul  1 09:08:37 2014
New Revision: 212099

URL: http://llvm.org/viewvc/llvm-project?rev=212099&view=rev
Log:
[RegAllocGreedy] Provide a flag to disable the local reassignment heuristic.
By default, no functionality change.

Before evicting a local variable, this heuristic tries to find another (set of)
local(s) that can be reassigned to a free color.

In some extreme cases (large basic blocks with tons of local variables), the
compilation time is dominated by the local interference checks that this
heuristic must perform, with no code gen gain.
E.g., the motivating example takes 4 minutes to compile with this heuristic, 12
seconds without.

Improving the situation will likely require to make drastic changes to the
register allocator and/or the interference check framework.

For now, provide this flag to better understand the impact of that heuristic.

<rdar://problem/17444599>

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

Modified: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp?rev=212099&r1=212098&r2=212099&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Tue Jul  1 09:08:37 2014
@@ -79,6 +79,12 @@ ExhaustiveSearch("exhaustive-register-se
                  cl::desc("Exhaustive Search for registers bypassing the depth "
                           "and interference cutoffs of last chance recoloring"));
 
+static cl::opt<bool> EnableLocalReassignment(
+    "enable-local-reassign", cl::Hidden,
+    cl::desc("Local reassignment can yield better allocation decisions, but "
+             "may be compile time intensive"),
+    cl::init(true));
+
 // FIXME: Find a good default for this flag and remove the flag.
 static cl::opt<unsigned>
 CSRFirstTimeCost("regalloc-csr-first-time-cost",
@@ -731,7 +737,7 @@ bool RAGreedy::canEvictInterference(Live
       // Evicting another local live range in this case could lead to suboptimal
       // coloring.
       if (!MaxCost.isMax() && IsLocal && LIS->intervalIsInOneMBB(*Intf) &&
-          !canReassign(*Intf, PhysReg)) {
+          (!EnableLocalReassignment || !canReassign(*Intf, PhysReg))) {
         return false;
       }
     }





More information about the llvm-commits mailing list