Skip to content

Commit 344df91

Browse files
authored
[Stack Switching] Mark ContNew as generative (#7849)
Each `cont.new` generates a new continuation, so we cannot e.g. LocalCSE them.
1 parent e9b4c9e commit 344df91

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

scripts/test/fuzzing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
'O3_stack-switching.wast',
110110
'coalesce-locals-stack-switching.wast',
111111
'dce-stack-switching.wast',
112+
'local-cse-cont.wast',
112113
'precompute-stack-switching.wast',
113114
'unsubtyping-stack-switching.wast',
114115
'vacuum-stack-switching.wast',

src/ir/properties.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ struct GenerativityScanner : public PostWalker<GenerativityScanner> {
3838
void visitArrayNewData(ArrayNewData* curr) { generative = true; }
3939
void visitArrayNewElem(ArrayNewElem* curr) { generative = true; }
4040
void visitArrayNewFixed(ArrayNewFixed* curr) { generative = true; }
41+
void visitContNew(ContNew* curr) { generative = true; }
4142
};
4243

4344
} // anonymous namespace
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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 --local-cse -all -S -o - | filecheck %s
5+
6+
(module
7+
;; CHECK: (type $func (func))
8+
(type $func (func))
9+
;; CHECK: (type $cont (cont $func))
10+
(type $cont (cont $func))
11+
12+
;; CHECK: (elem declare func $cont.new)
13+
14+
;; CHECK: (func $cont.new (type $func)
15+
;; CHECK-NEXT: (drop
16+
;; CHECK-NEXT: (cont.new $cont
17+
;; CHECK-NEXT: (ref.func $cont.new)
18+
;; CHECK-NEXT: )
19+
;; CHECK-NEXT: )
20+
;; CHECK-NEXT: (drop
21+
;; CHECK-NEXT: (cont.new $cont
22+
;; CHECK-NEXT: (ref.func $cont.new)
23+
;; CHECK-NEXT: )
24+
;; CHECK-NEXT: )
25+
;; CHECK-NEXT: )
26+
(func $cont.new (type $func)
27+
;; We cannot CSE here, as each of these emits a unique continuation.
28+
(drop
29+
(cont.new $cont
30+
(ref.func $cont.new)
31+
)
32+
)
33+
(drop
34+
(cont.new $cont
35+
(ref.func $cont.new)
36+
)
37+
)
38+
)
39+
)
40+

0 commit comments

Comments
 (0)