diff options
author | Alon Zakai <alonzakai@gmail.com> | 2017-05-10 14:38:20 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-10 14:38:20 -0700 |
commit | 6efa4a97b2c643bf35756bb6e989b90d6b3e44bc (patch) | |
tree | 64593c763ca43a2c641c652f5e39ac13db0618ef /src/passes/pass.cpp | |
parent | dbe3384034e12909694c554149a1fb536fbece21 (diff) | |
download | binaryen-6efa4a97b2c643bf35756bb6e989b90d6b3e44bc.tar.gz binaryen-6efa4a97b2c643bf35756bb6e989b90d6b3e44bc.tar.bz2 binaryen-6efa4a97b2c643bf35756bb6e989b90d6b3e44bc.zip |
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
Diffstat (limited to 'src/passes/pass.cpp')
-rw-r--r-- | src/passes/pass.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp index 51e76cdf7..50c8da46b 100644 --- a/src/passes/pass.cpp +++ b/src/passes/pass.cpp @@ -70,6 +70,7 @@ void PassRegistry::registerPasses() { registerPass("dce", "removes unreachable code", createDeadCodeEliminationPass); registerPass("duplicate-function-elimination", "removes duplicate functions", createDuplicateFunctionEliminationPass); registerPass("extract-function", "leaves just one function (useful for debugging)", createExtractFunctionPass); + registerPass("flatten-control-flow", "flattens out control flow to be only on blocks, not nested as expressions", createFlattenControlFlowPass); registerPass("inlining", "inlines functions (currently only ones with a single use)", createInliningPass); registerPass("legalize-js-interface", "legalizes i64 types on the import/export boundary", createLegalizeJSInterfacePass); registerPass("local-cse", "common subexpression elimination inside basic blocks", createLocalCSEPass); |