From d40f9d4b179e209ba028afa39d33153113b137ba Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 3 Apr 2026 11:24:09 -0700 Subject: [PATCH 1/2] go --- src/ir/module-utils.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/ir/module-utils.cpp b/src/ir/module-utils.cpp index 01f4e1cbc65..51166e7ddb6 100644 --- a/src/ir/module-utils.cpp +++ b/src/ir/module-utils.cpp @@ -363,6 +363,14 @@ struct TypeInfos { } } void note(Type type) { + if (type.isNumber() || type.getID() == Type::none || + type.getID() == Type::unreachable) { + return; + } + if (type.isRef()) { + note(type.getHeapType()); + return; + } for (HeapType ht : type.getHeapTypeChildren()) { note(ht); } @@ -374,6 +382,14 @@ struct TypeInfos { } } void include(Type type) { + if (type.isNumber() || type.getID() == Type::none || + type.getID() == Type::unreachable) { + return; + } + if (type.isRef()) { + include(type.getHeapType()); + return; + } for (HeapType ht : type.getHeapTypeChildren()) { include(ht); } From b3a330944dd31fb518d0ffdc224ecdeed2d6bf72 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 3 Apr 2026 11:36:35 -0700 Subject: [PATCH 2/2] fast --- src/ir/module-utils.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/ir/module-utils.cpp b/src/ir/module-utils.cpp index 51166e7ddb6..6ee94d35d65 100644 --- a/src/ir/module-utils.cpp +++ b/src/ir/module-utils.cpp @@ -363,16 +363,15 @@ struct TypeInfos { } } void note(Type type) { - if (type.isNumber() || type.getID() == Type::none || - type.getID() == Type::unreachable) { - return; - } + // Handle the common case of a ref directly, to avoid a scan of children. if (type.isRef()) { note(type.getHeapType()); return; } - for (HeapType ht : type.getHeapTypeChildren()) { - note(ht); + if (type.isTuple()) { + for (HeapType ht : type.getHeapTypeChildren()) { + note(ht); + } } } // Ensure a type is included without increasing its count. @@ -382,16 +381,14 @@ struct TypeInfos { } } void include(Type type) { - if (type.isNumber() || type.getID() == Type::none || - type.getID() == Type::unreachable) { - return; - } if (type.isRef()) { include(type.getHeapType()); return; } - for (HeapType ht : type.getHeapTypeChildren()) { - include(ht); + if (type.isTuple()) { + for (HeapType ht : type.getHeapTypeChildren()) { + include(ht); + } } } void noteControlFlow(Signature sig) {