PR3853: Add CodeGen support for __thread.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69545 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index a517d81..1a52ba2 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -656,10 +656,6 @@
     return llvm::ConstantExpr::getBitCast(Entry, Ty);
   }
   
-  // We don't support __thread yet.
-  if (D && D->isThreadSpecified())
-    ErrorUnsupported(D, "thread local ('__thread') variable", true);
-  
   // This is the first use or definition of a mangled name.  If there is a
   // deferred decl with this name, remember that we need to emit it at the end
   // of the file.
@@ -676,7 +672,7 @@
     new llvm::GlobalVariable(Ty->getElementType(), false, 
                              llvm::GlobalValue::ExternalLinkage,
                              0, "", &getModule(), 
-                             0, Ty->getAddressSpace());
+                             false, Ty->getAddressSpace());
   GV->setName(MangledName);
 
   // Handle things which are present even on external declarations.
@@ -691,6 +687,8 @@
 
     if (D->hasAttr<WeakAttr>() || D->hasAttr<WeakImportAttr>())
       GV->setLinkage(llvm::GlobalValue::ExternalWeakLinkage);
+
+    GV->setThreadLocal(D->isThreadSpecified());
   }
   
   return Entry = GV;