diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/lit/passes/signature-refining.wast | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/test/lit/passes/signature-refining.wast b/test/lit/passes/signature-refining.wast index 71eec54b2..fcffcc550 100644 --- a/test/lit/passes/signature-refining.wast +++ b/test/lit/passes/signature-refining.wast @@ -490,3 +490,137 @@ ) ) ) + +(module + ;; CHECK: (type $struct (struct_subtype data)) + (type $struct (struct_subtype data)) + + ;; This signature has a single function using it, which returns a more + ;; refined type, and we can refine to that. + ;; CHECK: (type $sig-can-refine (func_subtype (result (ref $struct)) func)) + (type $sig-can-refine (func_subtype (result anyref) func)) + + ;; Also a single function, but no refinement is possible. + ;; CHECK: (type $sig-cannot-refine (func_subtype (result anyref) func)) + (type $sig-cannot-refine (func_subtype (result anyref) func)) + + ;; The single function never returns, so no refinement is possible. + ;; CHECK: (type $sig-unreachable (func_subtype (result anyref) func)) + (type $sig-unreachable (func_subtype (result anyref) func)) + + ;; CHECK: (type $none_=>_none (func_subtype func)) + + ;; CHECK: (elem declare func $func-can-refine) + + ;; CHECK: (func $func-can-refine (type $sig-can-refine) (result (ref $struct)) + ;; CHECK-NEXT: (struct.new_default $struct) + ;; CHECK-NEXT: ) + (func $func-can-refine (type $sig-can-refine) (result anyref) + (struct.new $struct) + ) + + ;; CHECK: (func $func-cannot-refine (type $sig-cannot-refine) (result anyref) + ;; CHECK-NEXT: (ref.null any) + ;; CHECK-NEXT: ) + (func $func-cannot-refine (type $sig-cannot-refine) (result anyref) + (ref.null any) + ) + + ;; CHECK: (func $func-unreachable (type $sig-unreachable) (result anyref) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + (func $func-unreachable (type $sig-unreachable) (result anyref) + (unreachable) + ) + + ;; CHECK: (func $caller (type $none_=>_none) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (if (result (ref $struct)) + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: (call $func-can-refine) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (if (result (ref $struct)) + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: (call_ref + ;; CHECK-NEXT: (ref.func $func-can-refine) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $caller + ;; Add a call to see that we update call types properly. + ;; Put the call in an if so the refinalize will update the if type and get + ;; printed out conveniently. + (drop + (if (result anyref) + (i32.const 1) + (call $func-can-refine) + (unreachable) + ) + ) + ;; The same with a call_ref. + (drop + (if (result anyref) + (i32.const 1) + (call_ref + (ref.func $func-can-refine) + ) + (unreachable) + ) + ) + ) +) + +(module + ;; CHECK: (type $struct (struct_subtype data)) + (type $struct (struct_subtype data)) + + ;; This signature has multiple functions using it, and some of them have nulls + ;; which should be updated when we refine. + ;; CHECK: (type $sig (func_subtype (result (ref null $struct)) func)) + (type $sig (func_subtype (result anyref) func)) + + ;; CHECK: (func $func-1 (type $sig) (result (ref null $struct)) + ;; CHECK-NEXT: (struct.new_default $struct) + ;; CHECK-NEXT: ) + (func $func-1 (type $sig) (result anyref) + (struct.new $struct) + ) + + ;; CHECK: (func $func-2 (type $sig) (result (ref null $struct)) + ;; CHECK-NEXT: (ref.null $struct) + ;; CHECK-NEXT: ) + (func $func-2 (type $sig) (result anyref) + (ref.null any) + ) + + ;; CHECK: (func $func-3 (type $sig) (result (ref null $struct)) + ;; CHECK-NEXT: (ref.null $struct) + ;; CHECK-NEXT: ) + (func $func-3 (type $sig) (result anyref) + (ref.null eq) + ) + + ;; CHECK: (func $func-4 (type $sig) (result (ref null $struct)) + ;; CHECK-NEXT: (if + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: (return + ;; CHECK-NEXT: (ref.null $struct) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + (func $func-4 (type $sig) (result anyref) + (if + (i32.const 1) + (return + (ref.null any) + ) + ) + (unreachable) + ) +) |