summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-05-20 11:34:23 -0700
committerGitHub <noreply@github.com>2024-05-20 11:34:23 -0700
commit3e336052ea820be3e2da722f4a02f68d75283a6d (patch)
treec2d59aa758d01c7a27abdc72e860f924bb851a48 /test
parent5d64afabbd0da07506f68d6f22b3b358f0ca12b6 (diff)
downloadbinaryen-3e336052ea820be3e2da722f4a02f68d75283a6d.tar.gz
binaryen-3e336052ea820be3e2da722f4a02f68d75283a6d.tar.bz2
binaryen-3e336052ea820be3e2da722f4a02f68d75283a6d.zip
SimplifyGlobals: Do not switch a get to use a global of another type (#6605)
If we wanted to switch types in such cases we'd need to refinalize (which is likely worth doing, though other passes should refine globals anyhow).
Diffstat (limited to 'test')
-rw-r--r--test/lit/passes/simplify-globals-gc.wast24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/lit/passes/simplify-globals-gc.wast b/test/lit/passes/simplify-globals-gc.wast
index 76ce984e7..97063a1a1 100644
--- a/test/lit/passes/simplify-globals-gc.wast
+++ b/test/lit/passes/simplify-globals-gc.wast
@@ -31,3 +31,27 @@
)
)
+(module
+ ;; CHECK: (type $struct (struct ))
+ (type $struct (struct ))
+
+ ;; CHECK: (type $1 (func (result anyref)))
+
+ ;; CHECK: (global $a (ref $struct) (struct.new_default $struct))
+ (global $a (ref $struct) (struct.new_default $struct))
+ ;; CHECK: (global $b (ref $struct) (global.get $a))
+ (global $b (ref $struct) (global.get $a))
+ ;; CHECK: (global $c (ref null $struct) (global.get $a))
+ (global $c (ref null $struct) (global.get $a))
+
+ ;; CHECK: (func $get-c (type $1) (result anyref)
+ ;; CHECK-NEXT: (global.get $c)
+ ;; CHECK-NEXT: )
+ (func $get-c (result anyref)
+ ;; $c has a less-refined type than the other two. We do not switch this to
+ ;; get from either $a or $b because of that, but we could if we also
+ ;; refinalized TODO
+ (global.get $c)
+ )
+)
+