Skip to content

Commit e5aaa6c

Browse files
authored
Enable br_on_null and br_on_non_null spec tests (#7212)
Now that we support sending additional values on these branches, we can run their spec tests, so enable them. Also fix a bug with block naming that the spec tests exposed. We still cannot run the br_on_cast and br_on_cast fail spec tests, but update the relevant comments to describe the new reason they fail.
1 parent 3f6831c commit e5aaa6c

File tree

3 files changed

+103
-30
lines changed

3 files changed

+103
-30
lines changed

scripts/test/shared.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,8 @@ def get_tests(test_dir, extensions=[], recursive=False):
438438
'try_catch.wast', # Requires wast `register` support
439439
'tag.wast', # Non-empty tag results allowed by stack switching
440440
'try_table.wast', # Requires try_table interpretation
441-
'br_on_non_null.wast', # Requires sending values on br_on_non_null
442-
'br_on_null.wast', # Requires sending values on br_on_null
441+
# 'br_on_non_null.wast', # Requires sending values on br_on_non_null
442+
# 'br_on_null.wast', # Requires sending values on br_on_null
443443
'local_init.wast', # Requires local validation to respect unnamed blocks
444444
'ref_func.wast', # Requires rejecting undeclared functions references
445445
'ref_is_null.wast', # Requires ref.null wast constants
@@ -452,8 +452,8 @@ def get_tests(test_dir, extensions=[], recursive=False):
452452
'array.wast', # Requires support for table default elements
453453
'array_init_elem.wast', # Requires support for elem.drop
454454
'br_if.wast', # Requires more precise branch validation
455-
'br_on_cast.wast', # Requires sending values on br_on_cast
456-
'br_on_cast_fail.wast', # Requires sending values on br_on_cast_fail
455+
'br_on_cast.wast', # Requires host references to not be externalized i31refs
456+
'br_on_cast_fail.wast', # Requires host references to not be externalized i31refs
457457
'extern.wast', # Requires ref.host wast constants
458458
'i31.wast', # Requires support for table default elements
459459
'ref_cast.wast', # Requires host references to not be externalized i31refs

src/wasm/wasm-ir-builder.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,7 @@ Result<> IRBuilder::visitEnd() {
10541054
labelHint = 0;
10551055
} else if (auto* block = scope.getBlock()) {
10561056
assert(*expr == block);
1057+
block->name = Name();
10571058
block = fixExtraOutput(scope, label, block)->cast<Block>();
10581059
block->name = label;
10591060
block->finalize(block->type,

test/lit/basic/extra-branch-values.wast

Lines changed: 98 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
;; OPT_O: (import "env" "eqref" (global $eqref (mut eqref)))
2424
(import "env" "eqref" (global $eqref (mut eqref)))
2525

26-
;; CHECK: (import "env" "use-i32-any" (func $use-i32-any (type $14) (param i32 (ref any))))
27-
;; OPT_O: (import "env" "use-i32-any" (func $use-i32-any (type $14) (param i32 (ref any))))
26+
;; CHECK: (import "env" "use-i32-any" (func $use-i32-any (type $15) (param i32 (ref any))))
27+
;; OPT_O: (import "env" "use-i32-any" (func $use-i32-any (type $15) (param i32 (ref any))))
2828
(import "env" "use-i32-any" (func $use-i32-any (param i32 (ref any))))
2929

3030
;; CHECK: (tag $e (param i32))
@@ -34,7 +34,7 @@
3434
;; OPT_O: (tag $e2 (param i32))
3535
(tag $e2 (param i32))
3636

37-
;; CHECK: (func $br_on_null-one (type $15) (param $0 i32) (param $1 anyref) (result i32)
37+
;; CHECK: (func $br_on_null-one (type $8) (param $0 i32) (param $1 anyref) (result i32)
3838
;; CHECK-NEXT: (local $scratch anyref)
3939
;; CHECK-NEXT: (local $scratch_3 i32)
4040
;; CHECK-NEXT: (local $scratch_4 i32)
@@ -76,7 +76,7 @@
7676
;; CHECK-NEXT: (local.get $scratch_3)
7777
;; CHECK-NEXT: )
7878
;; CHECK-NEXT: )
79-
;; OPT_O: (func $br_on_null-one (type $15) (param $0 i32) (param $1 anyref) (result i32)
79+
;; OPT_O: (func $br_on_null-one (type $6) (param $0 i32) (param $1 anyref) (result i32)
8080
;; OPT_O-NEXT: (block $block (result i32)
8181
;; OPT_O-NEXT: (block $block0
8282
;; OPT_O-NEXT: (global.set $any
@@ -112,7 +112,7 @@
112112
;; CHECK-NEXT: (local $scratch_6 (ref any))
113113
;; CHECK-NEXT: (local $scratch_7 (tuple i32 i64))
114114
;; CHECK-NEXT: (local $scratch_8 i32)
115-
;; CHECK-NEXT: (block $block (type $12) (result i32 i64)
115+
;; CHECK-NEXT: (block $block (type $13) (result i32 i64)
116116
;; CHECK-NEXT: (block $block0
117117
;; CHECK-NEXT: (local.set $scratch_4
118118
;; CHECK-NEXT: (tuple.make 2
@@ -168,7 +168,7 @@
168168
;; CHECK-NEXT: )
169169
;; OPT_O: (func $br_on_null-two (type $16) (param $0 i32) (param $1 i64) (param $2 anyref) (result i32 i64)
170170
;; OPT_O-NEXT: (local $3 (tuple i32 i64))
171-
;; OPT_O-NEXT: (block $block (type $10) (result i32 i64)
171+
;; OPT_O-NEXT: (block $block (type $11) (result i32 i64)
172172
;; OPT_O-NEXT: (local.set $3
173173
;; OPT_O-NEXT: (tuple.make 2
174174
;; OPT_O-NEXT: (local.get $0)
@@ -215,7 +215,7 @@
215215
end
216216
)
217217

218-
;; CHECK: (func $br_on_non_null-one (type $8) (param $0 i32) (param $1 anyref) (result i32 (ref any))
218+
;; CHECK: (func $br_on_non_null-one (type $9) (param $0 i32) (param $1 anyref) (result i32 (ref any))
219219
;; CHECK-NEXT: (local $scratch anyref)
220220
;; CHECK-NEXT: (local $scratch_3 i32)
221221
;; CHECK-NEXT: (local $scratch_4 i32)
@@ -254,7 +254,7 @@
254254
;; CHECK-NEXT: )
255255
;; CHECK-NEXT: )
256256
;; CHECK-NEXT: )
257-
;; OPT_O: (func $br_on_non_null-one (type $6) (param $0 i32) (param $1 anyref) (result i32 (ref any))
257+
;; OPT_O: (func $br_on_non_null-one (type $7) (param $0 i32) (param $1 anyref) (result i32 (ref any))
258258
;; OPT_O-NEXT: (block $block (type $1) (result i32 (ref any))
259259
;; OPT_O-NEXT: (tuple.make 2
260260
;; OPT_O-NEXT: (local.get $0)
@@ -286,7 +286,7 @@
286286
end
287287
)
288288

289-
;; CHECK: (func $br_on_non_null-two (type $9) (param $0 i32) (param $1 i64) (param $2 anyref) (result i32 i64 (ref any))
289+
;; CHECK: (func $br_on_non_null-two (type $10) (param $0 i32) (param $1 i64) (param $2 anyref) (result i32 i64 (ref any))
290290
;; CHECK-NEXT: (local $scratch anyref)
291291
;; CHECK-NEXT: (local $scratch_4 (tuple i32 i64))
292292
;; CHECK-NEXT: (local $scratch_5 i64)
@@ -350,7 +350,7 @@
350350
;; CHECK-NEXT: )
351351
;; CHECK-NEXT: )
352352
;; CHECK-NEXT: )
353-
;; OPT_O: (func $br_on_non_null-two (type $7) (param $0 i32) (param $1 i64) (param $2 anyref) (result i32 i64 (ref any))
353+
;; OPT_O: (func $br_on_non_null-two (type $8) (param $0 i32) (param $1 i64) (param $2 anyref) (result i32 i64 (ref any))
354354
;; OPT_O-NEXT: (block $block (type $4) (result i32 i64 (ref any))
355355
;; OPT_O-NEXT: (tuple.make 3
356356
;; OPT_O-NEXT: (local.get $0)
@@ -484,7 +484,7 @@
484484
;; CHECK-NEXT: (local $scratch_7 (tuple i32 i64))
485485
;; CHECK-NEXT: (local $scratch_8 i32)
486486
;; CHECK-NEXT: (local $scratch_9 eqref)
487-
;; CHECK-NEXT: (block $block (type $13) (result i32 i64 eqref)
487+
;; CHECK-NEXT: (block $block (type $14) (result i32 i64 eqref)
488488
;; CHECK-NEXT: (local.set $scratch_9
489489
;; CHECK-NEXT: (block $block0 (result eqref)
490490
;; CHECK-NEXT: (local.set $scratch_4
@@ -550,7 +550,7 @@
550550
;; CHECK-NEXT: )
551551
;; CHECK-NEXT: )
552552
;; OPT_O: (func $br_on_cast-two (type $17) (param $0 i32) (param $1 i64) (param $2 anyref) (result i32 i64 eqref)
553-
;; OPT_O-NEXT: (block $block (type $11) (result i32 i64 eqref)
553+
;; OPT_O-NEXT: (block $block (type $12) (result i32 i64 eqref)
554554
;; OPT_O-NEXT: (tuple.make 3
555555
;; OPT_O-NEXT: (local.get $0)
556556
;; OPT_O-NEXT: (local.get $1)
@@ -764,7 +764,7 @@
764764
end
765765
)
766766

767-
;; CHECK: (func $br_on_cast_fail-one (type $8) (param $0 i32) (param $1 anyref) (result i32 (ref any))
767+
;; CHECK: (func $br_on_cast_fail-one (type $9) (param $0 i32) (param $1 anyref) (result i32 (ref any))
768768
;; CHECK-NEXT: (local $scratch anyref)
769769
;; CHECK-NEXT: (local $scratch_3 i32)
770770
;; CHECK-NEXT: (local $scratch_4 i32)
@@ -815,7 +815,7 @@
815815
;; CHECK-NEXT: )
816816
;; CHECK-NEXT: )
817817
;; CHECK-NEXT: )
818-
;; OPT_O: (func $br_on_cast_fail-one (type $6) (param $0 i32) (param $1 anyref) (result i32 (ref any))
818+
;; OPT_O: (func $br_on_cast_fail-one (type $7) (param $0 i32) (param $1 anyref) (result i32 (ref any))
819819
;; OPT_O-NEXT: (block $block (type $1) (result i32 (ref any))
820820
;; OPT_O-NEXT: (tuple.make 2
821821
;; OPT_O-NEXT: (local.get $0)
@@ -850,7 +850,7 @@
850850
end
851851
)
852852

853-
;; CHECK: (func $br_on_cast_fail-two (type $9) (param $0 i32) (param $1 i64) (param $2 anyref) (result i32 i64 (ref any))
853+
;; CHECK: (func $br_on_cast_fail-two (type $10) (param $0 i32) (param $1 i64) (param $2 anyref) (result i32 i64 (ref any))
854854
;; CHECK-NEXT: (local $scratch anyref)
855855
;; CHECK-NEXT: (local $scratch_4 (tuple i32 i64))
856856
;; CHECK-NEXT: (local $scratch_5 i64)
@@ -923,7 +923,7 @@
923923
;; CHECK-NEXT: )
924924
;; CHECK-NEXT: )
925925
;; CHECK-NEXT: )
926-
;; OPT_O: (func $br_on_cast_fail-two (type $7) (param $0 i32) (param $1 i64) (param $2 anyref) (result i32 i64 (ref any))
926+
;; OPT_O: (func $br_on_cast_fail-two (type $8) (param $0 i32) (param $1 i64) (param $2 anyref) (result i32 i64 (ref any))
927927
;; OPT_O-NEXT: (block $block (type $4) (result i32 i64 (ref any))
928928
;; OPT_O-NEXT: (tuple.make 3
929929
;; OPT_O-NEXT: (local.get $0)
@@ -1052,7 +1052,7 @@
10521052
end
10531053
)
10541054

1055-
;; CHECK: (func $br_on_cast_fail-to-nn (type $10) (param $0 i32) (param $1 anyref) (result i32 anyref)
1055+
;; CHECK: (func $br_on_cast_fail-to-nn (type $11) (param $0 i32) (param $1 anyref) (result i32 anyref)
10561056
;; CHECK-NEXT: (local $scratch anyref)
10571057
;; CHECK-NEXT: (local $scratch_3 i32)
10581058
;; CHECK-NEXT: (local $scratch_4 i32)
@@ -1103,8 +1103,8 @@
11031103
;; CHECK-NEXT: )
11041104
;; CHECK-NEXT: )
11051105
;; CHECK-NEXT: )
1106-
;; OPT_O: (func $br_on_cast_fail-to-nn (type $8) (param $0 i32) (param $1 anyref) (result i32 anyref)
1107-
;; OPT_O-NEXT: (block $block (type $12) (result i32 anyref)
1106+
;; OPT_O: (func $br_on_cast_fail-to-nn (type $9) (param $0 i32) (param $1 anyref) (result i32 anyref)
1107+
;; OPT_O-NEXT: (block $block (type $13) (result i32 anyref)
11081108
;; OPT_O-NEXT: (tuple.make 2
11091109
;; OPT_O-NEXT: (local.get $0)
11101110
;; OPT_O-NEXT: (block $block0 (result anyref)
@@ -1138,6 +1138,78 @@
11381138
end
11391139
)
11401140

1141+
;; CHECK: (func $unreachable-fallthrough (type $8) (param $0 i32) (param $1 anyref) (result i32)
1142+
;; CHECK-NEXT: (local $scratch anyref)
1143+
;; CHECK-NEXT: (local $scratch_3 i32)
1144+
;; CHECK-NEXT: (local $scratch_4 i32)
1145+
;; CHECK-NEXT: (local $scratch_5 (ref any))
1146+
;; CHECK-NEXT: (local $scratch_6 (tuple i32 (ref any)))
1147+
;; CHECK-NEXT: (local $scratch_7 i32)
1148+
;; CHECK-NEXT: (local.set $scratch_7
1149+
;; CHECK-NEXT: (tuple.extract 2 0
1150+
;; CHECK-NEXT: (local.tee $scratch_6
1151+
;; CHECK-NEXT: (block $l (type $3) (result i32 (ref any))
1152+
;; CHECK-NEXT: (local.set $scratch_5
1153+
;; CHECK-NEXT: (block $l0 (result (ref any))
1154+
;; CHECK-NEXT: (local.set $scratch_3
1155+
;; CHECK-NEXT: (block (result i32)
1156+
;; CHECK-NEXT: (local.set $scratch_4
1157+
;; CHECK-NEXT: (local.get $0)
1158+
;; CHECK-NEXT: )
1159+
;; CHECK-NEXT: (local.set $scratch
1160+
;; CHECK-NEXT: (local.get $1)
1161+
;; CHECK-NEXT: )
1162+
;; CHECK-NEXT: (local.get $scratch_4)
1163+
;; CHECK-NEXT: )
1164+
;; CHECK-NEXT: )
1165+
;; CHECK-NEXT: (br_on_non_null $l0
1166+
;; CHECK-NEXT: (local.get $scratch)
1167+
;; CHECK-NEXT: )
1168+
;; CHECK-NEXT: (br $l
1169+
;; CHECK-NEXT: (return
1170+
;; CHECK-NEXT: (local.get $scratch_3)
1171+
;; CHECK-NEXT: )
1172+
;; CHECK-NEXT: )
1173+
;; CHECK-NEXT: )
1174+
;; CHECK-NEXT: )
1175+
;; CHECK-NEXT: (tuple.make 2
1176+
;; CHECK-NEXT: (local.get $scratch_3)
1177+
;; CHECK-NEXT: (local.get $scratch_5)
1178+
;; CHECK-NEXT: )
1179+
;; CHECK-NEXT: )
1180+
;; CHECK-NEXT: )
1181+
;; CHECK-NEXT: )
1182+
;; CHECK-NEXT: )
1183+
;; CHECK-NEXT: (drop
1184+
;; CHECK-NEXT: (tuple.extract 2 1
1185+
;; CHECK-NEXT: (local.get $scratch_6)
1186+
;; CHECK-NEXT: )
1187+
;; CHECK-NEXT: )
1188+
;; CHECK-NEXT: (local.get $scratch_7)
1189+
;; CHECK-NEXT: )
1190+
;; OPT_O: (func $unreachable-fallthrough (type $6) (param $0 i32) (param $1 anyref) (result i32)
1191+
;; OPT_O-NEXT: (drop
1192+
;; OPT_O-NEXT: (block $l0 (result (ref any))
1193+
;; OPT_O-NEXT: (br_on_non_null $l0
1194+
;; OPT_O-NEXT: (local.get $1)
1195+
;; OPT_O-NEXT: )
1196+
;; OPT_O-NEXT: (return
1197+
;; OPT_O-NEXT: (local.get $0)
1198+
;; OPT_O-NEXT: )
1199+
;; OPT_O-NEXT: )
1200+
;; OPT_O-NEXT: )
1201+
;; OPT_O-NEXT: (local.get $0)
1202+
;; OPT_O-NEXT: )
1203+
(func $unreachable-fallthrough (export "unreachable-fallthrough") (param i32 anyref) (result i32)
1204+
block $l (result i32 (ref any))
1205+
local.get 0
1206+
local.get 1
1207+
br_on_non_null $l
1208+
return
1209+
end
1210+
drop
1211+
)
1212+
11411213
;; CHECK: (func $matching-branches (type $21) (param $0 i32) (param $1 anyref) (param $2 i32) (param $3 anyref) (result i32 eqref)
11421214
;; CHECK-NEXT: (local $scratch anyref)
11431215
;; CHECK-NEXT: (local $scratch_5 i32)
@@ -1824,7 +1896,7 @@
18241896
;; CHECK-NEXT: )
18251897
;; CHECK-NEXT: )
18261898
;; OPT_O: (func $with-block-param (type $25) (param $0 i64) (param $1 anyref) (result i64 eqref)
1827-
;; OPT_O-NEXT: (block $block (type $13) (result i64 eqref)
1899+
;; OPT_O-NEXT: (block $block (type $14) (result i64 eqref)
18281900
;; OPT_O-NEXT: (tuple.make 2
18291901
;; OPT_O-NEXT: (local.get $0)
18301902
;; OPT_O-NEXT: (block $block0 (result eqref)
@@ -1960,7 +2032,7 @@
19602032
end
19612033
)
19622034

1963-
;; CHECK: (func $loop-results (type $10) (param $0 i32) (param $1 anyref) (result i32 anyref)
2035+
;; CHECK: (func $loop-results (type $11) (param $0 i32) (param $1 anyref) (result i32 anyref)
19642036
;; CHECK-NEXT: (local $scratch (tuple i32 anyref))
19652037
;; CHECK-NEXT: (local $scratch_3 (tuple i32 anyref))
19662038
;; CHECK-NEXT: (local $scratch_4 anyref)
@@ -2026,7 +2098,7 @@
20262098
;; CHECK-NEXT: )
20272099
;; CHECK-NEXT: )
20282100
;; CHECK-NEXT: )
2029-
;; OPT_O: (func $loop-results (type $8) (param $0 i32) (param $1 anyref) (result i32 anyref)
2101+
;; OPT_O: (func $loop-results (type $9) (param $0 i32) (param $1 anyref) (result i32 anyref)
20302102
;; OPT_O-NEXT: (local $2 (tuple i32 anyref))
20312103
;; OPT_O-NEXT: (local $3 eqref)
20322104
;; OPT_O-NEXT: (local.set $2
@@ -2081,7 +2153,7 @@
20812153
end
20822154
)
20832155

2084-
;; CHECK: (func $if (type $11) (param $0 i32) (param $1 i32) (param $2 anyref) (result i32 eqref)
2156+
;; CHECK: (func $if (type $12) (param $0 i32) (param $1 i32) (param $2 anyref) (result i32 eqref)
20852157
;; CHECK-NEXT: (local $scratch anyref)
20862158
;; CHECK-NEXT: (local $scratch_4 i32)
20872159
;; CHECK-NEXT: (local $scratch_5 i32)
@@ -2143,7 +2215,7 @@
21432215
;; CHECK-NEXT: )
21442216
;; CHECK-NEXT: )
21452217
;; CHECK-NEXT: )
2146-
;; OPT_O: (func $if (type $9) (param $0 i32) (param $1 i32) (param $2 anyref) (result i32 eqref)
2218+
;; OPT_O: (func $if (type $10) (param $0 i32) (param $1 i32) (param $2 anyref) (result i32 eqref)
21472219
;; OPT_O-NEXT: (block $label (type $0) (result i32 eqref)
21482220
;; OPT_O-NEXT: (tuple.make 2
21492221
;; OPT_O-NEXT: (local.get $1)
@@ -2193,7 +2265,7 @@
21932265
end
21942266
)
21952267

2196-
;; CHECK: (func $else (type $11) (param $0 i32) (param $1 i32) (param $2 anyref) (result i32 eqref)
2268+
;; CHECK: (func $else (type $12) (param $0 i32) (param $1 i32) (param $2 anyref) (result i32 eqref)
21972269
;; CHECK-NEXT: (local $scratch anyref)
21982270
;; CHECK-NEXT: (local $scratch_4 i32)
21992271
;; CHECK-NEXT: (local $scratch_5 i32)
@@ -2255,7 +2327,7 @@
22552327
;; CHECK-NEXT: )
22562328
;; CHECK-NEXT: )
22572329
;; CHECK-NEXT: )
2258-
;; OPT_O: (func $else (type $9) (param $0 i32) (param $1 i32) (param $2 anyref) (result i32 eqref)
2330+
;; OPT_O: (func $else (type $10) (param $0 i32) (param $1 i32) (param $2 anyref) (result i32 eqref)
22592331
;; OPT_O-NEXT: (block $label (type $0) (result i32 eqref)
22602332
;; OPT_O-NEXT: (tuple.make 2
22612333
;; OPT_O-NEXT: (local.get $1)

0 commit comments

Comments
 (0)