aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGObjCMac.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-01-31 02:43:27 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-01-31 02:43:27 +0000
commit09796d6a23c683413470efd19dd5ad331d91af7d (patch)
treecb7d4e1a964e1ddfe1fe26835ac80cca1a69bcc9 /lib/CodeGen/CGObjCMac.cpp
parent21a4f62fa4403f273e8dbb8afcaf9812a2f525c9 (diff)
Use target alignment API to set objc2's meta-data
alignment. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63470 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGObjCMac.cpp')
-rw-r--r--lib/CodeGen/CGObjCMac.cpp33
1 files changed, 20 insertions, 13 deletions
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index 4e6611bc55..23d62097e6 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -363,11 +363,6 @@ protected:
/// defined. The return value has type ProtocolPtrTy.
llvm::Constant *GetProtocolRef(const ObjCProtocolDecl *PD);
- /// GetPointerAlign - get alignment of a pointer.
- uint32_t GetPointerAlign(void) {
- return CGM.getContext().getTypeAlign(CGM.getContext().VoidPtrTy) >> 3;
- }
-
public:
CGObjCCommonMac(CodeGen::CodeGenModule &cgm) : CGM(cgm)
{ }
@@ -3341,7 +3336,8 @@ llvm::GlobalVariable * CGObjCNonFragileABIMac::BuildClassRoTInitializer(
std::string("\01l_OBJC_METACLASS_RO_$_")+ClassName :
std::string("\01l_OBJC_CLASS_RO_$_")+ClassName,
&CGM.getModule());
- CLASS_RO_GV->setAlignment(GetPointerAlign());
+ CLASS_RO_GV->setAlignment(
+ CGM.getTargetData().getPrefTypeAlignment(ObjCTypes.ClassRonfABITy));
CLASS_RO_GV->setSection("__DATA, __objc_const");
UsedGlobals.push_back(CLASS_RO_GV);
return CLASS_RO_GV;
@@ -3385,7 +3381,8 @@ llvm::GlobalVariable * CGObjCNonFragileABIMac::BuildClassMetaData(
ClassName,
&CGM.getModule());
GV->setSection("__DATA, __objc_data");
- GV->setAlignment(GetPointerAlign());
+ GV->setAlignment(
+ CGM.getTargetData().getPrefTypeAlignment(ObjCTypes.ClassnfABITy));
if (HiddenVisibility)
GV->setVisibility(llvm::GlobalValue::HiddenVisibility);
UsedGlobals.push_back(GV);
@@ -3658,7 +3655,8 @@ void CGObjCNonFragileABIMac::GenerateCategory(const ObjCCategoryImplDecl *OCD)
Init,
ExtCatName,
&CGM.getModule());
- GCATV->setAlignment(GetPointerAlign());
+ GCATV->setAlignment(
+ CGM.getTargetData().getPrefTypeAlignment(ObjCTypes.CategorynfABITy));
GCATV->setSection("__DATA, __objc_const");
UsedGlobals.push_back(GCATV);
DefinedCategories.push_back(GCATV);
@@ -3715,7 +3713,8 @@ llvm::Constant *CGObjCNonFragileABIMac::EmitMethodList(
Init,
Name,
&CGM.getModule());
- GV->setAlignment(GetPointerAlign());
+ GV->setAlignment(
+ CGM.getTargetData().getPrefTypeAlignment(Init->getType()));
GV->setSection(Section);
UsedGlobals.push_back(GV);
return llvm::ConstantExpr::getBitCast(GV,
@@ -3735,6 +3734,8 @@ llvm::Constant * CGObjCNonFragileABIMac::EmitIvarOffsetVar(
CGM.getModule().getGlobalVariable(ExternalName);
if (IvarOffsetGV) {
// ivar offset symbol already built due to user code referencing it.
+ IvarOffsetGV->setAlignment(
+ CGM.getTargetData().getPrefTypeAlignment(ObjCTypes.Int8PtrTy));
IvarOffsetGV->setInitializer(Init);
UsedGlobals.push_back(IvarOffsetGV);
return IvarOffsetGV;
@@ -3747,6 +3748,8 @@ llvm::Constant * CGObjCNonFragileABIMac::EmitIvarOffsetVar(
Init,
ExternalName,
&CGM.getModule());
+ IvarOffsetGV->setAlignment(
+ CGM.getTargetData().getPrefTypeAlignment(ObjCTypes.Int8PtrTy));
// @private and @package have hidden visibility.
bool globalVisibility = (Ivar->getAccessControl() == ObjCIvarDecl::Public ||
Ivar->getAccessControl() == ObjCIvarDecl::Protected);
@@ -3848,7 +3851,8 @@ llvm::Constant *CGObjCNonFragileABIMac::EmitIvarList(
Init,
Prefix + OID->getNameAsString(),
&CGM.getModule());
- GV->setAlignment(GetPointerAlign());
+ GV->setAlignment(
+ CGM.getTargetData().getPrefTypeAlignment(Init->getType()));
GV->setSection("__DATA, __objc_const");
UsedGlobals.push_back(GV);
@@ -3974,7 +3978,8 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocol(
Init,
std::string("\01l_OBJC_PROTOCOL_$_")+ProtocolName,
&CGM.getModule());
- Entry->setAlignment(GetPointerAlign());
+ Entry->setAlignment(
+ CGM.getTargetData().getPrefTypeAlignment(ObjCTypes.ProtocolnfABITy));
Entry->setSection("__DATA,__datacoal_nt,coalesced");
}
Entry->setVisibility(llvm::GlobalValue::HiddenVisibility);
@@ -3989,7 +3994,8 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocol(
std::string("\01l_OBJC_LABEL_PROTOCOL_$_")
+ProtocolName,
&CGM.getModule());
- PTGV->setAlignment(GetPointerAlign());
+ PTGV->setAlignment(
+ CGM.getTargetData().getPrefTypeAlignment(ptype));
PTGV->setSection("__DATA, __objc_protolist");
PTGV->setVisibility(llvm::GlobalValue::HiddenVisibility);
UsedGlobals.push_back(PTGV);
@@ -4038,7 +4044,8 @@ CGObjCNonFragileABIMac::EmitProtocolList(const std::string &Name,
Name,
&CGM.getModule());
GV->setSection("__DATA, __objc_const");
- GV->setAlignment(GetPointerAlign());
+ GV->setAlignment(
+ CGM.getTargetData().getPrefTypeAlignment(Init->getType()));
UsedGlobals.push_back(GV);
return llvm::ConstantExpr::getBitCast(GV, ObjCTypes.ProtocolListnfABIPtrTy);
}