[PATCH] D33181: Don't allow -optimize-regalloc=false with -regalloc given for anything other than 'fast'

Jonas Paulsson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 15 01:23:06 PDT 2017


jonpa created this revision.

This fixes https://bugs.llvm.org/show_bug.cgi?id=33022:

> I discovered that the use of these two options made a lot of vregs survive the greedy register allocator. Eventually this was displayed:
> 
> MachineFunctionProperties required by Prologue/Epilogue Insertion & Frame Finalization pass are not met by function autogen_SD13131.
> Required properties: NoVRegs
> Current properties: NoPHIs, TracksLiveness
> MachineFunctionProperties check failed
> 
> My guess is that this is something that would never work. It seems to me that perhaps this combination of options should not be allowed, in case a >novice user happens to try it?




https://reviews.llvm.org/D33181

Files:
  lib/CodeGen/TargetPassConfig.cpp


Index: lib/CodeGen/TargetPassConfig.cpp
===================================================================
--- lib/CodeGen/TargetPassConfig.cpp
+++ lib/CodeGen/TargetPassConfig.cpp
@@ -556,6 +556,14 @@
     addPass(createVerifierPass());
 }
 
+/// -regalloc=... command line option.
+static FunctionPass *useDefaultRegisterAllocator() { return nullptr; }
+static cl::opt<RegisterRegAlloc::FunctionPassCtor, false,
+               RegisterPassParser<RegisterRegAlloc> >
+RegAlloc("regalloc",
+         cl::init(&useDefaultRegisterAllocator),
+         cl::desc("Register allocator to use"));
+
 /// Add the complete set of target-independent postISel code generator passes.
 ///
 /// This can be read as the standard order of major LLVM CodeGen stages. Stages
@@ -614,8 +622,12 @@
   // including phi elimination and scheduling.
   if (getOptimizeRegAlloc())
     addOptimizedRegAlloc(createRegAllocPass(true));
-  else
+  else {
+    assert ((RegAlloc == &useDefaultRegisterAllocator ||
+             RegAlloc == &createFastRegisterAllocator) &&
+        "Must use fast (default) register allocator for unoptimized regalloc.");
     addFastRegAlloc(createRegAllocPass(false));
+  }
 
   // Run post-ra passes.
   addPostRegAlloc();
@@ -748,19 +760,12 @@
 /// A dummy default pass factory indicates whether the register allocator is
 /// overridden on the command line.
 static llvm::once_flag InitializeDefaultRegisterAllocatorFlag;
-static FunctionPass *useDefaultRegisterAllocator() { return nullptr; }
+
 static RegisterRegAlloc
 defaultRegAlloc("default",
                 "pick register allocator based on -O option",
                 useDefaultRegisterAllocator);
 
-/// -regalloc=... command line option.
-static cl::opt<RegisterRegAlloc::FunctionPassCtor, false,
-               RegisterPassParser<RegisterRegAlloc> >
-RegAlloc("regalloc",
-         cl::init(&useDefaultRegisterAllocator),
-         cl::desc("Register allocator to use"));
-
 static void initializeDefaultRegisterAllocatorOnce() {
   RegisterRegAlloc::FunctionPassCtor Ctor = RegisterRegAlloc::getDefault();
 
@@ -770,7 +775,6 @@
   }
 }
 
-
 /// Instantiate the default register allocator pass for this target for either
 /// the optimized or unoptimized allocation path. This will be added to the pass
 /// manager by addFastRegAlloc in the unoptimized case or addOptimizedRegAlloc


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33181.98954.patch
Type: text/x-patch
Size: 2360 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170515/013af30a/attachment.bin>


More information about the llvm-commits mailing list