diff options
author | Alon Zakai <alonzakai@gmail.com> | 2018-08-07 20:01:07 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-07 20:01:07 -0700 |
commit | 9f8fa5a14d3b48c650c2574529fd95c329cb5358 (patch) | |
tree | ad447fed7ee7cc588a4372aa64d121993f1f2ada /src | |
parent | 353e2c4fcb7662b8c73f5673fd0fc21bcb7287c6 (diff) | |
download | binaryen-9f8fa5a14d3b48c650c2574529fd95c329cb5358.tar.gz binaryen-9f8fa5a14d3b48c650c2574529fd95c329cb5358.tar.bz2 binaryen-9f8fa5a14d3b48c650c2574529fd95c329cb5358.zip |
wasm-ctor-eval improvements (#1631)
* When we eval a ctor, don't just nop the function body that no longer needs to be executed, also remove the export (as we report the ctor being evalled, and the outside will no longer call it).
* Run the pass to remove unused global things. This can usually remove evalled ctors (unless something else happens to call them, which can't happen normally as LLVM wouldn't use a ctor in another place, but e.g. duplicate function merging might merge a ctor with another function).
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/wasm-ctor-eval.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/tools/wasm-ctor-eval.cpp b/src/tools/wasm-ctor-eval.cpp index b71a0356a..dee342255 100644 --- a/src/tools/wasm-ctor-eval.cpp +++ b/src/tools/wasm-ctor-eval.cpp @@ -345,9 +345,12 @@ void evalCtors(Module& wasm, std::vector<std::string> ctors) { } std::cerr << " ...success on " << ctor << ".\n"; // success, the entire function was evalled! + // we can nop the function (which may be used elsewhere) + // and remove the export auto* exp = wasm.getExport(ctor); auto* func = wasm.getFunction(exp->value); func->body = wasm.allocator.alloc<Nop>(); + wasm.removeExport(exp->name); } } catch (FailToEvalException& fail) { // that's it, we failed to even create the instance @@ -426,6 +429,7 @@ int main(int argc, const char* argv[]) { passRunner.add("dce"); passRunner.add("merge-blocks"); passRunner.add("vacuum"); + passRunner.add("remove-unused-module-elements"); passRunner.run(); } |