[clang] 55f86cf - [RISCV][clang] Fix wrong VLS CC detection (#130107)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 6 19:15:24 PST 2025
Author: Kito Cheng
Date: 2025-03-07T11:15:20+08:00
New Revision: 55f86cf02336e0a1bce81403296cce6d4cfbb1e4
URL: https://github.com/llvm/llvm-project/commit/55f86cf02336e0a1bce81403296cce6d4cfbb1e4
DIFF: https://github.com/llvm/llvm-project/commit/55f86cf02336e0a1bce81403296cce6d4cfbb1e4.diff
LOG: [RISCV][clang] Fix wrong VLS CC detection (#130107)
RISCVABIInfo::detectVLSCCEligibleStruct should early exit if VLS calling
convention is not used, however the sentinel value was not set to
correctly, it should be zero instead of one.
Added:
clang/test/CodeGen/RISCV/pr129995.cc
Modified:
clang/lib/CodeGen/Targets/RISCV.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/Targets/RISCV.cpp b/clang/lib/CodeGen/Targets/RISCV.cpp
index 081ae8a403111..5aa10ba41f5ed 100644
--- a/clang/lib/CodeGen/Targets/RISCV.cpp
+++ b/clang/lib/CodeGen/Targets/RISCV.cpp
@@ -389,7 +389,7 @@ ABIArgInfo RISCVABIInfo::coerceAndExpandFPCCEligibleStruct(
bool RISCVABIInfo::detectVLSCCEligibleStruct(QualType Ty, unsigned ABIVLen,
llvm::Type *&VLSType) const {
// No riscv_vls_cc attribute.
- if (ABIVLen == 1)
+ if (ABIVLen == 0)
return false;
// Legal struct for VLS calling convention should fulfill following rules:
diff --git a/clang/test/CodeGen/RISCV/pr129995.cc b/clang/test/CodeGen/RISCV/pr129995.cc
new file mode 100644
index 0000000000000..590c6b9fbdf96
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/pr129995.cc
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 triple riscv64 -emit-llvm -target-feature +m -target-feature +v -target-abi lp64d -o /dev/null %s
+
+struct a {
+ using b = char __attribute__((vector_size(sizeof(char))));
+};
+class c {
+ using d = a::b;
+ d e;
+
+public:
+ static c f();
+};
+class g {
+public:
+ template <class h> g(h);
+ friend g operator^(g, g) { c::f; }
+ friend g operator^=(g i, g j) { i ^ j; }
+};
+template <typename, int> using k = g;
+template <typename l> using m = k<l, sizeof(l)>;
+void n() {
+ void o();
+ m<char> p = o ^= p;
+}
More information about the cfe-commits
mailing list