Skip to content

Commit 55f86cf

Browse files
authored
[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.
1 parent 8839ba4 commit 55f86cf

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

clang/lib/CodeGen/Targets/RISCV.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ ABIArgInfo RISCVABIInfo::coerceAndExpandFPCCEligibleStruct(
389389
bool RISCVABIInfo::detectVLSCCEligibleStruct(QualType Ty, unsigned ABIVLen,
390390
llvm::Type *&VLSType) const {
391391
// No riscv_vls_cc attribute.
392-
if (ABIVLen == 1)
392+
if (ABIVLen == 0)
393393
return false;
394394

395395
// Legal struct for VLS calling convention should fulfill following rules:

clang/test/CodeGen/RISCV/pr129995.cc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// RUN: %clang_cc1 triple riscv64 -emit-llvm -target-feature +m -target-feature +v -target-abi lp64d -o /dev/null %s
2+
3+
struct a {
4+
using b = char __attribute__((vector_size(sizeof(char))));
5+
};
6+
class c {
7+
using d = a::b;
8+
d e;
9+
10+
public:
11+
static c f();
12+
};
13+
class g {
14+
public:
15+
template <class h> g(h);
16+
friend g operator^(g, g) { c::f; }
17+
friend g operator^=(g i, g j) { i ^ j; }
18+
};
19+
template <typename, int> using k = g;
20+
template <typename l> using m = k<l, sizeof(l)>;
21+
void n() {
22+
void o();
23+
m<char> p = o ^= p;
24+
}

0 commit comments

Comments
 (0)