1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-02-01 05:01:59 +01:00

[PowerPC] Only make copies of registers on stack in variadic function when va_start is called

On PPC64, for a variadic function, if va_start is not called, it won't
access any variadic argument on stack, thus we can save stores of
registers used to pass arguments.

Differential Revision: https://reviews.llvm.org/D82361
This commit is contained in:
Kai Luo 2020-07-09 06:51:49 +00:00
parent b4bde7a6b6
commit 8f0afb6658
3 changed files with 5 additions and 32 deletions

View File

@ -4299,7 +4299,11 @@ SDValue PPCTargetLowering::LowerFormalArguments_64SVR4(
// If the function takes variable number of arguments, make a frame index for
// the start of the first vararg value... for expansion of llvm.va_start.
if (isVarArg) {
// On ELFv2ABI spec, it writes:
// C programs that are intended to be *portable* across different compilers
// and architectures must use the header file <stdarg.h> to deal with variable
// argument lists.
if (isVarArg && MFI.hasVAStart()) {
int Depth = ArgOffset;
FuncInfo->setVarArgsFrameIndex(

View File

@ -6,13 +6,6 @@ define <8 x i32> @test_large_vec_vaarg(i32 %n, ...) {
; BE-LABEL: test_large_vec_vaarg:
; BE: # %bb.0:
; BE-NEXT: ld 3, -8(1)
; BE-NEXT: std 4, 56(1)
; BE-NEXT: std 5, 64(1)
; BE-NEXT: std 6, 72(1)
; BE-NEXT: std 7, 80(1)
; BE-NEXT: std 8, 88(1)
; BE-NEXT: std 9, 96(1)
; BE-NEXT: std 10, 104(1)
; BE-NEXT: addi 3, 3, 15
; BE-NEXT: rldicr 3, 3, 0, 59
; BE-NEXT: addi 4, 3, 16
@ -28,15 +21,8 @@ define <8 x i32> @test_large_vec_vaarg(i32 %n, ...) {
; LE-LABEL: test_large_vec_vaarg:
; LE: # %bb.0:
; LE-NEXT: ld 3, -8(1)
; LE-NEXT: std 4, 40(1)
; LE-NEXT: std 5, 48(1)
; LE-NEXT: std 6, 56(1)
; LE-NEXT: std 7, 64(1)
; LE-NEXT: addi 3, 3, 15
; LE-NEXT: rldicr 3, 3, 0, 59
; LE-NEXT: std 8, 72(1)
; LE-NEXT: std 9, 80(1)
; LE-NEXT: std 10, 88(1)
; LE-NEXT: addi 4, 3, 31
; LE-NEXT: addi 5, 3, 16
; LE-NEXT: rldicr 4, 4, 0, 59

View File

@ -7,29 +7,12 @@
define i32 @f(...) nounwind {
; BE-LABEL: f:
; BE: # %bb.0: # %entry
; BE-NEXT: mr r11, r3
; BE-NEXT: li r3, 0
; BE-NEXT: std r11, 48(r1)
; BE-NEXT: std r4, 56(r1)
; BE-NEXT: std r5, 64(r1)
; BE-NEXT: std r6, 72(r1)
; BE-NEXT: std r7, 80(r1)
; BE-NEXT: std r8, 88(r1)
; BE-NEXT: std r9, 96(r1)
; BE-NEXT: std r10, 104(r1)
; BE-NEXT: blr
;
; LE-LABEL: f:
; LE: # %bb.0: # %entry
; LE-NEXT: std r3, 32(r1)
; LE-NEXT: li r3, 0
; LE-NEXT: std r4, 40(r1)
; LE-NEXT: std r5, 48(r1)
; LE-NEXT: std r6, 56(r1)
; LE-NEXT: std r7, 64(r1)
; LE-NEXT: std r8, 72(r1)
; LE-NEXT: std r9, 80(r1)
; LE-NEXT: std r10, 88(r1)
; LE-NEXT: blr
entry:
ret i32 0