[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 =
----------------
topperc wrote:

Don't use `auto` to replace `bool`. It goes against our rules for use of `auto`. https://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable

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


More information about the llvm-commits mailing list