Tweaks to Objective-C metadata (32 & 64-bit) to match llvm-gcc.
- Set alignment on property lists.
- 32-bit:
o Set section on property lists.
o Fix section name for category class methods.
o Fix symbol name for property lists.
o Fix section name for class method.
o Set alignment and section on class extension structure.
o Set alignment on a number of things: instance variables, methods,
method descriptions, the symbols structure.
- 64-bit:
o Fix section flags for protocol list.
I doubt most of these were problems in practice, but it is nice to
match llvm-gcc.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69132 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index dd55e65..744481e 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -1308,10 +1308,12 @@
Values[2] = llvm::ConstantArray::get(AT, Properties);
llvm::Constant *Init = llvm::ConstantStruct::get(Values);
- // No special section on property lists?
llvm::GlobalVariable *GV =
- CreateMetadataVar(Name, Init, (ObjCABI == 2) ? "__DATA, __objc_const" : 0,
- 0, true);
+ CreateMetadataVar(Name, Init,
+ (ObjCABI == 2) ? "__DATA, __objc_const" :
+ "__OBJC,__property,regular,no_dead_strip",
+ (ObjCABI == 2) ? 8 : 4,
+ true);
return llvm::ConstantExpr::getBitCast(GV, ObjCTypes.PropertyListPtrTy);
}
@@ -1345,7 +1347,7 @@
Values[1] = llvm::ConstantArray::get(AT, Methods);
llvm::Constant *Init = llvm::ConstantStruct::get(Values);
- llvm::GlobalVariable *GV = CreateMetadataVar(Name, Init, Section, 0, true);
+ llvm::GlobalVariable *GV = CreateMetadataVar(Name, Init, Section, 4, true);
return llvm::ConstantExpr::getBitCast(GV,
ObjCTypes.MethodDescriptionListPtrTy);
}
@@ -1397,7 +1399,7 @@
InstanceMethods);
Values[3] =
EmitMethodList(std::string("\01L_OBJC_CATEGORY_CLASS_METHODS_") + ExtName,
- "__OBJC,__cat_class_meth,regular,no_dead_strip",
+ "__OBJC,__cat_cls_meth,regular,no_dead_strip",
ClassMethods);
if (Category) {
Values[4] =
@@ -1411,7 +1413,7 @@
// If there is no category @interface then there can be no properties.
if (Category) {
- Values[6] = EmitPropertyList(std::string("\01L_OBJC_$_PROP_LIST_") + ExtName,
+ Values[6] = EmitPropertyList(std::string("\01l_OBJC_$_PROP_LIST_") + ExtName,
OCD, Category, ObjCTypes);
} else {
Values[6] = llvm::Constant::getNullValue(ObjCTypes.PropertyListPtrTy);
@@ -1580,7 +1582,7 @@
Values[ 6] = EmitIvarList(ID, true);
Values[ 7] =
EmitMethodList("\01L_OBJC_CLASS_METHODS_" + ID->getNameAsString(),
- "__OBJC,__inst_meth,regular,no_dead_strip",
+ "__OBJC,__cls_meth,regular,no_dead_strip",
Methods);
// cache is always NULL.
Values[ 8] = llvm::Constant::getNullValue(ObjCTypes.CachePtrTy);
@@ -1658,7 +1660,7 @@
// FIXME: Output weak_ivar_layout string.
// Values[1] = BuildIvarLayout(ID, false);
Values[1] = GetIvarLayoutName(0, ObjCTypes);
- Values[2] = EmitPropertyList("\01L_OBJC_$_PROP_LIST_" + ID->getNameAsString(),
+ Values[2] = EmitPropertyList("\01l_OBJC_$_PROP_LIST_" + ID->getNameAsString(),
ID, ID->getClassInterface(), ObjCTypes);
// Return null if no extension bits are used.
@@ -1668,7 +1670,8 @@
llvm::Constant *Init =
llvm::ConstantStruct::get(ObjCTypes.ClassExtensionTy, Values);
return CreateMetadataVar("\01L_OBJC_CLASSEXT_" + ID->getNameAsString(),
- Init, 0, 0, true);
+ Init, "__OBJC,__class_ext,regular,no_dead_strip",
+ 4, true);
}
/// countInheritedIvars - count number of ivars in class and its super class(s)
@@ -1785,9 +1788,8 @@
GV = CreateMetadataVar("\01L_OBJC_INSTANCE_VARIABLES_"
+ ID->getNameAsString(),
Init, "__OBJC,__instance_vars,regular,no_dead_strip",
- 0, true);
- return llvm::ConstantExpr::getBitCast(GV,
- ObjCTypes.IvarListPtrTy);
+ 4, true);
+ return llvm::ConstantExpr::getBitCast(GV, ObjCTypes.IvarListPtrTy);
}
/*
@@ -1837,7 +1839,7 @@
Values[2] = llvm::ConstantArray::get(AT, Methods);
llvm::Constant *Init = llvm::ConstantStruct::get(Values);
- llvm::GlobalVariable *GV = CreateMetadataVar(Name, Init, Section, 0, true);
+ llvm::GlobalVariable *GV = CreateMetadataVar(Name, Init, Section, 4, true);
return llvm::ConstantExpr::getBitCast(GV,
ObjCTypes.MethodListPtrTy);
}
@@ -2488,7 +2490,7 @@
llvm::GlobalVariable *GV =
CreateMetadataVar("\01L_OBJC_SYMBOLS", Init,
"__OBJC,__symbols,regular,no_dead_strip",
- 0, true);
+ 4, true);
return llvm::ConstantExpr::getBitCast(GV, ObjCTypes.SymtabPtrTy);
}
@@ -2505,7 +2507,7 @@
Entry =
CreateMetadataVar("\01L_OBJC_CLASS_REFERENCES_", Casted,
"__OBJC,__cls_refs,literal_pointers,no_dead_strip",
- 0, true);
+ 4, true);
}
return Builder.CreateLoad(Entry, false, "tmp");
@@ -2521,7 +2523,7 @@
Entry =
CreateMetadataVar("\01L_OBJC_SELECTOR_REFERENCES_", Casted,
"__OBJC,__message_refs,literal_pointers,no_dead_strip",
- 0, true);
+ 4, true);
}
return Builder.CreateLoad(Entry, false, "tmp");
@@ -4765,7 +4767,7 @@
&CGM.getModule());
PTGV->setAlignment(
CGM.getTargetData().getPrefTypeAlignment(ObjCTypes.ProtocolnfABIPtrTy));
- PTGV->setSection("__DATA, __objc_protolist");
+ PTGV->setSection("__DATA, __objc_protolist, coalesced, no_dead_strip");
PTGV->setVisibility(llvm::GlobalValue::HiddenVisibility);
UsedGlobals.push_back(PTGV);
return Entry;
@@ -5055,9 +5057,9 @@
ObjCTypes.ClassnfABIPtrTy));
if (IsSuper)
- Entry->setSection("__DATA,__objc_superrefs,regular,no_dead_strip");
+ Entry->setSection("__DATA, __objc_superrefs, regular, no_dead_strip");
else
- Entry->setSection("__DATA,__objc_classrefs,regular,no_dead_strip");
+ Entry->setSection("__DATA, __objc_classrefs, regular, no_dead_strip");
UsedGlobals.push_back(Entry);
}