diff options
author | Joe Daniels <joseph_daniels@apple.com> | 2019-02-04 23:32:55 +0000 |
---|---|---|
committer | Joe Daniels <joseph_daniels@apple.com> | 2019-02-04 23:32:55 +0000 |
commit | f7393d2a3e5ce8766b9eab43d0b68de43f953a5b (patch) | |
tree | f109feeb8dc5c0c93220af790e418d6ae4adfb13 /clang/lib/CodeGen/CGObjCMac.cpp | |
parent | 3062887c9956f2eeabc2e017fbab5c3ab94710b9 (diff) | |
download | bcm5719-llvm-f7393d2a3e5ce8766b9eab43d0b68de43f953a5b.tar.gz bcm5719-llvm-f7393d2a3e5ce8766b9eab43d0b68de43f953a5b.zip |
[OBJC] Add attribute to mark Objective C class as non-lazy
A non-lazy class will be initialized eagerly when the Objective-C runtime is
loaded. This is required for certain system classes which have instances allocated in
non-standard ways, such as the classes for blocks and constant strings.
Adding this attribute is essentially equivalent to providing a trivial
+load method but avoids the (fairly small) load-time overheads associated
with defining and calling such a method.
Differential Revision: https://reviews.llvm.org/D56555
llvm-svn: 353116
Diffstat (limited to 'clang/lib/CodeGen/CGObjCMac.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGObjCMac.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp index 20b5a86cae4..7822a95285b 100644 --- a/clang/lib/CodeGen/CGObjCMac.cpp +++ b/clang/lib/CodeGen/CGObjCMac.cpp @@ -6261,9 +6261,10 @@ CGObjCNonFragileABIMac::BuildClassObject(const ObjCInterfaceDecl *CI, return GV; } -bool -CGObjCNonFragileABIMac::ImplementationIsNonLazy(const ObjCImplDecl *OD) const { - return OD->getClassMethod(GetNullarySelector("load")) != nullptr; +bool CGObjCNonFragileABIMac::ImplementationIsNonLazy( + const ObjCImplDecl *OD) const { + return OD->getClassMethod(GetNullarySelector("load")) != nullptr || + OD->getClassInterface()->hasAttr<ObjCNonLazyClassAttr>(); } void CGObjCNonFragileABIMac::GetClassSizeInfo(const ObjCImplementationDecl *OID, |