diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/passes/remove-unused-brs_all-features.txt | 65 | ||||
-rw-r--r-- | test/passes/remove-unused-brs_all-features.wast | 74 |
2 files changed, 137 insertions, 2 deletions
diff --git a/test/passes/remove-unused-brs_all-features.txt b/test/passes/remove-unused-brs_all-features.txt index 0c830cbc0..5cf83a0d7 100644 --- a/test/passes/remove-unused-brs_all-features.txt +++ b/test/passes/remove-unused-brs_all-features.txt @@ -1,14 +1,15 @@ (module - (type $struct (struct (field (ref null $vector)))) (type $vector (array (mut i32))) + (type $struct (struct (field (ref null $vector)))) (type $i32_=>_none (func (param i32))) + (type $none_=>_none (func)) (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)))) (import "out" "log" (func $log (param i32))) - (elem declare func $br_on-to-br $i32_=>_none $none_=>_i32) + (elem declare func $br_on-to-br $br_on-to-flow $i32_=>_none $none_=>_i32) (func $foo (result (ref null $struct)) (if (result (ref null $struct)) (i32.const 1) @@ -123,4 +124,64 @@ ) ) ) + (func $br_on-to-flow + (drop + (block $data (result (ref null data)) + (drop + (ref.func $br_on-to-flow) + ) + (ref.null data) + ) + ) + (drop + (block $datab (result (ref null data)) + (drop + (i31.new + (i32.const 1337) + ) + ) + (ref.null data) + ) + ) + (drop + (block $func (result funcref) + (drop + (array.new_default_with_rtt $vector + (i32.const 2) + (rtt.canon $vector) + ) + ) + (ref.null func) + ) + ) + (drop + (block $funcb (result funcref) + (drop + (i31.new + (i32.const 1337) + ) + ) + (ref.null func) + ) + ) + (drop + (block $i31 (result (ref null i31)) + (drop + (array.new_default_with_rtt $vector + (i32.const 2) + (rtt.canon $vector) + ) + ) + (ref.null i31) + ) + ) + (drop + (block $i31b (result (ref null i31)) + (drop + (ref.func $br_on-to-flow) + ) + (ref.null i31) + ) + ) + ) ) diff --git a/test/passes/remove-unused-brs_all-features.wast b/test/passes/remove-unused-brs_all-features.wast index 4f66f2fdd..4ee676589 100644 --- a/test/passes/remove-unused-brs_all-features.wast +++ b/test/passes/remove-unused-brs_all-features.wast @@ -108,4 +108,78 @@ ) ) ) + + ;; a br_on of the obviously incorrect kind can just flow out the value as the + ;; break is never taken + (func $br_on-to-flow + ;; brs to data + (drop + (block $data (result (ref null data)) + (drop + (br_on_data $data + (ref.func $br_on-to-flow) + ) + ) + (ref.null data) + ) + ) + (drop + (block $datab (result (ref null data)) + (drop + (br_on_data $datab + (i31.new (i32.const 1337)) + ) + ) + (ref.null data) + ) + ) + ;; brs to func + (drop + (block $func (result (ref null func)) + (drop + (br_on_func $func + (array.new_default_with_rtt $vector + (i32.const 2) + (rtt.canon $vector) + ) + ) + ) + (ref.null func) + ) + ) + (drop + (block $funcb (result (ref null func)) + (drop + (br_on_func $funcb + (i31.new (i32.const 1337)) + ) + ) + (ref.null func) + ) + ) + ;; brs to i31 + (drop + (block $i31 (result (ref null i31)) + (drop + (br_on_i31 $i31 + (array.new_default_with_rtt $vector + (i32.const 2) + (rtt.canon $vector) + ) + ) + ) + (ref.null i31) + ) + ) + (drop + (block $i31b (result (ref null i31)) + (drop + (br_on_i31 $i31b + (ref.func $br_on-to-flow) + ) + ) + (ref.null i31) + ) + ) + ) ) |