From 58626500527695865683d1d65053743de8770b60 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Wed, 19 Nov 2008 00:59:10 +0000 Subject: Generate strong write barriers for __strong objects. Also, took care of Daniel's commments. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59575 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExpr.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'lib/CodeGen/CGExpr.cpp') diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 98a54c6863..95733abbab 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -151,7 +151,7 @@ LValue CodeGenFunction::EmitLValue(const Expr *E) { /// this method emits the address of the lvalue, then loads the result as an /// rvalue, returning the rvalue. RValue CodeGenFunction::EmitLoadOfLValue(LValue LV, QualType ExprType) { - if (LV.isObjcWeak()) { + if (LV.ObjcWeak()) { // load of a __weak object. llvm::Value *AddrWeakObj = LV.getAddress(); llvm::Value *read_weak = CGM.getObjCRuntime().EmitObjCWeakRead(*this, @@ -335,7 +335,7 @@ RValue CodeGenFunction::EmitLoadOfExtVectorElementLValue(LValue LV, /// is 'Ty'. void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst, QualType Ty) { - if (Dst.isObjcWeak()) { + if (Dst.ObjcWeak()) { // load of a __weak object. llvm::Value *LvalueDst = Dst.getAddress(); llvm::Value *src = Src.getScalarVal(); @@ -343,6 +343,14 @@ void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst, return; } + if (Dst.ObjcStrong()) { + // load of a __strong object. + llvm::Value *LvalueDst = Dst.getAddress(); + llvm::Value *src = Src.getScalarVal(); + CGM.getObjCRuntime().EmitObjCGlobalAssign(*this, src, LvalueDst); + return; + } + if (!Dst.isSimple()) { if (Dst.isVectorElt()) { // Read/modify/write the vector, inserting the new element. @@ -510,10 +518,9 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) { } else if (VD && VD->isFileVarDecl()) { LValue LV = LValue::MakeAddr(CGM.GetAddrOfGlobalVar(VD), E->getType().getCVRQualifiers()); - if (VD->getAttr()) - { - ObjCGCAttr::GCAttrTypes attrType = (VD->getAttr())->getType(); - LValue::SetObjCGCAttrs(attrType == ObjCGCAttr::Weak, attrType == ObjCGCAttr::Strong, LV); + if (const ObjCGCAttr *A = VD->getAttr()) { + ObjCGCAttr::GCAttrTypes attrType = A->getType(); + LValue::SetObjCType(attrType == ObjCGCAttr::Weak, attrType == ObjCGCAttr::Strong, LV); } return LV; } else if (const FunctionDecl *FD = dyn_cast(E->getDecl())) { -- cgit v1.2.3