Skip to content

[wasm-split] Tidy up indirectCallsToSecondaryFunctions (NFC)#8726

Merged
aheejin merged 3 commits into
WebAssembly:mainfrom
aheejin:wasm_split_tidy
May 19, 2026
Merged

[wasm-split] Tidy up indirectCallsToSecondaryFunctions (NFC)#8726
aheejin merged 3 commits into
WebAssembly:mainfrom
aheejin:wasm_split_tidy

Conversation

@aheejin
Copy link
Copy Markdown
Member

@aheejin aheejin commented May 19, 2026

This avoids computing repeated expression multiple times and removes an unnecessary if condition.

This avoids computing repeated expression multiple times and removes an
unnecessary if condition.
@aheejin aheejin requested a review from tlively May 19, 2026 05:23
@aheejin aheejin requested a review from a team as a code owner May 19, 2026 05:23
// 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 &&
Copy link
Copy Markdown
Member Author

@aheejin aheejin May 19, 2026

Choose a reason for hiding this comment

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

This currModule != &parent.primary is not necessary because we already filter out when the callee's module is the primary module at the top of the function:

// Return if the call's target is not in one of the secondary module.
if (!parent.allSecondaryFuncs.contains(curr->target)) {
return;
}

So if currModule == calleeModule here, that means currModule is not a primary module anyway.

if (!secondaryGlobal) {
secondaryGlobal = ModuleUtils::copyGlobal(primaryGlobal, secondary);
makeImportExport(
*primaryGlobal, *secondaryGlobal, "global", ExternalKind::Global);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Drive-by NFC fix: This is only necessary when we copied the global. There is no harm in calling makeImportExport again on it though.

@aheejin aheejin requested a review from kripken May 19, 2026 20:52
@aheejin aheejin merged commit 5fcc1af into WebAssembly:main May 19, 2026
16 checks passed
@aheejin aheejin deleted the wasm_split_tidy branch May 19, 2026 21:37
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.

2 participants