Skip to content

Commit e6fcb78

Browse files
committed
handle try catch
1 parent cd0a99e commit e6fcb78

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/passes/TailCall.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace wasm {
88

99
namespace {
1010

11-
struct Finder : PostWalker<Finder> {
11+
struct Finder : TryDepthWalker<Finder> {
1212
std::vector<Call*> tailCalls;
1313
std::vector<CallIndirect*> tailCallIndirects;
1414
void visitFunction(Function* curr) { checkTailCall(curr->body); }
@@ -19,6 +19,10 @@ struct Finder : PostWalker<Finder> {
1919
if (expr == nullptr) {
2020
return;
2121
}
22+
if (tryDepth > 0) {
23+
// We are in a try block, so we cannot optimize tail calls.
24+
return;
25+
}
2226
if (auto* call = expr->dynCast<Call>()) {
2327
if (!call->isReturn && call->type == getFunction()->getResults()) {
2428
tailCalls.push_back(call);

0 commit comments

Comments
 (0)