Index: lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp =================================================================== --- lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp +++ lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp @@ -40,6 +40,18 @@ return new WebAssemblyMCAsmInfo(TT); } +static MCCodeGenInfo *createMCCodeGenInfo(const Triple& /*TT*/, + Reloc::Model RM, + CodeModel::Model CM, + CodeGenOpt::Level OL) { + assert(RM == Reloc::Default || RM == Reloc::Static + && "Non-default reloc models not supported yet"); + assert(CM == CodeModel::Default && "Non default code models not supported yet"); + MCCodeGenInfo *CGI = new MCCodeGenInfo(); + CGI->initMCCodeGenInfo(RM, CM, OL); + return CGI; +} + static MCInstrInfo *createMCInstrInfo() { MCInstrInfo *X = new MCInstrInfo(); InitWebAssemblyMCInstrInfo(X); @@ -99,6 +111,9 @@ // 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); Index: lib/Target/WebAssembly/WebAssemblyRegColoring.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyRegColoring.cpp +++ lib/Target/WebAssembly/WebAssemblyRegColoring.cpp @@ -29,10 +29,6 @@ #define DEBUG_TYPE "wasm-reg-coloring" -static cl::opt - 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 @@ << "********** 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 .) Index: lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp +++ lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp @@ -185,11 +185,14 @@ // Fails with: should be run after register allocation. disablePass(&MachineCopyPropagationID); - // Mark registers as representing wasm's expression stack. - addPass(createWebAssemblyRegStackify()); - // Run the register coloring pass to reduce the total number of registers. - addPass(createWebAssemblyRegColoring()); + 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()); + } TargetPassConfig::addPostRegAlloc();