diff options
author | Alon Zakai <azakai@google.com> | 2024-02-01 07:48:07 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-01 07:48:07 -0800 |
commit | 76a422b1359855a62b4114686363695b7b5c6889 (patch) | |
tree | cb06396f6ceb8b7fcd68ad73a1b76c0a5e51d961 /test | |
parent | 19fb1f44ccf91cf8d7268a047eb33b11b25fc1f0 (diff) | |
download | binaryen-76a422b1359855a62b4114686363695b7b5c6889.tar.gz binaryen-76a422b1359855a62b4114686363695b7b5c6889.tar.bz2 binaryen-76a422b1359855a62b4114686363695b7b5c6889.zip |
GUFA: Propagate string literals (#6262)
We only noted the type but not the literal value.
Diffstat (limited to 'test')
-rw-r--r-- | test/lit/passes/gufa-strings.wast | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/test/lit/passes/gufa-strings.wast b/test/lit/passes/gufa-strings.wast new file mode 100644 index 000000000..0501e3f56 --- /dev/null +++ b/test/lit/passes/gufa-strings.wast @@ -0,0 +1,59 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. +;; RUN: foreach %s %t wasm-opt -all --gufa -S -o - | filecheck %s + +(module + ;; CHECK: (type $0 (func)) + + ;; CHECK: (global $foo (mut (ref string)) (string.const "foo")) + (global $foo (mut (ref string)) (string.const "foo")) + + ;; CHECK: (global $bar (mut (ref string)) (string.const "bar")) + (global $bar (mut (ref string)) (string.const "bar")) + + ;; CHECK: (global $baz (mut (ref string)) (string.const "baz")) + (global $baz (mut (ref string)) (string.const "baz")) + + ;; CHECK: (func $set (type $0) + ;; CHECK-NEXT: (global.set $foo + ;; CHECK-NEXT: (string.const "foo") + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (global.set $bar + ;; CHECK-NEXT: (string.const "BAR_BAR_BAR") + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $set + ;; Modify $foo to the same value as it begins. + (global.set $foo + (string.const "foo") + ) + ;; Modify $bar to a new value + (global.set $bar + (string.const "BAR_BAR_BAR") + ) + ;; Do not modify $baz at all. + ) + + ;; CHECK: (func $get (type $0) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (string.const "foo") + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (global.get $bar) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (string.const "baz") + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $get + ;; $foo and $baz can be optimized, but not $bar. + (drop + (global.get $foo) + ) + (drop + (global.get $bar) + ) + (drop + (global.get $baz) + ) + ) +) |