Skip to content

Conversation

@tlively
Copy link
Member

@tlively tlively commented Jan 13, 2026

ReorderTypes previously collected the module types and their counts,
even though it already extends GlobalTypeRewriter, which also collects
the module types in its constructor. Not only did this duplicate work,
it was also a subtle source of bugs because ReorderTypes and
GlobalTypeRewriter collected types slightly differently. ReorderTypes
collected the binary types and GlobalTypeRewriter collected the used IR
types. This could result in different types being collected for the same
multivalue control flow signatures, causing an assertion failure when
a type was seemingly missing from the collected info.

Fix the problem and make the pass more efficient by simply not
collecting the types two separate times.

ReorderTypes previously collected the module types and their counts,
even though it already extends GlobalTypeRewriter, which also collects
the module types in its constructor. Not only did this duplicate work,
it was also a subtle source of bugs because ReorderTypes and
GlobalTypeRewriter collected types slightly differently. ReorderTypes
collected the binary types and GlobalTypeRewriter collected the used IR
types. This could result in different types being collected for the same
multivalue control flow signatures, causing an assertion failure when
a type was seemingly missing from the collected info.

Fix the problem and make the pass more efficient by simply not
collecting the types two separate times.
@tlively tlively requested a review from kripken January 13, 2026 02:58
namespace {

struct ReorderingTypeRewriter : GlobalTypeRewriter {
using InfoMap = InsertOrderedMap<HeapType, ModuleUtils::HeapTypeInfo>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
using InfoMap = InsertOrderedMap<HeapType, ModuleUtils::HeapTypeInfo>;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants