diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp index 02db1b142a22b..ec745ebabb4f6 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp @@ -1211,6 +1211,15 @@ WebAssemblyTargetLowering::LowerCall(CallLoweringInfo &CLI, } } } + + // If outgoing arguments are passed via the stack, we cannot tail call + for (const ISD::OutputArg &Out : CLI.Outs) { + if (Out.Flags.isByVal() && Out.Flags.getByValSize() != 0) { + NoTail( + "WebAssembly does not support tail calling with stack arguments"); + break; + } + } } SmallVectorImpl &Ins = CLI.Ins;