summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lit/passes/heap2local.wast57
1 files changed, 57 insertions, 0 deletions
diff --git a/test/lit/passes/heap2local.wast b/test/lit/passes/heap2local.wast
index 2e38b7e4e..143b7033a 100644
--- a/test/lit/passes/heap2local.wast
+++ b/test/lit/passes/heap2local.wast
@@ -4428,3 +4428,60 @@
)
)
)
+
+(module
+ ;; CHECK: (type $0 (func))
+
+ ;; CHECK: (type $A (sub (struct (field structref))))
+ (type $A (sub (struct (field structref))))
+
+ ;; CHECK: (func $struct.get-ref.eq (type $0)
+ ;; CHECK-NEXT: (local $x (ref $A))
+ ;; CHECK-NEXT: (local $1 structref)
+ ;; CHECK-NEXT: (if
+ ;; CHECK-NEXT: (block (result i32)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (block (result structref)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (block (result nullref)
+ ;; CHECK-NEXT: (local.set $1
+ ;; CHECK-NEXT: (ref.null none)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (ref.null none)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (local.get $1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (ref.null none)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (then
+ ;; CHECK-NEXT: (unreachable)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $struct.get-ref.eq
+ (local $x (ref $A))
+ ;; This ref.eq ends up comparing the tee'd allocation with a read of null
+ ;; from the allocation's field, which returns 0. This tests that we can
+ ;; differentiate when the allocation gets somewhere vs when it flows out
+ ;; from that place, as the allocation does reach the struct.get - hence we
+ ;; need to update it, when we optimize - but it does not flow it back out.
+ (if
+ (ref.eq
+ (struct.get $A 0
+ (local.tee $x
+ (struct.new_default $A)
+ )
+ )
+ (local.get $x)
+ )
+ (then
+ (unreachable)
+ )
+ )
+ )
+)