diff options
Diffstat (limited to 'src/wasm/wasm-emscripten.cpp')
-rw-r--r-- | src/wasm/wasm-emscripten.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/wasm/wasm-emscripten.cpp b/src/wasm/wasm-emscripten.cpp index bba638cf2..fea5048f6 100644 --- a/src/wasm/wasm-emscripten.cpp +++ b/src/wasm/wasm-emscripten.cpp @@ -477,12 +477,16 @@ std::string EmscriptenGlueGenerator::generateEmscriptenMetadata() { if (exp) { if (exp->kind == ExternalKind::Function) { auto* main = wasm.getFunction(exp->value); - mainReadsParams = true; - // If main does not read its parameters, it will just be a stub that - // calls __original_main (which has no parameters). - if (auto* call = main->body->dynCast<Call>()) { - if (call->operands.empty()) { - mainReadsParams = false; + mainReadsParams = main->getNumParams() > 0; + if (mainReadsParams) { + // Main could also be stub that just calls __original_main with + // no parameters. + // TODO(sbc): Remove this once https://reviews.llvm.org/D75277 + // lands. + if (auto* call = main->body->dynCast<Call>()) { + if (call->operands.empty()) { + mainReadsParams = false; + } } } } |