summaryrefslogtreecommitdiff
path: root/src/tools/asm2wasm.cpp
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2017-04-28 10:48:27 -0700
committerGitHub <noreply@github.com>2017-04-28 10:48:27 -0700
commit5d4f9eb82226acc0fdb5e2dea1a04e17c340c371 (patch)
treeb1b18217aec65f04da0080a1d6d2266489d56db7 /src/tools/asm2wasm.cpp
parenta0b162d13c7e8d5df1f1b6e33efd4d9e3f699aa9 (diff)
downloadbinaryen-5d4f9eb82226acc0fdb5e2dea1a04e17c340c371.tar.gz
binaryen-5d4f9eb82226acc0fdb5e2dea1a04e17c340c371.tar.bz2
binaryen-5d4f9eb82226acc0fdb5e2dea1a04e17c340c371.zip
Preserve debug info through the optimizer (#981)
* add debugInfo option to passes, and use it to keep debug info alive through optimizations when we need it * add fib testcase for debug info * when preserving debug info, do not move code around call-imports, so debug info intrinsics remain stationary * improve wasm-module-building handling of the single-threaded case: don't create workers, which is more efficient and also nicer for debugging * process debug info in a more precise way, reordering it from being after the node (as it was a comment in JS) to before the node * remove unreachable hack for debug info, which is no longer needed since we reorder them, and make sure to finalize blocks in which we reorder
Diffstat (limited to 'src/tools/asm2wasm.cpp')
-rw-r--r--src/tools/asm2wasm.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/tools/asm2wasm.cpp b/src/tools/asm2wasm.cpp
index 0679ad3f5..4ad5a5814 100644
--- a/src/tools/asm2wasm.cpp
+++ b/src/tools/asm2wasm.cpp
@@ -35,7 +35,6 @@ int main(int argc, const char *argv[]) {
bool runOptimizationPasses = false;
Asm2WasmBuilder::TrapMode trapMode = Asm2WasmBuilder::TrapMode::JS;
bool wasmOnly = false;
- bool debugInfo = false;
std::string symbolMap;
bool emitBinary = true;
@@ -98,7 +97,7 @@ int main(int argc, const char *argv[]) {
})
.add("--debuginfo", "-g", "Emit names section and debug info (for debug info you must emit text, -S, for this to work)",
Options::Arguments::Zero,
- [&](Options *o, const std::string &arguments) { debugInfo = true; })
+ [&](Options *o, const std::string &arguments) { passOptions.debugInfo = true; })
.add("--symbolmap", "-s", "Emit a symbol map (indexes => names)",
Options::Arguments::One,
[&](Options *o, const std::string &argument) { symbolMap = argument; })
@@ -128,7 +127,7 @@ int main(int argc, const char *argv[]) {
Asm2WasmPreProcessor pre;
// wasm binaries can contain a names section, but not full debug info
- pre.debugInfo = debugInfo && !emitBinary;
+ pre.debugInfo = passOptions.debugInfo && !emitBinary;
auto input(
read_file<std::vector<char>>(options.extra["infile"], Flags::Text, options.debug ? Flags::Debug : Flags::Release));
char *start = pre.process(input.data());
@@ -188,7 +187,7 @@ int main(int argc, const char *argv[]) {
if (options.debug) std::cerr << "printing..." << std::endl;
ModuleWriter writer;
writer.setDebug(options.debug);
- writer.setDebugInfo(debugInfo);
+ writer.setDebugInfo(passOptions.debugInfo);
writer.setSymbolMap(symbolMap);
writer.setBinary(emitBinary);
writer.write(wasm, options.extra["output"]);