diff options
| author | Derek Schuff <dschuff@google.com> | 2016-02-17 23:20:43 +0000 |
|---|---|---|
| committer | Derek Schuff <dschuff@google.com> | 2016-02-17 23:20:43 +0000 |
| commit | 71434ff6429e1ff330bf3bfa8340b2421a0a2b31 (patch) | |
| tree | b4a2b0fa305089efa4df5cb1fc14cd11bbf10b76 | |
| parent | 7687bcee4a5a83fc01141f47cc17a64fbdb96207 (diff) | |
| download | bcm5719-llvm-71434ff6429e1ff330bf3bfa8340b2421a0a2b31.tar.gz bcm5719-llvm-71434ff6429e1ff330bf3bfa8340b2421a0a2b31.zip | |
[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
llvm-svn: 261176
3 files changed, 23 insertions, 11 deletions
diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp index 039bc7128ca..a7a813313a2 100644 --- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp +++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp @@ -40,6 +40,20 @@ static MCAsmInfo *createMCAsmInfo(const MCRegisterInfo & /*MRI*/, 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 LLVMInitializeWebAssemblyTargetMC() { // 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); diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyRegColoring.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyRegColoring.cpp index fd54701c35c..9ec66595d8d 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyRegColoring.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyRegColoring.cpp @@ -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::runOnMachineFunction(MachineFunction &MF) { << "********** 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>.) diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp index 25f009d2fb3..2e2a1194502 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp @@ -185,11 +185,13 @@ void WebAssemblyPassConfig::addPostRegAlloc() { // 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(); |

