summaryrefslogtreecommitdiff
path: root/test/lit
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2023-10-16 15:51:05 -0700
committerGitHub <noreply@github.com>2023-10-16 15:51:05 -0700
commit2d1e1501f5da1436f61c8ff5440aca33e25a29e9 (patch)
treec75bd423561c1d33a59279cb45d5c5298d4ed954 /test/lit
parentf686b6887439f81a99599b0667e02c8d1f698935 (diff)
downloadbinaryen-2d1e1501f5da1436f61c8ff5440aca33e25a29e9.tar.gz
binaryen-2d1e1501f5da1436f61c8ff5440aca33e25a29e9.tar.bz2
binaryen-2d1e1501f5da1436f61c8ff5440aca33e25a29e9.zip
Heap2Local: Refinalize when removing a cast (#6012)
Diffstat (limited to 'test/lit')
-rw-r--r--test/lit/passes/heap2local.wast43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/lit/passes/heap2local.wast b/test/lit/passes/heap2local.wast
index b814c4987..04c0936c6 100644
--- a/test/lit/passes/heap2local.wast
+++ b/test/lit/passes/heap2local.wast
@@ -2035,3 +2035,46 @@
)
)
)
+
+(module
+ (type $A (sub (struct (field (mut i32)))))
+ (type $B (sub $A (struct (field (mut i32)))))
+
+ ;; CHECK: (func $func (type $0)
+ ;; CHECK-NEXT: (local $0 i32)
+ ;; CHECK-NEXT: (local $1 i32)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (block (result nullref)
+ ;; CHECK-NEXT: (block (result nullref)
+ ;; CHECK-NEXT: (block (result nullref)
+ ;; CHECK-NEXT: (local.set $1
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (local.set $0
+ ;; CHECK-NEXT: (local.get $1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (ref.null none)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $func
+ ;; We can replace the allocation with a local for the i32. While doing so we
+ ;; must be careful to still validate, and so when we remove the cast we must
+ ;; also ensure the blocks around it have types that still validate (using
+ ;; refinalize, which will make them all nullref, since the unused value
+ ;; flowing through them will be replaced with a null).
+ (drop
+ (block (result (ref $B))
+ (ref.cast (ref $B)
+ (block (result (ref $A))
+ (struct.new $B
+ (i32.const 0)
+ )
+ )
+ )
+ )
+ )
+ )
+)