diff options
author | Alon Zakai <alonzakai@gmail.com> | 2019-03-06 16:02:34 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-06 16:02:34 -0800 |
commit | 8b5b85463cd5f5fcfec4d0bc6acb52f2acb30d79 (patch) | |
tree | d568a0b58e4d04d7d725aff1e573205bef2a00a9 /src | |
parent | 6657500c924bdd40c8abf8c6a9655654b9342eca (diff) | |
download | binaryen-8b5b85463cd5f5fcfec4d0bc6acb52f2acb30d79.tar.gz binaryen-8b5b85463cd5f5fcfec4d0bc6acb52f2acb30d79.tar.bz2 binaryen-8b5b85463cd5f5fcfec4d0bc6acb52f2acb30d79.zip |
Don't create already-existing dynCalls (#1932)
This can happen in emscripten if we run fpcast-emu after previous passes created dynCalls already. If so, it's fine to just do nothing.
Fixes emscripten-core/emscripten#8229
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm/wasm-emscripten.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/wasm/wasm-emscripten.cpp b/src/wasm/wasm-emscripten.cpp index f7b7213d9..390266d44 100644 --- a/src/wasm/wasm-emscripten.cpp +++ b/src/wasm/wasm-emscripten.cpp @@ -182,12 +182,18 @@ void EmscriptenGlueGenerator::generateDynCallThunks() { for (const auto& indirectFunc : tableSegmentData) { std::string sig = getSig(wasm.getFunction(indirectFunc)); auto* funcType = ensureFunctionType(sig, &wasm); - if (!sigs.insert(sig).second) continue; // Sig is already in the set + if (!sigs.insert(sig).second) { + continue; // sig is already in the set + } + Name name = std::string("dynCall_") + sig; + if (wasm.getFunctionOrNull(name) || wasm.getExportOrNull(name)) { + continue; // module already contains this dyncall + } std::vector<NameType> params; params.emplace_back("fptr", i32); // function pointer param int p = 0; for (const auto& ty : funcType->params) params.emplace_back(std::to_string(p++), ty); - Function* f = builder.makeFunction(std::string("dynCall_") + sig, std::move(params), funcType->result, {}); + Function* f = builder.makeFunction(name, std::move(params), funcType->result, {}); Expression* fptr = builder.makeGetLocal(0, i32); std::vector<Expression*> args; for (unsigned i = 0; i < funcType->params.size(); ++i) { |