diff options
author | Alon Zakai <azakai@google.com> | 2023-01-05 11:08:06 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-05 11:08:06 -0800 |
commit | a090dcf453a701922ee6e5cfecdf5619ab6a023b (patch) | |
tree | 57e7a0e59d79e0f39d0be40e2511cc6a927ec0fb /test | |
parent | 5bf548b32e30fbae16dde5df703541ca7ac72f15 (diff) | |
download | binaryen-a090dcf453a701922ee6e5cfecdf5619ab6a023b.tar.gz binaryen-a090dcf453a701922ee6e5cfecdf5619ab6a023b.tar.bz2 binaryen-a090dcf453a701922ee6e5cfecdf5619ab6a023b.zip |
[Wasm GC] Clean up and improve null trap and cast optimizations (#5394)
visitRefCast can use trapOnNonNull. To make this not regress, add fallthrough
analysis there as well.
Minor test changes are due to trapOnNonNull using getDroppedChildren which
only emits drops of necessary children. It also tells us to refinalize so it is ok for it
to change the type to unreachable.
Diffstat (limited to 'test')
-rw-r--r-- | test/lit/passes/optimize-instructions-gc.wast | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/test/lit/passes/optimize-instructions-gc.wast b/test/lit/passes/optimize-instructions-gc.wast index fe18c015b..592ec80cd 100644 --- a/test/lit/passes/optimize-instructions-gc.wast +++ b/test/lit/passes/optimize-instructions-gc.wast @@ -1791,15 +1791,10 @@ ;; CHECK: (func $incompatible-cast-of-null (type $void) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (block (result (ref $array)) - ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.null none) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (unreachable) - ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (block (result (ref $array)) + ;; CHECK-NEXT: (block ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.as_non_null ;; CHECK-NEXT: (ref.null none) @@ -1811,15 +1806,10 @@ ;; CHECK-NEXT: ) ;; NOMNL: (func $incompatible-cast-of-null (type $void) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (block (result (ref $array)) - ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.null none) - ;; NOMNL-NEXT: ) - ;; NOMNL-NEXT: (unreachable) - ;; NOMNL-NEXT: ) + ;; NOMNL-NEXT: (unreachable) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (block (result (ref $array)) + ;; NOMNL-NEXT: (block ;; NOMNL-NEXT: (drop ;; NOMNL-NEXT: (ref.as_non_null ;; NOMNL-NEXT: (ref.null none) @@ -2178,6 +2168,16 @@ ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (local.tee $a + ;; CHECK-NEXT: (ref.null none) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; NOMNL: (func $ref-cast-static-null (type $void) ;; NOMNL-NEXT: (local $a (ref null $A)) @@ -2215,6 +2215,16 @@ ;; NOMNL-NEXT: (ref.null none) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) + ;; NOMNL-NEXT: (drop + ;; NOMNL-NEXT: (block + ;; NOMNL-NEXT: (drop + ;; NOMNL-NEXT: (local.tee $a + ;; NOMNL-NEXT: (ref.null none) + ;; NOMNL-NEXT: ) + ;; NOMNL-NEXT: ) + ;; NOMNL-NEXT: (unreachable) + ;; NOMNL-NEXT: ) + ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) (func $ref-cast-static-null (local $a (ref null $A)) @@ -2242,6 +2252,14 @@ ) ) ) + ;; A non-null cast of a falling-though null will trap. + (drop + (ref.cast $A + (local.tee $a + (ref.null $A) + ) + ) + ) ) ;; CHECK: (func $ref-cast-static-general (type $ref?|$A|_ref?|$B|_=>_none) (param $a (ref null $A)) (param $b (ref null $B)) |