[cfe-commits] r123391 - in /cfe/trunk: lib/CodeGen/CGDeclCXX.cpp test/CodeGenObjCXX/write-barrier-global-assign.mm
John McCall
rjmccall at apple.com
Thu Jan 13 13:00:55 PST 2011
On Jan 13, 2011, at 12:00 PM, Fariborz Jahanian wrote:
> 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);
getObjCGCAttrKind is expensive enough that you should really cache the result.
John.
More information about the cfe-commits
mailing list