[llvm-branch-commits] [cfe-branch] r71906 - in /cfe/branches/Apple/Dib: lib/CodeGen/CGObjCMac.cpp test/CodeGenObjC/non-lazy-classes.m
Mike Stump
mrs at apple.com
Fri May 15 16:08:33 PDT 2009
Author: mrs
Date: Fri May 15 18:08:32 2009
New Revision: 71906
URL: http://llvm.org/viewvc/llvm-project?rev=71906&view=rev
Log:
Merge in 71904:
Classes with "+load" methods need to go in the non-lazy class list (or
else the method will not be found by the runtime at class load time).
Added:
cfe/branches/Apple/Dib/test/CodeGenObjC/non-lazy-classes.m
- copied unchanged from r71904, cfe/trunk/test/CodeGenObjC/non-lazy-classes.m
Modified:
cfe/branches/Apple/Dib/lib/CodeGen/CGObjCMac.cpp
Modified: cfe/branches/Apple/Dib/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/lib/CodeGen/CGObjCMac.cpp?rev=71906&r1=71905&r2=71906&view=diff
==============================================================================
--- cfe/branches/Apple/Dib/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/branches/Apple/Dib/lib/CodeGen/CGObjCMac.cpp Fri May 15 18:08:32 2009
@@ -771,10 +771,16 @@
/// DefinedClasses - List of defined classes.
std::vector<llvm::GlobalValue*> DefinedClasses;
+
+ /// DefinedNonLazyClasses - List of defined "non-lazy" classes.
+ std::vector<llvm::GlobalValue*> DefinedNonLazyClasses;
/// DefinedCategories - List of defined categories.
std::vector<llvm::GlobalValue*> DefinedCategories;
+ /// DefinedNonLazyCategories - List of defined "non-lazy" categories.
+ std::vector<llvm::GlobalValue*> DefinedNonLazyCategories;
+
/// UsedGlobals - List of globals to pack into the llvm.used metadata
/// to prevent them from being clobbered.
std::vector<llvm::GlobalVariable*> UsedGlobals;
@@ -1196,6 +1202,10 @@
uint32_t &InstanceStart,
uint32_t &InstanceSize);
+ /// ImplementationIsNonLazy - Check whether the given category or
+ /// class implementation is "non-lazy".
+ bool ImplementationIsNonLazy(const DeclContext *DC) const;
+
public:
CGObjCNonFragileABIMac(CodeGen::CodeGenModule &cgm);
// FIXME. All stubs for now!
@@ -3977,21 +3987,21 @@
// Build list of all implemented class addresses in array
// L_OBJC_LABEL_CLASS_$.
- // FIXME. Also generate in L_OBJC_LABEL_NONLAZY_CLASS_$
- // list of 'nonlazy' implementations (defined as those with a +load{}
- // method!!).
AddModuleClassList(DefinedClasses,
"\01L_OBJC_LABEL_CLASS_$",
"__DATA, __objc_classlist, regular, no_dead_strip");
+ AddModuleClassList(DefinedNonLazyClasses,
+ "\01L_OBJC_LABEL_NONLAZY_CLASS_$",
+ "__DATA, __objc_nlclslist, regular, no_dead_strip");
// Build list of all implemented category addresses in array
// L_OBJC_LABEL_CATEGORY_$.
- // FIXME. Also generate in L_OBJC_LABEL_NONLAZY_CATEGORY_$
- // list of 'nonlazy' category implementations (defined as those with a +load{}
- // method!!).
AddModuleClassList(DefinedCategories,
"\01L_OBJC_LABEL_CATEGORY_$",
"__DATA, __objc_catlist, regular, no_dead_strip");
+ AddModuleClassList(DefinedNonLazyCategories,
+ "\01L_OBJC_LABEL_NONLAZY_CATEGORY_$",
+ "__DATA, __objc_nlcatlist, regular, no_dead_strip");
// static int L_OBJC_IMAGE_INFO[2] = { 0, flags };
// FIXME. flags can be 0 | 1 | 2 | 6. For now just use 0
@@ -4185,6 +4195,19 @@
return GV;
}
+bool
+CGObjCNonFragileABIMac::ImplementationIsNonLazy(const DeclContext *DC) const {
+ DeclContext::lookup_const_result res =
+ DC->lookup(CGM.getContext(), GetNullarySelector("load"));
+
+ for (; res.first != res.second; ++res.first)
+ if (const ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(*res.first))
+ if (OMD->isClassMethod())
+ return true;
+
+ return false;
+}
+
void CGObjCNonFragileABIMac::GetClassSizeInfo(const ObjCImplementationDecl *OID,
uint32_t &InstanceStart,
uint32_t &InstanceSize) {
@@ -4289,6 +4312,10 @@
classIsHidden);
DefinedClasses.push_back(ClassMD);
+ // Determine if this class is also "non-lazy".
+ if (ImplementationIsNonLazy(ID))
+ DefinedNonLazyClasses.push_back(ClassMD);
+
// Force the definition of the EHType if necessary.
if (flags & CLS_EXCEPTION)
GetInterfaceEHType(ID->getClassInterface(), true);
@@ -4339,8 +4366,7 @@
/// const struct _prop_list_t * const properties;
/// }
///
-void CGObjCNonFragileABIMac::GenerateCategory(const ObjCCategoryImplDecl *OCD)
-{
+void CGObjCNonFragileABIMac::GenerateCategory(const ObjCCategoryImplDecl *OCD) {
const ObjCInterfaceDecl *Interface = OCD->getClassInterface();
const char *Prefix = "\01l_OBJC_$_CATEGORY_";
std::string ExtCatName(Prefix + Interface->getNameAsString()+
@@ -4417,6 +4443,10 @@
GCATV->setSection("__DATA, __objc_const");
UsedGlobals.push_back(GCATV);
DefinedCategories.push_back(GCATV);
+
+ // Determine if this category is also "non-lazy".
+ if (ImplementationIsNonLazy(OCD))
+ DefinedNonLazyCategories.push_back(GCATV);
}
/// GetMethodConstant - Return a struct objc_method constant for the
More information about the llvm-branch-commits
mailing list