diff --git a/src/passes/opt-utils.h b/src/passes/opt-utils.h index 9bc81c3827f..1945167b075 100644 --- a/src/passes/opt-utils.h +++ b/src/passes/opt-utils.h @@ -37,7 +37,7 @@ inline void optimizeAfterInlining(const std::unordered_set& funcs, // save the full list of functions on the side std::vector> 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& funcs, func.release(); } all.swap(module->functions); - module->updateMaps(); + module->updateFunctionsMap(); } struct FunctionRefReplacer diff --git a/src/wasm.h b/src/wasm.h index d776ec9aa6f..dd989602ace 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -2239,6 +2239,7 @@ class Module { void removeGlobals(std::function pred); void removeTags(std::function pred); + void updateFunctionsMap(); void updateDataSegmentsMap(); void updateMaps(); diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp index 54e9dd1422a..b21c1849a31 100644 --- a/src/wasm/wasm.cpp +++ b/src/wasm/wasm.cpp @@ -1568,6 +1568,13 @@ void Module::removeTags(std::function 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();