Thread local variables aren't considered common linkage.

llvm-svn: 110530
This commit is contained in:
Eric Christopher 2010-08-08 01:37:14 +00:00
parent 8aa19b05ee
commit 6ff7161d51
2 changed files with 3 additions and 1 deletions

View 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);

View 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;