diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-01-30 23:15:42 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-01-30 23:15:42 +0000 |
commit | 014858b69f063cbf7b6513eebe964a9f6224970d (patch) | |
tree | f3e7e89323e2c7dd1c8e27e42e4f42e57f34c38f /lib/CodeGen/CGObjCMac.cpp | |
parent | cdf920ed6c610e21fc899ada93370a68c900d180 (diff) |
Setting correct alignent for objc2 meta-data.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63445 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGObjCMac.cpp')
-rw-r--r-- | lib/CodeGen/CGObjCMac.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index 14b39cb13b..07a9df272c 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -363,6 +363,11 @@ 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) { } @@ -3335,6 +3340,7 @@ 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->setSection("__DATA, __objc_const"); UsedGlobals.push_back(CLASS_RO_GV); return CLASS_RO_GV; @@ -3377,6 +3383,7 @@ llvm::GlobalVariable * CGObjCNonFragileABIMac::BuildClassMetaData( ClassName, &CGM.getModule()); GV->setSection("__DATA, __objc_const"); + GV->setAlignment(GetPointerAlign()); UsedGlobals.push_back(GV); return GV; } @@ -3644,6 +3651,7 @@ void CGObjCNonFragileABIMac::GenerateCategory(const ObjCCategoryImplDecl *OCD) Init, ExtCatName, &CGM.getModule()); + GCATV->setAlignment(GetPointerAlign()); GCATV->setSection("__DATA, __objc_const"); UsedGlobals.push_back(GCATV); DefinedCategories.push_back(GCATV); @@ -3700,6 +3708,7 @@ llvm::Constant *CGObjCNonFragileABIMac::EmitMethodList( Init, Name, &CGM.getModule()); + GV->setAlignment(GetPointerAlign()); GV->setSection(Section); UsedGlobals.push_back(GV); return llvm::ConstantExpr::getBitCast(GV, @@ -3953,6 +3962,7 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocol( Init, std::string("\01l_OBJC_PROTOCOL_$_")+ProtocolName, &CGM.getModule()); + Entry->setAlignment(GetPointerAlign()); Entry->setSection("__DATA,__datacoal_nt,coalesced"); } Entry->setVisibility(llvm::GlobalValue::HiddenVisibility); @@ -3967,6 +3977,7 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocol( std::string("\01l_OBJC_LABEL_PROTOCOL_$_") +ProtocolName, &CGM.getModule()); + PTGV->setAlignment(GetPointerAlign()); PTGV->setSection("__DATA, __objc_protolist"); PTGV->setVisibility(llvm::GlobalValue::HiddenVisibility); UsedGlobals.push_back(PTGV); @@ -4015,6 +4026,7 @@ CGObjCNonFragileABIMac::EmitProtocolList(const std::string &Name, Name, &CGM.getModule()); GV->setSection("__DATA, __objc_const"); + GV->setAlignment(GetPointerAlign()); UsedGlobals.push_back(GV); return llvm::ConstantExpr::getBitCast(GV, ObjCTypes.ProtocolListnfABIPtrTy); } |