diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/I64ToI32Lowering.cpp | 3 | ||||
-rw-r--r-- | src/passes/LogExecution.cpp | 3 | ||||
-rw-r--r-- | src/tools/wasm-reduce.cpp | 10 | ||||
-rw-r--r-- | src/wasm/wasm-emscripten.cpp | 3 |
4 files changed, 15 insertions, 4 deletions
diff --git a/src/passes/I64ToI32Lowering.cpp b/src/passes/I64ToI32Lowering.cpp index 697df1eef..9e6fd106b 100644 --- a/src/passes/I64ToI32Lowering.cpp +++ b/src/passes/I64ToI32Lowering.cpp @@ -175,6 +175,9 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> { } void visitFunction(Function* func) { + if (func->imported()) { + return; + } if (func->result == i64) { func->result = i32; // body may not have out param if it ends with control flow diff --git a/src/passes/LogExecution.cpp b/src/passes/LogExecution.cpp index 45a29eae9..65a802a2f 100644 --- a/src/passes/LogExecution.cpp +++ b/src/passes/LogExecution.cpp @@ -42,6 +42,9 @@ struct LogExecution : public WalkerPass<PostWalker<LogExecution>> { } void visitFunction(Function* curr) { + if (curr->imported()) { + return; + } curr->body = makeLogCall(curr->body); } diff --git a/src/tools/wasm-reduce.cpp b/src/tools/wasm-reduce.cpp index f31c11edd..bee6ba621 100644 --- a/src/tools/wasm-reduce.cpp +++ b/src/tools/wasm-reduce.cpp @@ -524,9 +524,11 @@ struct Reducer : public WalkerPass<PostWalker<Reducer, UnifiedExpressionVisitor< } void visitFunction(Function* curr) { - // extra chance to work on the function toplevel element, as if it can - // be reduced it's great - visitExpression(curr->body); + if (!curr->imported()) { + // extra chance to work on the function toplevel element, as if it can + // be reduced it's great + visitExpression(curr->body); + } // finish function funcsSeen++; static int last = 0; @@ -677,7 +679,7 @@ struct Reducer : public WalkerPass<PostWalker<Reducer, UnifiedExpressionVisitor< if (module->functions.size() == 1 && module->exports.empty() && module->table.segments.empty()) { auto* func = module->functions[0].get(); // We can't remove something that might have breaks to it. - if (!Properties::isNamedControlFlow(func->body)) { + if (!func->imported() && !Properties::isNamedControlFlow(func->body)) { auto funcType = func->type; auto funcResult = func->result; auto* funcBody = func->body; diff --git a/src/wasm/wasm-emscripten.cpp b/src/wasm/wasm-emscripten.cpp index 6667ac855..78d2d25c6 100644 --- a/src/wasm/wasm-emscripten.cpp +++ b/src/wasm/wasm-emscripten.cpp @@ -489,6 +489,9 @@ struct EmJsWalker : public PostWalker<EmJsWalker> { segmentOffsets(getSegmentOffsets(wasm)) { } void visitFunction(Function* curr) { + if (curr->imported()) { + return; + } if (!curr->name.startsWith(EM_JS_PREFIX.str)) { return; } |