diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/passes/remove-unused-brs_all-features.txt | 75 | ||||
-rw-r--r-- | test/passes/remove-unused-brs_all-features.wast | 55 |
2 files changed, 129 insertions, 1 deletions
diff --git a/test/passes/remove-unused-brs_all-features.txt b/test/passes/remove-unused-brs_all-features.txt index f8308c65f..0c830cbc0 100644 --- a/test/passes/remove-unused-brs_all-features.txt +++ b/test/passes/remove-unused-brs_all-features.txt @@ -2,11 +2,13 @@ (type $struct (struct (field (ref null $vector)))) (type $vector (array (mut i32))) (type $i32_=>_none (func (param i32))) + (type $ref|func|_=>_none (func (param (ref func)))) (type $none_=>_i32 (func (result i32))) (type $none_=>_f64 (func (result f64))) (type $i32_=>_funcref (func (param i32) (result funcref))) (type $none_=>_ref?|$struct| (func (result (ref null $struct)))) - (elem declare func $i32_=>_none $none_=>_i32) + (import "out" "log" (func $log (param i32))) + (elem declare func $br_on-to-br $i32_=>_none $none_=>_i32) (func $foo (result (ref null $struct)) (if (result (ref null $struct)) (i32.const 1) @@ -50,4 +52,75 @@ (local.get $x) ) ) + (func $br_on-to-br (param $func (ref func)) + (call $log + (i32.const 0) + ) + (block $null + (drop + (ref.func $br_on-to-br) + ) + (call $log + (i32.const 1) + ) + ) + (call $log + (i32.const 2) + ) + (drop + (block $func (result funcref) + (drop + (br $func + (ref.func $br_on-to-br) + ) + ) + (call $log + (i32.const 3) + ) + (ref.func $br_on-to-br) + ) + ) + (call $log + (i32.const 4) + ) + (drop + (block $data (result dataref) + (drop + (br $data + (array.new_default_with_rtt $vector + (i32.const 1) + (rtt.canon $vector) + ) + ) + ) + (call $log + (i32.const 5) + ) + (array.new_default_with_rtt $vector + (i32.const 2) + (rtt.canon $vector) + ) + ) + ) + (call $log + (i32.const 6) + ) + (drop + (block $i31 (result i31ref) + (drop + (br $i31 + (i31.new + (i32.const 42) + ) + ) + ) + (call $log + (i32.const 7) + ) + (i31.new + (i32.const 1337) + ) + ) + ) + ) ) diff --git a/test/passes/remove-unused-brs_all-features.wast b/test/passes/remove-unused-brs_all-features.wast index 1da00291d..4f66f2fdd 100644 --- a/test/passes/remove-unused-brs_all-features.wast +++ b/test/passes/remove-unused-brs_all-features.wast @@ -1,6 +1,7 @@ (module (type $vector (array (mut i32))) (type $struct (struct (field (ref null $vector)))) + (import "out" "log" (func $log (param i32))) (func $foo (result (ref null $struct)) (if (result (ref null $struct)) (i32.const 1) @@ -53,4 +54,58 @@ (ref.func $i32_=>_none) ) ) + + (func $br_on-to-br (param $func (ref func)) + (call $log (i32.const 0)) + (block $null + ;; a non-null reference is not null, and the br is never taken + (drop + (br_on_null $null (ref.func $br_on-to-br)) + ) + (call $log (i32.const 1)) + ) + (call $log (i32.const 2)) + (drop + (block $func (result funcref) + ;; a non-null function reference means we always take the br + (drop + (br_on_func $func (ref.func $br_on-to-br)) + ) + (call $log (i32.const 3)) + (ref.func $br_on-to-br) + ) + ) + (call $log (i32.const 4)) + (drop + (block $data (result dataref) + ;; a non-null data reference means we always take the br + (drop + (br_on_data $data + (array.new_default_with_rtt $vector + (i32.const 1) + (rtt.canon $vector) + ) + ) + ) + (call $log (i32.const 5)) + (array.new_default_with_rtt $vector + (i32.const 2) + (rtt.canon $vector) + ) + ) + ) + (call $log (i32.const 6)) + (drop + (block $i31 (result i31ref) + ;; a non-null i31 reference means we always take the br + (drop + (br_on_i31 $i31 + (i31.new (i32.const 42)) + ) + ) + (call $log (i32.const 7)) + (i31.new (i32.const 1337)) + ) + ) + ) ) |