Adopt objc_assign_threadlocal() for __thread variables of GC types.
Implements radar 8203301.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108917 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index d6a3456..b4ec0ca 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -836,8 +836,10 @@
llvm::Value *BytesBetween = Builder.CreateSub(LHS, RHS, "ivar.offset");
CGM.getObjCRuntime().EmitObjCIvarAssign(*this, src, dst,
BytesBetween);
- } else if (Dst.isGlobalObjCRef())
- CGM.getObjCRuntime().EmitObjCGlobalAssign(*this, src, LvalueDst);
+ } else if (Dst.isGlobalObjCRef()) {
+ CGM.getObjCRuntime().EmitObjCGlobalAssign(*this, src, LvalueDst,
+ Dst.isThreadLocalRef());
+ }
else
CGM.getObjCRuntime().EmitObjCStrongCastAssign(*this, src, LvalueDst);
return;
@@ -1055,8 +1057,10 @@
if (const DeclRefExpr *Exp = dyn_cast<DeclRefExpr>(E)) {
if (const VarDecl *VD = dyn_cast<VarDecl>(Exp->getDecl())) {
if ((VD->isBlockVarDecl() && !VD->hasLocalStorage()) ||
- VD->isFileVarDecl())
+ VD->isFileVarDecl()) {
LV.SetGlobalObjCRef(LV, true);
+ LV.SetThreadLocalRef(LV, VD->isThreadSpecified());
+ }
}
LV.SetObjCArray(LV, E->getType()->isArrayType());
return;