Skip to content

Commit 8f85446

Browse files
authored
[Multibyte] Handle ArrayStore in Precompute (#8511)
All GC writes must be handled there, to avoid it executing them and thinking they have no more effects.
1 parent 7116073 commit 8f85446

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

src/passes/Precompute.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ class PrecomputingExpressionRunner
215215
}
216216
// ArrayLen is not disallowed here as it is an immutable property.
217217
Flow visitArrayCopy(ArrayCopy* curr) { return Flow(NONCONSTANT_FLOW); }
218+
Flow visitArrayStore(ArrayStore* curr) { return Flow(NONCONSTANT_FLOW); }
218219

219220
// Generates heap info for a heap-allocating expression.
220221
Flow getGCAllocation(Expression* curr, std::function<Flow()> visitFunc) {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited.
2+
3+
;; RUN: foreach %s %t wasm-opt --precompute-propagate -all -S -o - | filecheck %s
4+
5+
(module
6+
;; CHECK: (type $array (array (mut i8)))
7+
(type $array (array (mut i8)))
8+
9+
;; CHECK: (func $array.store (type $1) (param $x (ref $array))
10+
;; CHECK-NEXT: (i64.store32 (type $array)
11+
;; CHECK-NEXT: (local.get $x)
12+
;; CHECK-NEXT: (i32.const 0)
13+
;; CHECK-NEXT: (i64.const 1)
14+
;; CHECK-NEXT: )
15+
;; CHECK-NEXT: )
16+
(func $array.store (param $x (ref $array))
17+
;; ArrayStore operations cannot be removed.
18+
(i64.store32 (type $array)
19+
(local.get $x)
20+
(i32.const 0)
21+
(i64.const 1)
22+
)
23+
)
24+
)

0 commit comments

Comments
 (0)