[llvm-branch-commits] [cfe-branch] r123634 - in /cfe/branches/Apple/whitney: lib/CodeGen/CGDeclCXX.cpp test/CodeGenObjCXX/write-barrier-global-assign.mm
Daniel Dunbar
daniel at zuster.org
Mon Jan 17 07:44:27 PST 2011
Author: ddunbar
Date: Mon Jan 17 09:44:27 2011
New Revision: 123634
URL: http://llvm.org/viewvc/llvm-project?rev=123634&view=rev
Log:
Merge r123391:
--
Author: Fariborz Jahanian <fjahanian at apple.com>
Date: Thu Jan 13 20:00:54 2011 +0000
Generate write-barriers for global objc
assigns. // rdar://8761767
Added:
cfe/branches/Apple/whitney/test/CodeGenObjCXX/write-barrier-global-assign.mm
Modified:
cfe/branches/Apple/whitney/lib/CodeGen/CGDeclCXX.cpp
Modified: cfe/branches/Apple/whitney/lib/CodeGen/CGDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/CodeGen/CGDeclCXX.cpp?rev=123634&r1=123633&r2=123634&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/branches/Apple/whitney/lib/CodeGen/CGDeclCXX.cpp Mon Jan 17 09:44:27 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/branches/Apple/whitney/test/CodeGenObjCXX/write-barrier-global-assign.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/test/CodeGenObjCXX/write-barrier-global-assign.mm?rev=123634&view=auto
==============================================================================
--- cfe/branches/Apple/whitney/test/CodeGenObjCXX/write-barrier-global-assign.mm (added)
+++ cfe/branches/Apple/whitney/test/CodeGenObjCXX/write-barrier-global-assign.mm Mon Jan 17 09:44:27 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 llvm-branch-commits
mailing list