forked from OSchip/llvm-project
Tweak CreateMetadataVar, take the exact alignment instead of relying
on LLVM TargetData. llvm-svn: 66455
This commit is contained in:
parent
66f84e7a42
commit
463cc8ade5
|
@ -436,11 +436,19 @@ protected:
|
||||||
/// This is a convenience wrapper which not only creates the
|
/// This is a convenience wrapper which not only creates the
|
||||||
/// variable, but also sets the section and alignment and adds the
|
/// variable, but also sets the section and alignment and adds the
|
||||||
/// global to the UsedGlobals list.
|
/// global to the UsedGlobals list.
|
||||||
|
///
|
||||||
|
/// \param Name - The variable name.
|
||||||
|
/// \param Init - The variable initializer; this is also used to
|
||||||
|
/// define the type of the variable.
|
||||||
|
/// \param Section - The section the variable should go into, or 0.
|
||||||
|
/// \param Align - The alignment for the variable, or 0.
|
||||||
|
/// \param AddToUsed - Whether the variable should be added to
|
||||||
|
/// llvm.
|
||||||
llvm::GlobalVariable *CreateMetadataVar(const std::string &Name,
|
llvm::GlobalVariable *CreateMetadataVar(const std::string &Name,
|
||||||
llvm::Constant *Init,
|
llvm::Constant *Init,
|
||||||
const char *Section,
|
const char *Section,
|
||||||
bool SetAlignment,
|
unsigned Align,
|
||||||
bool IsUsed);
|
bool AddToUsed);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CGObjCCommonMac(CodeGen::CodeGenModule &cgm) : CGM(cgm)
|
CGObjCCommonMac(CodeGen::CodeGenModule &cgm) : CGM(cgm)
|
||||||
|
@ -1857,8 +1865,8 @@ llvm::GlobalVariable *
|
||||||
CGObjCCommonMac::CreateMetadataVar(const std::string &Name,
|
CGObjCCommonMac::CreateMetadataVar(const std::string &Name,
|
||||||
llvm::Constant *Init,
|
llvm::Constant *Init,
|
||||||
const char *Section,
|
const char *Section,
|
||||||
bool SetAlignment,
|
unsigned Align,
|
||||||
bool IsUsed) {
|
bool AddToUsed) {
|
||||||
const llvm::Type *Ty = Init->getType();
|
const llvm::Type *Ty = Init->getType();
|
||||||
llvm::GlobalVariable *GV =
|
llvm::GlobalVariable *GV =
|
||||||
new llvm::GlobalVariable(Ty, false,
|
new llvm::GlobalVariable(Ty, false,
|
||||||
|
@ -1868,9 +1876,9 @@ CGObjCCommonMac::CreateMetadataVar(const std::string &Name,
|
||||||
&CGM.getModule());
|
&CGM.getModule());
|
||||||
if (Section)
|
if (Section)
|
||||||
GV->setSection(Section);
|
GV->setSection(Section);
|
||||||
if (SetAlignment)
|
if (Align)
|
||||||
GV->setAlignment(CGM.getTargetData().getPrefTypeAlignment(Ty));
|
GV->setAlignment(Align);
|
||||||
if (IsUsed)
|
if (AddToUsed)
|
||||||
UsedGlobals.push_back(GV);
|
UsedGlobals.push_back(GV);
|
||||||
return GV;
|
return GV;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue