From 710bf4eca962cdab46f3d73c376fb9e23a5874e8 Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Tue, 19 May 2026 05:13:54 +0000 Subject: [PATCH 1/3] [wasm-split] Tidy up indirectCallsToSecondaryFunctions (NFC) This avoids computing repeated expression multiple times and removes an unnecessary if condition. --- src/ir/module-splitting.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/ir/module-splitting.cpp b/src/ir/module-splitting.cpp index 9659121d6fe..0c0fd8cd338 100644 --- a/src/ir/module-splitting.cpp +++ b/src/ir/module-splitting.cpp @@ -997,18 +997,17 @@ void ModuleSplitter::indirectCallsToSecondaryFunctions() { // Return if the current module is the same module as the call's target, // because we don't need a call_indirect within the same module. Module* currModule = getModule(); - if (currModule != &parent.primary && - parent.secondaries.at(parent.funcToSecondaryIndex.at(curr->target)) - .get() == currModule) { + Module* calleeModule = + parent.secondaries.at(parent.funcToSecondaryIndex.at(curr->target)) + .get(); + if (calleeModule == currModule) { return; } - Builder builder(*getModule()); - Index secIndex = parent.funcToSecondaryIndex.at(curr->target); - auto* func = parent.secondaries.at(secIndex)->getFunction(curr->target); + Builder builder(*currModule); + auto* func = calleeModule->getFunction(curr->target); auto tableSlot = parent.tableManager.getSlot(curr->target, func->type.getHeapType()); - replaceCurrent( builder.makeCallIndirect(tableSlot.tableName, tableSlot.makeExpr(parent.primary), From 5e14f7e4b4079299e9f901c5b2ea3a78e090ec78 Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Tue, 19 May 2026 05:25:30 +0000 Subject: [PATCH 2/3] cosmetic --- src/ir/module-splitting.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ir/module-splitting.cpp b/src/ir/module-splitting.cpp index 0c0fd8cd338..d6cfe2eda98 100644 --- a/src/ir/module-splitting.cpp +++ b/src/ir/module-splitting.cpp @@ -1000,7 +1000,7 @@ void ModuleSplitter::indirectCallsToSecondaryFunctions() { Module* calleeModule = parent.secondaries.at(parent.funcToSecondaryIndex.at(curr->target)) .get(); - if (calleeModule == currModule) { + if (currModule == calleeModule) { return; } From 1224c58cd4854e5a25916af1400e720503bb257a Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Tue, 19 May 2026 05:43:57 +0000 Subject: [PATCH 3/3] drive-by NFC fix --- src/ir/module-splitting.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ir/module-splitting.cpp b/src/ir/module-splitting.cpp index d6cfe2eda98..6b233c5e624 100644 --- a/src/ir/module-splitting.cpp +++ b/src/ir/module-splitting.cpp @@ -1150,9 +1150,9 @@ void ModuleSplitter::setupTablePatching() { secondary.getGlobalOrNull(tableManager.activeBase.global); if (!secondaryGlobal) { secondaryGlobal = ModuleUtils::copyGlobal(primaryGlobal, secondary); + makeImportExport( + *primaryGlobal, *secondaryGlobal, "global", ExternalKind::Global); } - makeImportExport( - *primaryGlobal, *secondaryGlobal, "global", ExternalKind::Global); assert(tableManager.activeTableSegments.size() == 1 && "Unexpected number of segments with non-const base");