Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/ir/type-updating.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,14 @@ void GlobalTypeRewriter::mapTypeNamesAndIndices(const TypeMap& oldToNewTypes) {
}
if (auto it = wasm.typeNames.find(old); it != wasm.typeNames.end()) {
auto& names = it->second;
newTypeNames[new_] = names;
auto [newIt, inserted] = newTypeNames.insert({new_, names});
if (!inserted) {
// Multiple old type names are being merged into the same new type.
// Deterministically keep the lesser name.
if (names.name.view() < newIt->second.name.view()) {
newIt->second = names;
}
}
// Use the existing name in the new type, as usually it completely
// replaces the old. Rename the old name in a unique way to avoid
// confusion in the case that it remains used.
Expand All @@ -437,9 +444,12 @@ void GlobalTypeRewriter::mapTypeNamesAndIndices(const TypeMap& oldToNewTypes) {
}
}
if (auto it = wasm.typeIndices.find(old); it != wasm.typeIndices.end()) {
// It's ok if we end up with duplicate indices. Ties will be resolved in
// some arbitrary manner.
newTypeIndices[new_] = it->second;
auto [newIt, inserted] = newTypeIndices.insert({new_, it->second});
if (!inserted) {
// Multiple old type indices are being merged into the same new type.
// Deterministically keep the lesser index.
newIt->second = std::min(newIt->second, it->second);
}
}
}
newTypeNames.merge(wasm.typeNames);
Expand Down
1 change: 1 addition & 0 deletions src/passes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ set(passes_SOURCES
LocalSubtyping.cpp
LogExecution.cpp
LoopInvariantCodeMotion.cpp
MakeSharedObjects.cpp
MarkJSCalled.cpp
Memory64Lowering.cpp
MemoryPacking.cpp
Expand Down
Loading
Loading