summaryrefslogtreecommitdiff
path: root/test/lit/passes
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2023-05-10 12:36:08 -0700
committerGitHub <noreply@github.com>2023-05-10 12:36:08 -0700
commitc5c223943770412b2ebd7d9f23fce8c11cf5982e (patch)
tree4a4038c2a6caee19d0dc0f803535a57fa06a9d01 /test/lit/passes
parentee738ac1f838a090cac74ba8981e2104b6c02d44 (diff)
downloadbinaryen-c5c223943770412b2ebd7d9f23fce8c11cf5982e.tar.gz
binaryen-c5c223943770412b2ebd7d9f23fce8c11cf5982e.tar.bz2
binaryen-c5c223943770412b2ebd7d9f23fce8c11cf5982e.zip
Add a "mayNotReturn" effect (#5711)
This changes loops from having the effect "may trap (timeout)" to having "may not return." The only noticeable difference is in TrapsNeverHappen mode, which ignores the former but not the latter. So after this PR, in TNH mode we do not optimize away an infinite loop that seems to have no other side effects. We may also use this for other things in the future, like continuations/stack switching. There are upsides and downsides to allowing the optimizer to remove infinite loops (the C and C++ communities have had interesting discussions on that topic over the years...) but it seems safer to not optimize them out for now, to let the most code work properly. If a need comes up to optimize such code, we can look at various options then (like a flag to ignore infinite loops). See discussion in #5228
Diffstat (limited to 'test/lit/passes')
-rw-r--r--test/lit/passes/vacuum-tnh.wast13
1 files changed, 10 insertions, 3 deletions
diff --git a/test/lit/passes/vacuum-tnh.wast b/test/lit/passes/vacuum-tnh.wast
index 6b0907989..e4ce9765d 100644
--- a/test/lit/passes/vacuum-tnh.wast
+++ b/test/lit/passes/vacuum-tnh.wast
@@ -186,7 +186,14 @@
)
;; YESTNH: (func $drop-loop (type $none_=>_none)
- ;; YESTNH-NEXT: (nop)
+ ;; YESTNH-NEXT: (drop
+ ;; YESTNH-NEXT: (loop $loop (result i32)
+ ;; YESTNH-NEXT: (br_if $loop
+ ;; YESTNH-NEXT: (i32.const 1)
+ ;; YESTNH-NEXT: )
+ ;; YESTNH-NEXT: (i32.const 10)
+ ;; YESTNH-NEXT: )
+ ;; YESTNH-NEXT: )
;; YESTNH-NEXT: )
;; NO_TNH: (func $drop-loop (type $none_=>_none)
;; NO_TNH-NEXT: (drop
@@ -199,8 +206,8 @@
;; NO_TNH-NEXT: )
;; NO_TNH-NEXT: )
(func $drop-loop
- ;; A loop has effects, since it might infinite loop (and hit a timeout trap
- ;; eventually), so we do not vacuum it out unless we are ignoring traps.
+ ;; A loop has the effect of potentially being infinite. Even in TNH mode we
+ ;; do not optimize out such loops.
(drop
(loop $loop (result i32)
(br_if $loop