From 272ffea1237f1ebb0455949a102a141d55542a47 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 12 Nov 2021 08:52:11 -0800 Subject: 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. --- src/passes/ReorderFunctions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/passes/ReorderFunctions.cpp') 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 -- cgit v1.2.3