diff options
author | Wouter van Oortmerssen <aardappel@gmail.com> | 2020-04-30 11:41:39 -0700 |
---|---|---|
committer | Wouter van Oortmerssen <aardappel@gmail.com> | 2020-05-14 13:14:45 -0700 |
commit | 2b7fe0863ac3c076797404f90b49cee696af0564 (patch) | |
tree | 33c075c15c4f17b134b6615f7c557fdeab210ae3 /llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp | |
parent | 5144e48c1497e154961f22a7ac1de36c0d3e3f5d (diff) | |
download | llvm-2b7fe0863ac3c076797404f90b49cee696af0564.zip llvm-2b7fe0863ac3c076797404f90b49cee696af0564.tar.gz llvm-2b7fe0863ac3c076797404f90b49cee696af0564.tar.bz2 |
[WebAssembly] Added Debug Fixup pass
This pass changes debug_value instructions referring to stackified registers into TI_OPERAND_STACK with correct stack depth.
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp')
-rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp index 8a92abd..ca098427 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp @@ -45,6 +45,16 @@ static cl::opt<bool> EnableEmSjLj( cl::desc("WebAssembly Emscripten-style setjmp/longjmp handling"), cl::init(false)); +// A command-line option to keep implicit locals +// for the purpose of testing with lit/llc ONLY. +// This produces output which is not valid WebAssembly, and is not supported +// by assemblers/disassemblers and other MC based tools. +static cl::opt<bool> WasmDisableExplicitLocals( + "wasm-disable-explicit-locals", cl::Hidden, + cl::desc("WebAssembly: output implicit locals in" + " instruction output for test purposes only."), + cl::init(false)); + extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeWebAssemblyTarget() { // Register the target. RegisterTargetMachine<WebAssemblyTargetMachine> X( @@ -75,6 +85,7 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeWebAssemblyTarget() { initializeWebAssemblyExplicitLocalsPass(PR); initializeWebAssemblyLowerBrUnlessPass(PR); initializeWebAssemblyRegNumberingPass(PR); + initializeWebAssemblyDebugFixupPass(PR); initializeWebAssemblyPeepholePass(PR); } @@ -467,7 +478,8 @@ void WebAssemblyPassConfig::addPreEmitPass() { addPass(createWebAssemblyCFGStackify()); // Insert explicit local.get and local.set operators. - addPass(createWebAssemblyExplicitLocals()); + if (!WasmDisableExplicitLocals) + addPass(createWebAssemblyExplicitLocals()); // Lower br_unless into br_if. addPass(createWebAssemblyLowerBrUnless()); @@ -478,6 +490,10 @@ void WebAssemblyPassConfig::addPreEmitPass() { // Create a mapping from LLVM CodeGen virtual registers to wasm registers. addPass(createWebAssemblyRegNumbering()); + + // Fix debug_values whose defs have been stackified. + if (!WasmDisableExplicitLocals) + addPass(createWebAssemblyDebugFixup()); } yaml::MachineFunctionInfo * |