summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/passes/CoalesceLocals.cpp5
-rw-r--r--src/wasm2js.h1
2 files changed, 6 insertions, 0 deletions
diff --git a/src/passes/CoalesceLocals.cpp b/src/passes/CoalesceLocals.cpp
index 232685001..e5416971b 100644
--- a/src/passes/CoalesceLocals.cpp
+++ b/src/passes/CoalesceLocals.cpp
@@ -19,6 +19,11 @@
// is similar to register allocation, however, there is never any
// spilling, and there isn't a fixed number of locals.
//
+// NB: This pass is nonlinear in the number of locals. It is best to run it
+// after the number of locals has been somewhat reduced by other passes,
+// for example by simplify-locals (to remove unneeded uses of locals) and
+// reorder-locals (to sort them by # of uses and remove all unneeded ones).
+//
#include <algorithm>
#include <memory>
diff --git a/src/wasm2js.h b/src/wasm2js.h
index cc2cfa128..1fe5db0c1 100644
--- a/src/wasm2js.h
+++ b/src/wasm2js.h
@@ -326,6 +326,7 @@ Ref Wasm2JSBuilder::processWasm(Module* wasm, Name funcName) {
if (options.optimizeLevel > 0) {
runner.add("remove-unused-names");
runner.add("merge-blocks");
+ runner.add("reorder-locals");
runner.add("coalesce-locals");
}
runner.add("reorder-locals");