diff options
Diffstat (limited to 'test/lit')
-rw-r--r-- | test/lit/passes/vacuum-gc.wast | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/test/lit/passes/vacuum-gc.wast b/test/lit/passes/vacuum-gc.wast index 6e70425a2..bbb0c4c64 100644 --- a/test/lit/passes/vacuum-gc.wast +++ b/test/lit/passes/vacuum-gc.wast @@ -3,6 +3,12 @@ (module ;; CHECK: (type ${} (struct )) + + ;; CHECK: (import "binaryen-intrinsics" "call.without.effects" (func $call.without.effects (param i32 i32 funcref) (result anyref))) + (import "binaryen-intrinsics" "call.without.effects" (func $call.without.effects (param i32 i32 funcref) (result (ref null any)))) + ;; CHECK: (import "binaryen-intrinsics" "call.without.effects" (func $call.without.effects.non.null (param i32 i32 funcref) (result (ref any)))) + (import "binaryen-intrinsics" "call.without.effects" (func $call.without.effects.non.null (param i32 i32 funcref) (result (ref any)))) + (type ${} (struct)) ;; CHECK: (func $drop-ref-as (type $anyref_=>_none) (param $x anyref) @@ -90,4 +96,101 @@ ) ) ) + + ;; CHECK: (func $dropped-calls (type $none_=>_none) + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (call $helper-i32) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (call $helper-i32) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (call $helper-ref) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (call $helper-ref) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (call $helper-i32) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (call $helper-i32) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (call $call.without.effects.non.null + ;; CHECK-NEXT: (call $helper-i32) + ;; CHECK-NEXT: (call $helper-i32) + ;; CHECK-NEXT: (ref.func $helper-two-refs-non-null) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $dropped-calls + ;; The calls' outputs are used in a computation that itself has no effects, + ;; and is dropped, so we don't need it. But we can't remove the calls + ;; themselves, which should be all that remains, with drops of them (there + ;; will also be blocks, which merge-blocks would remove). + (drop + (i32.add + (call $helper-i32) + (call $helper-i32) + ) + ) + (drop + (ref.eq + (call $helper-ref) + (call $helper-ref) + ) + ) + ;; The call.without.effects can be removed, but not the two calls nested in + ;; it. + (drop + (call $call.without.effects + (call $helper-i32) + (call $helper-i32) + (ref.func $helper-two-refs) + ) + ) + ;; The non-null case however is tricky, and we do not handle it atm. TODO + (drop + (call $call.without.effects.non.null + (call $helper-i32) + (call $helper-i32) + (ref.func $helper-two-refs-non-null) + ) + ) + ) + + ;; CHECK: (func $helper-i32 (type $none_=>_i32) (result i32) + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + (func $helper-i32 (result i32) + (i32.const 1) + ) + + ;; CHECK: (func $helper-ref (type $none_=>_eqref) (result eqref) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + (func $helper-ref (result eqref) + (unreachable) + ) + + ;; CHECK: (func $helper-two-refs (type $i32_i32_=>_anyref) (param $0 i32) (param $1 i32) (result anyref) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + (func $helper-two-refs (param i32) (param i32) (result (ref null any)) + (unreachable) + ) + + ;; CHECK: (func $helper-two-refs-non-null (type $i32_i32_=>_ref|any|) (param $0 i32) (param $1 i32) (result (ref any)) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + (func $helper-two-refs-non-null (param i32) (param i32) (result (ref any)) + (unreachable) + ) ) |