Update for LLVM API change.

llvm-svn: 74986
This commit is contained in:
Owen Anderson 2009-07-08 01:29:18 +00:00
parent 5948fdf68b
commit 9f211fb4fa
7 changed files with 94 additions and 56 deletions

View File

@ -50,7 +50,7 @@ BuildDescriptorBlockDecl(bool BlockHasCopyDispose, uint64_t Size,
C = llvm::ConstantStruct::get(Elts); C = llvm::ConstantStruct::get(Elts);
C = new llvm::GlobalVariable(C->getType(), true, C = new llvm::GlobalVariable(CGM.getModule().getContext(), C->getType(), true,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
C, "__block_descriptor_tmp", &CGM.getModule()); C, "__block_descriptor_tmp", &CGM.getModule());
return C; return C;
@ -165,7 +165,8 @@ 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(C->getType(), true, C = new llvm::GlobalVariable(CGM.getModule().getContext(),
C->getType(), true,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
C, Name, &CGM.getModule()); C, Name, &CGM.getModule());
QualType BPT = BE->getType(); QualType BPT = BE->getType();
@ -513,7 +514,8 @@ 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(DescriptorStruct->getType(), true, new llvm::GlobalVariable(getModule().getContext(),
DescriptorStruct->getType(), true,
llvm::GlobalVariable::InternalLinkage, llvm::GlobalVariable::InternalLinkage,
DescriptorStruct, "__block_descriptor_global", DescriptorStruct, "__block_descriptor_global",
&getModule()); &getModule());
@ -555,7 +557,8 @@ 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(BlockLiteralStruct->getType(), true, new llvm::GlobalVariable(getModule().getContext(),
BlockLiteralStruct->getType(), true,
llvm::GlobalVariable::InternalLinkage, llvm::GlobalVariable::InternalLinkage,
BlockLiteralStruct, "__block_literal_global", BlockLiteralStruct, "__block_literal_global",
&getModule()); &getModule());

View File

@ -20,6 +20,7 @@
#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;
@ -38,7 +39,8 @@ CodeGenFunction::GenerateStaticCXXBlockVarDeclInit(const VarDecl &D,
// Create the guard variable. // Create the guard variable.
llvm::GlobalValue *GuardV = llvm::GlobalValue *GuardV =
new llvm::GlobalVariable(llvm::Type::Int64Ty, false, new llvm::GlobalVariable(CGM.getModule().getContext(),
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(),

View File

@ -104,7 +104,8 @@ 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(LTy, Ty.isConstant(getContext()), Linkage, return new llvm::GlobalVariable(CGM.getModule().getContext(),
LTy, Ty.isConstant(getContext()), Linkage,
llvm::Constant::getNullValue(LTy), Name, llvm::Constant::getNullValue(LTy), Name,
&CGM.getModule(), D.isThreadSpecified(), &CGM.getModule(), D.isThreadSpecified(),
Ty.getAddressSpace()); Ty.getAddressSpace());
@ -149,7 +150,8 @@ 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(Init->getType(), OldGV->isConstant(), GV = new llvm::GlobalVariable(CGM.getModule().getContext(),
Init->getType(), OldGV->isConstant(),
OldGV->getLinkage(), Init, "", OldGV->getLinkage(), Init, "",
&CGM.getModule(), D.isThreadSpecified(), &CGM.getModule(), D.isThreadSpecified(),
D.getType().getAddressSpace()); D.getType().getAddressSpace());

View File

@ -394,7 +394,7 @@ 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(C->getType(), C = new llvm::GlobalVariable(CGM.getModule().getContext(), C->getType(),
E->getType().isConstQualified(), E->getType().isConstQualified(),
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
C, ".compoundliteral", &CGM.getModule()); C, ".compoundliteral", &CGM.getModule());

View File

@ -184,10 +184,10 @@ 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(LongTy, false, ClassSymbol = new llvm::GlobalVariable(TheModule.getContext(), LongTy,
llvm::GlobalValue::ExternalLinkage, 0, symbolName, &TheModule); false, llvm::GlobalValue::ExternalLinkage, 0, symbolName, &TheModule);
} }
new llvm::GlobalVariable(ClassSymbol->getType(), true, new llvm::GlobalVariable(TheModule.getContext(), ClassSymbol->getType(), true,
llvm::GlobalValue::CommonLinkage, ClassSymbol, symbolRef, &TheModule); llvm::GlobalValue::CommonLinkage, ClassSymbol, symbolRef, &TheModule);
} }
@ -291,7 +291,8 @@ 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(ConstStr->getType(), true, ConstStr = new llvm::GlobalVariable(TheModule.getContext(),
ConstStr->getType(), true,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
ConstStr, Name, &TheModule); ConstStr, Name, &TheModule);
return llvm::ConstantExpr::getGetElementPtr(ConstStr, Zeros, 2); return llvm::ConstantExpr::getGetElementPtr(ConstStr, Zeros, 2);
@ -299,13 +300,13 @@ llvm::Constant *CGObjCGNU::MakeConstantString(const std::string &Str,
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(Ty, false, return new llvm::GlobalVariable(TheModule.getContext(), Ty, false,
llvm::GlobalValue::InternalLinkage, C, Name, &TheModule); llvm::GlobalValue::InternalLinkage, C, Name, &TheModule);
} }
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(Ty, false, return new llvm::GlobalVariable(TheModule.getContext(), Ty, false,
llvm::GlobalValue::InternalLinkage, C, Name, &TheModule); llvm::GlobalValue::InternalLinkage, C, Name, &TheModule);
} }
@ -868,7 +869,8 @@ 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(LongTy, false, llvm::GlobalValue::ExternalLinkage, new llvm::GlobalVariable(TheModule.getContext(), LongTy, false,
llvm::GlobalValue::ExternalLinkage,
llvm::ConstantInt::get(LongTy, 0), classSymbolName, &TheModule); llvm::ConstantInt::get(LongTy, 0), classSymbolName, &TheModule);
} }
@ -1100,8 +1102,8 @@ 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(SelStructPtrTy, llvm::Constant *SelPtr = new llvm::GlobalVariable(TheModule.getContext(),
true, llvm::GlobalValue::InternalLinkage, SelStructPtrTy, true, llvm::GlobalValue::InternalLinkage,
llvm::ConstantExpr::getGetElementPtr(SelectorList, Idxs, 2), llvm::ConstantExpr::getGetElementPtr(SelectorList, Idxs, 2),
".objc_sel_ptr", &TheModule); ".objc_sel_ptr", &TheModule);
// 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
@ -1117,8 +1119,8 @@ 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(SelStructPtrTy, true, llvm::Constant *SelPtr = new llvm::GlobalVariable(TheModule.getContext(),
llvm::GlobalValue::InternalLinkage, SelStructPtrTy, true, llvm::GlobalValue::InternalLinkage,
llvm::ConstantExpr::getGetElementPtr(SelectorList, Idxs, 2), llvm::ConstantExpr::getGetElementPtr(SelectorList, Idxs, 2),
".objc_sel_ptr", &TheModule); ".objc_sel_ptr", &TheModule);
// 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
@ -1566,8 +1568,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(LongTy, false, IvarOffsetGV = new llvm::GlobalVariable(TheModule.getContext(), LongTy,
llvm::GlobalValue::CommonLinkage, OffsetGuess, Name, &TheModule); false, llvm::GlobalValue::CommonLinkage, OffsetGuess, Name, &TheModule);
} }
return IvarOffsetGV; return IvarOffsetGV;
} }

View File

@ -1646,7 +1646,8 @@ llvm::Constant *CGObjCMac::GetOrEmitProtocol(const ObjCProtocolDecl *PD) {
Entry->setInitializer(Init); Entry->setInitializer(Init);
} else { } else {
Entry = Entry =
new llvm::GlobalVariable(ObjCTypes.ProtocolTy, false, new llvm::GlobalVariable(CGM.getModule().getContext(),
ObjCTypes.ProtocolTy, false,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
Init, Init,
std::string("\01L_OBJC_PROTOCOL_")+ProtocolName, std::string("\01L_OBJC_PROTOCOL_")+ProtocolName,
@ -1669,7 +1670,8 @@ 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(ObjCTypes.ProtocolTy, false, new llvm::GlobalVariable(CGM.getModule().getContext(),
ObjCTypes.ProtocolTy, false,
llvm::GlobalValue::ExternalLinkage, llvm::GlobalValue::ExternalLinkage,
0, 0,
"\01L_OBJC_PROTOCOL_" + PD->getNameAsString(), "\01L_OBJC_PROTOCOL_" + PD->getNameAsString(),
@ -2100,7 +2102,8 @@ 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(ObjCTypes.ClassTy, false, GV = new llvm::GlobalVariable(CGM.getModule().getContext(),
ObjCTypes.ClassTy, false,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
Init, Name, Init, Name,
&CGM.getModule()); &CGM.getModule());
@ -2130,7 +2133,8 @@ 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(ObjCTypes.ClassTy, false, return new llvm::GlobalVariable(CGM.getModule().getContext(),
ObjCTypes.ClassTy, false,
llvm::GlobalValue::ExternalLinkage, llvm::GlobalValue::ExternalLinkage,
0, 0,
Name, Name,
@ -2311,7 +2315,7 @@ 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(Ty, false, new llvm::GlobalVariable(CGM.getModule().getContext(), Ty, false,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
Init, Init,
Name, Name,
@ -4071,7 +4075,8 @@ void CGObjCNonFragileABIMac::AddModuleClassList(const
Symbols); Symbols);
llvm::GlobalVariable *GV = llvm::GlobalVariable *GV =
new llvm::GlobalVariable(Init->getType(), false, new llvm::GlobalVariable(CGM.getModule().getContext(),
Init->getType(), false,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
Init, Init,
SymbolName, SymbolName,
@ -4117,7 +4122,8 @@ 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(Init->getType(), false, new llvm::GlobalVariable(CGM.getModule().getContext(),
Init->getType(), false,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
Init, Init,
"\01L_OBJC_IMAGE_INFO", "\01L_OBJC_IMAGE_INFO",
@ -4261,7 +4267,8 @@ 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(ObjCTypes.ClassRonfABITy, false, new llvm::GlobalVariable(CGM.getModule().getContext(),
ObjCTypes.ClassRonfABITy, false,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
Init, Init,
(flags & CLS_META) ? (flags & CLS_META) ?
@ -4336,6 +4343,7 @@ 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(),
ObjCTypes.CacheTy, ObjCTypes.CacheTy,
false, false,
llvm::GlobalValue::ExternalLinkage, llvm::GlobalValue::ExternalLinkage,
@ -4344,6 +4352,7 @@ void CGObjCNonFragileABIMac::GenerateClass(const ObjCImplementationDecl *ID) {
&CGM.getModule()); &CGM.getModule());
ObjCEmptyVtableVar = new llvm::GlobalVariable( ObjCEmptyVtableVar = new llvm::GlobalVariable(
CGM.getModule().getContext(),
ObjCTypes.ImpnfABITy, ObjCTypes.ImpnfABITy,
false, false,
llvm::GlobalValue::ExternalLinkage, llvm::GlobalValue::ExternalLinkage,
@ -4453,6 +4462,7 @@ 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(),
Init->getType(), false, Init->getType(), false,
llvm::GlobalValue::WeakAnyLinkage, llvm::GlobalValue::WeakAnyLinkage,
Init, Init,
@ -4538,7 +4548,8 @@ 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(ObjCTypes.CategorynfABITy, = new llvm::GlobalVariable(CGM.getModule().getContext(),
ObjCTypes.CategorynfABITy,
false, false,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
Init, Init,
@ -4601,7 +4612,8 @@ 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(Init->getType(), false, new llvm::GlobalVariable(CGM.getModule().getContext(),
Init->getType(), false,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
Init, Init,
Name, Name,
@ -4630,7 +4642,7 @@ llvm::GlobalVariable * CGObjCNonFragileABIMac::ObjCIvarOffsetVariable(
CGM.getModule().getGlobalVariable(Name); CGM.getModule().getGlobalVariable(Name);
if (!IvarOffsetGV) if (!IvarOffsetGV)
IvarOffsetGV = IvarOffsetGV =
new llvm::GlobalVariable(ObjCTypes.LongTy, new llvm::GlobalVariable(CGM.getModule().getContext(), ObjCTypes.LongTy,
false, false,
llvm::GlobalValue::ExternalLinkage, llvm::GlobalValue::ExternalLinkage,
0, 0,
@ -4729,7 +4741,8 @@ 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(Init->getType(), false, new llvm::GlobalVariable(CGM.getModule().getContext(),
Init->getType(), false,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
Init, Init,
Prefix + OID->getNameAsString(), Prefix + OID->getNameAsString(),
@ -4752,7 +4765,8 @@ 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(ObjCTypes.ProtocolnfABITy, false, new llvm::GlobalVariable(CGM.getModule().getContext(),
ObjCTypes.ProtocolnfABITy, false,
llvm::GlobalValue::ExternalLinkage, llvm::GlobalValue::ExternalLinkage,
0, 0,
"\01l_OBJC_PROTOCOL_$_" + PD->getNameAsString(), "\01l_OBJC_PROTOCOL_$_" + PD->getNameAsString(),
@ -4856,7 +4870,8 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocol(
Entry->setInitializer(Init); Entry->setInitializer(Init);
} else { } else {
Entry = Entry =
new llvm::GlobalVariable(ObjCTypes.ProtocolnfABITy, false, new llvm::GlobalVariable(CGM.getModule().getContext(),
ObjCTypes.ProtocolnfABITy, false,
llvm::GlobalValue::WeakAnyLinkage, llvm::GlobalValue::WeakAnyLinkage,
Init, Init,
std::string("\01l_OBJC_PROTOCOL_$_")+ProtocolName, std::string("\01l_OBJC_PROTOCOL_$_")+ProtocolName,
@ -4870,6 +4885,7 @@ 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(),
ObjCTypes.ProtocolnfABIPtrTy, false, ObjCTypes.ProtocolnfABIPtrTy, false,
llvm::GlobalValue::WeakAnyLinkage, llvm::GlobalValue::WeakAnyLinkage,
Entry, Entry,
@ -4923,7 +4939,8 @@ 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(Init->getType(), false, GV = new llvm::GlobalVariable(CGM.getModule().getContext(),
Init->getType(), false,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
Init, Init,
Name, Name,
@ -5066,7 +5083,8 @@ 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(Init->getType(), false, GV = new llvm::GlobalVariable(CGM.getModule().getContext(),
Init->getType(), false,
llvm::GlobalValue::WeakAnyLinkage, llvm::GlobalValue::WeakAnyLinkage,
Init, Init,
Name, Name,
@ -5114,7 +5132,8 @@ 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(ObjCTypes.ClassnfABITy, false, GV = new llvm::GlobalVariable(CGM.getModule().getContext(),
ObjCTypes.ClassnfABITy, false,
llvm::GlobalValue::ExternalLinkage, llvm::GlobalValue::ExternalLinkage,
0, Name, &CGM.getModule()); 0, Name, &CGM.getModule());
} }
@ -5130,7 +5149,8 @@ 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(ObjCTypes.ClassnfABIPtrTy, false, new llvm::GlobalVariable(CGM.getModule().getContext(),
ObjCTypes.ClassnfABIPtrTy, false,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
ClassGV, ClassGV,
"\01L_OBJC_CLASSLIST_REFERENCES_$_", "\01L_OBJC_CLASSLIST_REFERENCES_$_",
@ -5154,7 +5174,8 @@ 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(ObjCTypes.ClassnfABIPtrTy, false, new llvm::GlobalVariable(CGM.getModule().getContext(),
ObjCTypes.ClassnfABIPtrTy, false,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
ClassGV, ClassGV,
"\01L_OBJC_CLASSLIST_SUP_REFS_$_", "\01L_OBJC_CLASSLIST_SUP_REFS_$_",
@ -5181,7 +5202,8 @@ 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(ObjCTypes.ClassnfABIPtrTy, false, new llvm::GlobalVariable(CGM.getModule().getContext(),
ObjCTypes.ClassnfABIPtrTy, false,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
MetaClassGV, MetaClassGV,
"\01L_OBJC_CLASSLIST_SUP_REFS_$_", "\01L_OBJC_CLASSLIST_SUP_REFS_$_",
@ -5269,7 +5291,8 @@ 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(ObjCTypes.SelectorPtrTy, false, new llvm::GlobalVariable(CGM.getModule().getContext(),
ObjCTypes.SelectorPtrTy, false,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
Casted, "\01L_OBJC_SELECTOR_REFERENCES_", Casted, "\01L_OBJC_SELECTOR_REFERENCES_",
&CGM.getModule()); &CGM.getModule());
@ -5469,7 +5492,8 @@ 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(ObjCTypes.EHTypeTy, false, new llvm::GlobalVariable(CGM.getModule().getContext(),
ObjCTypes.EHTypeTy, false,
llvm::GlobalValue::ExternalLinkage, llvm::GlobalValue::ExternalLinkage,
0, "OBJC_EHTYPE_id", &CGM.getModule()); 0, "OBJC_EHTYPE_id", &CGM.getModule());
SelectorArgs.push_back(IDEHType); SelectorArgs.push_back(IDEHType);
@ -5686,7 +5710,8 @@ 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(ObjCTypes.EHTypeTy, false, new llvm::GlobalVariable(CGM.getModule().getContext(),
ObjCTypes.EHTypeTy, false,
llvm::GlobalValue::ExternalLinkage, llvm::GlobalValue::ExternalLinkage,
0, 0,
(std::string("OBJC_EHTYPE_$_") + (std::string("OBJC_EHTYPE_$_") +
@ -5702,7 +5727,8 @@ 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(ObjCTypes.Int8PtrTy, false, VTableGV = new llvm::GlobalVariable(CGM.getModule().getContext(),
ObjCTypes.Int8PtrTy, false,
llvm::GlobalValue::ExternalLinkage, llvm::GlobalValue::ExternalLinkage,
0, VTableName, &CGM.getModule()); 0, VTableName, &CGM.getModule());
@ -5717,7 +5743,8 @@ CGObjCNonFragileABIMac::GetInterfaceEHType(const ObjCInterfaceDecl *ID,
if (Entry) { if (Entry) {
Entry->setInitializer(Init); Entry->setInitializer(Init);
} else { } else {
Entry = new llvm::GlobalVariable(ObjCTypes.EHTypeTy, false, Entry = new llvm::GlobalVariable(CGM.getModule().getContext(),
ObjCTypes.EHTypeTy, false,
llvm::GlobalValue::WeakAnyLinkage, llvm::GlobalValue::WeakAnyLinkage,
Init, Init,
(std::string("OBJC_EHTYPE_$_") + (std::string("OBJC_EHTYPE_$_") +

View File

@ -216,7 +216,7 @@ 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(AT, false, new llvm::GlobalVariable(TheModule.getContext(), AT, false,
llvm::GlobalValue::AppendingLinkage, llvm::GlobalValue::AppendingLinkage,
llvm::ConstantArray::get(AT, Ctors), llvm::ConstantArray::get(AT, Ctors),
GlobalName, GlobalName,
@ -234,7 +234,7 @@ void CodeGenModule::EmitAnnotations() {
Annotations.size()), Annotations.size()),
Annotations); Annotations);
llvm::GlobalValue *gv = llvm::GlobalValue *gv =
new llvm::GlobalVariable(Array->getType(), false, new llvm::GlobalVariable(TheModule.getContext(), Array->getType(), false,
llvm::GlobalValue::AppendingLinkage, Array, llvm::GlobalValue::AppendingLinkage, Array,
"llvm.global.annotations", &TheModule); "llvm.global.annotations", &TheModule);
gv->setSection("llvm.metadata"); gv->setSection("llvm.metadata");
@ -436,7 +436,7 @@ 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(ATy, false, new llvm::GlobalVariable(getModule().getContext(), ATy, false,
llvm::GlobalValue::AppendingLinkage, llvm::GlobalValue::AppendingLinkage,
llvm::ConstantArray::get(ATy, UsedArray), llvm::ConstantArray::get(ATy, UsedArray),
"llvm.used", &getModule()); "llvm.used", &getModule());
@ -494,12 +494,12 @@ 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(anno->getType(), false, new llvm::GlobalVariable(M->getContext(), anno->getType(), false,
llvm::GlobalValue::InternalLinkage, anno, llvm::GlobalValue::InternalLinkage, anno,
GV->getName() + StringPrefix, M); GV->getName() + StringPrefix, M);
// 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(unit->getType(), false, new llvm::GlobalVariable(M->getContext(), unit->getType(), false,
llvm::GlobalValue::InternalLinkage, unit, llvm::GlobalValue::InternalLinkage, unit,
StringPrefix, M); StringPrefix, M);
@ -719,7 +719,8 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMGlobal(const char *MangledName,
} }
llvm::GlobalVariable *GV = llvm::GlobalVariable *GV =
new llvm::GlobalVariable(Ty->getElementType(), false, new llvm::GlobalVariable(getModule().getContext(),
Ty->getElementType(), false,
llvm::GlobalValue::ExternalLinkage, llvm::GlobalValue::ExternalLinkage,
0, "", &getModule(), 0, "", &getModule(),
false, Ty->getAddressSpace()); false, Ty->getAddressSpace());
@ -1245,7 +1246,7 @@ 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(Ty, false, new llvm::GlobalVariable(getModule().getContext(), Ty, false,
llvm::GlobalVariable::ExternalLinkage, 0, llvm::GlobalVariable::ExternalLinkage, 0,
"__CFConstantStringClassReference", "__CFConstantStringClassReference",
&getModule()); &getModule());
@ -1299,7 +1300,7 @@ GetAddrOfConstantCFString(const StringLiteral *Literal) {
isConstant = true; isConstant = true;
} }
llvm::GlobalVariable *GV = llvm::GlobalVariable *GV =
new llvm::GlobalVariable(C->getType(), isConstant, new llvm::GlobalVariable(getModule().getContext(), C->getType(), isConstant,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
C, Prefix, &getModule()); C, Prefix, &getModule());
if (Sect) if (Sect)
@ -1321,7 +1322,7 @@ GetAddrOfConstantCFString(const StringLiteral *Literal) {
// The struct. // The struct.
C = llvm::ConstantStruct::get(STy, Fields); C = llvm::ConstantStruct::get(STy, Fields);
GV = new llvm::GlobalVariable(C->getType(), true, GV = new llvm::GlobalVariable(getModule().getContext(), C->getType(), true,
llvm::GlobalVariable::InternalLinkage, C, llvm::GlobalVariable::InternalLinkage, C,
getContext().Target.getCFStringSymbolPrefix(), getContext().Target.getCFStringSymbolPrefix(),
&getModule()); &getModule());
@ -1382,7 +1383,8 @@ 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(C->getType(), constant, return new llvm::GlobalVariable(CGM.getModule().getContext(),
C->getType(), constant,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,
C, GlobalName, &CGM.getModule()); C, GlobalName, &CGM.getModule());
} }