From b4503a23f28551acfc725a6e3aba2d72036eff4f Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 6 Dec 2018 09:49:05 -0800 Subject: Handle missing function in renameFunctions (#1808) In this case simple update all the uses of the missing function. This fixed the current emscripten failures. --- src/ir/module-utils.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') 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 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. -- cgit v1.2.3