-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[RISCV][clang] Fix wrong VLS CC detection #130107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
@llvm/pr-subscribers-clang-codegen @llvm/pr-subscribers-backend-risc-v Author: Kito Cheng (kito-cheng) ChangesRISCVABIInfo::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. Full diff: https://github.com/llvm/llvm-project/pull/130107.diff 2 Files Affected:
diff --git a/clang/lib/CodeGen/Targets/RISCV.cpp b/clang/lib/CodeGen/Targets/RISCV.cpp
index e350a3589dcaf..7fddde415e7cc 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;
+}
|
@llvm/pr-subscribers-clang Author: Kito Cheng (kito-cheng) ChangesRISCVABIInfo::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. Full diff: https://github.com/llvm/llvm-project/pull/130107.diff 2 Files Affected:
diff --git a/clang/lib/CodeGen/Targets/RISCV.cpp b/clang/lib/CodeGen/Targets/RISCV.cpp
index e350a3589dcaf..7fddde415e7cc 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;
+}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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.
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.