-
Notifications
You must be signed in to change notification settings - Fork 751
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
[SYCL] Forbid declaration of static non-const variable inside kernel. #1133
Conversation
clang/lib/Sema/SemaDecl.cpp
Outdated
@@ -6945,6 +6945,14 @@ NamedDecl *Sema::ActOnVariableDeclarator( | |||
NewVD->setTSCSpec(TSCS); | |||
} | |||
|
|||
// Varification, that if a static variable has been declared, then it is |
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.
// Varification, that if a static variable has been declared, then it is | |
// Static variables declared inside SYCL device code must be const or constexpr |
clang/lib/Sema/SemaDecl.cpp
Outdated
@@ -6945,6 +6945,14 @@ NamedDecl *Sema::ActOnVariableDeclarator( | |||
NewVD->setTSCSpec(TSCS); | |||
} | |||
|
|||
// Varification, that if a static variable has been declared, then it is | |||
// constant |
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.
// constant |
clang/lib/Sema/SemaDecl.cpp
Outdated
// Varification, that if a static variable has been declared, then it is | ||
// constant | ||
if (getLangOpts().SYCLIsDevice && SCSpec == DeclSpec::SCS_static && | ||
!R.isConstant(Context)) { |
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.
!R.isConstant(Context)) { | |
!R.isConstant(Context)) |
clang/lib/Sema/SemaDecl.cpp
Outdated
!R.isConstant(Context)) { | ||
SYCLDiagIfDeviceCode(D.getIdentifierLoc(), diag::err_sycl_restrict) | ||
<< Sema::KernelNonConstStaticDataVariable; | ||
} |
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.
} |
@@ -35,7 +36,7 @@ __attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) { | |||
int main() { | |||
kernel_single_task<class kernel>([]() { | |||
ret_char(); | |||
ret_arr(); | |||
ret_arr(); |
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.
ret_arr(); | |
ret_arr(); |
static int m; | ||
} | ||
|
||
template <typename name, typename Func> |
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.
template <typename name, typename Func> | |
template <typename Name, typename Func> |
e25a4ac
to
7db72a0
Compare
…ernel, ifthe variable is not const. Signed-off-by: Aleksander Fadeev <aleksander.fadeev@intel.com>
7db72a0
to
8b5af68
Compare
The BuiltIn variable/call name in SPV-IR should stick to "__spirv_BuiltIn*", no matter what the SPIR-V linkage name is. This is a regression of PR intel#1133. Signed-off-by: Yilong Guo <yilong.guo@intel.com> Original commit: KhronosGroup/SPIRV-LLVM-Translator@894f95b
Adding the error, that forbid declaration of static variable inside kernel, if the variable is not const.
Signed-off-by: Aleksander Fadeev aleksander.fadeev@intel.com