Skip to content

Commit 4cbc6b2

Browse files
More tests
1 parent 8f03f50 commit 4cbc6b2

File tree

1 file changed

+43
-8
lines changed

1 file changed

+43
-8
lines changed

test/lit/passes/global-effects-closed-world.wast

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
;; CHECK: (type $maybe-has-effects (func (param i32 i32)))
66
(type $maybe-has-effects (func (param i32 i32)))
77

8+
;; CHECK: (type $only-has-effects-in-non-exported-function (func (param f32 f32)))
9+
810
;; CHECK: (type $nopType (func (param i32)))
911
(type $nopType (func (param i32)))
1012

@@ -25,6 +27,8 @@
2527
;; CHECK: (type $func-with-super-param (sub $func-with-sub-param (func (param (ref $super)))))
2628
(type $func-with-super-param (sub $func-with-sub-param (func (param (ref $super)))))
2729

30+
(type $only-has-effects-in-non-exported-function (func (param f32 f32)))
31+
2832
(table 10 funcref)
2933

3034
;; CHECK: (global $g (mut i32) (i32.const 0))
@@ -51,7 +55,7 @@
5155
(nop)
5256
)
5357

54-
;; CHECK: (func $calls-nop-via-ref (type $6) (param $ref (ref $nopType))
58+
;; CHECK: (func $calls-nop-via-ref (type $7) (param $ref (ref $nopType))
5559
;; CHECK-NEXT: (call_ref $nopType
5660
;; CHECK-NEXT: (i32.const 1)
5761
;; CHECK-NEXT: (local.get $ref)
@@ -65,7 +69,7 @@
6569
(call_ref $nopType (i32.const 1) (local.get $ref))
6670
)
6771

68-
;; CHECK: (func $f (type $6) (param $ref (ref $nopType))
72+
;; CHECK: (func $f (type $7) (param $ref (ref $nopType))
6973
;; CHECK-NEXT: (nop)
7074
;; CHECK-NEXT: )
7175
(func $f (param $ref (ref $nopType))
@@ -74,7 +78,7 @@
7478
(call $calls-nop-via-ref (local.get $ref))
7579
)
7680

77-
;; CHECK: (func $calls-effectful-function-via-ref (type $7) (param $ref (ref $maybe-has-effects))
81+
;; CHECK: (func $calls-effectful-function-via-ref (type $8) (param $ref (ref $maybe-has-effects))
7882
;; CHECK-NEXT: (call_ref $maybe-has-effects
7983
;; CHECK-NEXT: (i32.const 1)
8084
;; CHECK-NEXT: (i32.const 2)
@@ -85,7 +89,7 @@
8589
(call_ref $maybe-has-effects (i32.const 1) (i32.const 2) (local.get $ref))
8690
)
8791

88-
;; CHECK: (func $g (type $7) (param $ref (ref $maybe-has-effects))
92+
;; CHECK: (func $g (type $8) (param $ref (ref $maybe-has-effects))
8993
;; CHECK-NEXT: (call $calls-effectful-function-via-ref
9094
;; CHECK-NEXT: (local.get $ref)
9195
;; CHECK-NEXT: )
@@ -96,7 +100,7 @@
96100
(call $calls-effectful-function-via-ref (local.get $ref))
97101
)
98102

99-
;; CHECK: (func $calls-uninhabited (type $8) (param $ref (ref $uninhabited))
103+
;; CHECK: (func $calls-uninhabited (type $9) (param $ref (ref $uninhabited))
100104
;; CHECK-NEXT: (call_ref $uninhabited
101105
;; CHECK-NEXT: (f32.const 0)
102106
;; CHECK-NEXT: (local.get $ref)
@@ -106,7 +110,7 @@
106110
(call_ref $uninhabited (f32.const 0) (local.get $ref))
107111
)
108112

109-
;; CHECK: (func $h (type $8) (param $ref (ref $uninhabited))
113+
;; CHECK: (func $h (type $9) (param $ref (ref $uninhabited))
110114
;; CHECK-NEXT: (nop)
111115
;; CHECK-NEXT: )
112116
(func $h (param $ref (ref $uninhabited))
@@ -129,7 +133,7 @@
129133
(unreachable)
130134
)
131135

132-
;; CHECK: (func $calls-ref-with-subtype (type $9) (param $func (ref $func-with-sub-param)) (param $sub (ref $sub))
136+
;; CHECK: (func $calls-ref-with-subtype (type $10) (param $func (ref $func-with-sub-param)) (param $sub (ref $sub))
133137
;; CHECK-NEXT: (call_ref $func-with-sub-param
134138
;; CHECK-NEXT: (local.get $sub)
135139
;; CHECK-NEXT: (local.get $func)
@@ -139,7 +143,7 @@
139143
(call_ref $func-with-sub-param (local.get $sub) (local.get $func))
140144
)
141145

142-
;; CHECK: (func $asdf (type $9) (param $func (ref $func-with-sub-param)) (param $sub (ref $sub))
146+
;; CHECK: (func $asdf (type $10) (param $func (ref $func-with-sub-param)) (param $sub (ref $sub))
143147
;; CHECK-NEXT: (call $calls-ref-with-subtype
144148
;; CHECK-NEXT: (local.get $func)
145149
;; CHECK-NEXT: (local.get $sub)
@@ -154,4 +158,35 @@
154158
;; include the unreachable effect and we can't optimize out this call.
155159
(call $calls-ref-with-subtype (local.get $func) (local.get $sub))
156160
)
161+
162+
;; CHECK: (func $no-effects (type $only-has-effects-in-non-exported-function) (param $0 f32) (param $1 f32)
163+
;; CHECK-NEXT: (nop)
164+
;; CHECK-NEXT: )
165+
(func $no-effects (type $only-has-effects-in-non-exported-function) (param f32 f32)
166+
)
167+
168+
;; CHECK: (func $has-effects-but-not-exported (type $only-has-effects-in-non-exported-function) (param $0 f32) (param $1 f32)
169+
;; CHECK-NEXT: (unreachable)
170+
;; CHECK-NEXT: )
171+
(func $has-effects-but-not-exported (type $only-has-effects-in-non-exported-function) (param f32 f32)
172+
(unreachable)
173+
)
174+
175+
;; CHECK: (func $calls-type-with-effects-but-not-addressable (type $11) (param $ref (ref $only-has-effects-in-non-exported-function))
176+
;; CHECK-NEXT: (call_ref $only-has-effects-in-non-exported-function
177+
;; CHECK-NEXT: (f32.const 0)
178+
;; CHECK-NEXT: (f32.const 0)
179+
;; CHECK-NEXT: (local.get $ref)
180+
;; CHECK-NEXT: )
181+
;; CHECK-NEXT: )
182+
(func $calls-type-with-effects-but-not-addressable (param $ref (ref $only-has-effects-in-non-exported-function))
183+
(call_ref $only-has-effects-in-non-exported-function (f32.const 0) (f32.const 0) (local.get $ref))
184+
)
185+
186+
;; CHECK: (func $i (type $11) (param $ref (ref $only-has-effects-in-non-exported-function))
187+
;; CHECK-NEXT: (nop)
188+
;; CHECK-NEXT: )
189+
(func $i (param $ref (ref $only-has-effects-in-non-exported-function))
190+
(call $calls-type-with-effects-but-not-addressable (local.get $ref))
191+
)
157192
)

0 commit comments

Comments
 (0)