diff options
author | Alon Zakai <azakai@google.com> | 2023-04-07 08:12:10 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-07 08:12:10 -0700 |
commit | e5be9ac2e2f22545ae02db43e9f94dd7d3dbceef (patch) | |
tree | de8eed7efbfa3e0d4361dbb08f03c534b0676fb9 /test/lit/passes/gufa-refs.wast | |
parent | 4f91c6a569614275d906a825d3f495541aa8802d (diff) | |
download | binaryen-e5be9ac2e2f22545ae02db43e9f94dd7d3dbceef.tar.gz binaryen-e5be9ac2e2f22545ae02db43e9f94dd7d3dbceef.tar.bz2 binaryen-e5be9ac2e2f22545ae02db43e9f94dd7d3dbceef.zip |
[Wasm GC] Fix GUFA on ArrayInit (#5638)
Diffstat (limited to 'test/lit/passes/gufa-refs.wast')
-rw-r--r-- | test/lit/passes/gufa-refs.wast | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/test/lit/passes/gufa-refs.wast b/test/lit/passes/gufa-refs.wast index 8bcf5c6a5..fe3eb70fc 100644 --- a/test/lit/passes/gufa-refs.wast +++ b/test/lit/passes/gufa-refs.wast @@ -5466,3 +5466,62 @@ ) ) ) + +;; Verify we do not error or misoptimize with array.init_elem. +(module + ;; CHECK: (type $vector (array (mut funcref))) + (type $vector (array (mut funcref))) + + (elem func) + + ;; CHECK: (type $none_=>_none (func)) + + ;; CHECK: (elem $0 func) + + ;; CHECK: (elem declare func $test) + + ;; CHECK: (func $test (type $none_=>_none) + ;; CHECK-NEXT: (local $ref (ref $vector)) + ;; CHECK-NEXT: (local.set $ref + ;; CHECK-NEXT: (array.new $vector + ;; CHECK-NEXT: (ref.func $test) + ;; CHECK-NEXT: (i32.const 100) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (array.init_elem $vector $0 + ;; CHECK-NEXT: (local.get $ref) + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (array.get $vector + ;; CHECK-NEXT: (local.get $ref) + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $test + (local $ref (ref $vector)) + (local.set $ref + (array.new $vector + (ref.func $test) + (i32.const 100) + ) + ) + (array.init_elem $vector 0 + (local.get $ref) + (i32.const 1) + (i32.const 1) + (i32.const 1) + ) + ;; We wrote a specific ref.func earlier, but also we did an init_elem whose + ;; values we consider unknown, so we will not optimize this get. + (drop + (array.get $vector + (local.get $ref) + (i32.const 1) + ) + ) + ) +) |