[llvm] [RISCV] Handle a split 2*XLen argument before pushing to PendingLocs. (PR #176183)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 15 07:28:54 PST 2026
https://github.com/topperc created https://github.com/llvm/llvm-project/pull/176183
Previously we pushed the second part to PendingLocs first, but never used it since the all values were still in variables.
>From 4412213c1767fc30ec6f9347b546d6bf6387e04e Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Wed, 14 Jan 2026 23:54:45 -0800
Subject: [PATCH] [RISCV] Handle a split 2*XLen argument before pushing to
PendingLocs.
Previously we pushed the second part to PendingLocs first, but
never used it since the all values were still in variables.
---
llvm/lib/Target/RISCV/RISCVCallingConv.cpp | 32 +++++++++++-----------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/llvm/lib/Target/RISCV/RISCVCallingConv.cpp b/llvm/lib/Target/RISCV/RISCVCallingConv.cpp
index 78f47794a5b66..ede67bd9bc90a 100644
--- a/llvm/lib/Target/RISCV/RISCVCallingConv.cpp
+++ b/llvm/lib/Target/RISCV/RISCVCallingConv.cpp
@@ -510,25 +510,11 @@ bool llvm::CC_RISCV(unsigned ValNo, MVT ValVT, MVT LocVT,
return false;
}
- // Split arguments might be passed indirectly, so keep track of the pending
- // values. Split vectors are passed via a mix of registers and indirectly, so
- // treat them as we would any other argument.
- if (ValVT.isScalarInteger() && (ArgFlags.isSplit() || !PendingLocs.empty())) {
- LocVT = XLenVT;
- LocInfo = CCValAssign::Indirect;
- PendingLocs.push_back(
- CCValAssign::getPending(ValNo, ValVT, LocVT, LocInfo));
- PendingArgFlags.push_back(ArgFlags);
- if (!ArgFlags.isSplitEnd()) {
- return false;
- }
- }
-
// If the split argument only had two elements, it should be passed directly
// in registers or on the stack.
if (ValVT.isScalarInteger() && ArgFlags.isSplitEnd() &&
- PendingLocs.size() <= 2) {
- assert(PendingLocs.size() == 2 && "Unexpected PendingLocs.size()");
+ PendingLocs.size() <= 1) {
+ assert(PendingLocs.size() == 1 && "Unexpected PendingLocs.size()");
// Apply the normal calling convention rules to the first half of the
// split argument.
CCValAssign VA = PendingLocs[0];
@@ -540,6 +526,20 @@ bool llvm::CC_RISCV(unsigned ValNo, MVT ValVT, MVT LocVT,
ABI == RISCVABI::ABI_ILP32E || ABI == RISCVABI::ABI_LP64E);
}
+ // Split arguments might be passed indirectly, so keep track of the pending
+ // values. Split vectors are passed via a mix of registers and indirectly, so
+ // treat them as we would any other argument.
+ if (ValVT.isScalarInteger() && (ArgFlags.isSplit() || !PendingLocs.empty())) {
+ LocVT = XLenVT;
+ LocInfo = CCValAssign::Indirect;
+ PendingLocs.push_back(
+ CCValAssign::getPending(ValNo, ValVT, LocVT, LocInfo));
+ PendingArgFlags.push_back(ArgFlags);
+ if (!ArgFlags.isSplitEnd()) {
+ return false;
+ }
+ }
+
// Allocate to a register if possible, or else a stack slot.
MCRegister Reg;
unsigned StoreSizeBytes = XLen / 8;
More information about the llvm-commits
mailing list