[cfe-commits] r123391 - in /cfe/trunk: lib/CodeGen/CGDeclCXX.cpp test/CodeGenObjCXX/write-barrier-global-assign.mm
Fariborz Jahanian
fjahanian at apple.com
Thu Jan 13 12:00:54 PST 2011
Author: fjahanian
Date: Thu Jan 13 14:00:54 2011
New Revision: 123391
URL: http://llvm.org/viewvc/llvm-project?rev=123391&view=rev
Log:
Generate write-barriers for global objc
assigns. // rdar://8761767
Added:
cfe/trunk/test/CodeGenObjCXX/write-barrier-global-assign.mm
Modified:
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=123391&r1=123390&r2=123391&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Thu Jan 13 14:00:54 2011
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "CodeGenFunction.h"
+#include "CGObjCRuntime.h"
#include "CGCXXABI.h"
#include "clang/Frontend/CodeGenOptions.h"
#include "llvm/Intrinsics.h"
@@ -34,7 +35,14 @@
unsigned Alignment = Context.getDeclAlign(&D).getQuantity();
if (!CGF.hasAggregateLLVMType(T)) {
llvm::Value *V = CGF.EmitScalarExpr(Init);
- CGF.EmitStoreOfScalar(V, DeclPtr, isVolatile, Alignment, T);
+ CodeGenModule &CGM = CGF.CGM;
+ if (CGF.getContext().getObjCGCAttrKind(T) == Qualifiers::Strong)
+ CGM.getObjCRuntime().EmitObjCGlobalAssign(CGF, V, DeclPtr,
+ D.isThreadSpecified());
+ else if (CGF.getContext().getObjCGCAttrKind(T) == Qualifiers::Weak)
+ CGM.getObjCRuntime().EmitObjCWeakAssign(CGF, V, DeclPtr);
+ else
+ CGF.EmitStoreOfScalar(V, DeclPtr, isVolatile, Alignment, T);
} else if (T->isAnyComplexType()) {
CGF.EmitComplexExprIntoAddr(Init, DeclPtr, isVolatile);
} else {
Added: cfe/trunk/test/CodeGenObjCXX/write-barrier-global-assign.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/write-barrier-global-assign.mm?rev=123391&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjCXX/write-barrier-global-assign.mm (added)
+++ cfe/trunk/test/CodeGenObjCXX/write-barrier-global-assign.mm Thu Jan 13 14:00:54 2011
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+// rdar://8761767
+
+ at class CPDestUser;
+
+CPDestUser* FUNC();
+
+// CHECK: {{call.* @objc_assign_global}}
+CPDestUser* globalUser = FUNC();
+
+// CHECK: {{call.* @objc_assign_weak}}
+__weak CPDestUser* weakUser = FUNC();
+
+
+// CHECK: {{call.* @objc_assign_global}}
+static CPDestUser* staticUser = FUNC();
+
+CPDestUser* GetDestUser()
+{
+// CHECK: {{call.* @objc_assign_global}}
+ static CPDestUser* gUser = FUNC();
+// CHECK: {{call.* @objc_assign_weak}}
+ static __weak CPDestUser* wUser = FUNC();
+ if (wUser)
+ return wUser;
+ if (staticUser)
+ return staticUser;
+ return gUser;
+}
More information about the cfe-commits
mailing list