summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/heap-types.wast44
-rw-r--r--test/heap-types.wast.from-wast55
-rw-r--r--test/heap-types.wast.fromBinary55
-rw-r--r--test/heap-types.wast.fromBinary.noDebugInfo55
-rw-r--r--test/lit/passes/remove-unused-brs-gc.wast54
-rw-r--r--test/passes/Oz_fuzz-exec_all-features.txt130
-rw-r--r--test/passes/Oz_fuzz-exec_all-features.wast115
-rw-r--r--test/passes/remove-unused-brs_all-features.txt16
-rw-r--r--test/passes/remove-unused-brs_all-features.wast9
9 files changed, 513 insertions, 20 deletions
diff --git a/test/heap-types.wast b/test/heap-types.wast
index 35284bef6..0445c97d5 100644
--- a/test/heap-types.wast
+++ b/test/heap-types.wast
@@ -194,6 +194,7 @@
(func $rtt-param-without-depth (param $rtt (rtt $parent)))
(func $rtt-operations
(local $temp.A (ref null $struct.A))
+ (local $temp.B (ref null $struct.B))
(drop
(ref.test (ref.null $struct.A) (rtt.canon $struct.B))
)
@@ -213,6 +214,16 @@
(unreachable)
)
)
+ (drop
+ (block $out2 (result (ref null $struct.A))
+ ;; set the value to a local with type $struct.A, showing that the value
+ ;; flowing out has the right type
+ (local.set $temp.B
+ (br_on_cast_fail $out2 (ref.null $struct.A) (rtt.canon $struct.B))
+ )
+ (ref.null $struct.A)
+ )
+ )
)
(func $ref.is_X (param $x anyref)
(if (ref.is_func (local.get $x)) (unreachable))
@@ -228,6 +239,9 @@
(func $br_on_X (param $x anyref)
(local $y anyref)
(local $z (ref null any))
+ (local $temp-func (ref null func))
+ (local $temp-data (ref null data))
+ (local $temp-i31 (ref null i31))
(block $null
(local.set $z
(br_on_null $null (local.get $x))
@@ -257,6 +271,36 @@
(ref.null i31)
)
)
+ (drop
+ (block $non-null (result (ref any))
+ (br_on_non_null $non-null (local.get $x))
+ (unreachable)
+ )
+ )
+ (drop
+ (block $non-func (result anyref)
+ (local.set $temp-func
+ (br_on_non_func $non-func (local.get $x))
+ )
+ (ref.null any)
+ )
+ )
+ (drop
+ (block $non-data (result anyref)
+ (local.set $temp-data
+ (br_on_non_data $non-data (local.get $x))
+ )
+ (ref.null any)
+ )
+ )
+ (drop
+ (block $non-i31 (result anyref)
+ (local.set $temp-i31
+ (br_on_non_i31 $non-i31 (local.get $x))
+ )
+ (ref.null any)
+ )
+ )
)
(func $unreachables-1
(drop
diff --git a/test/heap-types.wast.from-wast b/test/heap-types.wast.from-wast
index e9dfc9a25..dfb8b622a 100644
--- a/test/heap-types.wast.from-wast
+++ b/test/heap-types.wast.from-wast
@@ -1,8 +1,8 @@
(module
(type $struct.A (struct (field i32) (field f32) (field $named f64)))
+ (type $struct.B (struct (field i8) (field (mut i16)) (field (ref $struct.A)) (field (mut (ref $struct.A)))))
(type $vector (array (mut f64)))
(type $none_=>_none (func))
- (type $struct.B (struct (field i8) (field (mut i16)) (field (ref $struct.A)) (field (mut (ref $struct.A)))))
(type $grandchild (struct (field i32) (field i64)))
(type $struct.C (struct (field $named-mut (mut f32))))
(type $matrix (array (mut (ref null $vector))))
@@ -195,6 +195,7 @@
)
(func $rtt-operations
(local $temp.A (ref null $struct.A))
+ (local $temp.B (ref null $struct.B))
(drop
(ref.test
(ref.null $struct.A)
@@ -224,6 +225,17 @@
(unreachable)
)
)
+ (drop
+ (block $out2 (result (ref null $struct.A))
+ (local.set $temp.B
+ (br_on_cast_fail $out2
+ (ref.null $struct.A)
+ (rtt.canon $struct.B)
+ )
+ )
+ (ref.null $struct.A)
+ )
+ )
)
(func $ref.is_X (param $x anyref)
(if
@@ -270,6 +282,9 @@
(func $br_on_X (param $x anyref)
(local $y anyref)
(local $z anyref)
+ (local $temp-func funcref)
+ (local $temp-data (ref null data))
+ (local $temp-i31 (ref null i31))
(block $null
(local.set $z
(br_on_null $null
@@ -307,6 +322,44 @@
(ref.null i31)
)
)
+ (drop
+ (block $non-null (result (ref any))
+ (br_on_non_null $non-null
+ (local.get $x)
+ )
+ (unreachable)
+ )
+ )
+ (drop
+ (block $non-func (result anyref)
+ (local.set $temp-func
+ (br_on_non_func $non-func
+ (local.get $x)
+ )
+ )
+ (ref.null any)
+ )
+ )
+ (drop
+ (block $non-data (result anyref)
+ (local.set $temp-data
+ (br_on_non_data $non-data
+ (local.get $x)
+ )
+ )
+ (ref.null any)
+ )
+ )
+ (drop
+ (block $non-i31 (result anyref)
+ (local.set $temp-i31
+ (br_on_non_i31 $non-i31
+ (local.get $x)
+ )
+ )
+ (ref.null any)
+ )
+ )
)
(func $unreachables-1
(drop
diff --git a/test/heap-types.wast.fromBinary b/test/heap-types.wast.fromBinary
index dbe080996..314b3c29e 100644
--- a/test/heap-types.wast.fromBinary
+++ b/test/heap-types.wast.fromBinary
@@ -1,8 +1,8 @@
(module
(type $struct.A (struct (field i32) (field f32) (field $named f64)))
+ (type $struct.B (struct (field i8) (field (mut i16)) (field (ref $struct.A)) (field (mut (ref $struct.A)))))
(type $vector (array (mut f64)))
(type $none_=>_none (func))
- (type $struct.B (struct (field i8) (field (mut i16)) (field (ref $struct.A)) (field (mut (ref $struct.A)))))
(type $grandchild (struct (field i32) (field i64)))
(type $matrix (array (mut (ref null $vector))))
(type $struct.C (struct (field $named-mut (mut f32))))
@@ -195,6 +195,7 @@
)
(func $rtt-operations
(local $temp.A (ref null $struct.A))
+ (local $temp.B (ref null $struct.B))
(drop
(ref.test
(ref.null $struct.A)
@@ -223,6 +224,17 @@
)
)
)
+ (drop
+ (block $label$3 (result (ref null $struct.A))
+ (local.set $temp.B
+ (br_on_cast_fail $label$3
+ (ref.null $struct.A)
+ (rtt.canon $struct.B)
+ )
+ )
+ (ref.null $struct.A)
+ )
+ )
)
(func $ref.is_X (param $x anyref)
(if
@@ -269,6 +281,9 @@
(func $br_on_X (param $x anyref)
(local $y anyref)
(local $z anyref)
+ (local $temp-func funcref)
+ (local $temp-data (ref null data))
+ (local $temp-i31 (ref null i31))
(block $label$1
(local.set $z
(br_on_null $label$1
@@ -306,6 +321,44 @@
(ref.null i31)
)
)
+ (drop
+ (block $label$5 (result (ref any))
+ (br_on_non_null $label$5
+ (local.get $x)
+ )
+ (unreachable)
+ )
+ )
+ (drop
+ (block $label$6 (result anyref)
+ (local.set $temp-func
+ (br_on_non_func $label$6
+ (local.get $x)
+ )
+ )
+ (ref.null any)
+ )
+ )
+ (drop
+ (block $label$7 (result anyref)
+ (local.set $temp-data
+ (br_on_non_data $label$7
+ (local.get $x)
+ )
+ )
+ (ref.null any)
+ )
+ )
+ (drop
+ (block $label$8 (result anyref)
+ (local.set $temp-i31
+ (br_on_non_i31 $label$8
+ (local.get $x)
+ )
+ )
+ (ref.null any)
+ )
+ )
)
(func $unreachables-1
(unreachable)
diff --git a/test/heap-types.wast.fromBinary.noDebugInfo b/test/heap-types.wast.fromBinary.noDebugInfo
index 2fb57aacb..bb6ff9165 100644
--- a/test/heap-types.wast.fromBinary.noDebugInfo
+++ b/test/heap-types.wast.fromBinary.noDebugInfo
@@ -1,8 +1,8 @@
(module
(type ${i32_f32_f64} (struct (field i32) (field f32) (field f64)))
+ (type ${i8_mut:i16_ref|{i32_f32_f64}|_mut:ref|{i32_f32_f64}|} (struct (field i8) (field (mut i16)) (field (ref ${i32_f32_f64})) (field (mut (ref ${i32_f32_f64})))))
(type $[mut:f64] (array (mut f64)))
(type $none_=>_none (func))
- (type ${i8_mut:i16_ref|{i32_f32_f64}|_mut:ref|{i32_f32_f64}|} (struct (field i8) (field (mut i16)) (field (ref ${i32_f32_f64})) (field (mut (ref ${i32_f32_f64})))))
(type ${i32_i64} (struct (field i32) (field i64)))
(type $[mut:ref?|[mut:f64]|] (array (mut (ref null $[mut:f64]))))
(type ${mut:f32} (struct (field (mut f32))))
@@ -195,6 +195,7 @@
)
(func $4
(local $0 (ref null ${i32_f32_f64}))
+ (local $1 (ref null ${i8_mut:i16_ref|{i32_f32_f64}|_mut:ref|{i32_f32_f64}|}))
(drop
(ref.test
(ref.null ${i32_f32_f64})
@@ -223,6 +224,17 @@
)
)
)
+ (drop
+ (block $label$3 (result (ref null ${i32_f32_f64}))
+ (local.set $1
+ (br_on_cast_fail $label$3
+ (ref.null ${i32_f32_f64})
+ (rtt.canon ${i8_mut:i16_ref|{i32_f32_f64}|_mut:ref|{i32_f32_f64}|})
+ )
+ )
+ (ref.null ${i32_f32_f64})
+ )
+ )
)
(func $5 (param $0 anyref)
(if
@@ -269,6 +281,9 @@
(func $7 (param $0 anyref)
(local $1 anyref)
(local $2 anyref)
+ (local $3 funcref)
+ (local $4 (ref null data))
+ (local $5 (ref null i31))
(block $label$1
(local.set $2
(br_on_null $label$1
@@ -306,6 +321,44 @@
(ref.null i31)
)
)
+ (drop
+ (block $label$5 (result (ref any))
+ (br_on_non_null $label$5
+ (local.get $0)
+ )
+ (unreachable)
+ )
+ )
+ (drop
+ (block $label$6 (result anyref)
+ (local.set $3
+ (br_on_non_func $label$6
+ (local.get $0)
+ )
+ )
+ (ref.null any)
+ )
+ )
+ (drop
+ (block $label$7 (result anyref)
+ (local.set $4
+ (br_on_non_data $label$7
+ (local.get $0)
+ )
+ )
+ (ref.null any)
+ )
+ )
+ (drop
+ (block $label$8 (result anyref)
+ (local.set $5
+ (br_on_non_i31 $label$8
+ (local.get $0)
+ )
+ )
+ (ref.null any)
+ )
+ )
)
(func $8
(unreachable)
diff --git a/test/lit/passes/remove-unused-brs-gc.wast b/test/lit/passes/remove-unused-brs-gc.wast
new file mode 100644
index 000000000..7fe579c5a
--- /dev/null
+++ b/test/lit/passes/remove-unused-brs-gc.wast
@@ -0,0 +1,54 @@
+;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited.
+;; RUN: wasm-opt %s --remove-unused-brs -all -S -o - \
+;; RUN: | filecheck %s
+
+(module
+ ;; CHECK: (func $br_on_non_data-1
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (block $any (result anyref)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (br $any
+ ;; CHECK-NEXT: (ref.func $br_on_non_data-1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (ref.null any)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $br_on_non_data-1
+ (drop
+ (block $any (result anyref)
+ (drop
+ ;; A function is not data, and so we should branch.
+ (br_on_non_data $any
+ (ref.func $br_on_non_data-1)
+ )
+ )
+ (ref.null any)
+ )
+ )
+ )
+ ;; CHECK: (func $br_on_non_data-2 (param $data dataref)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (block $any (result anyref)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (local.get $data)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (ref.null any)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $br_on_non_data-2 (param $data (ref data))
+ (drop
+ (block $any (result anyref)
+ (drop
+ ;; Data is provided here, and so we will not branch.
+ (br_on_non_data $any
+ (local.get $data)
+ )
+ )
+ (ref.null any)
+ )
+ )
+ )
+)
diff --git a/test/passes/Oz_fuzz-exec_all-features.txt b/test/passes/Oz_fuzz-exec_all-features.txt
index 359311e41..2ce8cfa00 100644
--- a/test/passes/Oz_fuzz-exec_all-features.txt
+++ b/test/passes/Oz_fuzz-exec_all-features.txt
@@ -21,10 +21,23 @@
[fuzz-exec] calling br_on_cast
[LoggingExternalInterface logging 3]
[trap unreachable]
+[fuzz-exec] calling br_on_failed_cast-1
+[LoggingExternalInterface logging 1]
+[fuzz-exec] calling br_on_failed_cast-2
+[LoggingExternalInterface logging 1]
+[LoggingExternalInterface logging 999]
[fuzz-exec] calling cast-null-anyref-to-gc
[LoggingExternalInterface logging 0]
[fuzz-exec] calling br_on_data
[LoggingExternalInterface logging 1]
+[fuzz-exec] calling br_on_non_data-null
+[fuzz-exec] calling br_on_non_data-data
+[LoggingExternalInterface logging 1]
+[fuzz-exec] calling br_on_non_data-other
+[fuzz-exec] calling br-on_non_null
+[fuzz-exec] calling br-on_non_null-2
+[LoggingExternalInterface logging 1]
+[trap unreachable]
[fuzz-exec] calling rtt-and-cast-on-func
[LoggingExternalInterface logging 0]
[LoggingExternalInterface logging 1]
@@ -45,10 +58,10 @@
[LoggingExternalInterface logging 0]
[LoggingExternalInterface logging 10]
(module
- (type $struct (struct (field (mut i32))))
(type $void_func (func))
- (type $bytes (array (mut i8)))
+ (type $struct (struct (field (mut i32))))
(type $extendedstruct (struct (field (mut i32)) (field f64)))
+ (type $bytes (array (mut i8)))
(type $int_func (func (result i32)))
(type $i32_=>_none (func (param i32)))
(type $anyref_=>_none (func (param anyref)))
@@ -59,13 +72,20 @@
(export "arrays" (func $1))
(export "rtts" (func $2))
(export "br_on_cast" (func $3))
- (export "cast-null-anyref-to-gc" (func $4))
- (export "br_on_data" (func $6))
- (export "rtt-and-cast-on-func" (func $8))
+ (export "br_on_failed_cast-1" (func $4))
+ (export "br_on_failed_cast-2" (func $5))
+ (export "cast-null-anyref-to-gc" (func $6))
+ (export "br_on_data" (func $8))
+ (export "br_on_non_data-null" (func $9))
+ (export "br_on_non_data-data" (func $10))
+ (export "br_on_non_data-other" (func $9))
+ (export "br-on_non_null" (func $9))
+ (export "br-on_non_null-2" (func $13))
+ (export "rtt-and-cast-on-func" (func $15))
(export "array-alloc-failure" (func $9))
- (export "init-array-packed" (func $10))
- (export "cast-func-to-struct" (func $12))
- (export "array-copy" (func $13))
+ (export "init-array-packed" (func $17))
+ (export "cast-func-to-struct" (func $19))
+ (export "array-copy" (func $20))
(func $0 (; has Stack IR ;)
(local $0 i32)
(call $log
@@ -221,11 +241,61 @@
(unreachable)
)
(func $4 (; has Stack IR ;)
+ (local $0 anyref)
+ (local.set $0
+ (struct.new_default_with_rtt $struct
+ (rtt.canon $struct)
+ )
+ )
+ (drop
+ (block $any (result anyref)
+ (call $log
+ (i32.const 1)
+ )
+ (drop
+ (br_on_cast_fail $any
+ (local.get $0)
+ (rtt.canon $extendedstruct)
+ )
+ )
+ (call $log
+ (i32.const 999)
+ )
+ (ref.null any)
+ )
+ )
+ )
+ (func $5 (; has Stack IR ;)
+ (local $0 anyref)
+ (local.set $0
+ (struct.new_default_with_rtt $extendedstruct
+ (rtt.canon $extendedstruct)
+ )
+ )
+ (drop
+ (block $any (result anyref)
+ (call $log
+ (i32.const 1)
+ )
+ (drop
+ (br_on_cast_fail $any
+ (local.get $0)
+ (rtt.canon $extendedstruct)
+ )
+ )
+ (call $log
+ (i32.const 999)
+ )
+ (ref.null any)
+ )
+ )
+ )
+ (func $6 (; has Stack IR ;)
(call $log
(i32.const 0)
)
)
- (func $6 (; has Stack IR ;) (param $0 anyref)
+ (func $8 (; has Stack IR ;) (param $0 anyref)
(drop
(block $data (result dataref)
(drop
@@ -242,12 +312,30 @@
)
)
)
+ (func $9 (; has Stack IR ;)
+ (nop)
+ )
+ (func $10 (; has Stack IR ;)
+ (call $log
+ (i32.const 1)
+ )
+ )
+ (func $13 (; has Stack IR ;)
+ (drop
+ (block
+ (call $log
+ (i32.const 1)
+ )
+ (unreachable)
+ )
+ )
+ )
(func $a-void-func (; has Stack IR ;)
(call $log
(i32.const 1337)
)
)
- (func $8 (; has Stack IR ;)
+ (func $15 (; has Stack IR ;)
(call $log
(i32.const 0)
)
@@ -273,10 +361,7 @@
(i32.const 4)
)
)
- (func $9 (; has Stack IR ;)
- (nop)
- )
- (func $10 (; has Stack IR ;) (result i32)
+ (func $17 (; has Stack IR ;) (result i32)
(array.get_u $bytes
(array.new_with_rtt $bytes
(i32.const -43)
@@ -289,7 +374,7 @@
(func $call-target (; has Stack IR ;) (param $0 eqref)
(nop)
)
- (func $12 (; has Stack IR ;)
+ (func $19 (; has Stack IR ;)
(drop
(ref.cast
(ref.func $call-target)
@@ -297,7 +382,7 @@
)
)
)
- (func $13 (; has Stack IR ;)
+ (func $20 (; has Stack IR ;)
(local $0 (ref null $bytes))
(local $1 (ref null $bytes))
(array.set $bytes
@@ -378,10 +463,23 @@
[fuzz-exec] calling br_on_cast
[LoggingExternalInterface logging 3]
[trap unreachable]
+[fuzz-exec] calling br_on_failed_cast-1
+[LoggingExternalInterface logging 1]
+[fuzz-exec] calling br_on_failed_cast-2
+[LoggingExternalInterface logging 1]
+[LoggingExternalInterface logging 999]
[fuzz-exec] calling cast-null-anyref-to-gc
[LoggingExternalInterface logging 0]
[fuzz-exec] calling br_on_data
[LoggingExternalInterface logging 1]
+[fuzz-exec] calling br_on_non_data-null
+[fuzz-exec] calling br_on_non_data-data
+[LoggingExternalInterface logging 1]
+[fuzz-exec] calling br_on_non_data-other
+[fuzz-exec] calling br-on_non_null
+[fuzz-exec] calling br-on_non_null-2
+[LoggingExternalInterface logging 1]
+[trap unreachable]
[fuzz-exec] calling rtt-and-cast-on-func
[LoggingExternalInterface logging 0]
[LoggingExternalInterface logging 1]
diff --git a/test/passes/Oz_fuzz-exec_all-features.wast b/test/passes/Oz_fuzz-exec_all-features.wast
index 11a9f798d..93935d5c4 100644
--- a/test/passes/Oz_fuzz-exec_all-features.wast
+++ b/test/passes/Oz_fuzz-exec_all-features.wast
@@ -180,6 +180,50 @@
)
)
)
+ (func "br_on_failed_cast-1"
+ (local $any anyref)
+ ;; create a simple $struct, store it in an anyref
+ (local.set $any
+ (struct.new_default_with_rtt $struct (rtt.canon $struct))
+ )
+ (drop
+ (block $any (result (ref null any))
+ (call $log (i32.const 1))
+ (drop
+ ;; try to cast our simple $struct to an extended, which will fail, and
+ ;; so we will branch, skipping the next logging.
+ (br_on_cast_fail $any
+ (local.get $any)
+ (rtt.canon $extendedstruct)
+ )
+ )
+ (call $log (i32.const 999)) ;; we should skip this
+ (ref.null any)
+ )
+ )
+ )
+ (func "br_on_failed_cast-2"
+ (local $any anyref)
+ ;; create an $extendedstruct, store it in an anyref
+ (local.set $any
+ (struct.new_default_with_rtt $extendedstruct (rtt.canon $extendedstruct))
+ )
+ (drop
+ (block $any (result (ref null any))
+ (call $log (i32.const 1))
+ (drop
+ ;; try to cast our simple $struct to an extended, which will succeed, and
+ ;; so we will continue to the next logging.
+ (br_on_cast_fail $any
+ (local.get $any)
+ (rtt.canon $extendedstruct)
+ )
+ )
+ (call $log (i32.const 999))
+ (ref.null any)
+ )
+ )
+ )
(func "cast-null-anyref-to-gc"
;; a null anyref is a literal which is not even of GC data, as it's not an
;; array or a struct, so our casting code should not assume it is. it is ok
@@ -208,6 +252,77 @@
)
)
)
+ (func "br_on_non_data-null"
+ (local $x anyref)
+ (drop
+ (block $any (result anyref)
+ (drop
+ (br_on_non_data $any (local.get $x))
+ )
+ ;; $x is a null, and so it is not data, and the branch will be taken, and no
+ ;; logging will occur.
+ (call $log (i32.const 1))
+ (ref.null any)
+ )
+ )
+ )
+ (func "br_on_non_data-data"
+ (local $x anyref)
+ ;; set x to valid data
+ (local.set $x
+ (struct.new_default_with_rtt $struct
+ (rtt.canon $struct)
+ )
+ )
+ (drop
+ (block $any (result anyref)
+ (drop
+ (br_on_non_data $any (local.get $x))
+ )
+ ;; $x refers to valid data, and so we will not branch, and will log.
+ (call $log (i32.const 1))
+ (ref.null any)
+ )
+ )
+ )
+ (func "br_on_non_data-other"
+ (local $x anyref)
+ ;; set x to something that is not null, but also not data
+ (local.set $x
+ (ref.func $a-void-func)
+ )
+ (drop
+ (block $any (result anyref)
+ (drop
+ (br_on_non_data $any (local.get $x))
+ )
+ ;; $x refers to a function, so we will branch, and not log
+ (call $log (i32.const 1))
+ (ref.null any)
+ )
+ )
+ )
+ (func "br-on_non_null"
+ (drop
+ (block $non-null (result (ref any))
+ (br_on_non_null $non-null (ref.func $a-void-func))
+ ;; $x refers to a function, which is not null, so we will branch, and not
+ ;; log
+ (call $log (i32.const 1))
+ (unreachable)
+ )
+ )
+ )
+ (func "br-on_non_null-2"
+ (drop
+ (block $non-null (result (ref any))
+ (br_on_non_null $non-null (ref.null any))
+ ;; $x is null, and so we will not branch, and log and then trap
+ (call $log (i32.const 1))
+ (unreachable)
+ )
+ )
+ )
(func $a-void-func
(call $log (i32.const 1337))
)
diff --git a/test/passes/remove-unused-brs_all-features.txt b/test/passes/remove-unused-brs_all-features.txt
index 6f68797cf..abfcc3e76 100644
--- a/test/passes/remove-unused-brs_all-features.txt
+++ b/test/passes/remove-unused-brs_all-features.txt
@@ -1,8 +1,8 @@
(module
(type $vector (array (mut i32)))
(type $struct (struct (field (ref null $vector))))
- (type $i32_=>_none (func (param i32)))
(type $ref|func|_=>_none (func (param (ref func))))
+ (type $i32_=>_none (func (param i32)))
(type $none_=>_ref?|$struct| (func (result (ref null $struct))))
(type $none_=>_f64 (func (result f64)))
(type $none_=>_i32 (func (result i32)))
@@ -123,6 +123,20 @@
)
)
)
+ (call $log
+ (i32.const 8)
+ )
+ (drop
+ (block $non-null (result (ref $ref|func|_=>_none))
+ (br $non-null
+ (ref.func $br_on-to-br)
+ )
+ (call $log
+ (i32.const 9)
+ )
+ (ref.func $br_on-to-br)
+ )
+ )
)
(func $br_on-to-flow
(drop
diff --git a/test/passes/remove-unused-brs_all-features.wast b/test/passes/remove-unused-brs_all-features.wast
index 4ee676589..9614f7f5c 100644
--- a/test/passes/remove-unused-brs_all-features.wast
+++ b/test/passes/remove-unused-brs_all-features.wast
@@ -107,6 +107,15 @@
(i31.new (i32.const 1337))
)
)
+ (call $log (i32.const 8))
+ (drop
+ (block $non-null (result (ref func))
+ ;; a non-null reference is not null, and the br is always taken
+ (br_on_non_null $non-null (ref.func $br_on-to-br))
+ (call $log (i32.const 9))
+ (ref.func $br_on-to-br)
+ )
+ )
)
;; a br_on of the obviously incorrect kind can just flow out the value as the