Skip to content

Commit c3ead85

Browse files
committed
[RISCV][clang] Support RISC-V vectors in UninitializedValues.
RISC-V vectors are basically vectors, but we use builtin types to restrict the possible types. Treat them the same as vectors and scalars for this analysis. Reviewed By: reames Differential Revision: https://reviews.llvm.org/D136511
1 parent 975740b commit c3ead85

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

clang/include/clang/AST/Type.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2269,6 +2269,8 @@ class alignas(8) Type : public ExtQualsTypeCommonBase {
22692269
/// Check if the type is the CUDA device builtin texture type.
22702270
bool isCUDADeviceBuiltinTextureType() const;
22712271

2272+
bool isRVVType() const;
2273+
22722274
/// Return the implicit lifetime for this type, which must not be dependent.
22732275
Qualifiers::ObjCLifetime getObjCARCImplicitLifetime() const;
22742276

@@ -7201,6 +7203,14 @@ inline bool Type::isOpenCLSpecificType() const {
72017203
isQueueT() || isReserveIDT() || isPipeType() || isOCLExtOpaqueType();
72027204
}
72037205

7206+
inline bool Type::isRVVType() const {
7207+
#define RVV_TYPE(Name, Id, SingletonId) \
7208+
isSpecificBuiltinType(BuiltinType::Id) ||
7209+
return
7210+
#include "clang/Basic/RISCVVTypes.def"
7211+
false; // end of boolean or operation.
7212+
}
7213+
72047214
inline bool Type::isTemplateTypeParmType() const {
72057215
return isa<TemplateTypeParmType>(CanonicalType);
72067216
}

clang/lib/Analysis/UninitializedValues.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ static bool isTrackedVar(const VarDecl *vd, const DeclContext *dc) {
4646
!vd->isExceptionVariable() && !vd->isInitCapture() &&
4747
!vd->isImplicit() && vd->getDeclContext() == dc) {
4848
QualType ty = vd->getType();
49-
return ty->isScalarType() || ty->isVectorType() || ty->isRecordType();
49+
return ty->isScalarType() || ty->isVectorType() || ty->isRecordType() ||
50+
ty->isRVVType();
5051
}
5152
return false;
5253
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: %clang_cc1 -triple riscv64 -fsyntax-only -Wuninitialized -fsyntax-only -target-feature +v %s -verify
2+
3+
#pragma clang riscv intrinsic vector
4+
5+
void test1(int *input, long vl) {
6+
__rvv_int32m1_t x, y, z, w, X; // expected-note {{variable 'x' is declared here}} expected-note {{variable 'y' is declared here}} expected-note {{variable 'w' is declared here}} expected-note {{variable 'z' is declared here}}
7+
x = vxor_vv_i32m1(x,x, vl); // expected-warning {{variable 'x' is uninitialized when used here}}
8+
y = vxor_vv_i32m1(y,y, vl); // expected-warning {{variable 'y' is uninitialized when used here}}
9+
z = vxor_vv_i32m1(z,z, vl); // expected-warning {{variable 'z' is uninitialized when used here}}
10+
w = vxor_vv_i32m1(w,w, vl); // expected-warning {{variable 'w' is uninitialized when used here}}
11+
X = vle32_v_i32m1(&input[0], vl);
12+
X = vxor_vv_i32m1(X,X, vl); // no-warning
13+
}
14+

0 commit comments

Comments
 (0)