[llvm-branch-commits] [cfe-branch] r102331 - in /cfe/branches/Apple/williamson: lib/CodeGen/CGObjCMac.cpp test/CodeGenObjC/metadata_symbols.m
Daniel Dunbar
daniel at zuster.org
Mon Apr 26 03:55:44 PDT 2010
Author: ddunbar
Date: Mon Apr 26 05:55:44 2010
New Revision: 102331
URL: http://llvm.org/viewvc/llvm-project?rev=102331&view=rev
Log:
IRgen/NeXT: Fix several alignment issues with Objective-C metadata symbols: - Fix some places that had the alignment hard coded. - Use ABI type alignment, not preferred type alignment -- neither of this is exactly right, as we really want the C type alignment as required by the runtime, but the ABI alignment is a more correct choice.
This should be equivalent for x86_64, but fixes the alignment for ARM.
Modified:
cfe/branches/Apple/williamson/lib/CodeGen/CGObjCMac.cpp
cfe/branches/Apple/williamson/test/CodeGenObjC/metadata_symbols.m
Modified: cfe/branches/Apple/williamson/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/williamson/lib/CodeGen/CGObjCMac.cpp?rev=102331&r1=102330&r2=102331&view=diff
==============================================================================
--- cfe/branches/Apple/williamson/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/branches/Apple/williamson/lib/CodeGen/CGObjCMac.cpp Mon Apr 26 05:55:44 2010
@@ -4189,7 +4189,7 @@
llvm::GlobalValue::InternalLinkage,
Init,
SymbolName);
- GV->setAlignment(8);
+ GV->setAlignment(CGM.getTargetData().getABITypeAlignment(Init->getType()));
GV->setSection(SectionName);
CGM.AddUsedGlobal(GV);
}
@@ -4386,7 +4386,7 @@
std::string("\01l_OBJC_METACLASS_RO_$_")+ClassName :
std::string("\01l_OBJC_CLASS_RO_$_")+ClassName);
CLASS_RO_GV->setAlignment(
- CGM.getTargetData().getPrefTypeAlignment(ObjCTypes.ClassRonfABITy));
+ CGM.getTargetData().getABITypeAlignment(ObjCTypes.ClassRonfABITy));
CLASS_RO_GV->setSection("__DATA, __objc_const");
return CLASS_RO_GV;
@@ -4422,7 +4422,7 @@
GV->setInitializer(Init);
GV->setSection("__DATA, __objc_data");
GV->setAlignment(
- CGM.getTargetData().getPrefTypeAlignment(ObjCTypes.ClassnfABITy));
+ CGM.getTargetData().getABITypeAlignment(ObjCTypes.ClassnfABITy));
if (HiddenVisibility)
GV->setVisibility(llvm::GlobalValue::HiddenVisibility);
return GV;
@@ -4672,7 +4672,7 @@
Init,
ExtCatName);
GCATV->setAlignment(
- CGM.getTargetData().getPrefTypeAlignment(ObjCTypes.CategorynfABITy));
+ CGM.getTargetData().getABITypeAlignment(ObjCTypes.CategorynfABITy));
GCATV->setSection("__DATA, __objc_const");
CGM.AddUsedGlobal(GCATV);
DefinedCategories.push_back(GCATV);
@@ -4732,7 +4732,7 @@
Init,
Name);
GV->setAlignment(
- CGM.getTargetData().getPrefTypeAlignment(Init->getType()));
+ CGM.getTargetData().getABITypeAlignment(Init->getType()));
GV->setSection(Section);
CGM.AddUsedGlobal(GV);
return llvm::ConstantExpr::getBitCast(GV,
@@ -4767,7 +4767,7 @@
IvarOffsetGV->setInitializer(llvm::ConstantInt::get(ObjCTypes.LongTy,
Offset));
IvarOffsetGV->setAlignment(
- CGM.getTargetData().getPrefTypeAlignment(ObjCTypes.LongTy));
+ CGM.getTargetData().getABITypeAlignment(ObjCTypes.LongTy));
// FIXME: This matches gcc, but shouldn't the visibility be set on the use as
// well (i.e., in ObjCIvarOffsetVariable).
@@ -4854,7 +4854,7 @@
Init,
Prefix + OID->getName());
GV->setAlignment(
- CGM.getTargetData().getPrefTypeAlignment(Init->getType()));
+ CGM.getTargetData().getABITypeAlignment(Init->getType()));
GV->setSection("__DATA, __objc_const");
CGM.AddUsedGlobal(GV);
@@ -4973,7 +4973,7 @@
false, llvm::GlobalValue::WeakAnyLinkage, Init,
"\01l_OBJC_PROTOCOL_$_" + PD->getName());
Entry->setAlignment(
- CGM.getTargetData().getPrefTypeAlignment(ObjCTypes.ProtocolnfABITy));
+ CGM.getTargetData().getABITypeAlignment(ObjCTypes.ProtocolnfABITy));
Entry->setSection("__DATA,__datacoal_nt,coalesced");
}
Entry->setVisibility(llvm::GlobalValue::HiddenVisibility);
@@ -4986,7 +4986,7 @@
false, llvm::GlobalValue::WeakAnyLinkage, Entry,
"\01l_OBJC_LABEL_PROTOCOL_$_" + PD->getName());
PTGV->setAlignment(
- CGM.getTargetData().getPrefTypeAlignment(ObjCTypes.ProtocolnfABIPtrTy));
+ CGM.getTargetData().getABITypeAlignment(ObjCTypes.ProtocolnfABIPtrTy));
PTGV->setSection("__DATA, __objc_protolist, coalesced, no_dead_strip");
PTGV->setVisibility(llvm::GlobalValue::HiddenVisibility);
CGM.AddUsedGlobal(PTGV);
@@ -5042,7 +5042,7 @@
Name);
GV->setSection("__DATA, __objc_const");
GV->setAlignment(
- CGM.getTargetData().getPrefTypeAlignment(Init->getType()));
+ CGM.getTargetData().getABITypeAlignment(Init->getType()));
CGM.AddUsedGlobal(GV);
return llvm::ConstantExpr::getBitCast(GV,
ObjCTypes.ProtocolListnfABIPtrTy);
@@ -5239,7 +5239,7 @@
ClassGV,
"\01L_OBJC_CLASSLIST_REFERENCES_$_");
Entry->setAlignment(
- CGM.getTargetData().getPrefTypeAlignment(
+ CGM.getTargetData().getABITypeAlignment(
ObjCTypes.ClassnfABIPtrTy));
Entry->setSection("__DATA, __objc_classrefs, regular, no_dead_strip");
CGM.AddUsedGlobal(Entry);
@@ -5262,7 +5262,7 @@
ClassGV,
"\01L_OBJC_CLASSLIST_SUP_REFS_$_");
Entry->setAlignment(
- CGM.getTargetData().getPrefTypeAlignment(
+ CGM.getTargetData().getABITypeAlignment(
ObjCTypes.ClassnfABIPtrTy));
Entry->setSection("__DATA, __objc_superrefs, regular, no_dead_strip");
CGM.AddUsedGlobal(Entry);
@@ -5288,7 +5288,7 @@
MetaClassGV,
"\01L_OBJC_CLASSLIST_SUP_REFS_$_");
Entry->setAlignment(
- CGM.getTargetData().getPrefTypeAlignment(
+ CGM.getTargetData().getABITypeAlignment(
ObjCTypes.ClassnfABIPtrTy));
Entry->setSection("__DATA, __objc_superrefs, regular, no_dead_strip");
@@ -5848,7 +5848,8 @@
if (CGM.getLangOptions().getVisibilityMode() == LangOptions::Hidden)
Entry->setVisibility(llvm::GlobalValue::HiddenVisibility);
- Entry->setAlignment(8);
+ Entry->setAlignment(CGM.getTargetData().getABITypeAlignment(
+ ObjCTypes.EHTypeTy));
if (ForDefinition) {
Entry->setSection("__DATA,__objc_const");
Modified: cfe/branches/Apple/williamson/test/CodeGenObjC/metadata_symbols.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/williamson/test/CodeGenObjC/metadata_symbols.m?rev=102331&r1=102330&r2=102331&view=diff
==============================================================================
--- cfe/branches/Apple/williamson/test/CodeGenObjC/metadata_symbols.m (original)
+++ cfe/branches/Apple/williamson/test/CodeGenObjC/metadata_symbols.m Mon Apr 26 05:55:44 2010
@@ -23,6 +23,18 @@
// CHECK-X86_64-HIDDEN: define internal void @"\01-[A im0]"
// CHECK-X86_64-HIDDEN: define internal void @"\01-[A(Cat) im1]"
+// RUN: %clang_cc1 -triple armv6-apple-darwin10 -target-abi apcs-gnu -fobjc-nonfragile-abi -emit-llvm -o %t %s
+// RUN: FileCheck -check-prefix=CHECK-ARMV6 < %t %s
+
+// CHECK-ARMV6: @"OBJC_CLASS_$_A" = global {{.*}}, section "__DATA, __objc_data", align 4
+// CHECK-ARMV6: @"OBJC_METACLASS_$_A" = global {{.*}}, section "__DATA, __objc_data", align 4
+// CHECK-ARMV6: @"\01L_OBJC_CLASS_NAME_" = {{.*}}, section "__TEXT,__cstring,cstring_literals", align 1
+// CHECK-ARMV6: @"OBJC_EHTYPE_$_EH1" = weak global {{.*}}, section "__DATA,__datacoal_nt,coalesced", align 4
+// CHECK-ARMV6: @"OBJC_EHTYPE_$_EH2" = external global
+// CHECK-ARMV6: @"OBJC_EHTYPE_$_EH3" = global {{.*}}, section "__DATA,__objc_const", align 4
+// CHECK-ARMV6: @"\01L_OBJC_LABEL_CLASS_$" = internal global {{.*}}, section "__DATA, __objc_classlist, regular, no_dead_strip", align 4
+// CHECK-ARMV6: define internal arm_apcscc void @"\01-[A im0]"
+// CHECK-ARMV6: define internal arm_apcscc void @"\01-[A(Cat) im1]"
@interface A
@end
More information about the llvm-branch-commits
mailing list