================
@@ -5448,6 +5472,45 @@ static unsigned getMaxVectorWidth(const llvm::Type *Ty) {
   return MaxVectorWidth;
 }
 
+/// Returns the incoming llvm::Argument of the current function if this
+/// musttail call argument forwards an incoming Indirect parameter with a
+/// matching ABI shape; nullptr to fall through to the byval-temp path.
+/// Argument-side analog of a96c14eeb8fc (SRet musttail forwarding).
----------------
xroche wrote:

Dang indeed. I rewrote it in 99dfa79d0d3f to cover every case.

The new version routes each by-value struct argument through the matching 
incoming parameter. The incoming parameter's storage lives in the caller's 
caller's frame, so it should survive the tail call. If the source for that slot 
is already that pointer, then we pass it directly. Otherwise we copy the value 
into it

When more than one argument needs a copy, this is a little bit more messy: the 
writes are split in two passes.

- We capture every source value into a scratch buffer in our frame.
- We write each scratch into its destination.

The two passes matter for "swapped" cases like C(b, a), as writing b value into 
a storage would clobber the value the next slot still needs to read

This could probably be optimized, as we should NOT need to copy for cases like 
(b, a), but unsure if handling this is worth the complexity ?


https://github.com/llvm/llvm-project/pull/199351
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to