[clang] [llvm] [ARM] Fix musttail calls (PR #109943)

Reid Kleckner via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 25 14:40:29 PDT 2024


================
@@ -12658,10 +12658,10 @@ This instruction requires several arguments:
       the return value of the callee is returned to the caller's caller, even
       if a void return type is in use.
 
-   Both markers imply that the callee does not access allocas from the caller.
-   The ``tail`` marker additionally implies that the callee does not access
-   varargs from the caller. Calls marked ``musttail`` must obey the following
-   additional  rules:
+   Both markers imply that the callee does not access allocas or ``byval``
+   arguments from the caller. The ``tail`` marker additionally implies that the
----------------
rnk wrote:

I think you want to say that this case is not supported:
```
struct ByVal { int large[5]; };
void f(ByVal*);
void g(ByVal o) {
  [[clang::musttail]] f(&o);
}
```
The LangRef needs to permit *forwarding* cases like this, though:
```
struct ByVal { int large[5]; };
void f(ByVal a, ByVal b);
void g(ByVal a, ByVal b) {
  [[clang::musttail]] f(b, a);
}
```

We can make this work by copying the arguments out and back in before tearing down the call frame.

Can you please clarify? 

https://github.com/llvm/llvm-project/pull/109943


More information about the cfe-commits mailing list