summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/tools/wasm-reduce.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/tools/wasm-reduce.cpp b/src/tools/wasm-reduce.cpp
index 8e3368c40..78425bf80 100644
--- a/src/tools/wasm-reduce.cpp
+++ b/src/tools/wasm-reduce.cpp
@@ -414,8 +414,11 @@ struct Reducer : public WalkerPass<PostWalker<Reducer, UnifiedExpressionVisitor<
functionNames.push_back(func->name);
}
size_t skip = 1;
+ // If we just removed some functions in the previous iteration, keep trying to remove more
+ // as this is one of the most efficient ways to reduce.
+ bool justRemoved = false;
for (size_t i = 0; i < functionNames.size(); i++) {
- if (!shouldTryToReduce(std::max((factor / 100) + 1, 1000))) continue;
+ if (!justRemoved && !shouldTryToReduce(std::max((factor / 100) + 1, 1000))) continue;
std::vector<Name> names;
for (size_t j = 0; names.size() < skip && i + j < functionNames.size(); j++) {
auto name = functionNames[i + j];
@@ -425,7 +428,8 @@ struct Reducer : public WalkerPass<PostWalker<Reducer, UnifiedExpressionVisitor<
}
if (names.size() == 0) continue;
std::cout << "| try to remove " << names.size() << " functions (skip: " << skip << ")\n";
- if (tryToRemoveFunctions(names)) {
+ justRemoved = tryToRemoveFunctions(names);
+ if (justRemoved) {
noteReduction(names.size());
i += skip;
skip = std::min(size_t(factor), 2 * skip);