From 47a434ff3d49e7906eda88e8e8242e4297725b32 Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Wed, 5 Aug 2009 23:18:46 +0000 Subject: [PATCH] Update for LLVM API change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78259 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/CodeGen/ModuleBuilder.h | 2 +- include/clang/Frontend/ASTConsumers.h | 2 +- lib/CodeGen/ABIInfo.h | 2 +- lib/CodeGen/CGBlocks.cpp | 19 ++++--- lib/CodeGen/CGBlocks.h | 2 +- lib/CodeGen/CGDecl.cpp | 2 +- lib/CodeGen/CGExprConstant.cpp | 13 +++-- lib/CodeGen/CGObjCGNU.cpp | 43 ++++++++------- lib/CodeGen/CGObjCMac.cpp | 77 ++++++++++++++------------- lib/CodeGen/CGRecordLayoutBuilder.cpp | 3 +- lib/CodeGen/CGStmt.cpp | 2 +- lib/CodeGen/CodeGenFunction.h | 2 +- lib/CodeGen/CodeGenModule.cpp | 4 +- lib/CodeGen/CodeGenModule.h | 2 +- lib/CodeGen/CodeGenTypes.cpp | 5 +- lib/CodeGen/CodeGenTypes.h | 3 ++ lib/CodeGen/TargetABIInfo.cpp | 22 +++++--- 17 files changed, 115 insertions(+), 90 deletions(-) diff --git a/include/clang/CodeGen/ModuleBuilder.h b/include/clang/CodeGen/ModuleBuilder.h index 12b74d5147..0a08276a3f 100644 --- a/include/clang/CodeGen/ModuleBuilder.h +++ b/include/clang/CodeGen/ModuleBuilder.h @@ -18,7 +18,7 @@ #include namespace llvm { - class LLVMContext; + struct LLVMContext; class Module; } diff --git a/include/clang/Frontend/ASTConsumers.h b/include/clang/Frontend/ASTConsumers.h index 87c85e067f..4c3228c2ec 100644 --- a/include/clang/Frontend/ASTConsumers.h +++ b/include/clang/Frontend/ASTConsumers.h @@ -20,7 +20,7 @@ namespace llvm { class Module; - class LLVMContext; + struct LLVMContext; namespace sys { class Path; } } namespace clang { diff --git a/lib/CodeGen/ABIInfo.h b/lib/CodeGen/ABIInfo.h index c1a9481c4b..23edaa3c03 100644 --- a/lib/CodeGen/ABIInfo.h +++ b/lib/CodeGen/ABIInfo.h @@ -17,7 +17,7 @@ namespace llvm { class Type; class Value; - class LLVMContext; + struct LLVMContext; } namespace clang { diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp index cf49583db1..49fbb209ff 100644 --- a/lib/CodeGen/CGBlocks.cpp +++ b/lib/CodeGen/CGBlocks.cpp @@ -48,7 +48,7 @@ BuildDescriptorBlockDecl(bool BlockHasCopyDispose, uint64_t Size, Elts.push_back(BuildDestroyHelper(Ty, NoteForHelper)); } - C = llvm::ConstantStruct::get(Elts); + C = llvm::ConstantStruct::get(VMContext, Elts); C = new llvm::GlobalVariable(CGM.getModule(), C->getType(), true, llvm::GlobalValue::InternalLinkage, @@ -161,7 +161,7 @@ llvm::Value *CodeGenFunction::BuildBlockLiteralTmp(const BlockExpr *BE) { Elts[0] = CGM.getNSConcreteGlobalBlock(); Elts[1] = llvm::ConstantInt::get(IntTy, flags|BLOCK_IS_GLOBAL); - C = llvm::ConstantStruct::get(Elts); + C = llvm::ConstantStruct::get(VMContext, Elts); char Name[32]; sprintf(Name, "__block_holder_tmp_%d", CGM.getGlobalUniqueCount()); @@ -189,7 +189,7 @@ llvm::Value *CodeGenFunction::BuildBlockLiteralTmp(const BlockExpr *BE) { Types[i+5] = ConvertType(Ty); } - llvm::StructType *Ty = llvm::StructType::get(Types, true); + llvm::StructType *Ty = llvm::StructType::get(VMContext, Types, true); llvm::AllocaInst *A = CreateTempAlloca(Ty); A->setAlignment(subBlockAlign); @@ -310,7 +310,8 @@ const llvm::Type *BlockModule::getBlockDescriptorType() { // unsigned long reserved; // unsigned long block_size; // }; - BlockDescriptorType = llvm::StructType::get(UnsignedLongTy, + BlockDescriptorType = llvm::StructType::get(UnsignedLongTy->getContext(), + UnsignedLongTy, UnsignedLongTy, NULL); @@ -337,7 +338,8 @@ const llvm::Type *BlockModule::getGenericBlockLiteralType() { // void (*__invoke)(void *); // struct __block_descriptor *__descriptor; // }; - GenericBlockLiteralType = llvm::StructType::get(PtrToInt8Ty, + GenericBlockLiteralType = llvm::StructType::get(IntTy->getContext(), + PtrToInt8Ty, IntTy, IntTy, PtrToInt8Ty, @@ -369,7 +371,8 @@ const llvm::Type *BlockModule::getGenericExtendedBlockLiteralType() { // void *__copy_func_helper_decl; // void *__destroy_func_decl; // }; - GenericExtendedBlockLiteralType = llvm::StructType::get(PtrToInt8Ty, + GenericExtendedBlockLiteralType = llvm::StructType::get(IntTy->getContext(), + PtrToInt8Ty, IntTy, IntTy, PtrToInt8Ty, @@ -511,7 +514,7 @@ BlockModule::GetAddrOfGlobalBlock(const BlockExpr *BE, const char * n) { llvm::ConstantInt::get(UnsignedLongTy,BlockLiteralSize); llvm::Constant *DescriptorStruct = - llvm::ConstantStruct::get(&DescriptorFields[0], 2); + llvm::ConstantStruct::get(VMContext, &DescriptorFields[0], 2); llvm::GlobalVariable *Descriptor = new llvm::GlobalVariable(getModule(), DescriptorStruct->getType(), true, @@ -552,7 +555,7 @@ BlockModule::GetAddrOfGlobalBlock(const BlockExpr *BE, const char * n) { LiteralFields[4] = Descriptor; llvm::Constant *BlockLiteralStruct = - llvm::ConstantStruct::get(&LiteralFields[0], 5); + llvm::ConstantStruct::get(VMContext, &LiteralFields[0], 5); llvm::GlobalVariable *BlockLiteral = new llvm::GlobalVariable(getModule(), BlockLiteralStruct->getType(), true, diff --git a/lib/CodeGen/CGBlocks.h b/lib/CodeGen/CGBlocks.h index 5a0af04b24..42c4f73007 100644 --- a/lib/CodeGen/CGBlocks.h +++ b/lib/CodeGen/CGBlocks.h @@ -39,7 +39,7 @@ namespace llvm { class TargetData; class FunctionType; class Value; - class LLVMContext; + struct LLVMContext; } namespace clang { diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index bda3cf7e6f..477cf52aad 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -237,7 +237,7 @@ const llvm::Type *CodeGenFunction::BuildByRefType(QualType Ty, assert((Align <= unsigned(Target.getPointerAlign(0))/8) && "Can't align more than pointer yet"); Types[needsCopyDispose*2 + 4] = LTy; - return llvm::StructType::get(Types, false); + return llvm::StructType::get(VMContext, Types, false); } /// EmitLocalBlockVarDecl - Emit code and set up an entry in LocalDeclMap for a diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index 3a1eac9e04..eb9c982b40 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -340,7 +340,8 @@ public: return 0; llvm::Constant *Result = - llvm::ConstantStruct::get(Builder.Elements, Builder.Packed); + llvm::ConstantStruct::get(CGF->getLLVMContext(), + Builder.Elements, Builder.Packed); assert(llvm::RoundUpToAlignment(Builder.NextFieldOffsetInBytes, Builder.getAlignment(Result)) == @@ -406,7 +407,8 @@ public: Types.push_back(Ty); } - llvm::StructType* STy = llvm::StructType::get(Types, false); + llvm::StructType* STy = llvm::StructType::get(C->getType()->getContext(), + Types, false); return llvm::ConstantStruct::get(STy, Elts); } @@ -463,7 +465,8 @@ public: std::vector Types; for (unsigned i = 0; i < Elts.size(); ++i) Types.push_back(Elts[i]->getType()); - const llvm::StructType *SType = llvm::StructType::get(Types, true); + const llvm::StructType *SType = llvm::StructType::get(AType->getContext(), + Types, true); return llvm::ConstantStruct::get(SType, Elts); } @@ -731,7 +734,7 @@ llvm::Constant *CodeGenModule::EmitConstantExpr(const Expr *E, Complex[1] = llvm::ConstantInt::get(VMContext, Result.Val.getComplexIntImag()); - return llvm::ConstantStruct::get(Complex, 2); + return llvm::ConstantStruct::get(VMContext, Complex, 2); } case APValue::Float: return llvm::ConstantFP::get(VMContext, Result.Val.getFloat()); @@ -743,7 +746,7 @@ llvm::Constant *CodeGenModule::EmitConstantExpr(const Expr *E, Complex[1] = llvm::ConstantFP::get(VMContext, Result.Val.getComplexFloatImag()); - return llvm::ConstantStruct::get(Complex, 2); + return llvm::ConstantStruct::get(VMContext, Complex, 2); } case APValue::Vector: { llvm::SmallVector Inits; diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp index e8c3e2ffef..ac03ebb32b 100644 --- a/lib/CodeGen/CGObjCGNU.cpp +++ b/lib/CodeGen/CGObjCGNU.cpp @@ -324,7 +324,7 @@ llvm::Constant *CGObjCGNU::GenerateConstantString(const ObjCStringLiteral *SL) { Ivars.push_back(MakeConstantString(Str)); Ivars.push_back(llvm::ConstantInt::get(IntTy, Str.size())); llvm::Constant *ObjCStr = MakeGlobal( - llvm::StructType::get(PtrToInt8Ty, PtrToInt8Ty, IntTy, NULL), + llvm::StructType::get(VMContext, PtrToInt8Ty, PtrToInt8Ty, IntTy, NULL), Ivars, ".objc_str"); ConstantStrings.push_back( llvm::ConstantExpr::getBitCast(ObjCStr, PtrToInt8Ty)); @@ -397,14 +397,14 @@ CGObjCGNU::GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF, // Cast the pointer to a simplified version of the class structure ReceiverClass = CGF.Builder.CreateBitCast(ReceiverClass, llvm::PointerType::getUnqual( - llvm::StructType::get(IdTy, IdTy, NULL))); + llvm::StructType::get(VMContext, IdTy, IdTy, NULL))); // Get the superclass pointer ReceiverClass = CGF.Builder.CreateStructGEP(ReceiverClass, 1); // Load the superclass pointer ReceiverClass = CGF.Builder.CreateLoad(ReceiverClass); // Construct the structure used to look up the IMP - llvm::StructType *ObjCSuperTy = llvm::StructType::get(Receiver->getType(), - IdTy, NULL); + llvm::StructType *ObjCSuperTy = llvm::StructType::get(VMContext, + Receiver->getType(), IdTy, NULL); llvm::Value *ObjCSuper = CGF.Builder.CreateAlloca(ObjCSuperTy); CGF.Builder.CreateStore(Receiver, CGF.Builder.CreateStructGEP(ObjCSuper, 0)); @@ -496,7 +496,7 @@ llvm::Constant *CGObjCGNU::GenerateMethodList(const std::string &ClassName, const llvm::SmallVectorImpl &MethodTypes, bool isClassMethodList) { // Get the method structure type. - llvm::StructType *ObjCMethodTy = llvm::StructType::get( + llvm::StructType *ObjCMethodTy = llvm::StructType::get(VMContext, PtrToInt8Ty, // Really a selector, but the runtime creates it us. PtrToInt8Ty, // Method types llvm::PointerType::getUnqual(IMPTy), //Method pointer @@ -531,7 +531,8 @@ llvm::Constant *CGObjCGNU::GenerateMethodList(const std::string &ClassName, llvm::SmallVector ObjCMethodListFields; llvm::PATypeHolder OpaqueNextTy = llvm::OpaqueType::get(); llvm::Type *NextPtrTy = llvm::PointerType::getUnqual(OpaqueNextTy); - llvm::StructType *ObjCMethodListTy = llvm::StructType::get(NextPtrTy, + llvm::StructType *ObjCMethodListTy = llvm::StructType::get(VMContext, + NextPtrTy, IntTy, ObjCMethodArrayTy, NULL); @@ -557,7 +558,7 @@ llvm::Constant *CGObjCGNU::GenerateIvarList( const llvm::SmallVectorImpl &IvarTypes, const llvm::SmallVectorImpl &IvarOffsets) { // Get the method structure type. - llvm::StructType *ObjCIvarTy = llvm::StructType::get( + llvm::StructType *ObjCIvarTy = llvm::StructType::get(VMContext, PtrToInt8Ty, PtrToInt8Ty, IntTy, @@ -583,7 +584,7 @@ llvm::Constant *CGObjCGNU::GenerateIvarList( Elements.push_back(llvm::ConstantInt::get(IntTy, (int)IvarNames.size())); Elements.push_back(llvm::ConstantArray::get(ObjCIvarArrayTy, Ivars)); // Structure containing array and array count - llvm::StructType *ObjCIvarListTy = llvm::StructType::get(IntTy, + llvm::StructType *ObjCIvarListTy = llvm::StructType::get(VMContext, IntTy, ObjCIvarArrayTy, NULL); @@ -605,7 +606,7 @@ llvm::Constant *CGObjCGNU::GenerateClassStructure( // Set up the class structure // Note: Several of these are char*s when they should be ids. This is // because the runtime performs this translation on load. - llvm::StructType *ClassTy = llvm::StructType::get( + llvm::StructType *ClassTy = llvm::StructType::get(VMContext, PtrToInt8Ty, // class_pointer PtrToInt8Ty, // super_class PtrToInt8Ty, // name @@ -647,7 +648,7 @@ llvm::Constant *CGObjCGNU::GenerateProtocolMethodList( const llvm::SmallVectorImpl &MethodNames, const llvm::SmallVectorImpl &MethodTypes) { // Get the method structure type. - llvm::StructType *ObjCMethodDescTy = llvm::StructType::get( + llvm::StructType *ObjCMethodDescTy = llvm::StructType::get(VMContext, PtrToInt8Ty, // Really a selector, but the runtime does the casting for us. PtrToInt8Ty, NULL); @@ -665,7 +666,7 @@ llvm::Constant *CGObjCGNU::GenerateProtocolMethodList( MethodNames.size()); llvm::Constant *Array = llvm::ConstantArray::get(ObjCMethodArrayTy, Methods); - llvm::StructType *ObjCMethodDescListTy = llvm::StructType::get( + llvm::StructType *ObjCMethodDescListTy = llvm::StructType::get(VMContext, IntTy, ObjCMethodArrayTy, NULL); Methods.clear(); Methods.push_back(llvm::ConstantInt::get(IntTy, MethodNames.size())); @@ -678,7 +679,7 @@ llvm::Constant *CGObjCGNU::GenerateProtocolList( const llvm::SmallVectorImpl &Protocols) { llvm::ArrayType *ProtocolArrayTy = llvm::ArrayType::get(PtrToInt8Ty, Protocols.size()); - llvm::StructType *ProtocolListTy = llvm::StructType::get( + llvm::StructType *ProtocolListTy = llvm::StructType::get(VMContext, PtrTy, //Should be a recurisve pointer, but it's always NULL here. LongTy,//FIXME: Should be size_t ProtocolArrayTy, @@ -722,7 +723,7 @@ llvm::Constant *CGObjCGNU::GenerateEmptyProtocol( GenerateProtocolMethodList(EmptyConstantVector, EmptyConstantVector); // Protocols are objects containing lists of the methods implemented and // protocols adopted. - llvm::StructType *ProtocolTy = llvm::StructType::get(IdTy, + llvm::StructType *ProtocolTy = llvm::StructType::get(VMContext, IdTy, PtrToInt8Ty, ProtocolList->getType(), InstanceMethodList->getType(), @@ -777,7 +778,7 @@ void CGObjCGNU::GenerateProtocol(const ObjCProtocolDecl *PD) { GenerateProtocolMethodList(ClassMethodNames, ClassMethodTypes); // Protocols are objects containing lists of the methods implemented and // protocols adopted. - llvm::StructType *ProtocolTy = llvm::StructType::get(IdTy, + llvm::StructType *ProtocolTy = llvm::StructType::get(VMContext, IdTy, PtrToInt8Ty, ProtocolList->getType(), InstanceMethodList->getType(), @@ -847,8 +848,8 @@ void CGObjCGNU::GenerateCategory(const ObjCCategoryImplDecl *OCD) { Elements.push_back(llvm::ConstantExpr::getBitCast( GenerateProtocolList(Protocols), PtrTy)); Categories.push_back(llvm::ConstantExpr::getBitCast( - MakeGlobal(llvm::StructType::get(PtrToInt8Ty, PtrToInt8Ty, PtrTy, - PtrTy, PtrTy, NULL), Elements), PtrTy)); + MakeGlobal(llvm::StructType::get(VMContext, PtrToInt8Ty, PtrToInt8Ty, + PtrTy, PtrTy, PtrTy, NULL), Elements), PtrTy)); } void CGObjCGNU::GenerateClass(const ObjCImplementationDecl *OID) { @@ -1023,7 +1024,8 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() { const llvm::Type *SelStructPtrTy = SelectorTy; bool isSelOpaque = false; if (SelStructTy == 0) { - SelStructTy = llvm::StructType::get(PtrToInt8Ty, PtrToInt8Ty, NULL); + SelStructTy = llvm::StructType::get(VMContext, PtrToInt8Ty, + PtrToInt8Ty, NULL); SelStructPtrTy = llvm::PointerType::getUnqual(SelStructTy); isSelOpaque = true; } @@ -1045,7 +1047,7 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() { Elements.push_back(llvm::ConstantArray::get(StaticsArrayTy, ConstantStrings)); llvm::StructType *StaticsListTy = - llvm::StructType::get(PtrToInt8Ty, StaticsArrayTy, NULL); + llvm::StructType::get(VMContext, PtrToInt8Ty, StaticsArrayTy, NULL); llvm::Type *StaticsListPtrTy = llvm::PointerType::getUnqual(StaticsListTy); Statics = MakeGlobal(StaticsListTy, Elements, ".objc_statics"); @@ -1060,7 +1062,8 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() { // Array of classes, categories, and constant objects llvm::ArrayType *ClassListTy = llvm::ArrayType::get(PtrToInt8Ty, Classes.size() + Categories.size() + 2); - llvm::StructType *SymTabTy = llvm::StructType::get(LongTy, SelStructPtrTy, + llvm::StructType *SymTabTy = llvm::StructType::get(VMContext, + LongTy, SelStructPtrTy, llvm::Type::Int16Ty, llvm::Type::Int16Ty, ClassListTy, NULL); @@ -1153,7 +1156,7 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() { // The symbol table is contained in a module which has some version-checking // constants - llvm::StructType * ModuleTy = llvm::StructType::get(LongTy, LongTy, + llvm::StructType * ModuleTy = llvm::StructType::get(VMContext, LongTy, LongTy, PtrToInt8Ty, llvm::PointerType::getUnqual(SymTabTy), NULL); Elements.clear(); // Runtime version used for compatibility checking. diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index 3c61cb8f7f..1e41c00d4c 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -1770,7 +1770,7 @@ CGObjCMac::EmitProtocolList(const std::string &Name, ProtocolRefs.size()), ProtocolRefs); - llvm::Constant *Init = llvm::ConstantStruct::get(Values); + llvm::Constant *Init = llvm::ConstantStruct::get(VMContext, Values); llvm::GlobalVariable *GV = CreateMetadataVar(Name, Init, "__OBJC,__cat_cls_meth,regular,no_dead_strip", 4, false); @@ -1815,7 +1815,7 @@ llvm::Constant *CGObjCCommonMac::EmitPropertyList(const std::string &Name, llvm::ArrayType *AT = llvm::ArrayType::get(ObjCTypes.PropertyTy, Properties.size()); Values[2] = llvm::ConstantArray::get(AT, Properties); - llvm::Constant *Init = llvm::ConstantStruct::get(Values); + llvm::Constant *Init = llvm::ConstantStruct::get(VMContext, Values); llvm::GlobalVariable *GV = CreateMetadataVar(Name, Init, @@ -1855,7 +1855,7 @@ llvm::Constant *CGObjCMac::EmitMethodDescList(const std::string &Name, llvm::ArrayType *AT = llvm::ArrayType::get(ObjCTypes.MethodDescriptionTy, Methods.size()); Values[1] = llvm::ConstantArray::get(AT, Methods); - llvm::Constant *Init = llvm::ConstantStruct::get(Values); + llvm::Constant *Init = llvm::ConstantStruct::get(VMContext, Values); llvm::GlobalVariable *GV = CreateMetadataVar(Name, Init, Section, 4, true); return llvm::ConstantExpr::getBitCast(GV, @@ -2228,7 +2228,7 @@ llvm::Constant *CGObjCMac::EmitIvarList(const ObjCImplementationDecl *ID, llvm::ArrayType *AT = llvm::ArrayType::get(ObjCTypes.IvarTy, Ivars.size()); Values[1] = llvm::ConstantArray::get(AT, Ivars); - llvm::Constant *Init = llvm::ConstantStruct::get(Values); + llvm::Constant *Init = llvm::ConstantStruct::get(VMContext, Values); llvm::GlobalVariable *GV; if (ForClass) @@ -2288,7 +2288,7 @@ llvm::Constant *CGObjCMac::EmitMethodList(const std::string &Name, llvm::ArrayType *AT = llvm::ArrayType::get(ObjCTypes.MethodTy, Methods.size()); Values[2] = llvm::ConstantArray::get(AT, Methods); - llvm::Constant *Init = llvm::ConstantStruct::get(Values); + llvm::Constant *Init = llvm::ConstantStruct::get(VMContext, Values); llvm::GlobalVariable *GV = CreateMetadataVar(Name, Init, Section, 4, true); return llvm::ConstantExpr::getBitCast(GV, @@ -2924,7 +2924,7 @@ llvm::Constant *CGObjCMac::EmitModuleSymbols() { NumClasses + NumCategories), Symbols); - llvm::Constant *Init = llvm::ConstantStruct::get(Values); + llvm::Constant *Init = llvm::ConstantStruct::get(VMContext, Values); llvm::GlobalVariable *GV = CreateMetadataVar("\01L_OBJC_SYMBOLS", Init, @@ -3567,7 +3567,7 @@ ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm) // char *name; // char *attributes; // } - PropertyTy = llvm::StructType::get(Int8PtrTy, Int8PtrTy, NULL); + PropertyTy = llvm::StructType::get(VMContext, Int8PtrTy, Int8PtrTy, NULL); CGM.getModule().addTypeName("struct._prop_t", PropertyTy); @@ -3576,7 +3576,7 @@ ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm) // uint32_t count_of_properties; // struct _prop_t prop_list[count_of_properties]; // } - PropertyListTy = llvm::StructType::get(IntTy, + PropertyListTy = llvm::StructType::get(VMContext, IntTy, IntTy, llvm::ArrayType::get(PropertyTy, 0), NULL); @@ -3590,7 +3590,7 @@ ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm) // char *method_type; // char *_imp; // } - MethodTy = llvm::StructType::get(SelectorPtrTy, + MethodTy = llvm::StructType::get(VMContext, SelectorPtrTy, Int8PtrTy, Int8PtrTy, NULL); @@ -3610,7 +3610,7 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm) // char *types; // } MethodDescriptionTy = - llvm::StructType::get(SelectorPtrTy, + llvm::StructType::get(VMContext, SelectorPtrTy, Int8PtrTy, NULL); CGM.getModule().addTypeName("struct._objc_method_description", @@ -3621,7 +3621,7 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm) // struct _objc_method_description[1]; // } MethodDescriptionListTy = - llvm::StructType::get(IntTy, + llvm::StructType::get(VMContext, IntTy, llvm::ArrayType::get(MethodDescriptionTy, 0), NULL); CGM.getModule().addTypeName("struct._objc_method_description_list", @@ -3640,7 +3640,7 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm) // struct _objc_property_list *instance_properties; // } ProtocolExtensionTy = - llvm::StructType::get(IntTy, + llvm::StructType::get(VMContext, IntTy, MethodDescriptionListPtrTy, MethodDescriptionListPtrTy, PropertyListPtrTy, @@ -3657,7 +3657,8 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm) llvm::PATypeHolder ProtocolListTyHolder = llvm::OpaqueType::get(); const llvm::Type *T = - llvm::StructType::get(llvm::PointerType::getUnqual(ProtocolListTyHolder), + llvm::StructType::get(VMContext, + llvm::PointerType::getUnqual(ProtocolListTyHolder), LongTy, llvm::ArrayType::get(ProtocolTyHolder, 0), NULL); @@ -3670,7 +3671,7 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm) // struct _objc_method_description_list *instance_methods; // struct _objc_method_description_list *class_methods; // } - T = llvm::StructType::get(ProtocolExtensionPtrTy, + T = llvm::StructType::get(VMContext, ProtocolExtensionPtrTy, Int8PtrTy, llvm::PointerType::getUnqual(ProtocolListTyHolder), MethodDescriptionListPtrTy, @@ -3695,7 +3696,7 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm) // char *ivar_type; // int ivar_offset; // } - IvarTy = llvm::StructType::get(Int8PtrTy, + IvarTy = llvm::StructType::get(VMContext, Int8PtrTy, Int8PtrTy, IntTy, NULL); @@ -3713,7 +3714,7 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm) // struct _objc_class_extension * ClassExtensionTy = - llvm::StructType::get(IntTy, + llvm::StructType::get(VMContext, IntTy, Int8PtrTy, PropertyListPtrTy, NULL); @@ -3736,7 +3737,8 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm) // char *ivar_layout; // struct _objc_class_ext *ext; // }; - T = llvm::StructType::get(llvm::PointerType::getUnqual(ClassTyHolder), + T = llvm::StructType::get(VMContext, + llvm::PointerType::getUnqual(ClassTyHolder), llvm::PointerType::getUnqual(ClassTyHolder), Int8PtrTy, LongTy, @@ -3763,7 +3765,7 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm) // uint32_t size; // sizeof(struct _objc_category) // struct _objc_property_list *instance_properties;// category's @property // } - CategoryTy = llvm::StructType::get(Int8PtrTy, + CategoryTy = llvm::StructType::get(VMContext, Int8PtrTy, Int8PtrTy, MethodListPtrTy, MethodListPtrTy, @@ -3782,7 +3784,7 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm) // short cat_def_cnt; // char *defs[cls_def_cnt + cat_def_cnt]; // } - SymtabTy = llvm::StructType::get(LongTy, + SymtabTy = llvm::StructType::get(VMContext, LongTy, SelectorPtrTy, ShortTy, ShortTy, @@ -3798,7 +3800,7 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm) // struct _objc_symtab* symtab; // } ModuleTy = - llvm::StructType::get(LongTy, + llvm::StructType::get(VMContext, LongTy, LongTy, Int8PtrTy, SymtabPtrTy, @@ -3815,8 +3817,8 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm) llvm::PointerType::getUnqual(llvm::Type::Int8Ty), 4); ExceptionDataTy = - llvm::StructType::get(llvm::ArrayType::get(llvm::Type::Int32Ty, - SetJmpBufferSize), + llvm::StructType::get(VMContext, llvm::ArrayType::get(llvm::Type::Int32Ty, + SetJmpBufferSize), StackPtrTy, NULL); CGM.getModule().addTypeName("struct._objc_exception_data", ExceptionDataTy); @@ -3831,7 +3833,7 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul // uint32_t method_count; // struct _objc_method method_list[method_count]; // } - MethodListnfABITy = llvm::StructType::get(IntTy, + MethodListnfABITy = llvm::StructType::get(VMContext, IntTy, IntTy, llvm::ArrayType::get(MethodTy, 0), NULL); @@ -3856,7 +3858,7 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul // Holder for struct _protocol_list_t * llvm::PATypeHolder ProtocolListTyHolder = llvm::OpaqueType::get(); - ProtocolnfABITy = llvm::StructType::get(ObjectPtrTy, + ProtocolnfABITy = llvm::StructType::get(VMContext, ObjectPtrTy, Int8PtrTy, llvm::PointerType::getUnqual( ProtocolListTyHolder), @@ -3878,7 +3880,7 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul // long protocol_count; // Note, this is 32/64 bit // struct _protocol_t *[protocol_count]; // } - ProtocolListnfABITy = llvm::StructType::get(LongTy, + ProtocolListnfABITy = llvm::StructType::get(VMContext, LongTy, llvm::ArrayType::get( ProtocolnfABIPtrTy, 0), NULL); @@ -3897,7 +3899,8 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul // uint32_t alignment; // uint32_t size; // } - IvarnfABITy = llvm::StructType::get(llvm::PointerType::getUnqual(LongTy), + IvarnfABITy = llvm::StructType::get(VMContext, + llvm::PointerType::getUnqual(LongTy), Int8PtrTy, Int8PtrTy, IntTy, @@ -3910,7 +3913,7 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul // uint32 count; // struct _iver_t list[count]; // } - IvarListnfABITy = llvm::StructType::get(IntTy, + IvarListnfABITy = llvm::StructType::get(VMContext, IntTy, IntTy, llvm::ArrayType::get( IvarnfABITy, 0), @@ -3934,7 +3937,7 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul // } // FIXME. Add 'reserved' field in 64bit abi mode! - ClassRonfABITy = llvm::StructType::get(IntTy, + ClassRonfABITy = llvm::StructType::get(VMContext, IntTy, IntTy, IntTy, Int8PtrTy, @@ -3965,7 +3968,8 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul llvm::PATypeHolder ClassTyHolder = llvm::OpaqueType::get(); ClassnfABITy = - llvm::StructType::get(llvm::PointerType::getUnqual(ClassTyHolder), + llvm::StructType::get(VMContext, + llvm::PointerType::getUnqual(ClassTyHolder), llvm::PointerType::getUnqual(ClassTyHolder), CachePtrTy, llvm::PointerType::getUnqual(ImpnfABITy), @@ -3987,7 +3991,7 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul // const struct _protocol_list_t * const protocols; // const struct _prop_list_t * const properties; // } - CategorynfABITy = llvm::StructType::get(Int8PtrTy, + CategorynfABITy = llvm::StructType::get(VMContext, Int8PtrTy, ClassnfABIPtrTy, MethodListnfABIPtrTy, MethodListnfABIPtrTy, @@ -4028,7 +4032,7 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul // SUPER_IMP messenger; // SEL name; // }; - SuperMessageRefTy = llvm::StructType::get(ImpnfABITy, + SuperMessageRefTy = llvm::StructType::get(VMContext, ImpnfABITy, SelectorPtrTy, NULL); CGM.getModule().addTypeName("struct._super_message_ref_t", SuperMessageRefTy); @@ -4042,7 +4046,8 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul // const char* name; // c++ typeinfo string // Class cls; // }; - EHTypeTy = llvm::StructType::get(llvm::PointerType::getUnqual(Int8PtrTy), + EHTypeTy = llvm::StructType::get(VMContext, + llvm::PointerType::getUnqual(Int8PtrTy), Int8PtrTy, ClassnfABIPtrTy, NULL); @@ -4598,7 +4603,7 @@ llvm::Constant *CGObjCNonFragileABIMac::EmitMethodList( llvm::ArrayType *AT = llvm::ArrayType::get(ObjCTypes.MethodTy, Methods.size()); Values[2] = llvm::ConstantArray::get(AT, Methods); - llvm::Constant *Init = llvm::ConstantStruct::get(Values); + llvm::Constant *Init = llvm::ConstantStruct::get(VMContext, Values); llvm::GlobalVariable *GV = new llvm::GlobalVariable(CGM.getModule(), Init->getType(), false, @@ -4724,7 +4729,7 @@ llvm::Constant *CGObjCNonFragileABIMac::EmitIvarList( llvm::ArrayType *AT = llvm::ArrayType::get(ObjCTypes.IvarnfABITy, Ivars.size()); Values[2] = llvm::ConstantArray::get(AT, Ivars); - llvm::Constant *Init = llvm::ConstantStruct::get(Values); + llvm::Constant *Init = llvm::ConstantStruct::get(VMContext, Values); const char *Prefix = "\01l_OBJC_$_INSTANCE_VARIABLES_"; llvm::GlobalVariable *GV = new llvm::GlobalVariable(CGM.getModule(), Init->getType(), false, @@ -4918,7 +4923,7 @@ CGObjCNonFragileABIMac::EmitProtocolList(const std::string &Name, ProtocolRefs.size()), ProtocolRefs); - llvm::Constant *Init = llvm::ConstantStruct::get(Values); + llvm::Constant *Init = llvm::ConstantStruct::get(VMContext, Values); GV = new llvm::GlobalVariable(CGM.getModule(), Init->getType(), false, llvm::GlobalValue::InternalLinkage, Init, @@ -5052,7 +5057,7 @@ CodeGen::RValue CGObjCNonFragileABIMac::EmitMessageSend( std::vector Values(2); Values[0] = Fn; Values[1] = GetMethodVarName(Sel); - llvm::Constant *Init = llvm::ConstantStruct::get(Values); + llvm::Constant *Init = llvm::ConstantStruct::get(VMContext, Values); GV = new llvm::GlobalVariable(CGM.getModule(), Init->getType(), false, llvm::GlobalValue::WeakAnyLinkage, Init, diff --git a/lib/CodeGen/CGRecordLayoutBuilder.cpp b/lib/CodeGen/CGRecordLayoutBuilder.cpp index 5f07a5f083..241a6e5395 100644 --- a/lib/CodeGen/CGRecordLayoutBuilder.cpp +++ b/lib/CodeGen/CGRecordLayoutBuilder.cpp @@ -298,7 +298,8 @@ CGRecordLayoutBuilder::ComputeLayout(CodeGenTypes &Types, Builder.Layout(D); - const llvm::Type *Ty = llvm::StructType::get(Builder.FieldTypes, + const llvm::Type *Ty = llvm::StructType::get(Types.getLLVMContext(), + Builder.FieldTypes, Builder.Packed); // Add all the field numbers. diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp index 5b17b7b900..22d9a991ef 100644 --- a/lib/CodeGen/CGStmt.cpp +++ b/lib/CodeGen/CGStmt.cpp @@ -1002,7 +1002,7 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) { else if (ResultRegTypes.size() == 1) ResultType = ResultRegTypes[0]; else - ResultType = llvm::StructType::get(ResultRegTypes); + ResultType = llvm::StructType::get(VMContext, ResultRegTypes); const llvm::FunctionType *FTy = llvm::FunctionType::get(ResultType, ArgTypes, false); diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index b814ed7c5c..6a887d1aa9 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -31,7 +31,7 @@ namespace llvm { class BasicBlock; - class LLVMContext; + struct LLVMContext; class Module; class SwitchInst; class Value; diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index df1781de9e..249764e9d9 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -203,7 +203,7 @@ void CodeGenModule::EmitCtorList(const CtorList &Fns, const char *GlobalName) { // Get the type of a ctor entry, { i32, void ()* }. llvm::StructType* CtorStructTy = - llvm::StructType::get(llvm::Type::Int32Ty, + llvm::StructType::get(VMContext, llvm::Type::Int32Ty, llvm::PointerType::getUnqual(CtorFTy), NULL); // Construct the constructor and destructor arrays. @@ -507,7 +507,7 @@ llvm::Constant *CodeGenModule::EmitAnnotateAttr(llvm::GlobalValue *GV, llvm::ConstantExpr::getBitCast(unitGV, SBP), llvm::ConstantInt::get(llvm::Type::Int32Ty, LineNo) }; - return llvm::ConstantStruct::get(Fields, 4, false); + return llvm::ConstantStruct::get(VMContext, Fields, 4, false); } bool CodeGenModule::MayDeferGeneration(const ValueDecl *Global) { diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h index c7437d18ef..7c1108e801 100644 --- a/lib/CodeGen/CodeGenModule.h +++ b/lib/CodeGen/CodeGenModule.h @@ -35,7 +35,7 @@ namespace llvm { class GlobalValue; class TargetData; class FunctionType; - class LLVMContext; + struct LLVMContext; } namespace clang { diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp index c20e90e8ce..0cb0c72f2e 100644 --- a/lib/CodeGen/CodeGenTypes.cpp +++ b/lib/CodeGen/CodeGenTypes.cpp @@ -237,7 +237,7 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) { case Type::Complex: { const llvm::Type *EltTy = ConvertTypeRecursive(cast(Ty).getElementType()); - return llvm::StructType::get(EltTy, EltTy, NULL); + return llvm::StructType::get(TheModule.getContext(), EltTy, EltTy, NULL); } case Type::LValueReference: case Type::RValueReference: { @@ -360,7 +360,8 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) { QualType ETy = cast(Ty).getPointeeType(); if (ETy->isFunctionType()) { - return llvm::StructType::get(ConvertType(Context.getPointerDiffType()), + return llvm::StructType::get(TheModule.getContext(), + ConvertType(Context.getPointerDiffType()), ConvertType(Context.getPointerDiffType()), NULL); } else diff --git a/lib/CodeGen/CodeGenTypes.h b/lib/CodeGen/CodeGenTypes.h index 0f6e51d1d3..acb5803841 100644 --- a/lib/CodeGen/CodeGenTypes.h +++ b/lib/CodeGen/CodeGenTypes.h @@ -14,6 +14,7 @@ #ifndef CLANG_CODEGEN_CODEGENTYPES_H #define CLANG_CODEGEN_CODEGENTYPES_H +#include "llvm/Module.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallSet.h" #include @@ -27,6 +28,7 @@ namespace llvm { class PATypeHolder; class TargetData; class Type; + struct LLVMContext; } namespace clang { @@ -146,6 +148,7 @@ public: TargetInfo &getTarget() const { return Target; } ASTContext &getContext() const { return Context; } const ABIInfo &getABIInfo() const; + llvm::LLVMContext &getLLVMContext() { return TheModule.getContext(); } /// ConvertType - Convert type T into a llvm::Type. const llvm::Type *ConvertType(QualType T); diff --git a/lib/CodeGen/TargetABIInfo.cpp b/lib/CodeGen/TargetABIInfo.cpp index ae9ccb1be4..87f728eb44 100644 --- a/lib/CodeGen/TargetABIInfo.cpp +++ b/lib/CodeGen/TargetABIInfo.cpp @@ -875,7 +875,7 @@ ABIArgInfo X86_64ABIInfo::classifyReturnType(QualType RetTy, // %st1. case ComplexX87: assert(Hi == ComplexX87 && "Unexpected ComplexX87 classification."); - ResType = llvm::StructType::get(llvm::Type::X86_FP80Ty, + ResType = llvm::StructType::get(VMContext, llvm::Type::X86_FP80Ty, llvm::Type::X86_FP80Ty, NULL); break; @@ -892,10 +892,12 @@ ABIArgInfo X86_64ABIInfo::classifyReturnType(QualType RetTy, case NoClass: break; case Integer: - ResType = llvm::StructType::get(ResType, llvm::Type::Int64Ty, NULL); + ResType = llvm::StructType::get(VMContext, ResType, + llvm::Type::Int64Ty, NULL); break; case SSE: - ResType = llvm::StructType::get(ResType, llvm::Type::DoubleTy, NULL); + ResType = llvm::StructType::get(VMContext, ResType, + llvm::Type::DoubleTy, NULL); break; // AMD64-ABI 3.2.3p4: Rule 5. If the class is SSEUP, the eightbyte @@ -915,7 +917,8 @@ ABIArgInfo X86_64ABIInfo::classifyReturnType(QualType RetTy, // preceeded by X87. In such situations we follow gcc and pass the // extra bits in an SSE reg. if (Lo != X87) - ResType = llvm::StructType::get(ResType, llvm::Type::DoubleTy, NULL); + ResType = llvm::StructType::get(VMContext, ResType, + llvm::Type::DoubleTy, NULL); break; } @@ -985,7 +988,8 @@ ABIArgInfo X86_64ABIInfo::classifyArgumentType(QualType Ty, ASTContext &Context, case NoClass: break; case Integer: - ResType = llvm::StructType::get(ResType, llvm::Type::Int64Ty, NULL); + ResType = llvm::StructType::get(VMContext, ResType, + llvm::Type::Int64Ty, NULL); ++neededInt; break; @@ -993,7 +997,8 @@ ABIArgInfo X86_64ABIInfo::classifyArgumentType(QualType Ty, ASTContext &Context, // memory), except in situations involving unions. case X87Up: case SSE: - ResType = llvm::StructType::get(ResType, llvm::Type::DoubleTy, NULL); + ResType = llvm::StructType::get(VMContext, ResType, + llvm::Type::DoubleTy, NULL); ++neededSSE; break; @@ -1214,7 +1219,8 @@ llvm::Value *X86_64ABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty, llvm::ConstantInt::get(llvm::Type::Int32Ty, 16)); const llvm::Type *DblPtrTy = llvm::PointerType::getUnqual(llvm::Type::DoubleTy); - const llvm::StructType *ST = llvm::StructType::get(llvm::Type::DoubleTy, + const llvm::StructType *ST = llvm::StructType::get(VMContext, + llvm::Type::DoubleTy, llvm::Type::DoubleTy, NULL); llvm::Value *V, *Tmp = CGF.CreateTempAlloca(ST); @@ -1355,7 +1361,7 @@ ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty, } std::vector LLVMFields; LLVMFields.push_back(llvm::ArrayType::get(ElemTy, SizeRegs)); - const llvm::Type* STy = llvm::StructType::get(LLVMFields, true); + const llvm::Type* STy = llvm::StructType::get(VMContext, LLVMFields, true); return ABIArgInfo::getCoerce(STy); } -- 2.40.0