diff options
author | Alon Zakai <azakai@google.com> | 2024-04-25 15:21:26 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-25 15:21:26 -0700 |
commit | c33f126046d6504064d587b8bd7c310a7fdf2087 (patch) | |
tree | 81f828a7ee018c017f21ad15aa0d236c174790d3 /test/lit/passes/vacuum-strings.wast | |
parent | 956d2d89d530012885c1f88c87bf8b872c187b70 (diff) | |
download | binaryen-c33f126046d6504064d587b8bd7c310a7fdf2087.tar.gz binaryen-c33f126046d6504064d587b8bd7c310a7fdf2087.tar.bz2 binaryen-c33f126046d6504064d587b8bd7c310a7fdf2087.zip |
[Strings] Fix effects of string.compare and add fuzzing (#6547)
We added string.compare late in the spec process, and forgot to add effects for it.
Unlike string.eq, it can trap.
Also use makeTrappingRefUse in recent fuzzer string generation places that I
forgot, which should reduce the amount of traps in fuzzer output.
Diffstat (limited to 'test/lit/passes/vacuum-strings.wast')
-rw-r--r-- | test/lit/passes/vacuum-strings.wast | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/test/lit/passes/vacuum-strings.wast b/test/lit/passes/vacuum-strings.wast new file mode 100644 index 000000000..6925d52e6 --- /dev/null +++ b/test/lit/passes/vacuum-strings.wast @@ -0,0 +1,84 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited. +;; RUN: wasm-opt %s --vacuum -all -S -o - | filecheck %s + +(module + ;; CHECK: (func $compare (type $0) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (string.compare + ;; CHECK-NEXT: (string.const "hello") + ;; CHECK-NEXT: (ref.null none) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (string.compare + ;; CHECK-NEXT: (ref.null none) + ;; CHECK-NEXT: (string.const "world") + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (string.compare + ;; CHECK-NEXT: (ref.null none) + ;; CHECK-NEXT: (ref.null none) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $compare + ;; We cannot vacuum away compares that might trap. + (drop + (string.compare + (string.const "hello") + (string.const "world") + ) + ) + (drop + (string.compare + (string.const "hello") + (ref.null none) + ) + ) + (drop + (string.compare + (ref.null none) + (string.const "world") + ) + ) + (drop + (string.compare + (ref.null none) + (ref.null none) + ) + ) + ) + + ;; CHECK: (func $eq (type $0) + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: ) + (func $eq + ;; Equals, however, never traps so all these can be removed. + (drop + (string.eq + (string.const "hello") + (string.const "world") + ) + ) + (drop + (string.eq + (string.const "hello") + (ref.null none) + ) + ) + (drop + (string.eq + (ref.null none) + (string.const "world") + ) + ) + (drop + (string.eq + (ref.null none) + (ref.null none) + ) + ) + ) +) + |