Skip to content

Commit 6efa4a9

Browse files
authored
Flatten control flow pass (#999)
This pass flattens out control flow in order to achieve 2 properties: * Control flow structures (block, loop, if) and control flow operations (br, br_if, br_table, return, unreachable) may only be block children, a loop body, or an if-true or if-false. (I.e., they cannot be nested inside an i32.add, a drop, a call, an if-condition, etc.) * Disallow block, loop, and if return values, i.e., do not use control flow to pass around values. As a result, expressions cannot contain control flow, and overall control flow is simpler, more structured, and more "flat". This should make things like re-relooping wasm code much easier, as they can run after the cfg is flattened
1 parent dbe3384 commit 6efa4a9

File tree

7 files changed

+2432
-0
lines changed

7 files changed

+2432
-0
lines changed

src/passes/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ SET(passes_SOURCES
55
DeadCodeElimination.cpp
66
DuplicateFunctionElimination.cpp
77
ExtractFunction.cpp
8+
FlattenControlFlow.cpp
89
Inlining.cpp
910
LegalizeJSInterface.cpp
1011
LocalCSE.cpp

0 commit comments

Comments
 (0)