Skip to content

Commit 2579fa3

Browse files
authored
Fix TypeMapper::getNewHeapType() on types being rebuilt (#8499)
When we find a type in the mapping, we still need to get its temp type, as it may be in the process of being rebuilt.
1 parent 5646ea6 commit 2579fa3

2 files changed

Lines changed: 38 additions & 1 deletion

File tree

src/ir/type-updating.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ class TypeMapper : public GlobalTypeRewriter {
502502
HeapType getNewHeapType(HeapType type) {
503503
auto iter = mapping.find(type);
504504
if (iter != mapping.end()) {
505-
return iter->second;
505+
type = iter->second;
506506
}
507507
return getTempHeapType(type);
508508
}

test/lit/passes/type-merging-cont.wast

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,40 @@
4545
)
4646
)
4747

48+
;; A chain of continuations. During merging here we map types that are being
49+
;; rebuilt, and should not error while doing so. We can merge the function
50+
;; types, and all but two of the continuations.
51+
(module
52+
(rec
53+
;; CHECK: (rec
54+
;; CHECK-NEXT: (type $func (sub (func)))
55+
(type $func (sub (func)))
56+
;; CHECK: (type $cont (sub (cont $func)))
57+
(type $cont (sub (cont $func)))
58+
(type $contB (sub $cont (cont $func)))
59+
(type $contC (sub $contB (cont $func)))
60+
(type $funcB (sub $func (func)))
61+
;; CHECK: (type $contD (sub final $cont (cont $func)))
62+
(type $contD (sub final $contC (cont $funcB)))
63+
)
64+
65+
;; CHECK: (type $3 (func))
66+
67+
;; CHECK: (func $uses (type $3)
68+
;; CHECK-NEXT: (local $func (ref $func))
69+
;; CHECK-NEXT: (local $funcB (ref $func))
70+
;; CHECK-NEXT: (local $cont (ref $cont))
71+
;; CHECK-NEXT: (local $contB (ref $cont))
72+
;; CHECK-NEXT: (local $contC (ref $cont))
73+
;; CHECK-NEXT: (local $contD (ref $contD))
74+
;; CHECK-NEXT: )
75+
(func $uses
76+
(local $func (ref $func))
77+
(local $funcB (ref $funcB))
78+
(local $cont (ref $cont))
79+
(local $contB (ref $contB))
80+
(local $contC (ref $contC))
81+
(local $contD (ref $contD))
82+
)
83+
)
84+

0 commit comments

Comments
 (0)