diff options
author | Alon Zakai <azakai@google.com> | 2024-10-10 16:06:11 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-10 16:06:11 -0700 |
commit | f0a5e488ae68074837706edafb54050e56cf9937 (patch) | |
tree | af4a6a40344212c73a94554ff6ba0e1dfda5cf95 /src | |
parent | a8aa6602cdbedd04e69d362c01bbf378a44b395d (diff) | |
download | binaryen-f0a5e488ae68074837706edafb54050e56cf9937.tar.gz binaryen-f0a5e488ae68074837706edafb54050e56cf9937.tar.bz2 binaryen-f0a5e488ae68074837706edafb54050e56cf9937.zip |
[Wasm EH] Optimize values flowing out of TryTable (#6997)
This allows
(block $out (result i32)
(try_table (catch..)
..
(br $out
(i32.const 42)
)
)
)
=>
(block $out (result i32)
(try_table (result i32) (catch..) ;; add a result
..
(i32.const 42) ;; remove the br around the value
)
)
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/RemoveUnusedBrs.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/passes/RemoveUnusedBrs.cpp b/src/passes/RemoveUnusedBrs.cpp index c2f470d80..2452130cc 100644 --- a/src/passes/RemoveUnusedBrs.cpp +++ b/src/passes/RemoveUnusedBrs.cpp @@ -260,15 +260,16 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> { } } } else if (curr->is<Nop>()) { - // ignore (could be result of a previous cycle) + // Ignore (could be result of a previous cycle). self->stopValueFlow(); - } else if (curr->is<Loop>()) { // TODO: eh - // do nothing - it's ok for values to flow out + } else if (curr->is<Loop>() || curr->is<TryTable>()) { + // Do nothing - it's ok for values to flow out. + // TODO: Legacy Try as well? } else if (auto* sw = curr->dynCast<Switch>()) { self->stopFlow(); self->optimizeSwitch(sw); } else { - // anything else stops the flow + // Anything else stops the flow. self->stopFlow(); } } |