summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2014-03-04 18:34:52 +0000
committerFariborz Jahanian <fjahanian@apple.com>2014-03-04 18:34:52 +0000
commitdafffbe2beb7e69aacb9c73a9ea173bb2563867d (patch)
tree68a2cc9e8236a5cbb75b92523839450d53f13ac5 /clang/lib
parentb8322b13f84e2291ce0d5ebe1fbaf9a2af3ac477 (diff)
downloadbcm5719-llvm-dafffbe2beb7e69aacb9c73a9ea173bb2563867d.tar.gz
bcm5719-llvm-dafffbe2beb7e69aacb9c73a9ea173bb2563867d.zip
Objective-C IRGen. Fix up the hueristics for determining
if an ivar offset load is invariant iff inside an instance method and ivar belongs to instance method's class and one of its super class. // rdar://16095748 llvm-svn: 202872
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/CodeGen/CGObjCMac.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index f558412f716..ebbd7007c14 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/lib/CodeGen/CGObjCMac.cpp
@@ -1442,11 +1442,10 @@ private:
bool ImplementationIsNonLazy(const ObjCImplDecl *OD) const;
bool IsIvarOffsetKnownIdempotent(const CodeGen::CodeGenFunction &CGF,
- const ObjCInterfaceDecl *ID,
const ObjCIvarDecl *IV) {
- // Annotate the load as an invariant load iff the object type is the type,
- // or a derived type, of the class containing the ivar within an ObjC
- // method. This check is needed because the ivar offset is a lazily
+ // Annotate the load as an invariant load iff inside an instance method
+ // and ivar belongs to instance method's class and one of its super class.
+ // This check is needed because the ivar offset is a lazily
// initialised value that may depend on objc_msgSend to perform a fixup on
// the first message dispatch.
//
@@ -1454,9 +1453,12 @@ private:
// base of the ivar access is a parameter to an Objective C method.
// However, because the parameters are not available in the current
// interface, we cannot perform this check.
- if (CGF.CurFuncDecl && isa<ObjCMethodDecl>(CGF.CurFuncDecl))
- if (IV->getContainingInterface()->isSuperClassOf(ID))
- return true;
+ if (const ObjCMethodDecl *MD =
+ dyn_cast_or_null<ObjCMethodDecl>(CGF.CurFuncDecl))
+ if (MD->isInstanceMethod() &&
+ !isa<ObjCProtocolDecl>(MD->getDeclContext()))
+ if (const ObjCInterfaceDecl *ID = MD->getClassInterface())
+ return IV->getContainingInterface()->isSuperClassOf(ID);
return false;
}
@@ -6479,7 +6481,7 @@ LValue CGObjCNonFragileABIMac::EmitObjCValueForIvar(
ObjCInterfaceDecl *ID = ObjectTy->getAs<ObjCObjectType>()->getInterface();
llvm::Value *Offset = EmitIvarOffset(CGF, ID, Ivar);
- if (IsIvarOffsetKnownIdempotent(CGF, ID, Ivar))
+ if (IsIvarOffsetKnownIdempotent(CGF, Ivar))
if (llvm::LoadInst *LI = cast<llvm::LoadInst>(Offset))
LI->setMetadata(CGM.getModule().getMDKindID("invariant.load"),
llvm::MDNode::get(VMContext, ArrayRef<llvm::Value*>()));
OpenPOWER on IntegriCloud