diff options
author | Alon Zakai <azakai@google.com> | 2022-11-22 14:17:30 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-22 14:17:30 -0800 |
commit | c834ac4c11ecbb4e17e81d3ebcb64a6c6f453818 (patch) | |
tree | 58677554dcf57ef32b2e8d93ab7f1f7310662804 /test | |
parent | 09ce29d4ab6fd03a9e777f7244154f504a6c0113 (diff) | |
download | binaryen-c834ac4c11ecbb4e17e81d3ebcb64a6c6f453818.tar.gz binaryen-c834ac4c11ecbb4e17e81d3ebcb64a6c6f453818.tar.bz2 binaryen-c834ac4c11ecbb4e17e81d3ebcb64a6c6f453818.zip |
[Wasm GC] Fix CoalesceLocals on tees that receive a refined type (#5289)
Same testcase as in #5287 but in another pass.
Diffstat (limited to 'test')
-rw-r--r-- | test/lit/passes/coalesce-locals-gc.wast | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/test/lit/passes/coalesce-locals-gc.wast b/test/lit/passes/coalesce-locals-gc.wast index 5947aae11..f8694ce86 100644 --- a/test/lit/passes/coalesce-locals-gc.wast +++ b/test/lit/passes/coalesce-locals-gc.wast @@ -8,8 +8,16 @@ ;; testcases. (module + ;; CHECK: (type $A (struct (field dataref))) + ;; CHECK: (type $array (array (mut i8))) (type $array (array (mut i8))) + + (type $A (struct_subtype (field (ref null data)) data)) + + ;; CHECK: (type $B (struct (field (ref data)))) + (type $B (struct_subtype (field (ref data)) $A)) + ;; CHECK: (global $global (ref null $array) (ref.null none)) (global $global (ref null $array) (ref.null $array)) @@ -165,4 +173,47 @@ (local.get $null-i31) ) ) + + ;; CHECK: (func $remove-tee-refinalize (param $0 (ref null $A)) (param $1 (ref null $B)) (result dataref) + ;; CHECK-NEXT: (struct.get $A 0 + ;; CHECK-NEXT: (block (result (ref null $A)) + ;; CHECK-NEXT: (local.get $1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $remove-tee-refinalize + (param $a (ref null $A)) + (param $b (ref null $B)) + (result (ref null data)) + ;; The local.tee receives a $B and flows out an $A. We want to avoid changing + ;; types here, so we'll wrap it in a block, and leave further improvements + ;; for other passes. + (struct.get $A 0 + (local.tee $a + (local.get $b) + ) + ) + ) + + ;; CHECK: (func $remove-tee-refinalize-2 (param $0 (ref null $A)) (param $1 (ref null $B)) (result dataref) + ;; CHECK-NEXT: (struct.get $A 0 + ;; CHECK-NEXT: (block (result (ref null $A)) + ;; CHECK-NEXT: (local.get $1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $remove-tee-refinalize-2 + (param $a (ref null $A)) + (param $b (ref null $B)) + (result (ref null data)) + ;; As above, but with an extra tee in the middle. The result should be the + ;; same. + (struct.get $A 0 + (local.tee $a + (local.tee $a + (local.get $b) + ) + ) + ) + ) ) |