Skip to content
Closed
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
19 changes: 16 additions & 3 deletions src/ir/module-splitting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,13 +515,26 @@ void ModuleSplitter::exportImportFunction(Name funcName,

void ModuleSplitter::moveSecondaryFunctions() {
// Move the specified functions from the primary to the secondary modules.
std::unordered_map<Name, std::unique_ptr<Function>> movedFunctions;
auto& functions = primary.functions;
for (auto& func : functions) {
if (allSecondaryFuncs.count(func->name)) {
movedFunctions[func->name] = std::move(func);
}
}
functions.erase(
std::remove_if(functions.begin(),
functions.end(),
[](const std::unique_ptr<Function>& func) { return !func; }),
functions.end());
primary.updateFunctionsMap();

for (auto& funcNames : config.secondaryFuncs) {
auto secondary = initSecondary(primary);
for (auto funcName : funcNames) {
if (allSecondaryFuncs.count(funcName)) {
auto* func = primary.getFunction(funcName);
ModuleUtils::copyFunction(func, *secondary);
primary.removeFunction(funcName);
assert(movedFunctions.count(funcName));
secondary->addFunction(std::move(movedFunctions[funcName]));
funcToSecondaryIndex[funcName] = secondaries.size();
}
}
Expand Down
Loading