[llvm] [X86] Elect to tail call when `sret` ptr is passed to the callee (PR #146575)

Antonio Frighetto via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 3 07:40:12 PDT 2025


================
@@ -725,27 +662,17 @@ define fastcc void @t21_sret_to_sret_more_args2(ptr noalias sret(%struct.foo) %a
 ;
 ; X64-LABEL: t21_sret_to_sret_more_args2:
 ; X64:       # %bb.0:
-; X64-NEXT:    pushq %rbx
 ; X64-NEXT:    movl %esi, %eax
-; X64-NEXT:    movq %rdi, %rbx
 ; X64-NEXT:    movl %edx, %esi
 ; X64-NEXT:    movl %eax, %edx
-; X64-NEXT:    callq f_sret at PLT
-; X64-NEXT:    movq %rbx, %rax
-; X64-NEXT:    popq %rbx
-; X64-NEXT:    retq
+; X64-NEXT:    jmp f_sret at PLT # TAILCALL
 ;
 ; X32-LABEL: t21_sret_to_sret_more_args2:
 ; X32:       # %bb.0:
-; X32-NEXT:    pushq %rbx
 ; X32-NEXT:    movl %esi, %eax
-; X32-NEXT:    movq %rdi, %rbx
 ; X32-NEXT:    movl %edx, %esi
 ; X32-NEXT:    movl %eax, %edx
-; X32-NEXT:    callq f_sret at PLT
-; X32-NEXT:    movl %ebx, %eax
-; X32-NEXT:    popq %rbx
-; X32-NEXT:    retq
+; X32-NEXT:    jmp f_sret at PLT # TAILCALL
----------------
antoniofrighetto wrote:

Added this one, and variants thereof, thanks (this was one above was already restrained by these lines:
https://github.com/llvm/llvm-project/blob/220a00239696257a02fe625a4819fcd038e9dd07/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp#L8905-L8909
).

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


More information about the llvm-commits mailing list