summaryrefslogtreecommitdiff
path: root/src/passes/ReorderFunctions.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2021-11-12 08:52:11 -0800
committerGitHub <noreply@github.com>2021-11-12 08:52:11 -0800
commit272ffea1237f1ebb0455949a102a141d55542a47 (patch)
treee241dbb10dd8a103f43cf571e210c6e56e178e73 /src/passes/ReorderFunctions.cpp
parent50e66800dc28d67ea1cc88172f459df1ca96507d (diff)
downloadbinaryen-272ffea1237f1ebb0455949a102a141d55542a47.tar.gz
binaryen-272ffea1237f1ebb0455949a102a141d55542a47.tar.bz2
binaryen-272ffea1237f1ebb0455949a102a141d55542a47.zip
MergeBlocks: Rewrite to use a generic algorithm (#4323)
Before this we had special logic for various call types. This replaces all that with a single general code path, which unifies everything except for control flow constructs (which remain as before, handled in a special way for each of them). The algorithm is simple and direct, basically it goes through the children and when it finds a block, it sees if it can move the block's contents outside of the parent. While doing so it takes into account effects and so forth. To make this easy, a random-access API is added to ChildIterator. Diff without whitespace makes the existing test updates a lot simpler. Note that this is not NFC as the old algorithm had some quirks like not taking into account effects when there were more than 2 children; the new code is uniform in how it handles things. This ends up removing 19% of all blocks in j2wasm, which reduces 1% of total code size.
Diffstat (limited to 'src/passes/ReorderFunctions.cpp')
-rw-r--r--src/passes/ReorderFunctions.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/passes/ReorderFunctions.cpp b/src/passes/ReorderFunctions.cpp
index 66b8275ef..326893951 100644
--- a/src/passes/ReorderFunctions.cpp
+++ b/src/passes/ReorderFunctions.cpp
@@ -24,7 +24,7 @@
// a less beneficial position for compression, that is, mutually-compressible
// functions are no longer together (when they were before, in the original
// order, the has some natural tendency one way or the other). TODO: investigate
-// similarity ordering here.
+// similarity ordering here (see #4322)
//
#include <memory>