[llvm] e2b9318 - [PowerPC] Only make copies of registers on stack in variadic function when va_start is called
Kai Luo via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 9 00:39:57 PDT 2020
Author: Kai Luo
Date: 2020-07-09T07:18:17Z
New Revision: e2b93185b84bd88264377f785465933a89faa4f8
URL: https://github.com/llvm/llvm-project/commit/e2b93185b84bd88264377f785465933a89faa4f8
DIFF: https://github.com/llvm/llvm-project/commit/e2b93185b84bd88264377f785465933a89faa4f8.diff
LOG: [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
Added:
Modified:
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/test/CodeGen/PowerPC/legalize-vaarg.ll
llvm/test/CodeGen/PowerPC/ppc64-varargs.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index ff8e2382ec65..229c5a76010c 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -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
diff erent 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(
diff --git a/llvm/test/CodeGen/PowerPC/legalize-vaarg.ll b/llvm/test/CodeGen/PowerPC/legalize-vaarg.ll
index 296dea2f1f21..d937acc09c64 100644
--- a/llvm/test/CodeGen/PowerPC/legalize-vaarg.ll
+++ b/llvm/test/CodeGen/PowerPC/legalize-vaarg.ll
@@ -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
diff --git a/llvm/test/CodeGen/PowerPC/ppc64-varargs.ll b/llvm/test/CodeGen/PowerPC/ppc64-varargs.ll
index 56816aee6704..5aeedbf13e0b 100644
--- a/llvm/test/CodeGen/PowerPC/ppc64-varargs.ll
+++ b/llvm/test/CodeGen/PowerPC/ppc64-varargs.ll
@@ -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
More information about the llvm-commits
mailing list