From 989ee9bca6228e31e9ea1128d167f498cd931766 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 19 Mar 2026 13:42:39 -0700 Subject: [PATCH 1/2] fix --- src/ir/type-updating.h | 2 +- test/lit/passes/type-merging-cont.wast | 27 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/ir/type-updating.h b/src/ir/type-updating.h index 52a3e09027f..0e050becc59 100644 --- a/src/ir/type-updating.h +++ b/src/ir/type-updating.h @@ -502,7 +502,7 @@ class TypeMapper : public GlobalTypeRewriter { HeapType getNewHeapType(HeapType type) { auto iter = mapping.find(type); if (iter != mapping.end()) { - return iter->second; + type = iter->second; } return getTempHeapType(type); } diff --git a/test/lit/passes/type-merging-cont.wast b/test/lit/passes/type-merging-cont.wast index c7b57669d17..3acacc047f5 100644 --- a/test/lit/passes/type-merging-cont.wast +++ b/test/lit/passes/type-merging-cont.wast @@ -45,3 +45,30 @@ ) ) +;; A chain of continuations. During merging here we map types that are being +;; rebuilt, and should not error while doing so. We can merge the function +;; types, and all but two of the continuations. +(module + (rec + ;; CHECK: (rec + ;; CHECK-NEXT: (type $func (sub (func))) + (type $func (sub (func))) + ;; CHECK: (type $cont (sub (cont $func))) + (type $cont (sub (cont $func))) + (type $contB (sub $cont (cont $func))) + (type $contC (sub $contB (cont $func))) + (type $funcB (sub $func (func))) + ;; CHECK: (type $contD (sub final $cont (cont $func))) + (type $contD (sub final $contC (cont $funcB))) + ) + + ;; CHECK: (type $3 (func)) + + ;; CHECK: (func $use-rec-group (type $3) + ;; CHECK-NEXT: (local $t (ref null $contD)) + ;; CHECK-NEXT: ) + (func $use-rec-group + (local $t (ref null $contD)) + ) +) + From dfb13eaf7d423d0d486805774b36d4a0ecc29a4e Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 19 Mar 2026 14:04:08 -0700 Subject: [PATCH 2/2] improve test --- test/lit/passes/type-merging-cont.wast | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/test/lit/passes/type-merging-cont.wast b/test/lit/passes/type-merging-cont.wast index 3acacc047f5..a9c479f5a8c 100644 --- a/test/lit/passes/type-merging-cont.wast +++ b/test/lit/passes/type-merging-cont.wast @@ -64,11 +64,21 @@ ;; CHECK: (type $3 (func)) - ;; CHECK: (func $use-rec-group (type $3) - ;; CHECK-NEXT: (local $t (ref null $contD)) + ;; CHECK: (func $uses (type $3) + ;; CHECK-NEXT: (local $func (ref $func)) + ;; CHECK-NEXT: (local $funcB (ref $func)) + ;; CHECK-NEXT: (local $cont (ref $cont)) + ;; CHECK-NEXT: (local $contB (ref $cont)) + ;; CHECK-NEXT: (local $contC (ref $cont)) + ;; CHECK-NEXT: (local $contD (ref $contD)) ;; CHECK-NEXT: ) - (func $use-rec-group - (local $t (ref null $contD)) + (func $uses + (local $func (ref $func)) + (local $funcB (ref $funcB)) + (local $cont (ref $cont)) + (local $contB (ref $contB)) + (local $contC (ref $contC)) + (local $contD (ref $contD)) ) )