diff options
author | Sam Clegg <sbc@chromium.org> | 2020-01-23 17:44:55 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-23 17:44:55 -0800 |
commit | b880950c56673b36127438d432f0a24eca92c773 (patch) | |
tree | 92eefd8285dea2f55e3939b84c4efc20dd7c9bdd /src | |
parent | dbb33e7dcc514b19bf91518f47fa46a47cd484a3 (diff) | |
download | binaryen-b880950c56673b36127438d432f0a24eca92c773.tar.gz binaryen-b880950c56673b36127438d432f0a24eca92c773.tar.bz2 binaryen-b880950c56673b36127438d432f0a24eca92c773.zip |
Consistent detection of invoke_ functions in PostEmscripten.cpp (#2619)
We should be looking at the import name when determining if a function
is an invoke function.
This is a precursor to re-landing the fix for
https://github.com/emscripten-core/emscripten/issues/9950.
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/PostEmscripten.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/passes/PostEmscripten.cpp b/src/passes/PostEmscripten.cpp index 9d23a299c..e6eeb8e2a 100644 --- a/src/passes/PostEmscripten.cpp +++ b/src/passes/PostEmscripten.cpp @@ -34,7 +34,9 @@ namespace wasm { namespace { -static bool isInvoke(Name name) { return name.startsWith("invoke_"); } +static bool isInvoke(Function* F) { + return F->imported() && F->module == ENV && F->base.startsWith("invoke_"); +} struct OptimizeCalls : public WalkerPass<PostWalker<OptimizeCalls>> { bool isFunctionParallel() override { return true; } @@ -123,7 +125,7 @@ struct PostEmscripten : public Pass { // First, check if this code even uses invokes. bool hasInvokes = false; for (auto& imp : module->functions) { - if (imp->imported() && imp->module == ENV && isInvoke(imp->base)) { + if (isInvoke(imp.get())) { hasInvokes = true; } } @@ -169,7 +171,8 @@ struct PostEmscripten : public Pass { : map(map), flatTable(flatTable) {} void visitCall(Call* curr) { - if (isInvoke(curr->target)) { + auto* target = getModule()->getFunction(curr->target); + if (isInvoke(target)) { // The first operand is the function pointer index, which must be // constant if we are to optimize it statically. if (auto* index = curr->operands[0]->dynCast<Const>()) { |