summaryrefslogtreecommitdiff
path: root/test/lit/passes
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2021-04-13 15:29:13 -0700
committerGitHub <noreply@github.com>2021-04-13 15:29:13 -0700
commitd321458d57e6977ceaba90099e80b80cf6d472ed (patch)
tree4c57ee8d9f6828ab588b925c71e9dd543f669322 /test/lit/passes
parentb0af95200a37d76eccf285dcb45b4ed6162212d0 (diff)
downloadbinaryen-d321458d57e6977ceaba90099e80b80cf6d472ed.tar.gz
binaryen-d321458d57e6977ceaba90099e80b80cf6d472ed.tar.bz2
binaryen-d321458d57e6977ceaba90099e80b80cf6d472ed.zip
[Wasm GC] Full precompute support for GC (#3803)
The precompute pass ignored all reference types, but that was overly pessimistic: we can precompute some of them, namely a null and a reference to a function are fully precomputable, etc. To allow that to work, add missing integration in getFallthrough as well. With this, we can precompute quite a lot of field accesses in the existing -Oz testcase, as can be seen from the output. That testcase runs --fuzz-exec so it prints out all those logged values, proving they have not changed.
Diffstat (limited to 'test/lit/passes')
-rw-r--r--test/lit/passes/precompute-gc.wast37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/lit/passes/precompute-gc.wast b/test/lit/passes/precompute-gc.wast
new file mode 100644
index 000000000..9402aa068
--- /dev/null
+++ b/test/lit/passes/precompute-gc.wast
@@ -0,0 +1,37 @@
+;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited.
+;; RUN: wasm-opt %s --remove-unused-names --precompute-propagate -all -S -o - \
+;; RUN: | filecheck %s
+
+(module
+ ;; CHECK: (func $test-fallthrough (result i32)
+ ;; CHECK-NEXT: (local $x funcref)
+ ;; CHECK-NEXT: (local.set $x
+ ;; CHECK-NEXT: (block (result funcref)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (call $test-fallthrough)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (ref.null func)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: )
+ (func $test-fallthrough (result i32)
+ (local $x funcref)
+ (local.set $x
+ ;; the fallthrough value should be used. for that to be possible with a block
+ ;; we need for it not to have a name, which is why --remove-unused-names is
+ ;; run
+ (block (result (funcref))
+ ;; make a call so the block is not trivially removable
+ (drop
+ (call $test-fallthrough)
+ )
+ (ref.null func)
+ )
+ )
+ ;; the null in the local should be propagated to here
+ (ref.is_null
+ (local.get $x)
+ )
+ )
+)