diff options
Diffstat (limited to 'test/lit/passes/remove-unused-brs-gc.wast')
-rw-r--r-- | test/lit/passes/remove-unused-brs-gc.wast | 101 |
1 files changed, 25 insertions, 76 deletions
diff --git a/test/lit/passes/remove-unused-brs-gc.wast b/test/lit/passes/remove-unused-brs-gc.wast index e063fa482..50ffd9583 100644 --- a/test/lit/passes/remove-unused-brs-gc.wast +++ b/test/lit/passes/remove-unused-brs-gc.wast @@ -11,57 +11,6 @@ (type $struct2 (struct)) ) - ;; CHECK: (func $br_on_non_i31-1 (type $none_=>_none) - ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (block $any (result (ref null $struct)) - ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br $any - ;; CHECK-NEXT: (struct.new_default $struct) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.null none) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - (func $br_on_non_i31-1 - (drop - (block $any (result anyref) - (drop - ;; An struct is not an i31, and so we should branch. - (br_on_non_i31 $any - (struct.new $struct) - ) - ) - (ref.null any) - ) - ) - ) - ;; CHECK: (func $br_on_non_i31-2 (type $none_=>_none) - ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (block $any (result nullref) - ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (i31.new - ;; CHECK-NEXT: (i32.const 0) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.null none) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - (func $br_on_non_i31-2 - (drop - (block $any (result anyref) - (drop - ;; An i31 is provided here, and so we will not branch. - (br_on_non_i31 $any - (i31.new (i32.const 0)) - ) - ) - (ref.null any) - ) - ) - ) - ;; CHECK: (func $br_on-if (type $ref|struct|_=>_none) (param $0 (ref struct)) ;; CHECK-NEXT: (block $label ;; CHECK-NEXT: (drop @@ -93,51 +42,51 @@ ) ) - ;; CHECK: (func $nested_br_on (type $none_=>_i31ref) (result i31ref) - ;; CHECK-NEXT: (block $label$1 (result (ref i31)) + ;; CHECK: (func $br_on_cast (type $none_=>_ref|$struct|) (result (ref $struct)) + ;; CHECK-NEXT: (block $block (result (ref $struct)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br $label$1 - ;; CHECK-NEXT: (i31.new - ;; CHECK-NEXT: (i32.const 0) - ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (br $block + ;; CHECK-NEXT: (struct.new_default $struct) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $nested_br_on (result i31ref) - (block $label$1 (result i31ref) + (func $br_on_cast (result (ref $struct)) + (block $block (result (ref $struct)) (drop - ;; The inner br_on_i31 will become a direct br since the type proves it - ;; is in fact data. That then becomes unreachable, and the parent must - ;; handle that properly (do nothing without hitting an assertion). - (br_on_i31 $label$1 - (br_on_i31 $label$1 - (i31.new (i32.const 0)) - ) + ;; This static cast can be computed at compile time: it will definitely be + ;; taken, so we can turn it into a normal br. + (br_on_cast $block anyref (ref $struct) + (struct.new $struct) ) ) (unreachable) ) ) - ;; CHECK: (func $br_on_cast (type $none_=>_ref|$struct|) (result (ref $struct)) - ;; CHECK-NEXT: (block $block (result (ref $struct)) + ;; CHECK: (func $nested_br_on_cast (type $none_=>_i31ref) (result i31ref) + ;; CHECK-NEXT: (block $label$1 (result (ref i31)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br $block - ;; CHECK-NEXT: (struct.new_default $struct) + ;; CHECK-NEXT: (br $label$1 + ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $br_on_cast (result (ref $struct)) - (block $block (result (ref $struct)) + (func $nested_br_on_cast (result i31ref) + (block $label$1 (result i31ref) (drop - ;; This static cast can be computed at compile time: it will definitely be - ;; taken, so we can turn it into a normal br. - (br_on_cast $block anyref (ref $struct) - (struct.new $struct) + ;; The inner br_on_cast will become a direct br since the type proves it + ;; is in fact i31. That then becomes unreachable, and the parent must + ;; handle that properly (do nothing without hitting an assertion). + (br_on_cast $label$1 (ref any) (ref i31) + (br_on_cast $label$1 (ref any) (ref i31) + (i31.new (i32.const 0)) + ) ) ) (unreachable) |