File tree Expand file tree Collapse file tree 4 files changed +36
-9
lines changed Expand file tree Collapse file tree 4 files changed +36
-9
lines changed Original file line number Diff line number Diff line change @@ -164,10 +164,6 @@ class LLVM_LIBRARY_VISIBILITY SPIR32SYCLDeviceTargetInfo
164164 // to parse host code. So we allow compilation of exception_ptr but
165165 // if exceptions are used in device code we should emit a diagnostic.
166166 MaxAtomicInlineWidth = 32 ;
167- // This is workaround for mutex class.
168- // I'm not sure about this hack but I guess that mutex_class is same
169- // problem.
170- TLSSupported = true ;
171167 }
172168};
173169
@@ -182,10 +178,6 @@ class LLVM_LIBRARY_VISIBILITY SPIR64SYCLDeviceTargetInfo
182178 // to parse host code. So we allow compilation of exception_ptr but
183179 // if exceptions are used in device code we should emit a diagnostic.
184180 MaxAtomicInlineWidth = 64 ;
185- // This is workaround for mutex class.
186- // I'm not sure about this hack but I guess that mutex_class is same
187- // problem.
188- TLSSupported = true ;
189181 }
190182};
191183
Original file line number Diff line number Diff line change @@ -6729,6 +6729,14 @@ NamedDecl *Sema::ActOnVariableDeclarator(
67296729 // proper storage class for other tools to use even if we're not going
67306730 // to emit any code for it.
67316731 NewVD->setTSCSpec(TSCS);
6732+ } else if (getLangOpts().SYCLIsDevice) {
6733+ // While SYCL does not support TLS, emitting the diagnostic here
6734+ // prevents the compilation of header files with TLS declarations.
6735+ // When TLS objects are used in kernel code, they are diagnosed.
6736+ // We still need to mark the variable as TLS so it shows up in AST with
6737+ // proper storage class for other tools to use even if we're not going
6738+ // to emit any code for it.
6739+ NewVD->setTSCSpec(TSCS);
67326740 } else
67336741 Diag(D.getDeclSpec().getThreadStorageClassSpecLoc(),
67346742 diag::err_thread_unsupported);
Original file line number Diff line number Diff line change @@ -209,9 +209,12 @@ class MarkDeviceFunction : public RecursiveASTVisitor<MarkDeviceFunction> {
209209 SemaRef.Diag (E->getExprLoc (), diag::err_sycl_restrict)
210210 << Sema::KernelNonConstStaticDataVariable;
211211 else if (!IsConst && VD->hasGlobalStorage () && !VD->isStaticLocal () &&
212- !VD->isStaticDataMember () && !isa<ParmVarDecl>(VD))
212+ !VD->isStaticDataMember () && !isa<ParmVarDecl>(VD)) {
213+ if (VD->getTLSKind () != VarDecl::TLS_None)
214+ SemaRef.Diag (E->getLocation (), diag::err_thread_unsupported);
213215 SemaRef.Diag (E->getLocation (), diag::err_sycl_restrict)
214216 << Sema::KernelGlobalVariable;
217+ }
215218 if (!VD->isLocalVarDeclOrParm () && VD->hasGlobalStorage ()) {
216219 VD->addAttr (SYCLDeviceAttr::CreateImplicit (SemaRef.Context ));
217220 SemaRef.addSyclDeviceDecl (VD);
Original file line number Diff line number Diff line change 1+ // RUN: %clang_cc1 -verify -fsyntax-only -fsycl-is-device %s
2+
3+ extern __thread void * __once_callable; // expected-no-error
4+ extern __thread void (*__once_call)(); // expected-no-error
5+
6+ void usage () {
7+ // expected-error@+2{{thread-local storage is not supported for the current target}}
8+ // expected-error@+1{{SYCL kernel cannot use a global variable}}
9+ __once_callable = 0 ;
10+ // expected-error@+3{{thread-local storage is not supported for the current target}}
11+ // expected-error@+2{{SYCL kernel cannot use a global variable}}
12+ // expected-error@+1{{SYCL kernel cannot call through a function pointer}}
13+ __once_call ();
14+ }
15+
16+ template <typename name, typename Func>
17+ __attribute__ ((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
18+ kernelFunc ();
19+ }
20+
21+ int main () {
22+ kernel_single_task<class fake_kernel >([]() { usage (); });
23+ return 0 ;
24+ }
You can’t perform that action at this time.
0 commit comments