[llvm] [RISCV] Support tail calls for functions with sret parameters (PR #223999)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 16 21:05:01 PDT 2026
================
@@ -27620,12 +27587,23 @@ bool RISCVTargetLowering::isEligibleForTailCallOptimization(
if (VA.getLocInfo() == CCValAssign::Indirect)
return false;
- // Do not tail call opt if either caller or callee uses struct return
- // semantics.
- auto IsCallerStructRet = Caller.hasStructRetAttr();
+ // If the callee has an sret parameter, conservatively require it to receive
+ // the caller's sret pointer. If only the caller has an sret parameter, treat
+ // that pointer like an ordinary pointer when passing call arguments.
+ // TODO: Support other sret buffers that outlive the caller, such as globals.
+ auto IsCallerStructRet =
+ !Caller.arg_empty() && Caller.getArg(0)->hasStructRetAttr();
----------------
topperc wrote:
Does `!Caller.arg_empty() && Caller.getArg(0)->hasStructRetAttr()` return something different than the original `Caller.hasStructRetAttr()`?
https://github.com/llvm/llvm-project/pull/223999
More information about the llvm-commits
mailing list