[cfe-commits] r59748 - in /cfe/trunk/lib/CodeGen: CGExpr.cpp CGValue.h

Fariborz Jahanian fjahanian at apple.com
Thu Nov 20 12:53:22 PST 2008


Author: fjahanian
Date: Thu Nov 20 14:53:20 2008
New Revision: 59748

URL: http://llvm.org/viewvc/llvm-project?rev=59748&view=rev
Log:
Support generation of objc_assign_ivar for ivar
write-barriers.

Modified:
    cfe/trunk/lib/CodeGen/CGExpr.cpp
    cfe/trunk/lib/CodeGen/CGValue.h

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=59748&r1=59747&r2=59748&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Nov 20 14:53:20 2008
@@ -372,7 +372,10 @@
     // load of a __strong object. 
     llvm::Value *LvalueDst = Dst.getAddress();
     llvm::Value *src = Src.getScalarVal();
-    CGM.getObjCRuntime().EmitObjCGlobalAssign(*this, src, LvalueDst);
+    if (Dst.isObjCIvar())
+      CGM.getObjCRuntime().EmitObjCIvarAssign(*this, src, LvalueDst);
+    else
+      CGM.getObjCRuntime().EmitObjCGlobalAssign(*this, src, LvalueDst);
     return;
   }
   
@@ -523,7 +526,7 @@
 
 /// SetVarDeclObjCAttribute - Set __weak/__strong attributes into the LValue
 /// object.
-static void SetVarDeclObjCAttribute(ASTContext &Ctx, const VarDecl *VD, 
+static void SetVarDeclObjCAttribute(ASTContext &Ctx, const Decl *VD, 
                                     const QualType &Ty, LValue &LV)
 {
   if (const ObjCGCAttr *A = VD->getAttr<ObjCGCAttr>()) {
@@ -932,7 +935,10 @@
   unsigned Index = CGM.getTypes().getLLVMFieldNo(Ivar);
   
   llvm::Value *V = Builder.CreateStructGEP(BaseValue, Index, "tmp");
-  return LValue::MakeAddr(V, Ivar->getType().getCVRQualifiers()|CVRQualifiers);
+  LValue LV = LValue::MakeAddr(V, Ivar->getType().getCVRQualifiers()|CVRQualifiers);
+  SetVarDeclObjCAttribute(getContext(), Ivar, Ivar->getType(), LV);
+  LValue::SetObjCIvar(LV);
+  return LV;
 }
 
 LValue CodeGenFunction::EmitObjCIvarRefLValue(const ObjCIvarRefExpr *E) {

Modified: cfe/trunk/lib/CodeGen/CGValue.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGValue.h?rev=59748&r1=59747&r2=59748&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGValue.h (original)
+++ cfe/trunk/lib/CodeGen/CGValue.h Thu Nov 20 14:53:20 2008
@@ -137,8 +137,12 @@
   // FIXME: set but never used, what effect should it have?
   bool Restrict:1;
 
+  // objective-c's ivar
+  bool Ivar:1;
+
   // objective-c's gc attributes
   unsigned ObjCType : 2;  
+  
 
 private:
   static void SetQualifiers(unsigned Qualifiers, LValue& R) {
@@ -147,6 +151,7 @@
     // FIXME: Convenient place to set objc flags to 0. This
     // should really be done in a user-defined constructor instead.
     R.ObjCType = None;
+    R.Ivar = false;
   }
   
 public:
@@ -159,9 +164,14 @@
   bool isVolatileQualified() const { return Volatile; }
   bool isRestrictQualified() const { return Restrict; }
   
+  bool isObjCIvar() const { return Ivar; }
   bool isObjCWeak() const { return ObjCType == Weak; }
   bool isObjCStrong() const { return ObjCType == Strong; }
   
+  static void SetObjCIvar(LValue& R) {
+    R.Ivar = true;
+  }
+    
   static void SetObjCType(bool isWeak, bool isStrong, LValue& R) {
     assert(!(isWeak == true && isStrong == true));
     if (isWeak)





More information about the cfe-commits mailing list