Skip to content

Commit e964f13

Browse files
tlivelyradekdoulik
authored andcommitted
Update lit tests to parse with the new parser (WebAssembly#6290)
Get as many of the lit tests as possible to parse with the new parser, mostly by moving declared module items to be after imports. Also fix a bug in the new parser's pop validation to allow supertypes of the expected type. The two big issues that still prevent some lit tests from working correctly under the new parser are missing support for symbolic field names and missing support for source map annotations.
1 parent bf1cdb8 commit e964f13

39 files changed

+129
-85
lines changed

src/wasm/wasm-ir-builder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,7 @@ Result<> IRBuilder::makePop(Type type) {
13231323
"pop instructions may only appear at the beginning of catch blocks"};
13241324
}
13251325
auto expectedType = scope.exprStack[0]->type;
1326-
if (type != expectedType) {
1326+
if (!Type::isSubType(expectedType, type)) {
13271327
return Err{std::string("Expected pop of type ") + expectedType.toString()};
13281328
}
13291329
return Ok{};

test/lit/basic/multi-table.wast

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,16 @@
1515
(type $none_=>_none (func))
1616
(type $A (struct))
1717
;; CHECK-TEXT: (import "a" "b" (table $t1 1 10 funcref))
18-
19-
;; CHECK-TEXT: (global $g1 (ref null $none_=>_none) (ref.func $f))
2018
;; CHECK-BIN: (import "a" "b" (table $t1 1 10 funcref))
19+
(import "a" "b" (table $t1 1 10 funcref))
2120

21+
;; CHECK-TEXT: (global $g1 (ref null $none_=>_none) (ref.func $f))
2222
;; CHECK-BIN: (global $g1 (ref null $none_=>_none) (ref.func $f))
2323
(global $g1 (ref null $none_=>_none) (ref.func $f))
2424
;; CHECK-TEXT: (global $g2 i32 (i32.const 0))
2525
;; CHECK-BIN: (global $g2 i32 (i32.const 0))
2626
(global $g2 i32 (i32.const 0))
2727

28-
(import "a" "b" (table $t1 1 10 funcref))
2928
;; CHECK-TEXT: (table $t2 3 3 funcref)
3029
;; CHECK-BIN: (table $t2 3 3 funcref)
3130
(table $t2 3 3 funcref)

test/lit/basic/reference-types.wast

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,19 @@
4343
;; CHECK-TEXT: (import "env" "import_global" (global $import_global eqref))
4444

4545
;; CHECK-TEXT: (import "env" "import_func" (func $import_func (type $8) (param eqref) (result funcref)))
46+
;; CHECK-BIN: (type $5 (func))
47+
48+
;; CHECK-BIN: (type $6 (func (result eqref)))
49+
50+
;; CHECK-BIN: (type $7 (func (param i32)))
51+
52+
;; CHECK-BIN: (type $8 (func (param eqref) (result funcref)))
53+
54+
;; CHECK-BIN: (import "env" "import_global" (global $import_global eqref))
55+
56+
;; CHECK-BIN: (import "env" "import_func" (func $import_func (type $8) (param eqref) (result funcref)))
57+
(import "env" "import_func" (func $import_func (param eqref) (result funcref)))
58+
(import "env" "import_global" (global $import_global eqref))
4659

4760
;; CHECK-TEXT: (global $global_eqref (mut eqref) (ref.null none))
4861

@@ -69,18 +82,6 @@
6982
;; CHECK-TEXT: (func $take_eqref (type $sig_eqref) (param $0 eqref)
7083
;; CHECK-TEXT-NEXT: (nop)
7184
;; CHECK-TEXT-NEXT: )
72-
;; CHECK-BIN: (type $5 (func))
73-
74-
;; CHECK-BIN: (type $6 (func (result eqref)))
75-
76-
;; CHECK-BIN: (type $7 (func (param i32)))
77-
78-
;; CHECK-BIN: (type $8 (func (param eqref) (result funcref)))
79-
80-
;; CHECK-BIN: (import "env" "import_global" (global $import_global eqref))
81-
82-
;; CHECK-BIN: (import "env" "import_func" (func $import_func (type $8) (param eqref) (result funcref)))
83-
8485
;; CHECK-BIN: (global $global_eqref (mut eqref) (ref.null none))
8586

8687
;; CHECK-BIN: (global $global_funcref (mut funcref) (ref.null nofunc))
@@ -172,8 +173,6 @@
172173
;; CHECK-BIN-NODEBUG: (elem declare func $23 $3)
173174
(elem declare func $ref-taken-but-not-in-table)
174175

175-
(import "env" "import_func" (func $import_func (param eqref) (result funcref)))
176-
(import "env" "import_global" (global $import_global eqref))
177176
(export "export_func" (func $import_func))
178177
(export "export_global" (global $import_global))
179178

test/lit/basic/tags.wast

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
;; Test tags
1313

1414
(module
15+
(tag $e-import (import "env" "im0") (param i32))
16+
(import "env" "im1" (tag (param i32 f32)))
17+
1518
(tag (param i32))
19+
1620
;; CHECK-TEXT: (type $0 (func (param i32 f32)))
1721

1822
;; CHECK-TEXT: (type $1 (func (param i32)))
@@ -54,9 +58,7 @@
5458
;; CHECK-TEXT: (tag $e-export (param i32))
5559
;; CHECK-BIN: (tag $e-export (param i32))
5660
(tag $e-export (export "ex0") (param i32))
57-
(tag $e-import (import "env" "im0") (param i32))
5861

59-
(import "env" "im1" (tag (param i32 f32)))
6062
;; CHECK-TEXT: (export "ex0" (tag $e-export))
6163

6264
;; CHECK-TEXT: (export "ex1" (tag $e))

test/lit/exec/strings.wast

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
(module
66
(type $array16 (array (mut i16)))
7+
(memory 1 1)
78

89
;; CHECK: [fuzz-exec] calling new_wtf16_array
910
;; CHECK-NEXT: [fuzz-exec] note result: new_wtf16_array => string("ello")

test/lit/merge/fusing.wat.second

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
;; Use a different prefix than in first ($main instead of $other).
77
(import "first" "bar" (func $main.bar))
88

9+
(import "first" "mem" (memory $other.mem 1))
10+
11+
(import "first" "exn" (tag $exn))
12+
913
(memory $second.mem 2)
1014

1115
(export "mem" (memory $second.mem))
@@ -26,15 +30,12 @@
2630
)
2731
)
2832

29-
(import "first" "mem" (memory $other.mem 1))
30-
3133
(func $keepalive2 (export "keepalive2") (result i32)
3234
;; Load from the memory imported from the second module.
3335
(i32.load $other.mem
3436
(i32.const 10)
3537
)
3638
)
3739

38-
(import "first" "exn" (tag $exn))
3940
(func $keepalive3 (export "keepalive3") (throw $exn))
4041
)

test/lit/merge/memory_data.wat.second

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
(module
2+
;; Test that the import remains
3+
(import "import" "mem" (memory $imported 10000))
4+
25
(memory $other 100)
36

47
(memory $bar 1000)
58

6-
;; Test that the import remains
7-
(import "import" "mem" (memory $imported 10000))
8-
99
(data $a (memory $other) (i32.const 0) "a2")
1010

1111
(data $b (memory $bar) (i32.const 0) "b2")

test/lit/merge/renamings.wat.second

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
(module
22
(type $array (array (mut (ref null func))))
33

4+
;; Test that the import remains
5+
(import "elsewhere" "some.tag" (tag $imported (param f64)))
6+
47
(tag $foo (param f32))
58

69
(tag $other (param f64))
710

8-
;; Test that the import remains
9-
(import "elsewhere" "some.tag" (tag $imported (param f64)))
10-
1111
(memory $foo 50 60)
1212

1313
(memory $other 70 80)

test/lit/passes/asyncify-wasm64.wast

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
;; CHECK: (type $f (func (param i32)))
99
(type $f (func (param i32)))
10-
(memory i64 1 2)
1110
;; CHECK: (type $2 (func))
1211

1312
;; CHECK: (type $3 (func (param i64)))
@@ -18,6 +17,9 @@
1817
(import "env" "import" (func $import))
1918
;; CHECK: (import "env" "import2" (func $import2 (param i32)))
2019
(import "env" "import2" (func $import2 (param i32)))
20+
21+
(memory i64 1 2)
22+
2123
(table funcref (elem $liveness2 $liveness2))
2224
;; CHECK: (global $__asyncify_state (mut i32) (i32.const 0))
2325

test/lit/passes/asyncify-wasm64_pass-arg=in-secondary-memory.wast

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
;; RUN: wasm-opt --enable-memory64 --enable-multimemory --asyncify --pass-arg=asyncify-in-secondary-memory %s -S -o - | filecheck %s
44

55
(module
6-
(memory i64 1 2)
76
;; CHECK: (type $0 (func))
87

98
;; CHECK: (type $1 (func (param i32)))
@@ -14,6 +13,9 @@
1413

1514
;; CHECK: (import "env" "import" (func $import))
1615
(import "env" "import" (func $import))
16+
17+
(memory i64 1 2)
18+
1719
;; CHECK: (global $__asyncify_state (mut i32) (i32.const 0))
1820

1921
;; CHECK: (global $__asyncify_data (mut i32) (i32.const 0))

test/lit/passes/asyncify.wast

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
(module
77
;; CHECK: (type $f (func (param i32)))
88
(type $f (func (param i32)))
9-
(memory 1 2)
109
;; CHECK: (type $1 (func (param i32 i32)))
1110

1211
;; CHECK: (type $2 (func))
@@ -17,15 +16,16 @@
1716
(import "env" "import" (func $import))
1817
;; CHECK: (import "env" "import2" (func $import2 (param i32)))
1918
(import "env" "import2" (func $import2 (param i32)))
20-
(table funcref (elem $liveness2 $liveness2))
19+
2120
;; CHECK: (global $__asyncify_state (mut i32) (i32.const 0))
2221

2322
;; CHECK: (global $__asyncify_data (mut i32) (i32.const 0))
2423

25-
;; CHECK: (memory $0 1 2)
26-
27-
;; CHECK: (table $0 2 2 funcref)
24+
;; CHECK: (memory $m 1 2)
25+
(memory $m 1 2)
2826

27+
;; CHECK: (table $t 2 2 funcref)
28+
(table $t funcref (elem $liveness2 $liveness2))
2929
;; CHECK: (elem $0 (i32.const 0) $liveness2 $liveness2)
3030

3131
;; CHECK: (export "asyncify_start_unwind" (func $asyncify_start_unwind))

test/lit/passes/asyncify_enable-multivalue.wast

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55

66
;; Pre-existing imports that the pass turns into the implementations.
77
(module
8-
(memory 1 2)
98
(import "asyncify" "start_unwind" (func $asyncify_start_unwind (param i32)))
109
(import "asyncify" "stop_unwind" (func $asyncify_stop_unwind))
1110
(import "asyncify" "start_rewind" (func $asyncify_start_rewind (param i32)))
1211
(import "asyncify" "stop_rewind" (func $asyncify_stop_rewind))
12+
13+
(memory 1 2)
1314
;; CHECK: (type $0 (func))
1415

1516
;; CHECK: (type $1 (func (param i32)))
@@ -404,7 +405,6 @@
404405
;; CHECK-NEXT: (global.get $__asyncify_state)
405406
;; CHECK-NEXT: )
406407
(module
407-
(memory 1 2)
408408
;; CHECK: (type $0 (func))
409409

410410
;; CHECK: (type $1 (func (param i32)))
@@ -423,6 +423,8 @@
423423
(import "env" "import3" (func $import3 (param i32)))
424424
;; CHECK: (import "env" "import-mv" (func $import-mv (result i32 i64)))
425425
(import "env" "import-mv" (func $import-mv (result i32 i64)))
426+
427+
(memory 1 2)
426428
;; CHECK: (global $__asyncify_state (mut i32) (i32.const 0))
427429

428430
;; CHECK: (global $__asyncify_data (mut i32) (i32.const 0))

test/lit/passes/asyncify_mod-asyncify-always-and-only-unwind.wast

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
;; RUN: foreach %s %t wasm-opt --asyncify --mod-asyncify-always-and-only-unwind -S -o - | filecheck %s
55

66
(module
7-
(memory 1 2)
87
;; CHECK: (type $0 (func))
98

109
;; CHECK: (type $1 (func (result i32)))
@@ -17,6 +16,9 @@
1716
(import "env" "import2" (func $import2 (result i32)))
1817
;; CHECK: (import "env" "import3" (func $import3 (param i32)))
1918
(import "env" "import3" (func $import3 (param i32)))
19+
20+
(memory 1 2)
21+
2022
;; CHECK: (global $__asyncify_state (mut i32) (i32.const 0))
2123

2224
;; CHECK: (global $__asyncify_data (mut i32) (i32.const 0))

test/lit/passes/asyncify_mod-asyncify-always-and-only-unwind_O.wast

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
;; RUN: foreach %s %t wasm-opt --asyncify --mod-asyncify-always-and-only-unwind -O -S -o - | filecheck %s
55

66
(module
7-
(memory 1 2)
87
;; CHECK: (type $0 (func))
98

109
;; CHECK: (type $1 (func (param i32)))
@@ -15,6 +14,10 @@
1514
(import "env" "import" (func $import))
1615
(import "env" "import2" (func $import2 (result i32)))
1716
(import "env" "import3" (func $import3 (param i32)))
17+
18+
19+
(memory 1 2)
20+
1821
;; CHECK: (global $__asyncify_state (mut i32) (i32.const 0))
1922

2023
;; CHECK: (global $__asyncify_data (mut i32) (i32.const 0))

test/lit/passes/asyncify_mod-asyncify-never-unwind.wast

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
;; RUN: foreach %s %t wasm-opt --asyncify --mod-asyncify-never-unwind -S -o - | filecheck %s
55

66
(module
7-
(memory 1 2)
87
;; CHECK: (type $0 (func))
98

109
;; CHECK: (type $1 (func (result i32)))
@@ -17,6 +16,9 @@
1716
(import "env" "import2" (func $import2 (result i32)))
1817
;; CHECK: (import "env" "import3" (func $import3 (param i32)))
1918
(import "env" "import3" (func $import3 (param i32)))
19+
20+
(memory 1 2)
21+
2022
;; CHECK: (global $__asyncify_state (mut i32) (i32.const 0))
2123

2224
;; CHECK: (global $__asyncify_data (mut i32) (i32.const 0))

test/lit/passes/asyncify_mod-asyncify-never-unwind_O.wast

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
;; RUN: foreach %s %t wasm-opt --asyncify --mod-asyncify-never-unwind -O -S -o - | filecheck %s
55

66
(module
7-
(memory 1 2)
87
;; CHECK: (type $0 (func))
98

109
;; CHECK: (type $1 (func (param i32)))
@@ -15,6 +14,9 @@
1514
(import "env" "import" (func $import))
1615
(import "env" "import2" (func $import2 (result i32)))
1716
(import "env" "import3" (func $import3 (param i32)))
17+
18+
(memory 1 2)
19+
1820
;; CHECK: (global $__asyncify_state (mut i32) (i32.const 0))
1921

2022
;; CHECK: (global $__asyncify_data (mut i32) (i32.const 0))

test/lit/passes/asyncify_optimize-level=1.wast

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
;; RUN: foreach %s %t wasm-opt --asyncify --optimize-level=1 -S -o - | filecheck %s
55

66
(module
7-
(memory 1 2)
87
;; CHECK: (type $0 (func))
98

109
;; CHECK: (type $1 (func (param i32)))
@@ -19,6 +18,9 @@
1918
(import "env" "import2" (func $import2 (result i32)))
2019
;; CHECK: (import "env" "import3" (func $import3 (param i32)))
2120
(import "env" "import3" (func $import3 (param i32)))
21+
22+
(memory 1 2)
23+
2224
;; CHECK: (global $__asyncify_state (mut i32) (i32.const 0))
2325

2426
;; CHECK: (global $__asyncify_data (mut i32) (i32.const 0))

test/lit/passes/[email protected]

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
;; RUN: foreach %s %t wasm-opt --asyncify --pass-arg=asyncify-addlist@foo -S -o - | filecheck %s
55

66
(module
7-
(memory 1 2)
87
;; CHECK: (type $0 (func))
98

109
;; CHECK: (type $1 (func (param i32)))
@@ -13,6 +12,9 @@
1312

1413
;; CHECK: (import "env" "import" (func $import))
1514
(import "env" "import" (func $import))
15+
16+
(memory 1 2)
17+
1618
;; CHECK: (global $__asyncify_state (mut i32) (i32.const 0))
1719

1820
;; CHECK: (global $__asyncify_data (mut i32) (i32.const 0))

test/lit/passes/asyncify_pass-arg=asyncify-addlist@foo_pass-arg=asyncify-ignore-indirect.wast

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@
66
(module
77
;; CHECK: (type $t (func))
88
(type $t (func))
9-
(memory 1 2)
10-
(table 1 funcref)
11-
(elem (i32.const 0))
129
;; CHECK: (type $1 (func (param i32)))
1310

1411
;; CHECK: (type $2 (func (result i32)))
1512

1613
;; CHECK: (import "env" "import" (func $import))
1714
(import "env" "import" (func $import))
15+
16+
(memory 1 2)
17+
(table 1 funcref)
18+
(elem (i32.const 0))
19+
1820
;; CHECK: (global $__asyncify_state (mut i32) (i32.const 0))
1921

2022
;; CHECK: (global $__asyncify_data (mut i32) (i32.const 0))

0 commit comments

Comments
 (0)