summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2024-09-17 13:59:17 -0700
committerGitHub <noreply@github.com>2024-09-17 13:59:17 -0700
commitda5646961c61f21dbb1d6218e370325ba43be9f0 (patch)
tree915c2853c377e6214199cb8e06997618518a7036 /src/tools
parentf9b64c8c5d9ad720304e101dc58790f3bbfdfc3c (diff)
downloadbinaryen-da5646961c61f21dbb1d6218e370325ba43be9f0.tar.gz
binaryen-da5646961c61f21dbb1d6218e370325ba43be9f0.tar.bz2
binaryen-da5646961c61f21dbb1d6218e370325ba43be9f0.zip
[wasm-split] Configure split functions rather than kept functions (#6949)
The configuration for the module splitting utility previous took a set of functions to keep in the primary module. Change it to take a list of functions to split into the secondary module instead. This improves the code quality in multi-split mode because it keeps stub functions generated by previous splits from being moved into secondary modules during later splits.
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/wasm-split/wasm-split.cpp11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/tools/wasm-split/wasm-split.cpp b/src/tools/wasm-split/wasm-split.cpp
index 1cfe5bad9..d26f6f1d6 100644
--- a/src/tools/wasm-split/wasm-split.cpp
+++ b/src/tools/wasm-split/wasm-split.cpp
@@ -221,7 +221,7 @@ void splitModule(const WasmSplitOptions& options) {
std::set<Name> splitFuncs;
if (options.profileFile.size()) {
- // Use the profile to set `keepFuncs`.
+ // Use the profile to set `keepFuncs` and `splitFuncs`.
uint64_t hash = hashFile(options.inputFiles[0]);
getFunctionsToKeepAndSplit(
wasm, hash, options.profileFile, keepFuncs, splitFuncs);
@@ -319,7 +319,7 @@ void splitModule(const WasmSplitOptions& options) {
// Actually perform the splitting
ModuleSplitting::Config config;
- config.primaryFuncs = std::move(keepFuncs);
+ config.secondaryFuncs = std::move(splitFuncs);
if (options.importNamespace.size()) {
config.importNamespace = options.importNamespace;
}
@@ -418,9 +418,6 @@ void multiSplitModule(const WasmSplitOptions& options) {
config.usePlaceholders = false;
config.importNamespace = "";
config.minimizeNewExportNames = true;
- for (auto& func : wasm.functions) {
- config.primaryFuncs.insert(func->name);
- }
for (auto& [mod, funcs] : moduleFuncs) {
if (options.verbose) {
std::cerr << "Splitting module " << mod << '\n';
@@ -428,9 +425,7 @@ void multiSplitModule(const WasmSplitOptions& options) {
if (!options.quiet && funcs.empty()) {
std::cerr << "warning: Module " << mod << " will be empty\n";
}
- for (auto& func : funcs) {
- config.primaryFuncs.erase(Name(func));
- }
+ config.secondaryFuncs = std::set<Name>(funcs.begin(), funcs.end());
auto splitResults = ModuleSplitting::splitFunctions(wasm, config);
// TODO: symbolMap, placeholderMap, emitModuleNames
// TODO: Support --emit-text and use .wast in that case.