summaryrefslogtreecommitdiff
path: root/src/ir/module-splitting.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ir/module-splitting.cpp')
-rw-r--r--src/ir/module-splitting.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/ir/module-splitting.cpp b/src/ir/module-splitting.cpp
index adda1f4a6..777818689 100644
--- a/src/ir/module-splitting.cpp
+++ b/src/ir/module-splitting.cpp
@@ -316,6 +316,7 @@ struct ModuleSplitter {
void exportImportCalledPrimaryFunctions();
void setupTablePatching();
void shareImportableItems();
+ void removeUnusedSecondaryElements();
ModuleSplitter(Module& primary, const Config& config)
: config(config), secondaryPtr(initSecondary(primary)), primary(primary),
@@ -334,6 +335,7 @@ struct ModuleSplitter {
exportImportCalledPrimaryFunctions();
setupTablePatching();
shareImportableItems();
+ removeUnusedSecondaryElements();
}
};
@@ -872,6 +874,15 @@ void ModuleSplitter::shareImportableItems() {
}
}
+void ModuleSplitter::removeUnusedSecondaryElements() {
+ // TODO: It would be better to be more selective about only exporting and
+ // importing those items that the secondary module needs. This would reduce
+ // code size in the primary module as well.
+ PassRunner runner(&secondary);
+ runner.add("remove-unused-module-elements");
+ runner.run();
+}
+
} // anonymous namespace
Results splitFunctions(Module& primary, const Config& config) {