[llvm] r261176 - [WebAssembly] Disable register stackification and coloring when not optimizing

Derek Schuff via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 17 15:20:44 PST 2016


Author: dschuff
Date: Wed Feb 17 17:20:43 2016
New Revision: 261176

URL: http://llvm.org/viewvc/llvm-project?rev=261176&view=rev
Log:
[WebAssembly] Disable register stackification and coloring when not optimizing

These passes are optimizations, and should be disabled when not
optimizing.
Also create an MCCodeGenInfo so the opt level is correctly plumbed to
the backend pass manager.
Also remove the command line flag for disabling register coloring;
running llc with -O0 should now be useful for debugging, so it's not
necessary.

Differential Revision: http://reviews.llvm.org/D17327

Modified:
    llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp
    llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegColoring.cpp
    llvm/trunk/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp

Modified: llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp?rev=261176&r1=261175&r2=261176&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp Wed Feb 17 17:20:43 2016
@@ -40,6 +40,20 @@ static MCAsmInfo *createMCAsmInfo(const
   return new WebAssemblyMCAsmInfo(TT);
 }
 
+static MCCodeGenInfo *createMCCodeGenInfo(const Triple & /*TT*/,
+                                          Reloc::Model /*RM*/,
+                                          CodeModel::Model CM,
+                                          CodeGenOpt::Level OL) {
+  CodeModel::Model M = (CM == CodeModel::Default || CM == CodeModel::JITDefault)
+                           ? CodeModel::Large
+                           : CM;
+  if (M != CodeModel::Large)
+    report_fatal_error("Non-large code models are not supported yet");
+  MCCodeGenInfo *CGI = new MCCodeGenInfo();
+  CGI->initMCCodeGenInfo(Reloc::PIC_, CM, OL);
+  return CGI;
+}
+
 static MCInstrInfo *createMCInstrInfo() {
   MCInstrInfo *X = new MCInstrInfo();
   InitWebAssemblyMCInstrInfo(X);
@@ -99,6 +113,9 @@ extern "C" void LLVMInitializeWebAssembl
     // Register the MC instruction info.
     TargetRegistry::RegisterMCInstrInfo(*T, createMCInstrInfo);
 
+    // Register the MC codegen info.
+    TargetRegistry::RegisterMCCodeGenInfo(*T, createMCCodeGenInfo);
+
     // Register the MC register info.
     TargetRegistry::RegisterMCRegInfo(*T, createMCRegisterInfo);
 

Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegColoring.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegColoring.cpp?rev=261176&r1=261175&r2=261176&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegColoring.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyRegColoring.cpp Wed Feb 17 17:20:43 2016
@@ -29,10 +29,6 @@ using namespace llvm;
 
 #define DEBUG_TYPE "wasm-reg-coloring"
 
-static cl::opt<bool>
-    DisableRegColoring("disable-wasm-reg-coloring", cl::Hidden, cl::init(false),
-                       cl::desc("Disable WebAssembly register coloring"));
-
 namespace {
 class WebAssemblyRegColoring final : public MachineFunctionPass {
 public:
@@ -80,9 +76,6 @@ bool WebAssemblyRegColoring::runOnMachin
            << "********** Function: " << MF.getName() << '\n';
   });
 
-  if (DisableRegColoring)
-    return false;
-
   // If there are calls to setjmp or sigsetjmp, don't perform coloring. Virtual
   // registers could be modified before the longjmp is executed, resulting in
   // the wrong value being used afterwards. (See <rdar://problem/8007500>.)

Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp?rev=261176&r1=261175&r2=261176&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp Wed Feb 17 17:20:43 2016
@@ -185,11 +185,13 @@ void WebAssemblyPassConfig::addPostRegAl
   // Fails with: should be run after register allocation.
   disablePass(&MachineCopyPropagationID);
 
-  // Mark registers as representing wasm's expression stack.
-  addPass(createWebAssemblyRegStackify());
+  if (getOptLevel() != CodeGenOpt::None) {
+    // Mark registers as representing wasm's expression stack.
+    addPass(createWebAssemblyRegStackify());
 
-  // Run the register coloring pass to reduce the total number of registers.
-  addPass(createWebAssemblyRegColoring());
+    // Run the register coloring pass to reduce the total number of registers.
+    addPass(createWebAssemblyRegColoring());
+  }
 
   TargetPassConfig::addPostRegAlloc();
 




More information about the llvm-commits mailing list