[PATCH] [cuda] Preserve TLS storage class of host variable during device-side compilation.

Artem Belevich tra at google.com
Tue Apr 28 10:16:42 PDT 2015


Hi eliben, jpienaar,

Side effect of r235907 is that host-side TLS variables ended up in AST as non-TLS during device-side compilation.
While missing thread storage class spec does not affect generated code because the variable will be ignored 
during code generation, we've lost information which is useful during source analysis.

This patch preserves host variable's TLS class during device-side compilation.

http://reviews.llvm.org/D9327

Files:
  lib/Sema/SemaDecl.cpp

Index: lib/Sema/SemaDecl.cpp
===================================================================
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5769,12 +5769,16 @@
            diag::err_thread_non_global)
         << DeclSpec::getSpecifierName(TSCS);
     else if (!Context.getTargetInfo().isTLSSupported()) {
-      if (getLangOpts().CUDA)
+      if (getLangOpts().CUDA) {
         // Postpone error emission until we've collected attributes required to
         // figure out whether it's a host or device variable and whether the
         // error should be ignored.
         EmitTLSUnsupportedError = true;
-      else
+        // We still need to mark the variable as TLS so it shows up in AST with
+        // proper storage class for other tools to use even if we're not going
+        // to emit any code for it.
+        NewVD->setTSCSpec(TSCS);
+      } else
         Diag(D.getDeclSpec().getThreadStorageClassSpecLoc(),
              diag::err_thread_unsupported);
     } else

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9327.24562.patch
Type: text/x-patch
Size: 997 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150428/3b37b261/attachment.bin>


More information about the cfe-commits mailing list