aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2012-01-07 18:56:22 +0000
committerFariborz Jahanian <fjahanian@apple.com>2012-01-07 18:56:22 +0000
commitb6e5fe3cae9bf456f084c555c3ecc256f4181cc5 (patch)
tree7b25ec7544561549a766fabbfb16de423b185784
parentc5bdc556f6a65c677e0ed73f918c3000ecad33af (diff)
objc++: More codegen stuff for atomic properties of c++ objects
with non-trivial copies. // rdar://6137845 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147735 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/CGObjC.cpp25
-rw-r--r--lib/CodeGen/CodeGenFunction.h6
2 files changed, 22 insertions, 9 deletions
diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp
index 0f23a2129a..1b3eba4018 100644
--- a/lib/CodeGen/CGObjC.cpp
+++ b/lib/CodeGen/CGObjC.cpp
@@ -564,12 +564,14 @@ PropertyImplStrategy::PropertyImplStrategy(CodeGenModule &CGM,
/// is illegal within a category.
void CodeGenFunction::GenerateObjCGetter(ObjCImplementationDecl *IMP,
const ObjCPropertyImplDecl *PID) {
+ llvm::Constant *AtomicHelperFn =
+ GenerateObjCAtomicCopyHelperFunction(PID, false);
const ObjCPropertyDecl *PD = PID->getPropertyDecl();
ObjCMethodDecl *OMD = PD->getGetterMethodDecl();
assert(OMD && "Invalid call to generate getter (empty method)");
StartObjCMethod(OMD, IMP->getClassInterface(), PID->getLocStart());
- generateObjCGetterBody(IMP, PID);
+ generateObjCGetterBody(IMP, PID, AtomicHelperFn);
FinishFunction();
}
@@ -599,7 +601,8 @@ static bool hasTrivialGetExpr(const ObjCPropertyImplDecl *propImpl) {
void
CodeGenFunction::generateObjCGetterBody(const ObjCImplementationDecl *classImpl,
- const ObjCPropertyImplDecl *propImpl) {
+ const ObjCPropertyImplDecl *propImpl,
+ llvm::Constant *AtomicHelperFn) {
// If there's a non-trivial 'get' expression, we just have to emit that.
if (!hasTrivialGetExpr(propImpl)) {
ReturnStmt ret(SourceLocation(), propImpl->getGetterCXXConstructor(),
@@ -989,7 +992,8 @@ CodeGenFunction::generateObjCSetterBody(const ObjCImplementationDecl *classImpl,
/// is illegal within a category.
void CodeGenFunction::GenerateObjCSetter(ObjCImplementationDecl *IMP,
const ObjCPropertyImplDecl *PID) {
- llvm::Constant *AtomicHelperFn = GenerateObjCAtomicCopyHelperFunction(PID);
+ llvm::Constant *AtomicHelperFn =
+ GenerateObjCAtomicCopyHelperFunction(PID, true);
const ObjCPropertyDecl *PD = PID->getPropertyDecl();
ObjCMethodDecl *OMD = PD->getSetterMethodDecl();
assert(OMD && "Invalid call to generate setter (empty method)");
@@ -2533,7 +2537,8 @@ void CodeGenFunction::EmitExtendGCLifetime(llvm::Value *object) {
///
llvm::Constant *
CodeGenFunction::GenerateObjCAtomicCopyHelperFunction(
- const ObjCPropertyImplDecl *PID) {
+ const ObjCPropertyImplDecl *PID,
+ bool forSetter) {
// FIXME. This api is for NeXt runtime only for now.
if (!getLangOptions().CPlusPlus || !getLangOptions().NeXTRuntime)
return 0;
@@ -2541,10 +2546,16 @@ CodeGenFunction::GenerateObjCAtomicCopyHelperFunction(
if (!Ty->isRecordType())
return 0;
const ObjCPropertyDecl *PD = PID->getPropertyDecl();
- if (!(PD->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_atomic) ||
- hasTrivialSetExpr(PID) || /* temporary */ true)
+ if ((!(PD->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_atomic))
+ || /* temporary */ true)
return 0;
-
+ if (forSetter) {
+ if (hasTrivialSetExpr(PID))
+ return 0;
+ }
+ else
+ if (hasTrivialGetExpr(PID))
+ return 0;
llvm::Constant * HelperFn = CGM.getAtomicHelperFnMap(Ty);
if (HelperFn)
return HelperFn;
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h
index d016bbe3e4..938acd3c56 100644
--- a/lib/CodeGen/CodeGenFunction.h
+++ b/lib/CodeGen/CodeGenFunction.h
@@ -1300,7 +1300,8 @@ public:
void GenerateObjCGetter(ObjCImplementationDecl *IMP,
const ObjCPropertyImplDecl *PID);
void generateObjCGetterBody(const ObjCImplementationDecl *classImpl,
- const ObjCPropertyImplDecl *propImpl);
+ const ObjCPropertyImplDecl *propImpl,
+ llvm::Constant *AtomicHelperFn);
void GenerateObjCCtorDtorMethod(ObjCImplementationDecl *IMP,
ObjCMethodDecl *MD, bool ctor);
@@ -1335,7 +1336,8 @@ public:
llvm::Constant *GenerateCopyHelperFunction(const CGBlockInfo &blockInfo);
llvm::Constant *GenerateDestroyHelperFunction(const CGBlockInfo &blockInfo);
llvm::Constant *GenerateObjCAtomicCopyHelperFunction(
- const ObjCPropertyImplDecl *PID);
+ const ObjCPropertyImplDecl *PID,
+ bool forSetter);
void BuildBlockRelease(llvm::Value *DeclPtr, BlockFieldFlags flags);