summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-06-24 12:17:53 -0700
committerGitHub <noreply@github.com>2024-06-24 12:17:53 -0700
commit78b3c40310e886fb93480008fc55cdcd4fffa52c (patch)
treee0975b0bebc140959084be5b7499da6a76a08a20
parented35193eef158d4685a88ed00d742d969d366c64 (diff)
downloadbinaryen-78b3c40310e886fb93480008fc55cdcd4fffa52c.tar.gz
binaryen-78b3c40310e886fb93480008fc55cdcd4fffa52c.tar.bz2
binaryen-78b3c40310e886fb93480008fc55cdcd4fffa52c.zip
[WasmGC] Add missing ArrayNew variants to Properties::isGenerative (#6691)
Fixes #6690
-rw-r--r--src/ir/properties.cpp2
-rw-r--r--test/lit/passes/local-cse_all-features.wast92
2 files changed, 89 insertions, 5 deletions
diff --git a/src/ir/properties.cpp b/src/ir/properties.cpp
index 1346f6cad..dd9a10a8e 100644
--- a/src/ir/properties.cpp
+++ b/src/ir/properties.cpp
@@ -35,6 +35,8 @@ struct GenerativityScanner : public PostWalker<GenerativityScanner> {
void visitCallRef(CallRef* curr) { generative = true; }
void visitStructNew(StructNew* curr) { generative = true; }
void visitArrayNew(ArrayNew* curr) { generative = true; }
+ void visitArrayNewData(ArrayNewData* curr) { generative = true; }
+ void visitArrayNewElem(ArrayNewElem* curr) { generative = true; }
void visitArrayNewFixed(ArrayNewFixed* curr) { generative = true; }
};
diff --git a/test/lit/passes/local-cse_all-features.wast b/test/lit/passes/local-cse_all-features.wast
index 368936ae9..8878d595f 100644
--- a/test/lit/passes/local-cse_all-features.wast
+++ b/test/lit/passes/local-cse_all-features.wast
@@ -64,16 +64,30 @@
;; CHECK: (type $B (array (mut i32)))
(type $B (array (mut i32)))
-
;; CHECK: (type $2 (func (param (ref $A))))
;; CHECK: (type $3 (func))
- ;; CHECK: (type $4 (func (param (ref null $A))))
+ ;; CHECK: (type $C (array (mut funcref)))
+ (type $C (array (mut funcref)))
+
+ ;; CHECK: (type $5 (func (param (ref null $A))))
+
+ ;; CHECK: (type $6 (func (param (ref null $B) (ref $A))))
+
+ ;; CHECK: (memory $memory 1)
+ (memory $memory 1)
- ;; CHECK: (type $5 (func (param (ref null $B) (ref $A))))
+ ;; CHECK: (data $data "abcdefg")
+ (data $data "abcdefg")
- ;; CHECK: (func $struct-gets-nullable (type $4) (param $ref (ref null $A))
+ ;; CHECK: (table $table 10 funcref)
+ (table $table 10 funcref)
+
+ ;; CHECK: (elem $elem (i32.const 0) $creations)
+ (elem $elem (i32.const 0) funcref (ref.func $creations))
+
+ ;; CHECK: (func $struct-gets-nullable (type $5) (param $ref (ref null $A))
;; CHECK-NEXT: (local $1 i32)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (local.tee $1
@@ -205,6 +219,40 @@
;; CHECK-NEXT: (i32.const 1)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (array.new_data $B $data
+ ;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: (i32.const 5)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (array.new_data $B $data
+ ;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: (i32.const 5)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (array.new_elem $C $elem
+ ;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: (i32.const 5)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (array.new_elem $C $elem
+ ;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: (i32.const 5)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (array.new_fixed $B 1
+ ;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (array.new_fixed $B 1
+ ;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $creations
;; Allocating GC data has no side effects, but each allocation is unique
@@ -231,6 +279,40 @@
(i32.const 1)
)
)
+ (drop
+ (array.new_data $B $data
+ (i32.const 1)
+ (i32.const 5)
+ )
+ )
+ (drop
+ (array.new_data $B $data
+ (i32.const 1)
+ (i32.const 5)
+ )
+ )
+ (drop
+ (array.new_elem $C $elem
+ (i32.const 1)
+ (i32.const 5)
+ )
+ )
+ (drop
+ (array.new_elem $C $elem
+ (i32.const 1)
+ (i32.const 5)
+ )
+ )
+ (drop
+ (array.new_fixed $B 1
+ (i32.const 1)
+ )
+ )
+ (drop
+ (array.new_fixed $B 1
+ (i32.const 1)
+ )
+ )
)
;; CHECK: (func $nested-generativity (type $3)
@@ -263,7 +345,7 @@
)
)
- ;; CHECK: (func $structs-and-arrays-do-not-alias (type $5) (param $array (ref null $B)) (param $struct (ref $A))
+ ;; CHECK: (func $structs-and-arrays-do-not-alias (type $6) (param $array (ref null $B)) (param $struct (ref $A))
;; CHECK-NEXT: (local $2 i32)
;; CHECK-NEXT: (array.set $B
;; CHECK-NEXT: (local.get $array)