summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2018-12-06 09:49:05 -0800
committerGitHub <noreply@github.com>2018-12-06 09:49:05 -0800
commitb4503a23f28551acfc725a6e3aba2d72036eff4f (patch)
tree99854b2e7b2da1146570a87c5e90bb08a875a49c /src
parent4c764d52b1e734c8dad295e1c970007512794bf6 (diff)
downloadbinaryen-b4503a23f28551acfc725a6e3aba2d72036eff4f.tar.gz
binaryen-b4503a23f28551acfc725a6e3aba2d72036eff4f.tar.bz2
binaryen-b4503a23f28551acfc725a6e3aba2d72036eff4f.zip
Handle missing function in renameFunctions (#1808)
In this case simple update all the uses of the missing function. This fixed the current emscripten failures.
Diffstat (limited to 'src')
-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.