diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/asm2wasm-main.cpp | 11 | ||||
-rw-r--r-- | src/asm2wasm.h | 3 |
2 files changed, 11 insertions, 3 deletions
diff --git a/src/asm2wasm-main.cpp b/src/asm2wasm-main.cpp index cbcb3b547..56e8a417f 100644 --- a/src/asm2wasm-main.cpp +++ b/src/asm2wasm-main.cpp @@ -29,6 +29,7 @@ using namespace cashew; using namespace wasm; int main(int argc, const char *argv[]) { + bool opts = true; bool imprecise = false; Options options("asm2wasm", "Translate asm.js files to .wast files"); @@ -47,6 +48,10 @@ int main(int argc, const char *argv[]) { [](Options *o, const std::string &argument) { o->extra["total memory"] = argument; }) + .add("--no-opts", "-n", "Disable optimization passes", Options::Arguments::Zero, + [&opts](Options *o, const std::string &) { + opts = false; + }) .add("--imprecise", "-i", "Imprecise optimizations", Options::Arguments::Zero, [&imprecise](Options *o, const std::string &) { imprecise = true; @@ -90,8 +95,10 @@ int main(int argc, const char *argv[]) { Asm2WasmBuilder asm2wasm(wasm, pre.memoryGrowth, options.debug, imprecise); asm2wasm.processAsm(asmjs); - if (options.debug) std::cerr << "optimizing..." << std::endl; - asm2wasm.optimize(); + if (opts) { + if (options.debug) std::cerr << "optimizing..." << std::endl; + asm2wasm.optimize(); + } if (options.debug) std::cerr << "printing..." << std::endl; Output output(options.extra["output"], options.debug); diff --git a/src/asm2wasm.h b/src/asm2wasm.h index c994d0ef2..4c37b7705 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -419,8 +419,9 @@ private: return nullptr; } + // ensure a nameless block Block* blockify(Expression* expression) { - if (expression->is<Block>()) return expression->dyn_cast<Block>(); + if (expression->is<Block>() && !expression->cast<Block>()->name.is()) return expression->dyn_cast<Block>(); auto ret = allocator.alloc<Block>(); ret->list.push_back(expression); ret->finalize(); |