summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2023-04-05 12:24:30 -0700
committerGitHub <noreply@github.com>2023-04-05 12:24:30 -0700
commit30097e5da0a99fa42dac1af1efeb435c5f15e1f0 (patch)
treec752d76f012445d092458ebfa79450bbb7a0d432 /src
parent9ee557aa7fbb494b222c4692cbef1c2be983e532 (diff)
downloadbinaryen-30097e5da0a99fa42dac1af1efeb435c5f15e1f0.tar.gz
binaryen-30097e5da0a99fa42dac1af1efeb435c5f15e1f0.tar.bz2
binaryen-30097e5da0a99fa42dac1af1efeb435c5f15e1f0.zip
Only update functions in optimizeAfterInlining() (#5624)
This saves the work of freeing and allocating for all the other maps. This is a code path that is used by several passes so it showed up in profiling for #5561
Diffstat (limited to 'src')
-rw-r--r--src/passes/opt-utils.h4
-rw-r--r--src/wasm.h1
-rw-r--r--src/wasm/wasm.cpp12
3 files changed, 11 insertions, 6 deletions
diff --git a/src/passes/opt-utils.h b/src/passes/opt-utils.h
index 9bc81c382..1945167b0 100644
--- a/src/passes/opt-utils.h
+++ b/src/passes/opt-utils.h
@@ -37,7 +37,7 @@ inline void optimizeAfterInlining(const std::unordered_set<Function*>& funcs,
// save the full list of functions on the side
std::vector<std::unique_ptr<Function>> all;
all.swap(module->functions);
- module->updateMaps();
+ module->updateFunctionsMap();
for (auto& func : funcs) {
module->addFunction(func);
}
@@ -53,7 +53,7 @@ inline void optimizeAfterInlining(const std::unordered_set<Function*>& funcs,
func.release();
}
all.swap(module->functions);
- module->updateMaps();
+ module->updateFunctionsMap();
}
struct FunctionRefReplacer
diff --git a/src/wasm.h b/src/wasm.h
index d776ec9aa..dd989602a 100644
--- a/src/wasm.h
+++ b/src/wasm.h
@@ -2239,6 +2239,7 @@ public:
void removeGlobals(std::function<bool(Global*)> pred);
void removeTags(std::function<bool(Tag*)> pred);
+ void updateFunctionsMap();
void updateDataSegmentsMap();
void updateMaps();
diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp
index 54e9dd142..b21c1849a 100644
--- a/src/wasm/wasm.cpp
+++ b/src/wasm/wasm.cpp
@@ -1568,6 +1568,13 @@ void Module::removeTags(std::function<bool(Tag*)> pred) {
removeModuleElements(tags, tagsMap, pred);
}
+void Module::updateFunctionsMap() {
+ functionsMap.clear();
+ for (auto& curr : functions) {
+ functionsMap[curr->name] = curr.get();
+ }
+}
+
void Module::updateDataSegmentsMap() {
dataSegmentsMap.clear();
for (auto& curr : dataSegments) {
@@ -1576,10 +1583,7 @@ void Module::updateDataSegmentsMap() {
}
void Module::updateMaps() {
- functionsMap.clear();
- for (auto& curr : functions) {
- functionsMap[curr->name] = curr.get();
- }
+ updateFunctionsMap();
exportsMap.clear();
for (auto& curr : exports) {
exportsMap[curr->name] = curr.get();