]> granicus.if.org Git - clang/commitdiff
Thread local variables aren't considered common linkage.
authorEric Christopher <echristo@apple.com>
Sun, 8 Aug 2010 01:37:14 +0000 (01:37 +0000)
committerEric Christopher <echristo@apple.com>
Sun, 8 Aug 2010 01:37:14 +0000 (01:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110530 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenModule.cpp
test/CodeGen/thread-specifier.c

index 297aa4524e3883ae22a6358b87548186087963f6..6283b744c3e05019d6f4654d12eadc189fa72b63 100644 (file)
@@ -1201,7 +1201,8 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {
     GV->setLinkage(llvm::GlobalVariable::WeakAnyLinkage);   
   else if (!getLangOptions().CPlusPlus && !CodeGenOpts.NoCommon &&
            !D->hasExternalStorage() && !D->getInit() &&
-           !D->getAttr<SectionAttr>()) {
+           !D->getAttr<SectionAttr>() && !D->isThreadSpecified()) {
+    // Thread local vars aren't considered common linkage.
     GV->setLinkage(llvm::GlobalVariable::CommonLinkage);
     // common vars aren't constant even if declared const.
     GV->setConstant(false);
index b1e1ed84647fc608dd5558b64761699dccaaa1e5..a16103f08f6d4335fa8d655f36de05cd1bc2f894 100644 (file)
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple i686-pc-linux-gnu -emit-llvm -o - %s | grep thread_local | count 4
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -emit-llvm -o - %s | not grep common
 
 __thread int a;
 extern __thread int b;