[llvm] [RISCV] Compute VarArgsSaveSize even for the all register allocated case. NFC (PR #74209)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 2 14:18:30 PST 2023
https://github.com/topperc created https://github.com/llvm/llvm-project/pull/74209
The computation we use for computing the size already returns 0 when all registers are allocated. We don't need an if to set it to 0.
Use the size being 0 to check for whether we need to spill registers or not.
I have another change I want to make to this code, but this change seemed to stand on its own. I left the curly braces since I need them for the other change.
>From ea7ab511b4197240f84649af23967190cd974670 Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Sat, 2 Dec 2023 14:12:30 -0800
Subject: [PATCH] [RISCV] Compute VarArgsSaveSize even for the all register
allocated case. NFC
The computation we use for computing the size already returns 0
when all registers are allocated. We don't need an if to set it to 0.
Use the size being 0 to check for whether we need to spill registers
or not.
I have another change I want to make to this code, but this change
seemed to stand on its own. I left the curly braces since I need
them for the other change.
---
llvm/lib/Target/RISCV/GISel/RISCVCallLowering.cpp | 8 ++++----
llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 7 +++----
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/llvm/lib/Target/RISCV/GISel/RISCVCallLowering.cpp b/llvm/lib/Target/RISCV/GISel/RISCVCallLowering.cpp
index bd602635dd5f7..9e96fba069c4e 100644
--- a/llvm/lib/Target/RISCV/GISel/RISCVCallLowering.cpp
+++ b/llvm/lib/Target/RISCV/GISel/RISCVCallLowering.cpp
@@ -441,14 +441,14 @@ void RISCVCallLowering::saveVarArgRegisters(
// Offset of the first variable argument from stack pointer, and size of
// the vararg save area. For now, the varargs save area is either zero or
// large enough to hold a0-a7.
- int VaArgOffset, VarArgsSaveSize;
+ int VaArgOffset;
+ int VarArgsSaveSize = XLenInBytes * (ArgRegs.size() - Idx);
+
// If all registers are allocated, then all varargs must be passed on the
// stack and we don't need to save any argregs.
- if (ArgRegs.size() == Idx) {
+ if (VarArgsSaveSize == 0) {
VaArgOffset = Assigner.StackSize;
- VarArgsSaveSize = 0;
} else {
- VarArgsSaveSize = XLenInBytes * (ArgRegs.size() - Idx);
VaArgOffset = -VarArgsSaveSize;
}
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 241bc96766f29..cf1b11c14b6d0 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -17694,15 +17694,14 @@ SDValue RISCVTargetLowering::LowerFormalArguments(
// Offset of the first variable argument from stack pointer, and size of
// the vararg save area. For now, the varargs save area is either zero or
// large enough to hold a0-a7.
- int VaArgOffset, VarArgsSaveSize;
+ int VaArgOffset;
+ int VarArgsSaveSize = XLenInBytes * (ArgRegs.size() - Idx);
// If all registers are allocated, then all varargs must be passed on the
// stack and we don't need to save any argregs.
- if (ArgRegs.size() == Idx) {
+ if (VarArgsSaveSize == 0) {
VaArgOffset = CCInfo.getStackSize();
- VarArgsSaveSize = 0;
} else {
- VarArgsSaveSize = XLenInBytes * (ArgRegs.size() - Idx);
VaArgOffset = -VarArgsSaveSize;
}
More information about the llvm-commits
mailing list