diff options
Diffstat (limited to 'test/lit')
-rw-r--r-- | test/lit/passes/precompute-ref-func.wast | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/test/lit/passes/precompute-ref-func.wast b/test/lit/passes/precompute-ref-func.wast index df4415c7b..495563271 100644 --- a/test/lit/passes/precompute-ref-func.wast +++ b/test/lit/passes/precompute-ref-func.wast @@ -2,18 +2,23 @@ ;; RUN: wasm-opt %s -all --precompute -S -o - | filecheck %s (module - ;; CHECK: (type $0 (func (result funcref))) ;; CHECK: (type $shared-func (shared (func (result (ref null (shared func)))))) (type $shared-func (shared (func (result (ref null (shared func)))))) + + ;; CHECK: (type $func (func (result funcref))) + (type $func (func (result funcref))) + + ;; CHECK: (type $2 (func (result (ref $shared-func)))) + ;; CHECK: (elem declare func $test $test-shared) - ;; CHECK: (func $test (type $0) (result funcref) + ;; CHECK: (func $test (type $func) (result funcref) ;; CHECK-NEXT: (return ;; CHECK-NEXT: (ref.func $test) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $test (result funcref) + (func $test (type $func) (result funcref) (block (return (ref.func $test) @@ -33,4 +38,28 @@ ) ) ) + + ;; CHECK: (func $precompute-nested-brs (type $2) (result (ref $shared-func)) + ;; CHECK-NEXT: (ref.func $test-shared) + ;; CHECK-NEXT: ) + (func $precompute-nested-brs (result (ref $shared-func)) + ;; We have two nested brs here, and we can precompute it all. While doing so + ;; we must not get confused between the targets and values: one sends a + ;; shared func, the other a normal func, so the types are different, and any + ;; mistake there will fail validation (say, if we reused the ref.func from + ;; the inner br when generating the outer one). + (block $shared (result (ref $shared-func)) + (drop + (block $func (result (ref $func)) + (br_if $func + (ref.func $test) + (br $shared + (ref.func $test-shared) + ) + ) + ) + ) + (ref.func $test-shared) + ) + ) ) |