Skip to content

Commit 2e2fa27

Browse files
committed
Merge branch 'unsubtyping-optimize-descs' into unsubtyping-exact-casts
2 parents a2ddce0 + 7e6d093 commit 2e2fa27

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

src/passes/Unsubtyping.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,7 @@ struct Unsubtyping : Pass {
644644
info.descriptors.insert({*desc, type});
645645
}
646646
void visitRefGetDesc(RefGetDesc* curr) {
647+
Super::visitRefGetDesc(curr);
647648
if (!curr->ref->type.isStruct()) {
648649
return;
649650
}
@@ -664,6 +665,7 @@ struct Unsubtyping : Pass {
664665
noteDescriptor(curr->desc->type.getHeapType());
665666
}
666667
void visitStructNew(StructNew* curr) {
668+
Super::visitStructNew(curr);
667669
if (curr->type == Type::unreachable || !curr->desc) {
668670
return;
669671
}

test/lit/passes/unsubtyping.wast

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1892,3 +1892,31 @@
18921892
)
18931893
)
18941894
)
1895+
1896+
;; Even though our analysis has its own visitor for StructNew, it should still
1897+
;; be able to collect subtype constraints from StructNews.
1898+
(module
1899+
;; CHECK: (rec
1900+
;; CHECK-NEXT: (type $A (sub (struct (field (ref null $A)))))
1901+
(type $A (sub (struct (field (ref null $A)))))
1902+
;; CHECK: (type $B (sub $A (struct (field (ref null $A)))))
1903+
(type $B (sub $A (struct (field (ref null $A)))))
1904+
1905+
;; CHECK: (type $2 (func (param (ref null $B))))
1906+
1907+
;; CHECK: (func $test (type $2) (param $B (ref null $B))
1908+
;; CHECK-NEXT: (drop
1909+
;; CHECK-NEXT: (struct.new $A
1910+
;; CHECK-NEXT: (local.get $B)
1911+
;; CHECK-NEXT: )
1912+
;; CHECK-NEXT: )
1913+
;; CHECK-NEXT: )
1914+
(func $test (param $B (ref null $B))
1915+
(drop
1916+
;; This requires B <: A.
1917+
(struct.new $A
1918+
(local.get $B)
1919+
)
1920+
)
1921+
)
1922+
)

0 commit comments

Comments
 (0)