[clang] 8ad82b4 - [clang][Interp] Fix re-visiting OpenCL variables of in constant AS
Timm Bäder via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 12 00:53:43 PDT 2024
Author: Timm Bäder
Date: 2024-06-12T09:53:33+02:00
New Revision: 8ad82b419b88102746735505effe5bc09f26ae54
URL: https://github.com/llvm/llvm-project/commit/8ad82b419b88102746735505effe5bc09f26ae54
DIFF: https://github.com/llvm/llvm-project/commit/8ad82b419b88102746735505effe5bc09f26ae54.diff
LOG: [clang][Interp] Fix re-visiting OpenCL variables of in constant AS
We need to use isConstant() here, isConstQualified() is not enough.
Added:
Modified:
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/test/AST/Interp/opencl.cl
Removed:
################################################################################
diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index e766558ab3083..602d105715d2b 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -3964,7 +3964,7 @@ bool ByteCodeExprGen<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) {
if (const auto *VD = dyn_cast<VarDecl>(D)) {
// Visit local const variables like normal.
if ((VD->isLocalVarDecl() || VD->isStaticDataMember()) &&
- VD->getType().isConstQualified()) {
+ VD->getType().isConstant(Ctx.getASTContext())) {
if (!this->visitVarDecl(VD))
return false;
// Retry.
@@ -3973,8 +3973,8 @@ bool ByteCodeExprGen<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) {
}
} else {
if (const auto *VD = dyn_cast<VarDecl>(D);
- VD && VD->getAnyInitializer() && VD->getType().isConstQualified() &&
- !VD->isWeak()) {
+ VD && VD->getAnyInitializer() &&
+ VD->getType().isConstant(Ctx.getASTContext()) && !VD->isWeak()) {
if (!this->visitVarDecl(VD))
return false;
// Retry.
diff --git a/clang/test/AST/Interp/opencl.cl b/clang/test/AST/Interp/opencl.cl
index fd7756fff7c11..32cc000cefd30 100644
--- a/clang/test/AST/Interp/opencl.cl
+++ b/clang/test/AST/Interp/opencl.cl
@@ -36,3 +36,10 @@ void negativeShift32(int a,int b) {
int2 A = {1,2};
int4 B = {(int2)(1,2), (int2)(3,4)};
+
+
+constant int sz0 = 5;
+kernel void testvla()
+{
+ int vla0[sz0];
+}
More information about the cfe-commits
mailing list