summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ir/module-utils.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/ir/module-utils.h b/src/ir/module-utils.h
index 851b926c6..a77adf293 100644
--- a/src/ir/module-utils.h
+++ b/src/ir/module-utils.h
@@ -135,8 +135,12 @@ template<typename T>
inline void renameFunctions(Module& wasm, T& map) {
// Update the function itself.
for (auto& pair : map) {
- assert(!wasm.getFunctionOrNull(pair.second));
- wasm.getFunction(pair.first)->name = pair.second;
+ if (Function* F = wasm.getFunctionOrNull(pair.first)) {
+ // In some cases t he function itself might have been removed already
+ // and we just want to rename all its (now invalid) uses.
+ assert(!wasm.getFunctionOrNull(pair.second));
+ F->name = pair.second;
+ }
}
wasm.updateMaps();
// Update other global things.