Skip to content

Commit dcf18a7

Browse files
authored
[Testing] Port test/passes/duplicate-function-elimination-* tests to lit (#7682)
This just runs `./scripts/port_passes_tests_to_lit.py test/passes/duplicate-function-elimination_*.wast`. The script just copies the `.wast` files to `test/lit/passes` and runs `update_lit_checks.py` on the copied files.
1 parent 6b72393 commit dcf18a7

9 files changed

+4528
-4629
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
2+
;; NOTE: This test was ported using port_passes_tests_to_lit.py and could be cleaned up.
3+
4+
;; RUN: foreach %s %t wasm-opt --duplicate-function-elimination --all-features -S -o - | filecheck %s
5+
6+
;; --duplicate-function-elimination should not remove functions used in ref.func.
7+
(module
8+
;; CHECK: (type $0 (func (result i32)))
9+
10+
;; CHECK: (type $1 (func (result funcref)))
11+
12+
;; CHECK: (elem declare func $0)
13+
14+
;; CHECK: (func $0 (type $0) (result i32)
15+
;; CHECK-NEXT: (i32.const 0)
16+
;; CHECK-NEXT: )
17+
(func $0 (result i32)
18+
(i32.const 0)
19+
)
20+
(func $1 (result i32)
21+
(i32.const 0)
22+
)
23+
;; CHECK: (func $test (type $1) (result funcref)
24+
;; CHECK-NEXT: (ref.func $0)
25+
;; CHECK-NEXT: )
26+
(func $test (result funcref)
27+
(ref.func $1)
28+
)
29+
)
30+
;; renaming after deduplication must only affect functions
31+
(module
32+
;; CHECK: (type $0 (func))
33+
34+
;; CHECK: (global $bar i32 (i32.const 0))
35+
36+
;; CHECK: (memory $foo 16 16)
37+
(memory $foo 16 16)
38+
(global $bar i32 (i32.const 0))
39+
;; CHECK: (export "memory" (memory $foo))
40+
(export "memory" (memory $foo))
41+
;; CHECK: (export "global" (global $bar))
42+
(export "global" (global $bar))
43+
;; CHECK: (func $bar (type $0)
44+
;; CHECK-NEXT: )
45+
(func $bar ;; happens to share a name with the global
46+
)
47+
(func $foo ;; happens to share a name with the memory
48+
)
49+
)
50+
;; renaming after deduplication must update ref.funcs in globals
51+
(module
52+
;; CHECK: (type $func (func (result i32)))
53+
(type $func (func (result i32)))
54+
;; CHECK: (global $global$0 (ref $func) (ref.func $foo))
55+
(global $global$0 (ref $func) (ref.func $bar))
56+
;; These two identical functions can be merged. The ref.func in the global must
57+
;; be updated accordingly.
58+
;; CHECK: (export "export" (func $export))
59+
60+
;; CHECK: (func $foo (type $func) (result i32)
61+
;; CHECK-NEXT: (unreachable)
62+
;; CHECK-NEXT: )
63+
(func $foo (result i32)
64+
(unreachable)
65+
)
66+
(func $bar (result i32)
67+
(unreachable)
68+
)
69+
;; CHECK: (func $export (type $func) (result i32)
70+
;; CHECK-NEXT: (call_ref $func
71+
;; CHECK-NEXT: (global.get $global$0)
72+
;; CHECK-NEXT: )
73+
;; CHECK-NEXT: )
74+
(func $export (export "export") (result i32)
75+
(call_ref $func
76+
(global.get $global$0)
77+
)
78+
)
79+
)

0 commit comments

Comments
 (0)