Update for LLVM API change.

llvm-svn: 75028
This commit is contained in:
Owen Anderson 2009-07-08 19:05:04 +00:00
parent fa04002254
commit c10c8d3e2b
7 changed files with 122 additions and 183 deletions

View File

@ -50,9 +50,9 @@ BuildDescriptorBlockDecl(bool BlockHasCopyDispose, uint64_t Size,
C = llvm::ConstantStruct::get(Elts); C = llvm::ConstantStruct::get(Elts);
C = new llvm::GlobalVariable(CGM.getModule().getContext(), C->getType(), true, C = new llvm::GlobalVariable(CGM.getModule(), C->getType(), true,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
C, "__block_descriptor_tmp", &CGM.getModule()); C, "__block_descriptor_tmp");
return C; return C;
} }
@ -165,10 +165,9 @@ llvm::Value *CodeGenFunction::BuildBlockLiteralTmp(const BlockExpr *BE) {
char Name[32]; char Name[32];
sprintf(Name, "__block_holder_tmp_%d", CGM.getGlobalUniqueCount()); sprintf(Name, "__block_holder_tmp_%d", CGM.getGlobalUniqueCount());
C = new llvm::GlobalVariable(CGM.getModule().getContext(), C = new llvm::GlobalVariable(CGM.getModule(), C->getType(), true,
C->getType(), true,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
C, Name, &CGM.getModule()); C, Name);
QualType BPT = BE->getType(); QualType BPT = BE->getType();
C = llvm::ConstantExpr::getBitCast(C, ConvertType(BPT)); C = llvm::ConstantExpr::getBitCast(C, ConvertType(BPT));
return C; return C;
@ -514,11 +513,9 @@ BlockModule::GetAddrOfGlobalBlock(const BlockExpr *BE, const char * n) {
llvm::ConstantStruct::get(&DescriptorFields[0], 2); llvm::ConstantStruct::get(&DescriptorFields[0], 2);
llvm::GlobalVariable *Descriptor = llvm::GlobalVariable *Descriptor =
new llvm::GlobalVariable(getModule().getContext(), new llvm::GlobalVariable(getModule(), DescriptorStruct->getType(), true,
DescriptorStruct->getType(), true,
llvm::GlobalVariable::InternalLinkage, llvm::GlobalVariable::InternalLinkage,
DescriptorStruct, "__block_descriptor_global", DescriptorStruct, "__block_descriptor_global");
&getModule());
// Generate the constants for the block literal. // Generate the constants for the block literal.
llvm::Constant *LiteralFields[5]; llvm::Constant *LiteralFields[5];
@ -557,11 +554,9 @@ BlockModule::GetAddrOfGlobalBlock(const BlockExpr *BE, const char * n) {
llvm::ConstantStruct::get(&LiteralFields[0], 5); llvm::ConstantStruct::get(&LiteralFields[0], 5);
llvm::GlobalVariable *BlockLiteral = llvm::GlobalVariable *BlockLiteral =
new llvm::GlobalVariable(getModule().getContext(), new llvm::GlobalVariable(getModule(), BlockLiteralStruct->getType(), true,
BlockLiteralStruct->getType(), true,
llvm::GlobalVariable::InternalLinkage, llvm::GlobalVariable::InternalLinkage,
BlockLiteralStruct, "__block_literal_global", BlockLiteralStruct, "__block_literal_global");
&getModule());
return BlockLiteral; return BlockLiteral;
} }

View File

@ -20,7 +20,6 @@
#include "clang/AST/Decl.h" #include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h" #include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclObjC.h" #include "clang/AST/DeclObjC.h"
#include "llvm/Module.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
using namespace clang; using namespace clang;
using namespace CodeGen; using namespace CodeGen;
@ -39,12 +38,10 @@ CodeGenFunction::GenerateStaticCXXBlockVarDeclInit(const VarDecl &D,
// Create the guard variable. // Create the guard variable.
llvm::GlobalValue *GuardV = llvm::GlobalValue *GuardV =
new llvm::GlobalVariable(CGM.getModule().getContext(), new llvm::GlobalVariable(CGM.getModule(), llvm::Type::Int64Ty, false,
llvm::Type::Int64Ty, false,
GV->getLinkage(), GV->getLinkage(),
llvm::Constant::getNullValue(llvm::Type::Int64Ty), llvm::Constant::getNullValue(llvm::Type::Int64Ty),
GuardVName.c_str(), GuardVName.c_str());
&CGM.getModule());
// Load the first byte of the guard variable. // Load the first byte of the guard variable.
const llvm::Type *PtrTy = llvm::PointerType::get(llvm::Type::Int8Ty, 0); const llvm::Type *PtrTy = llvm::PointerType::get(llvm::Type::Int8Ty, 0);

View File

@ -104,10 +104,10 @@ CodeGenFunction::CreateStaticBlockVarDecl(const VarDecl &D,
} }
const llvm::Type *LTy = CGM.getTypes().ConvertTypeForMem(Ty); const llvm::Type *LTy = CGM.getTypes().ConvertTypeForMem(Ty);
return new llvm::GlobalVariable(CGM.getModule().getContext(), return new llvm::GlobalVariable(CGM.getModule(), LTy,
LTy, Ty.isConstant(getContext()), Linkage, Ty.isConstant(getContext()), Linkage,
llvm::Constant::getNullValue(LTy), Name, llvm::Constant::getNullValue(LTy), Name,
&CGM.getModule(), D.isThreadSpecified(), 0, D.isThreadSpecified(),
Ty.getAddressSpace()); Ty.getAddressSpace());
} }
@ -150,10 +150,10 @@ void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D) {
if (GV->getType() != Init->getType()) { if (GV->getType() != Init->getType()) {
llvm::GlobalVariable *OldGV = GV; llvm::GlobalVariable *OldGV = GV;
GV = new llvm::GlobalVariable(CGM.getModule().getContext(), GV = new llvm::GlobalVariable(CGM.getModule(), Init->getType(),
Init->getType(), OldGV->isConstant(), OldGV->isConstant(),
OldGV->getLinkage(), Init, "", OldGV->getLinkage(), Init, "",
&CGM.getModule(), D.isThreadSpecified(), 0, D.isThreadSpecified(),
D.getType().getAddressSpace()); D.getType().getAddressSpace());
// Steal the name of the old global // Steal the name of the old global

View File

@ -394,10 +394,10 @@ public:
llvm::Constant* C = Visit(CLE->getInitializer()); llvm::Constant* C = Visit(CLE->getInitializer());
// FIXME: "Leaked" on failure. // FIXME: "Leaked" on failure.
if (C) if (C)
C = new llvm::GlobalVariable(CGM.getModule().getContext(), C->getType(), C = new llvm::GlobalVariable(CGM.getModule(), C->getType(),
E->getType().isConstQualified(), E->getType().isConstQualified(),
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
C, ".compoundliteral", &CGM.getModule()); C, ".compoundliteral");
return C; return C;
} }
case Expr::DeclRefExprClass: case Expr::DeclRefExprClass:

View File

@ -184,11 +184,11 @@ void CGObjCGNU::EmitClassRef(const std::string &className){
std::string symbolName = "__objc_class_name_" + className; std::string symbolName = "__objc_class_name_" + className;
llvm::GlobalVariable *ClassSymbol = TheModule.getGlobalVariable(symbolName); llvm::GlobalVariable *ClassSymbol = TheModule.getGlobalVariable(symbolName);
if (!ClassSymbol) { if (!ClassSymbol) {
ClassSymbol = new llvm::GlobalVariable(TheModule.getContext(), LongTy, ClassSymbol = new llvm::GlobalVariable(TheModule, LongTy, false,
false, llvm::GlobalValue::ExternalLinkage, 0, symbolName, &TheModule); llvm::GlobalValue::ExternalLinkage, 0, symbolName);
} }
new llvm::GlobalVariable(TheModule.getContext(), ClassSymbol->getType(), true, new llvm::GlobalVariable(TheModule, ClassSymbol->getType(), true,
llvm::GlobalValue::CommonLinkage, ClassSymbol, symbolRef, &TheModule); llvm::GlobalValue::CommonLinkage, ClassSymbol, symbolRef);
} }
static std::string SymbolNameForClass(const std::string &ClassName) { static std::string SymbolNameForClass(const std::string &ClassName) {
@ -291,23 +291,22 @@ llvm::Value *CGObjCGNU::GetSelector(CGBuilderTy &Builder, const ObjCMethodDecl
llvm::Constant *CGObjCGNU::MakeConstantString(const std::string &Str, llvm::Constant *CGObjCGNU::MakeConstantString(const std::string &Str,
const std::string &Name) { const std::string &Name) {
llvm::Constant * ConstStr = llvm::ConstantArray::get(Str); llvm::Constant * ConstStr = llvm::ConstantArray::get(Str);
ConstStr = new llvm::GlobalVariable(TheModule.getContext(), ConstStr = new llvm::GlobalVariable(TheModule, ConstStr->getType(), true,
ConstStr->getType(), true,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
ConstStr, Name, &TheModule); ConstStr, Name);
return llvm::ConstantExpr::getGetElementPtr(ConstStr, Zeros, 2); return llvm::ConstantExpr::getGetElementPtr(ConstStr, Zeros, 2);
} }
llvm::Constant *CGObjCGNU::MakeGlobal(const llvm::StructType *Ty, llvm::Constant *CGObjCGNU::MakeGlobal(const llvm::StructType *Ty,
std::vector<llvm::Constant*> &V, const std::string &Name) { std::vector<llvm::Constant*> &V, const std::string &Name) {
llvm::Constant *C = llvm::ConstantStruct::get(Ty, V); llvm::Constant *C = llvm::ConstantStruct::get(Ty, V);
return new llvm::GlobalVariable(TheModule.getContext(), Ty, false, return new llvm::GlobalVariable(TheModule, Ty, false,
llvm::GlobalValue::InternalLinkage, C, Name, &TheModule); llvm::GlobalValue::InternalLinkage, C, Name);
} }
llvm::Constant *CGObjCGNU::MakeGlobal(const llvm::ArrayType *Ty, llvm::Constant *CGObjCGNU::MakeGlobal(const llvm::ArrayType *Ty,
std::vector<llvm::Constant*> &V, const std::string &Name) { std::vector<llvm::Constant*> &V, const std::string &Name) {
llvm::Constant *C = llvm::ConstantArray::get(Ty, V); llvm::Constant *C = llvm::ConstantArray::get(Ty, V);
return new llvm::GlobalVariable(TheModule.getContext(), Ty, false, return new llvm::GlobalVariable(TheModule, Ty, false,
llvm::GlobalValue::InternalLinkage, C, Name, &TheModule); llvm::GlobalValue::InternalLinkage, C, Name);
} }
/// Generate an NSConstantString object. /// Generate an NSConstantString object.
@ -869,9 +868,9 @@ void CGObjCGNU::GenerateClass(const ObjCImplementationDecl *OID) {
TheModule.getGlobalVariable(classSymbolName)) { TheModule.getGlobalVariable(classSymbolName)) {
symbol->setInitializer(llvm::ConstantInt::get(LongTy, 0)); symbol->setInitializer(llvm::ConstantInt::get(LongTy, 0));
} else { } else {
new llvm::GlobalVariable(TheModule.getContext(), LongTy, false, new llvm::GlobalVariable(TheModule, LongTy, false,
llvm::GlobalValue::ExternalLinkage, llvm::GlobalValue::ExternalLinkage, llvm::ConstantInt::get(LongTy, 0),
llvm::ConstantInt::get(LongTy, 0), classSymbolName, &TheModule); classSymbolName);
} }
// Get the size of instances. // Get the size of instances.
@ -1102,10 +1101,10 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() {
iter != iterEnd; ++iter) { iter != iterEnd; ++iter) {
llvm::Constant *Idxs[] = {Zeros[0], llvm::Constant *Idxs[] = {Zeros[0],
llvm::ConstantInt::get(llvm::Type::Int32Ty, index++), Zeros[0]}; llvm::ConstantInt::get(llvm::Type::Int32Ty, index++), Zeros[0]};
llvm::Constant *SelPtr = new llvm::GlobalVariable(TheModule.getContext(), llvm::Constant *SelPtr = new llvm::GlobalVariable(TheModule, SelStructPtrTy,
SelStructPtrTy, true, llvm::GlobalValue::InternalLinkage, true, llvm::GlobalValue::InternalLinkage,
llvm::ConstantExpr::getGetElementPtr(SelectorList, Idxs, 2), llvm::ConstantExpr::getGetElementPtr(SelectorList, Idxs, 2),
".objc_sel_ptr", &TheModule); ".objc_sel_ptr");
// If selectors are defined as an opaque type, cast the pointer to this // If selectors are defined as an opaque type, cast the pointer to this
// type. // type.
if (isSelOpaque) { if (isSelOpaque) {
@ -1119,10 +1118,10 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() {
iter != iterEnd; iter++) { iter != iterEnd; iter++) {
llvm::Constant *Idxs[] = {Zeros[0], llvm::Constant *Idxs[] = {Zeros[0],
llvm::ConstantInt::get(llvm::Type::Int32Ty, index++), Zeros[0]}; llvm::ConstantInt::get(llvm::Type::Int32Ty, index++), Zeros[0]};
llvm::Constant *SelPtr = new llvm::GlobalVariable(TheModule.getContext(), llvm::Constant *SelPtr = new llvm::GlobalVariable(TheModule, SelStructPtrTy,
SelStructPtrTy, true, llvm::GlobalValue::InternalLinkage, true, llvm::GlobalValue::InternalLinkage,
llvm::ConstantExpr::getGetElementPtr(SelectorList, Idxs, 2), llvm::ConstantExpr::getGetElementPtr(SelectorList, Idxs, 2),
".objc_sel_ptr", &TheModule); ".objc_sel_ptr");
// If selectors are defined as an opaque type, cast the pointer to this // If selectors are defined as an opaque type, cast the pointer to this
// type. // type.
if (isSelOpaque) { if (isSelOpaque) {
@ -1568,8 +1567,8 @@ llvm::GlobalVariable *CGObjCGNU::ObjCIvarOffsetVariable(
uint64_t Offset = ComputeIvarBaseOffset(CGM, ID, Ivar); uint64_t Offset = ComputeIvarBaseOffset(CGM, ID, Ivar);
llvm::ConstantInt *OffsetGuess = llvm::ConstantInt *OffsetGuess =
llvm::ConstantInt::get(LongTy, Offset, "ivar"); llvm::ConstantInt::get(LongTy, Offset, "ivar");
IvarOffsetGV = new llvm::GlobalVariable(TheModule.getContext(), LongTy, IvarOffsetGV = new llvm::GlobalVariable(TheModule, LongTy, false,
false, llvm::GlobalValue::CommonLinkage, OffsetGuess, Name, &TheModule); llvm::GlobalValue::CommonLinkage, OffsetGuess, Name);
} }
return IvarOffsetGV; return IvarOffsetGV;
} }

View File

@ -1646,12 +1646,10 @@ llvm::Constant *CGObjCMac::GetOrEmitProtocol(const ObjCProtocolDecl *PD) {
Entry->setInitializer(Init); Entry->setInitializer(Init);
} else { } else {
Entry = Entry =
new llvm::GlobalVariable(CGM.getModule().getContext(), new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ProtocolTy, false,
ObjCTypes.ProtocolTy, false,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
Init, Init,
std::string("\01L_OBJC_PROTOCOL_")+ProtocolName, std::string("\01L_OBJC_PROTOCOL_")+ProtocolName);
&CGM.getModule());
Entry->setSection("__OBJC,__protocol,regular,no_dead_strip"); Entry->setSection("__OBJC,__protocol,regular,no_dead_strip");
Entry->setAlignment(4); Entry->setAlignment(4);
UsedGlobals.push_back(Entry); UsedGlobals.push_back(Entry);
@ -1670,12 +1668,10 @@ llvm::Constant *CGObjCMac::GetOrEmitProtocolRef(const ObjCProtocolDecl *PD) {
// reference or not. At module finalization we add the empty // reference or not. At module finalization we add the empty
// contents for protocols which were referenced but never defined. // contents for protocols which were referenced but never defined.
Entry = Entry =
new llvm::GlobalVariable(CGM.getModule().getContext(), new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ProtocolTy, false,
ObjCTypes.ProtocolTy, false,
llvm::GlobalValue::ExternalLinkage, llvm::GlobalValue::ExternalLinkage,
0, 0,
"\01L_OBJC_PROTOCOL_" + PD->getNameAsString(), "\01L_OBJC_PROTOCOL_" + PD->getNameAsString());
&CGM.getModule());
Entry->setSection("__OBJC,__protocol,regular,no_dead_strip"); Entry->setSection("__OBJC,__protocol,regular,no_dead_strip");
Entry->setAlignment(4); Entry->setAlignment(4);
UsedGlobals.push_back(Entry); UsedGlobals.push_back(Entry);
@ -2102,11 +2098,9 @@ llvm::Constant *CGObjCMac::EmitMetaClass(const ObjCImplementationDecl *ID,
GV->setLinkage(llvm::GlobalValue::InternalLinkage); GV->setLinkage(llvm::GlobalValue::InternalLinkage);
GV->setInitializer(Init); GV->setInitializer(Init);
} else { } else {
GV = new llvm::GlobalVariable(CGM.getModule().getContext(), GV = new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ClassTy, false,
ObjCTypes.ClassTy, false,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
Init, Name, Init, Name);
&CGM.getModule());
} }
GV->setSection("__OBJC,__meta_class,regular,no_dead_strip"); GV->setSection("__OBJC,__meta_class,regular,no_dead_strip");
GV->setAlignment(4); GV->setAlignment(4);
@ -2133,12 +2127,10 @@ llvm::Constant *CGObjCMac::EmitMetaClassRef(const ObjCInterfaceDecl *ID) {
} else { } else {
// Generate as an external reference to keep a consistent // Generate as an external reference to keep a consistent
// module. This will be patched up when we emit the metaclass. // module. This will be patched up when we emit the metaclass.
return new llvm::GlobalVariable(CGM.getModule().getContext(), return new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ClassTy, false,
ObjCTypes.ClassTy, false,
llvm::GlobalValue::ExternalLinkage, llvm::GlobalValue::ExternalLinkage,
0, 0,
Name, Name);
&CGM.getModule());
} }
} }
@ -2315,11 +2307,10 @@ CGObjCCommonMac::CreateMetadataVar(const std::string &Name,
bool AddToUsed) { bool AddToUsed) {
const llvm::Type *Ty = Init->getType(); const llvm::Type *Ty = Init->getType();
llvm::GlobalVariable *GV = llvm::GlobalVariable *GV =
new llvm::GlobalVariable(CGM.getModule().getContext(), Ty, false, new llvm::GlobalVariable(CGM.getModule(), Ty, false,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
Init, Init,
Name, Name);
&CGM.getModule());
if (Section) if (Section)
GV->setSection(Section); GV->setSection(Section);
if (Align) if (Align)
@ -4075,12 +4066,10 @@ void CGObjCNonFragileABIMac::AddModuleClassList(const
Symbols); Symbols);
llvm::GlobalVariable *GV = llvm::GlobalVariable *GV =
new llvm::GlobalVariable(CGM.getModule().getContext(), new llvm::GlobalVariable(CGM.getModule(), Init->getType(), false,
Init->getType(), false,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
Init, Init,
SymbolName, SymbolName);
&CGM.getModule());
GV->setAlignment(8); GV->setAlignment(8);
GV->setSection(SectionName); GV->setSection(SectionName);
UsedGlobals.push_back(GV); UsedGlobals.push_back(GV);
@ -4122,12 +4111,10 @@ void CGObjCNonFragileABIMac::FinishNonFragileABIModule() {
llvm::ArrayType::get(ObjCTypes.IntTy, 2), llvm::ArrayType::get(ObjCTypes.IntTy, 2),
Values); Values);
llvm::GlobalVariable *IMGV = llvm::GlobalVariable *IMGV =
new llvm::GlobalVariable(CGM.getModule().getContext(), new llvm::GlobalVariable(CGM.getModule(), Init->getType(), false,
Init->getType(), false,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
Init, Init,
"\01L_OBJC_IMAGE_INFO", "\01L_OBJC_IMAGE_INFO");
&CGM.getModule());
IMGV->setSection("__DATA, __objc_imageinfo, regular, no_dead_strip"); IMGV->setSection("__DATA, __objc_imageinfo, regular, no_dead_strip");
IMGV->setConstant(true); IMGV->setConstant(true);
UsedGlobals.push_back(IMGV); UsedGlobals.push_back(IMGV);
@ -4267,14 +4254,12 @@ llvm::GlobalVariable * CGObjCNonFragileABIMac::BuildClassRoTInitializer(
llvm::Constant *Init = llvm::ConstantStruct::get(ObjCTypes.ClassRonfABITy, llvm::Constant *Init = llvm::ConstantStruct::get(ObjCTypes.ClassRonfABITy,
Values); Values);
llvm::GlobalVariable *CLASS_RO_GV = llvm::GlobalVariable *CLASS_RO_GV =
new llvm::GlobalVariable(CGM.getModule().getContext(), new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ClassRonfABITy, false,
ObjCTypes.ClassRonfABITy, false,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
Init, Init,
(flags & CLS_META) ? (flags & CLS_META) ?
std::string("\01l_OBJC_METACLASS_RO_$_")+ClassName : std::string("\01l_OBJC_METACLASS_RO_$_")+ClassName :
std::string("\01l_OBJC_CLASS_RO_$_")+ClassName, std::string("\01l_OBJC_CLASS_RO_$_")+ClassName);
&CGM.getModule());
CLASS_RO_GV->setAlignment( CLASS_RO_GV->setAlignment(
CGM.getTargetData().getPrefTypeAlignment(ObjCTypes.ClassRonfABITy)); CGM.getTargetData().getPrefTypeAlignment(ObjCTypes.ClassRonfABITy));
CLASS_RO_GV->setSection("__DATA, __objc_const"); CLASS_RO_GV->setSection("__DATA, __objc_const");
@ -4343,22 +4328,20 @@ void CGObjCNonFragileABIMac::GenerateClass(const ObjCImplementationDecl *ID) {
std::string ClassName = ID->getNameAsString(); std::string ClassName = ID->getNameAsString();
if (!ObjCEmptyCacheVar) { if (!ObjCEmptyCacheVar) {
ObjCEmptyCacheVar = new llvm::GlobalVariable( ObjCEmptyCacheVar = new llvm::GlobalVariable(
CGM.getModule().getContext(), CGM.getModule(),
ObjCTypes.CacheTy, ObjCTypes.CacheTy,
false, false,
llvm::GlobalValue::ExternalLinkage, llvm::GlobalValue::ExternalLinkage,
0, 0,
"_objc_empty_cache", "_objc_empty_cache");
&CGM.getModule());
ObjCEmptyVtableVar = new llvm::GlobalVariable( ObjCEmptyVtableVar = new llvm::GlobalVariable(
CGM.getModule().getContext(), CGM.getModule(),
ObjCTypes.ImpnfABITy, ObjCTypes.ImpnfABITy,
false, false,
llvm::GlobalValue::ExternalLinkage, llvm::GlobalValue::ExternalLinkage,
0, 0,
"_objc_empty_vtable", "_objc_empty_vtable");
&CGM.getModule());
} }
assert(ID->getClassInterface() && assert(ID->getClassInterface() &&
"CGObjCNonFragileABIMac::GenerateClass - class is 0"); "CGObjCNonFragileABIMac::GenerateClass - class is 0");
@ -4462,12 +4445,11 @@ llvm::Value *CGObjCNonFragileABIMac::GenerateProtocolRef(CGBuilderTy &Builder,
if (PTGV) if (PTGV)
return Builder.CreateLoad(PTGV, false, "tmp"); return Builder.CreateLoad(PTGV, false, "tmp");
PTGV = new llvm::GlobalVariable( PTGV = new llvm::GlobalVariable(
CGM.getModule().getContext(), CGM.getModule(),
Init->getType(), false, Init->getType(), false,
llvm::GlobalValue::WeakAnyLinkage, llvm::GlobalValue::WeakAnyLinkage,
Init, Init,
ProtocolName, ProtocolName);
&CGM.getModule());
PTGV->setSection("__DATA, __objc_protorefs, coalesced, no_dead_strip"); PTGV->setSection("__DATA, __objc_protorefs, coalesced, no_dead_strip");
PTGV->setVisibility(llvm::GlobalValue::HiddenVisibility); PTGV->setVisibility(llvm::GlobalValue::HiddenVisibility);
UsedGlobals.push_back(PTGV); UsedGlobals.push_back(PTGV);
@ -4548,13 +4530,11 @@ void CGObjCNonFragileABIMac::GenerateCategory(const ObjCCategoryImplDecl *OCD) {
llvm::ConstantStruct::get(ObjCTypes.CategorynfABITy, llvm::ConstantStruct::get(ObjCTypes.CategorynfABITy,
Values); Values);
llvm::GlobalVariable *GCATV llvm::GlobalVariable *GCATV
= new llvm::GlobalVariable(CGM.getModule().getContext(), = new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.CategorynfABITy,
ObjCTypes.CategorynfABITy,
false, false,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
Init, Init,
ExtCatName, ExtCatName);
&CGM.getModule());
GCATV->setAlignment( GCATV->setAlignment(
CGM.getTargetData().getPrefTypeAlignment(ObjCTypes.CategorynfABITy)); CGM.getTargetData().getPrefTypeAlignment(ObjCTypes.CategorynfABITy));
GCATV->setSection("__DATA, __objc_const"); GCATV->setSection("__DATA, __objc_const");
@ -4612,12 +4592,10 @@ llvm::Constant *CGObjCNonFragileABIMac::EmitMethodList(
llvm::Constant *Init = llvm::ConstantStruct::get(Values); llvm::Constant *Init = llvm::ConstantStruct::get(Values);
llvm::GlobalVariable *GV = llvm::GlobalVariable *GV =
new llvm::GlobalVariable(CGM.getModule().getContext(), new llvm::GlobalVariable(CGM.getModule(), Init->getType(), false,
Init->getType(), false,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
Init, Init,
Name, Name);
&CGM.getModule());
GV->setAlignment( GV->setAlignment(
CGM.getTargetData().getPrefTypeAlignment(Init->getType())); CGM.getTargetData().getPrefTypeAlignment(Init->getType()));
GV->setSection(Section); GV->setSection(Section);
@ -4642,12 +4620,11 @@ llvm::GlobalVariable * CGObjCNonFragileABIMac::ObjCIvarOffsetVariable(
CGM.getModule().getGlobalVariable(Name); CGM.getModule().getGlobalVariable(Name);
if (!IvarOffsetGV) if (!IvarOffsetGV)
IvarOffsetGV = IvarOffsetGV =
new llvm::GlobalVariable(CGM.getModule().getContext(), ObjCTypes.LongTy, new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.LongTy,
false, false,
llvm::GlobalValue::ExternalLinkage, llvm::GlobalValue::ExternalLinkage,
0, 0,
Name, Name);
&CGM.getModule());
return IvarOffsetGV; return IvarOffsetGV;
} }
@ -4741,12 +4718,10 @@ llvm::Constant *CGObjCNonFragileABIMac::EmitIvarList(
llvm::Constant *Init = llvm::ConstantStruct::get(Values); llvm::Constant *Init = llvm::ConstantStruct::get(Values);
const char *Prefix = "\01l_OBJC_$_INSTANCE_VARIABLES_"; const char *Prefix = "\01l_OBJC_$_INSTANCE_VARIABLES_";
llvm::GlobalVariable *GV = llvm::GlobalVariable *GV =
new llvm::GlobalVariable(CGM.getModule().getContext(), new llvm::GlobalVariable(CGM.getModule(), Init->getType(), false,
Init->getType(), false,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
Init, Init,
Prefix + OID->getNameAsString(), Prefix + OID->getNameAsString());
&CGM.getModule());
GV->setAlignment( GV->setAlignment(
CGM.getTargetData().getPrefTypeAlignment(Init->getType())); CGM.getTargetData().getPrefTypeAlignment(Init->getType()));
GV->setSection("__DATA, __objc_const"); GV->setSection("__DATA, __objc_const");
@ -4765,12 +4740,10 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocolRef(
// reference or not. At module finalization we add the empty // reference or not. At module finalization we add the empty
// contents for protocols which were referenced but never defined. // contents for protocols which were referenced but never defined.
Entry = Entry =
new llvm::GlobalVariable(CGM.getModule().getContext(), new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ProtocolnfABITy, false,
ObjCTypes.ProtocolnfABITy, false,
llvm::GlobalValue::ExternalLinkage, llvm::GlobalValue::ExternalLinkage,
0, 0,
"\01l_OBJC_PROTOCOL_$_" + PD->getNameAsString(), "\01l_OBJC_PROTOCOL_$_" + PD->getNameAsString());
&CGM.getModule());
Entry->setSection("__DATA,__datacoal_nt,coalesced"); Entry->setSection("__DATA,__datacoal_nt,coalesced");
UsedGlobals.push_back(Entry); UsedGlobals.push_back(Entry);
} }
@ -4870,12 +4843,10 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocol(
Entry->setInitializer(Init); Entry->setInitializer(Init);
} else { } else {
Entry = Entry =
new llvm::GlobalVariable(CGM.getModule().getContext(), new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ProtocolnfABITy, false,
ObjCTypes.ProtocolnfABITy, false,
llvm::GlobalValue::WeakAnyLinkage, llvm::GlobalValue::WeakAnyLinkage,
Init, Init,
std::string("\01l_OBJC_PROTOCOL_$_")+ProtocolName, std::string("\01l_OBJC_PROTOCOL_$_")+ProtocolName);
&CGM.getModule());
Entry->setAlignment( Entry->setAlignment(
CGM.getTargetData().getPrefTypeAlignment(ObjCTypes.ProtocolnfABITy)); CGM.getTargetData().getPrefTypeAlignment(ObjCTypes.ProtocolnfABITy));
Entry->setSection("__DATA,__datacoal_nt,coalesced"); Entry->setSection("__DATA,__datacoal_nt,coalesced");
@ -4885,13 +4856,12 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocol(
// Use this protocol meta-data to build protocol list table in section // Use this protocol meta-data to build protocol list table in section
// __DATA, __objc_protolist // __DATA, __objc_protolist
llvm::GlobalVariable *PTGV = new llvm::GlobalVariable( llvm::GlobalVariable *PTGV = new llvm::GlobalVariable(
CGM.getModule().getContext(), CGM.getModule(),
ObjCTypes.ProtocolnfABIPtrTy, false, ObjCTypes.ProtocolnfABIPtrTy, false,
llvm::GlobalValue::WeakAnyLinkage, llvm::GlobalValue::WeakAnyLinkage,
Entry, Entry,
std::string("\01l_OBJC_LABEL_PROTOCOL_$_") std::string("\01l_OBJC_LABEL_PROTOCOL_$_")
+ProtocolName, +ProtocolName);
&CGM.getModule());
PTGV->setAlignment( PTGV->setAlignment(
CGM.getTargetData().getPrefTypeAlignment(ObjCTypes.ProtocolnfABIPtrTy)); CGM.getTargetData().getPrefTypeAlignment(ObjCTypes.ProtocolnfABIPtrTy));
PTGV->setSection("__DATA, __objc_protolist, coalesced, no_dead_strip"); PTGV->setSection("__DATA, __objc_protolist, coalesced, no_dead_strip");
@ -4939,12 +4909,10 @@ CGObjCNonFragileABIMac::EmitProtocolList(const std::string &Name,
ProtocolRefs); ProtocolRefs);
llvm::Constant *Init = llvm::ConstantStruct::get(Values); llvm::Constant *Init = llvm::ConstantStruct::get(Values);
GV = new llvm::GlobalVariable(CGM.getModule().getContext(), GV = new llvm::GlobalVariable(CGM.getModule(), Init->getType(), false,
Init->getType(), false,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
Init, Init,
Name, Name);
&CGM.getModule());
GV->setSection("__DATA, __objc_const"); GV->setSection("__DATA, __objc_const");
GV->setAlignment( GV->setAlignment(
CGM.getTargetData().getPrefTypeAlignment(Init->getType())); CGM.getTargetData().getPrefTypeAlignment(Init->getType()));
@ -5083,12 +5051,10 @@ CodeGen::RValue CGObjCNonFragileABIMac::EmitMessageSend(
Values[0] = Fn; Values[0] = Fn;
Values[1] = GetMethodVarName(Sel); Values[1] = GetMethodVarName(Sel);
llvm::Constant *Init = llvm::ConstantStruct::get(Values); llvm::Constant *Init = llvm::ConstantStruct::get(Values);
GV = new llvm::GlobalVariable(CGM.getModule().getContext(), GV = new llvm::GlobalVariable(CGM.getModule(), Init->getType(), false,
Init->getType(), false,
llvm::GlobalValue::WeakAnyLinkage, llvm::GlobalValue::WeakAnyLinkage,
Init, Init,
Name, Name);
&CGM.getModule());
GV->setVisibility(llvm::GlobalValue::HiddenVisibility); GV->setVisibility(llvm::GlobalValue::HiddenVisibility);
GV->setAlignment(16); GV->setAlignment(16);
GV->setSection("__DATA, __objc_msgrefs, coalesced"); GV->setSection("__DATA, __objc_msgrefs, coalesced");
@ -5132,10 +5098,9 @@ CGObjCNonFragileABIMac::GetClassGlobal(const std::string &Name) {
llvm::GlobalVariable *GV = CGM.getModule().getGlobalVariable(Name); llvm::GlobalVariable *GV = CGM.getModule().getGlobalVariable(Name);
if (!GV) { if (!GV) {
GV = new llvm::GlobalVariable(CGM.getModule().getContext(), GV = new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ClassnfABITy,
ObjCTypes.ClassnfABITy, false, false, llvm::GlobalValue::ExternalLinkage,
llvm::GlobalValue::ExternalLinkage, 0, Name);
0, Name, &CGM.getModule());
} }
return GV; return GV;
@ -5149,12 +5114,10 @@ llvm::Value *CGObjCNonFragileABIMac::EmitClassRef(CGBuilderTy &Builder,
std::string ClassName(getClassSymbolPrefix() + ID->getNameAsString()); std::string ClassName(getClassSymbolPrefix() + ID->getNameAsString());
llvm::GlobalVariable *ClassGV = GetClassGlobal(ClassName); llvm::GlobalVariable *ClassGV = GetClassGlobal(ClassName);
Entry = Entry =
new llvm::GlobalVariable(CGM.getModule().getContext(), new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ClassnfABIPtrTy,
ObjCTypes.ClassnfABIPtrTy, false, false, llvm::GlobalValue::InternalLinkage,
llvm::GlobalValue::InternalLinkage,
ClassGV, ClassGV,
"\01L_OBJC_CLASSLIST_REFERENCES_$_", "\01L_OBJC_CLASSLIST_REFERENCES_$_");
&CGM.getModule());
Entry->setAlignment( Entry->setAlignment(
CGM.getTargetData().getPrefTypeAlignment( CGM.getTargetData().getPrefTypeAlignment(
ObjCTypes.ClassnfABIPtrTy)); ObjCTypes.ClassnfABIPtrTy));
@ -5174,12 +5137,10 @@ CGObjCNonFragileABIMac::EmitSuperClassRef(CGBuilderTy &Builder,
std::string ClassName(getClassSymbolPrefix() + ID->getNameAsString()); std::string ClassName(getClassSymbolPrefix() + ID->getNameAsString());
llvm::GlobalVariable *ClassGV = GetClassGlobal(ClassName); llvm::GlobalVariable *ClassGV = GetClassGlobal(ClassName);
Entry = Entry =
new llvm::GlobalVariable(CGM.getModule().getContext(), new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ClassnfABIPtrTy,
ObjCTypes.ClassnfABIPtrTy, false, false, llvm::GlobalValue::InternalLinkage,
llvm::GlobalValue::InternalLinkage,
ClassGV, ClassGV,
"\01L_OBJC_CLASSLIST_SUP_REFS_$_", "\01L_OBJC_CLASSLIST_SUP_REFS_$_");
&CGM.getModule());
Entry->setAlignment( Entry->setAlignment(
CGM.getTargetData().getPrefTypeAlignment( CGM.getTargetData().getPrefTypeAlignment(
ObjCTypes.ClassnfABIPtrTy)); ObjCTypes.ClassnfABIPtrTy));
@ -5202,12 +5163,10 @@ llvm::Value *CGObjCNonFragileABIMac::EmitMetaClassRef(CGBuilderTy &Builder,
std::string MetaClassName(getMetaclassSymbolPrefix() + ID->getNameAsString()); std::string MetaClassName(getMetaclassSymbolPrefix() + ID->getNameAsString());
llvm::GlobalVariable *MetaClassGV = GetClassGlobal(MetaClassName); llvm::GlobalVariable *MetaClassGV = GetClassGlobal(MetaClassName);
Entry = Entry =
new llvm::GlobalVariable(CGM.getModule().getContext(), new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ClassnfABIPtrTy, false,
ObjCTypes.ClassnfABIPtrTy, false,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
MetaClassGV, MetaClassGV,
"\01L_OBJC_CLASSLIST_SUP_REFS_$_", "\01L_OBJC_CLASSLIST_SUP_REFS_$_");
&CGM.getModule());
Entry->setAlignment( Entry->setAlignment(
CGM.getTargetData().getPrefTypeAlignment( CGM.getTargetData().getPrefTypeAlignment(
ObjCTypes.ClassnfABIPtrTy)); ObjCTypes.ClassnfABIPtrTy));
@ -5291,11 +5250,9 @@ llvm::Value *CGObjCNonFragileABIMac::EmitSelector(CGBuilderTy &Builder,
llvm::ConstantExpr::getBitCast(GetMethodVarName(Sel), llvm::ConstantExpr::getBitCast(GetMethodVarName(Sel),
ObjCTypes.SelectorPtrTy); ObjCTypes.SelectorPtrTy);
Entry = Entry =
new llvm::GlobalVariable(CGM.getModule().getContext(), new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.SelectorPtrTy, false,
ObjCTypes.SelectorPtrTy, false,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
Casted, "\01L_OBJC_SELECTOR_REFERENCES_", Casted, "\01L_OBJC_SELECTOR_REFERENCES_");
&CGM.getModule());
Entry->setSection("__DATA, __objc_selrefs, literal_pointers, no_dead_strip"); Entry->setSection("__DATA, __objc_selrefs, literal_pointers, no_dead_strip");
UsedGlobals.push_back(Entry); UsedGlobals.push_back(Entry);
} }
@ -5492,10 +5449,10 @@ CGObjCNonFragileABIMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
CGM.getModule().getGlobalVariable("OBJC_EHTYPE_id"); CGM.getModule().getGlobalVariable("OBJC_EHTYPE_id");
if (!IDEHType) if (!IDEHType)
IDEHType = IDEHType =
new llvm::GlobalVariable(CGM.getModule().getContext(), new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.EHTypeTy,
ObjCTypes.EHTypeTy, false, false,
llvm::GlobalValue::ExternalLinkage, llvm::GlobalValue::ExternalLinkage,
0, "OBJC_EHTYPE_id", &CGM.getModule()); 0, "OBJC_EHTYPE_id");
SelectorArgs.push_back(IDEHType); SelectorArgs.push_back(IDEHType);
HasCatchAll = true; HasCatchAll = true;
break; break;
@ -5710,13 +5667,11 @@ CGObjCNonFragileABIMac::GetInterfaceEHType(const ObjCInterfaceDecl *ID,
// attribute, emit an external reference. // attribute, emit an external reference.
if (hasObjCExceptionAttribute(CGM.getContext(), ID)) if (hasObjCExceptionAttribute(CGM.getContext(), ID))
return Entry = return Entry =
new llvm::GlobalVariable(CGM.getModule().getContext(), new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.EHTypeTy, false,
ObjCTypes.EHTypeTy, false,
llvm::GlobalValue::ExternalLinkage, llvm::GlobalValue::ExternalLinkage,
0, 0,
(std::string("OBJC_EHTYPE_$_") + (std::string("OBJC_EHTYPE_$_") +
ID->getIdentifier()->getName()), ID->getIdentifier()->getName()));
&CGM.getModule());
} }
// Otherwise we need to either make a new entry or fill in the // Otherwise we need to either make a new entry or fill in the
@ -5727,10 +5682,10 @@ CGObjCNonFragileABIMac::GetInterfaceEHType(const ObjCInterfaceDecl *ID,
llvm::GlobalVariable *VTableGV = llvm::GlobalVariable *VTableGV =
CGM.getModule().getGlobalVariable(VTableName); CGM.getModule().getGlobalVariable(VTableName);
if (!VTableGV) if (!VTableGV)
VTableGV = new llvm::GlobalVariable(CGM.getModule().getContext(), VTableGV = new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.Int8PtrTy,
ObjCTypes.Int8PtrTy, false, false,
llvm::GlobalValue::ExternalLinkage, llvm::GlobalValue::ExternalLinkage,
0, VTableName, &CGM.getModule()); 0, VTableName);
llvm::Value *VTableIdx = llvm::ConstantInt::get(llvm::Type::Int32Ty, 2); llvm::Value *VTableIdx = llvm::ConstantInt::get(llvm::Type::Int32Ty, 2);
@ -5743,13 +5698,11 @@ CGObjCNonFragileABIMac::GetInterfaceEHType(const ObjCInterfaceDecl *ID,
if (Entry) { if (Entry) {
Entry->setInitializer(Init); Entry->setInitializer(Init);
} else { } else {
Entry = new llvm::GlobalVariable(CGM.getModule().getContext(), Entry = new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.EHTypeTy, false,
ObjCTypes.EHTypeTy, false,
llvm::GlobalValue::WeakAnyLinkage, llvm::GlobalValue::WeakAnyLinkage,
Init, Init,
(std::string("OBJC_EHTYPE_$_") + (std::string("OBJC_EHTYPE_$_") +
ID->getIdentifier()->getName()), ID->getIdentifier()->getName()));
&CGM.getModule());
} }
if (CGM.getLangOptions().getVisibilityMode() == LangOptions::Hidden) if (CGM.getLangOptions().getVisibilityMode() == LangOptions::Hidden)

View File

@ -216,11 +216,10 @@ void CodeGenModule::EmitCtorList(const CtorList &Fns, const char *GlobalName) {
if (!Ctors.empty()) { if (!Ctors.empty()) {
llvm::ArrayType *AT = llvm::ArrayType::get(CtorStructTy, Ctors.size()); llvm::ArrayType *AT = llvm::ArrayType::get(CtorStructTy, Ctors.size());
new llvm::GlobalVariable(TheModule.getContext(), AT, false, new llvm::GlobalVariable(TheModule, AT, false,
llvm::GlobalValue::AppendingLinkage, llvm::GlobalValue::AppendingLinkage,
llvm::ConstantArray::get(AT, Ctors), llvm::ConstantArray::get(AT, Ctors),
GlobalName, GlobalName);
&TheModule);
} }
} }
@ -234,9 +233,9 @@ void CodeGenModule::EmitAnnotations() {
Annotations.size()), Annotations.size()),
Annotations); Annotations);
llvm::GlobalValue *gv = llvm::GlobalValue *gv =
new llvm::GlobalVariable(TheModule.getContext(), Array->getType(), false, new llvm::GlobalVariable(TheModule, Array->getType(), false,
llvm::GlobalValue::AppendingLinkage, Array, llvm::GlobalValue::AppendingLinkage, Array,
"llvm.global.annotations", &TheModule); "llvm.global.annotations");
gv->setSection("llvm.metadata"); gv->setSection("llvm.metadata");
} }
@ -436,10 +435,10 @@ void CodeGenModule::EmitLLVMUsed() {
llvm::ArrayType *ATy = llvm::ArrayType::get(i8PTy, UsedArray.size()); llvm::ArrayType *ATy = llvm::ArrayType::get(i8PTy, UsedArray.size());
llvm::GlobalVariable *GV = llvm::GlobalVariable *GV =
new llvm::GlobalVariable(getModule().getContext(), ATy, false, new llvm::GlobalVariable(getModule(), ATy, false,
llvm::GlobalValue::AppendingLinkage, llvm::GlobalValue::AppendingLinkage,
llvm::ConstantArray::get(ATy, UsedArray), llvm::ConstantArray::get(ATy, UsedArray),
"llvm.used", &getModule()); "llvm.used");
GV->setSection("llvm.metadata"); GV->setSection("llvm.metadata");
} }
@ -494,14 +493,14 @@ llvm::Constant *CodeGenModule::EmitAnnotateAttr(llvm::GlobalValue *GV,
// created to hold the bytes of the strings. // created to hold the bytes of the strings.
const char *StringPrefix = getContext().Target.getStringSymbolPrefix(true); const char *StringPrefix = getContext().Target.getStringSymbolPrefix(true);
llvm::GlobalValue *annoGV = llvm::GlobalValue *annoGV =
new llvm::GlobalVariable(M->getContext(), anno->getType(), false, new llvm::GlobalVariable(*M, anno->getType(), false,
llvm::GlobalValue::InternalLinkage, anno, llvm::GlobalValue::InternalLinkage, anno,
GV->getName() + StringPrefix, M); GV->getName() + StringPrefix);
// translation unit name string, emitted into the llvm.metadata section. // translation unit name string, emitted into the llvm.metadata section.
llvm::GlobalValue *unitGV = llvm::GlobalValue *unitGV =
new llvm::GlobalVariable(M->getContext(), unit->getType(), false, new llvm::GlobalVariable(*M, unit->getType(), false,
llvm::GlobalValue::InternalLinkage, unit, llvm::GlobalValue::InternalLinkage, unit,
StringPrefix, M); StringPrefix);
// Create the ConstantStruct for the global annotation. // Create the ConstantStruct for the global annotation.
llvm::Constant *Fields[4] = { llvm::Constant *Fields[4] = {
@ -719,10 +718,9 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMGlobal(const char *MangledName,
} }
llvm::GlobalVariable *GV = llvm::GlobalVariable *GV =
new llvm::GlobalVariable(getModule().getContext(), new llvm::GlobalVariable(getModule(), Ty->getElementType(), false,
Ty->getElementType(), false,
llvm::GlobalValue::ExternalLinkage, llvm::GlobalValue::ExternalLinkage,
0, "", &getModule(), 0, "", 0,
false, Ty->getAddressSpace()); false, Ty->getAddressSpace());
GV->setName(MangledName); GV->setName(MangledName);
@ -1246,10 +1244,9 @@ GetAddrOfConstantCFString(const StringLiteral *Literal) {
// likely see an opaque error message. This is a general issue with relying // likely see an opaque error message. This is a general issue with relying
// on particular names. // on particular names.
llvm::GlobalVariable *GV = llvm::GlobalVariable *GV =
new llvm::GlobalVariable(getModule().getContext(), Ty, false, new llvm::GlobalVariable(getModule(), Ty, false,
llvm::GlobalVariable::ExternalLinkage, 0, llvm::GlobalVariable::ExternalLinkage, 0,
"__CFConstantStringClassReference", "__CFConstantStringClassReference");
&getModule());
// Decay array -> ptr // Decay array -> ptr
CFConstantStringClassRef = CFConstantStringClassRef =
@ -1300,9 +1297,9 @@ GetAddrOfConstantCFString(const StringLiteral *Literal) {
isConstant = true; isConstant = true;
} }
llvm::GlobalVariable *GV = llvm::GlobalVariable *GV =
new llvm::GlobalVariable(getModule().getContext(), C->getType(), isConstant, new llvm::GlobalVariable(getModule(), C->getType(), isConstant,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
C, Prefix, &getModule()); C, Prefix);
if (Sect) if (Sect)
GV->setSection(Sect); GV->setSection(Sect);
if (isUTF16) { if (isUTF16) {
@ -1322,10 +1319,9 @@ GetAddrOfConstantCFString(const StringLiteral *Literal) {
// The struct. // The struct.
C = llvm::ConstantStruct::get(STy, Fields); C = llvm::ConstantStruct::get(STy, Fields);
GV = new llvm::GlobalVariable(getModule().getContext(), C->getType(), true, GV = new llvm::GlobalVariable(getModule(), C->getType(), true,
llvm::GlobalVariable::InternalLinkage, C, llvm::GlobalVariable::InternalLinkage, C,
getContext().Target.getCFStringSymbolPrefix(), getContext().Target.getCFStringSymbolPrefix());
&getModule());
if (const char *Sect = getContext().Target.getCFStringSection()) if (const char *Sect = getContext().Target.getCFStringSection())
GV->setSection(Sect); GV->setSection(Sect);
Entry.setValue(GV); Entry.setValue(GV);
@ -1383,10 +1379,9 @@ static llvm::Constant *GenerateStringLiteral(const std::string &str,
llvm::Constant *C = llvm::ConstantArray::get(str, false); llvm::Constant *C = llvm::ConstantArray::get(str, false);
// Create a global variable for this string // Create a global variable for this string
return new llvm::GlobalVariable(CGM.getModule().getContext(), return new llvm::GlobalVariable(CGM.getModule(), C->getType(), constant,
C->getType(), constant,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
C, GlobalName, &CGM.getModule()); C, GlobalName);
} }
/// GetAddrOfConstantString - Returns a pointer to a character array /// GetAddrOfConstantString - Returns a pointer to a character array