[llvm] r206072 - [RegAllocGreedy][Last Chance Recoloring] Addition of

Quentin Colombet qcolombet at apple.com
Fri Apr 11 14:39:45 PDT 2014


Author: qcolombet
Date: Fri Apr 11 16:39:44 2014
New Revision: 206072

URL: http://llvm.org/viewvc/llvm-project?rev=206072&view=rev
Log:
[RegAllocGreedy][Last Chance Recoloring] Addition of
-fexhaustive-register-search option to allow an exhaustive search during last
chance recoloring.

This is related to PR18747

Patch by MAYUR PANDEY <mayur.p at samsung.com>. 

Modified:
    llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp
    llvm/trunk/test/CodeGen/X86/ragreedy-last-chance-recoloring.ll

Modified: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp?rev=206072&r1=206071&r2=206072&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Fri Apr 11 16:39:44 2014
@@ -73,6 +73,11 @@ static cl::opt<unsigned> LastChanceRecol
              " interference at a time"),
     cl::init(8));
 
+static cl::opt<bool>
+ExhaustiveSearch("fexhaustive-register-search", cl::NotHidden,
+                 cl::desc("Exhaustive Search for registers bypassing the depth "
+                          "and interference cutoffs of last chance recoloring"));
+
 // FIXME: Find a good default for this flag and remove the flag.
 static cl::opt<unsigned>
 CSRFirstTimeCost("regalloc-csr-first-time-cost",
@@ -1932,7 +1937,7 @@ RAGreedy::mayRecolorAllInterferences(uns
     // If there is LastChanceRecoloringMaxInterference or more interferences,
     // chances are one would not be recolorable.
     if (Q.collectInterferingVRegs(LastChanceRecoloringMaxInterference) >=
-        LastChanceRecoloringMaxInterference) {
+        LastChanceRecoloringMaxInterference && !ExhaustiveSearch) {
       DEBUG(dbgs() << "Early abort: too many interferences.\n");
       CutOffInfo |= CO_Interf;
       return false;
@@ -2005,7 +2010,7 @@ unsigned RAGreedy::tryLastChanceRecolori
   // We may want to reconsider that if we end up with a too large search space
   // for target with hundreds of registers.
   // Indeed, in that case we may want to cut the search space earlier.
-  if (Depth >= LastChanceRecoloringMaxDepth) {
+  if (Depth >= LastChanceRecoloringMaxDepth && !ExhaustiveSearch) {
     DEBUG(dbgs() << "Abort because max depth has been reached.\n");
     CutOffInfo |= CO_Depth;
     return ~0u;
@@ -2139,14 +2144,17 @@ unsigned RAGreedy::selectOrSplit(LiveInt
   if (Reg == ~0U && (CutOffInfo != CO_None)) {
     uint8_t CutOffEncountered = CutOffInfo & (CO_Depth | CO_Interf);
     if (CutOffEncountered == CO_Depth)
-      Ctx.emitError(
-          "register allocation failed: maximum depth for recoloring reached");
+      Ctx.emitError("register allocation failed: maximum depth for recoloring "
+                    "reached. Use -fexhaustive-register-search to skip "
+                    "cutoffs");
     else if (CutOffEncountered == CO_Interf)
       Ctx.emitError("register allocation failed: maximum interference for "
-                    "recoloring reached");
+                    "recoloring reached. Use -fexhaustive-register-search "
+                    "to skip cutoffs");
     else if (CutOffEncountered == (CO_Depth | CO_Interf))
       Ctx.emitError("register allocation failed: maximum interference and "
-                    "depth for recoloring reached");
+                    "depth for recoloring reached. Use "
+                    "-fexhaustive-register-search to skip cutoffs");
   }
   return Reg;
 }

Modified: llvm/trunk/test/CodeGen/X86/ragreedy-last-chance-recoloring.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/ragreedy-last-chance-recoloring.ll?rev=206072&r1=206071&r2=206072&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/ragreedy-last-chance-recoloring.ll (original)
+++ llvm/trunk/test/CodeGen/X86/ragreedy-last-chance-recoloring.ll Fri Apr 11 16:39:44 2014
@@ -8,6 +8,10 @@
 ; RUN: not llc -regalloc=greedy -relocation-model=pic -lcr-max-interf=1  < %s 2>&1 | FileCheck %s --check-prefix=CHECK-INTERF
 ; Test whether failure due to cutoff for interference is reported
 
+; RUN: llc -regalloc=greedy -relocation-model=pic -lcr-max-interf=1 -lcr-max-depth=0 -fexhaustive-register-search < %s > %t 2>&1
+; RUN: FileCheck --input-file=%t %s --check-prefix=CHECK-EXHAUSTIVE
+; Test whether fexhaustive-register-search can bypass the depth and interference cutoffs of last chance recoloring 
+
 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32-S128"
 target triple = "i386-apple-macosx"
 
@@ -20,6 +24,7 @@ target triple = "i386-apple-macosx"
 ; CHECK-NOT: ran out of registers during register allocation
 ; CHECK-INTERF: error: register allocation failed: maximum interference for recoloring reached
 ; CHECK-DEPTH: error: register allocation failed: maximum depth for recoloring reached
+; CHECK-EXHAUSTIVE-NOT: error: register allocation failed: maximum {{depth|interference}} for recoloring reached
 define void @fp_dh_f870bf31fd8ffe068450366e3f05389a(i8* %arg) #0 {
 bb:
   indirectbr i8* undef, [label %bb85, label %bb206]





More information about the llvm-commits mailing list