From 91f31dc234bbc98f3dd20e6741a7b0b98c7916bf Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Sun, 8 Aug 2010 01:37:14 +0000 Subject: [PATCH] Thread local variables aren't considered common linkage. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110530 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenModule.cpp | 3 ++- test/CodeGen/thread-specifier.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 297aa4524e..6283b744c3 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -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()) { + !D->getAttr() && !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); diff --git a/test/CodeGen/thread-specifier.c b/test/CodeGen/thread-specifier.c index b1e1ed8464..a16103f08f 100644 --- a/test/CodeGen/thread-specifier.c +++ b/test/CodeGen/thread-specifier.c @@ -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; -- 2.50.1