diff options
author | Alon Zakai <azakai@google.com> | 2022-09-16 14:11:25 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-16 21:11:25 +0000 |
commit | 4e24fdfd74347dc40ba32efee6b154e6ec9827c0 (patch) | |
tree | 42413adab127314c4b0bd5035db4aae55359ff08 /test/passes/remove-unused-names_remove-unused-brs_vacuum.txt | |
parent | 241dee74dd8e58e166a4aa64c15e0f71ed1819bf (diff) | |
download | binaryen-4e24fdfd74347dc40ba32efee6b154e6ec9827c0.tar.gz binaryen-4e24fdfd74347dc40ba32efee6b154e6ec9827c0.tar.bz2 binaryen-4e24fdfd74347dc40ba32efee6b154e6ec9827c0.zip |
Effects: Clarify trap effect meaning, and consider infinite loops to trap due to timeout (#5039)
I think this simplifies the logic behind what we consider to trap. Before we had kind of
a hack in visitLoop that now has a more clear reasoning behind it: we consider as
trapping things that trap in all VMs all the time, or will eventually. So a single allocation
doesn't trap, but an unbounded amount can, and an infinite loop is considered to
trap as well (a timeout in a VM will be hit eventually, somehow).
This means we cannot optimize way a trivial infinite loop with no effects in it,
while (1) {}
But we can optimize it out in trapsNeverHappen mode. In any event, such a loop
is not a realistic situation; an infinite loop with some other effect in it, like a call to
an import, will not be optimized out, of course.
Also clarify some other things regarding traps and trapsNeverHappen following
recent discussions in https://github.com/emscripten-core/emscripten/issues/17732
Specifically, TNH will never be allowed to remove calls to imports.
Diffstat (limited to 'test/passes/remove-unused-names_remove-unused-brs_vacuum.txt')
-rw-r--r-- | test/passes/remove-unused-names_remove-unused-brs_vacuum.txt | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/test/passes/remove-unused-names_remove-unused-brs_vacuum.txt b/test/passes/remove-unused-names_remove-unused-brs_vacuum.txt index 83be83c5a..ca856396e 100644 --- a/test/passes/remove-unused-names_remove-unused-brs_vacuum.txt +++ b/test/passes/remove-unused-names_remove-unused-brs_vacuum.txt @@ -71,8 +71,12 @@ (block $label$3 (block (if - (i32.eqz - (local.get $var$8) + (local.get $var$8) + (loop $label$8 + (if + (local.get $var$3) + (br $label$8) + ) ) (if (i32.eqz |