From 977fa551eed60b2ec7e133f6ec9dc4feecf89798 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Thu, 6 Aug 2009 01:47:39 +0200 Subject: [PATCH] Push the context through StructType::get. Requires LLVM >= 78258. Also remove old #if's. --- gen/abi-x86-64.cpp | 3 ++- gen/arrays.cpp | 8 ++++---- gen/complex.cpp | 2 +- gen/dwarftypes.cpp | 18 +++++++++--------- gen/main.cpp | 4 ---- gen/nested.cpp | 2 +- gen/rttibuilder.cpp | 4 ++-- gen/runtime.cpp | 12 ++++++------ gen/statements.cpp | 2 +- gen/structs.cpp | 2 +- gen/tocall.cpp | 6 +++--- gen/todebug.cpp | 2 +- gen/toir.cpp | 2 +- gen/tollvm.cpp | 18 +++++++++--------- gen/toobj.cpp | 4 ++-- gen/typinf.cpp | 5 ----- ir/irclass.cpp | 13 ++++--------- ir/irstruct.cpp | 4 ++-- ir/irtype.cpp | 8 ++++---- ir/irtypeclass.cpp | 4 ++-- ir/irtypefunction.cpp | 2 +- ir/irtypestruct.cpp | 2 +- 22 files changed, 57 insertions(+), 70 deletions(-) diff --git a/gen/abi-x86-64.cpp b/gen/abi-x86-64.cpp index dd816532..dcaa8f86 100644 --- a/gen/abi-x86-64.cpp +++ b/gen/abi-x86-64.cpp @@ -36,6 +36,7 @@ #include "declaration.h" #include "aggregate.h" +#include "gen/irstate.h" #include "gen/llvm.h" #include "gen/tollvm.h" #include "gen/logger.h" @@ -281,7 +282,7 @@ namespace { default: assert(0 && "Unanticipated argument class for second half"); } - return LLStructType::get(parts); + return LLStructType::get(gIR->context(), parts); } } diff --git a/gen/arrays.cpp b/gen/arrays.cpp index 9c5a3116..c36bafcd 100644 --- a/gen/arrays.cpp +++ b/gen/arrays.cpp @@ -26,12 +26,12 @@ const LLStructType* DtoArrayType(Type* arrayTy) const LLType* elemty = DtoType(arrayTy->nextOf()); if (elemty == LLType::VoidTy) elemty = LLType::Int8Ty; - return LLStructType::get(DtoSize_t(), getPtrToType(elemty), NULL); + return LLStructType::get(gIR->context(), DtoSize_t(), getPtrToType(elemty), NULL); } const LLStructType* DtoArrayType(const LLType* t) { - return LLStructType::get(DtoSize_t(), getPtrToType(t), NULL); + return LLStructType::get(gIR->context(), DtoSize_t(), getPtrToType(t), NULL); } ////////////////////////////////////////////////////////////////////////////////////////// @@ -309,7 +309,7 @@ LLConstant* DtoConstArrayInitializer(ArrayInitializer* arrinit) LLConstant* constarr; if (mismatch) - constarr = LLConstantStruct::get(initvals); + constarr = LLConstantStruct::get(gIR->context(), initvals); else constarr = LLConstantArray::get(LLArrayType::get(llelemty, arrlen), initvals); @@ -394,7 +394,7 @@ void DtoStaticArrayCopy(LLValue* dst, LLValue* src) LLConstant* DtoConstSlice(LLConstant* dim, LLConstant* ptr) { LLConstant* values[2] = { dim, ptr }; - return LLConstantStruct::get(values, 2); + return LLConstantStruct::get(gIR->context(), values, 2); } ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/gen/complex.cpp b/gen/complex.cpp index a1daa4e6..b74a665f 100644 --- a/gen/complex.cpp +++ b/gen/complex.cpp @@ -16,7 +16,7 @@ const llvm::StructType* DtoComplexType(Type* type) { Type* t = type->toBasetype(); const LLType* base = DtoComplexBaseType(t); - return llvm::StructType::get(base, base, NULL); + return llvm::StructType::get(gIR->context(), base, base, NULL); } const LLType* DtoComplexBaseType(Type* t) diff --git a/gen/dwarftypes.cpp b/gen/dwarftypes.cpp index ba55a278..232d7c87 100644 --- a/gen/dwarftypes.cpp +++ b/gen/dwarftypes.cpp @@ -23,13 +23,13 @@ void RegisterDwarfSymbols(llvm::Module* mod) { std::vectorStructTy_llvm_dbg_anchor_type_fields; StructTy_llvm_dbg_anchor_type_fields.push_back(IntegerType::get(32)); StructTy_llvm_dbg_anchor_type_fields.push_back(IntegerType::get(32)); - StructType* StructTy_llvm_dbg_anchor_type = StructType::get(StructTy_llvm_dbg_anchor_type_fields, /*isPacked=*/false); + StructType* StructTy_llvm_dbg_anchor_type = StructType::get(mod->getContext(), StructTy_llvm_dbg_anchor_type_fields, /*isPacked=*/false); mod->addTypeName("llvm.dbg.anchor.type", StructTy_llvm_dbg_anchor_type); std::vectorStructTy_llvm_dbg_basictype_type_fields; StructTy_llvm_dbg_basictype_type_fields.push_back(IntegerType::get(32)); std::vectorStructTy_1_fields; - StructType* StructTy_1 = StructType::get(StructTy_1_fields, /*isPacked=*/false); + StructType* StructTy_1 = StructType::get(mod->getContext(), StructTy_1_fields, /*isPacked=*/false); PointerType* PointerTy_0 = PointerType::get(StructTy_1,0); @@ -44,7 +44,7 @@ void RegisterDwarfSymbols(llvm::Module* mod) { StructTy_llvm_dbg_basictype_type_fields.push_back(IntegerType::get(64)); StructTy_llvm_dbg_basictype_type_fields.push_back(IntegerType::get(32)); StructTy_llvm_dbg_basictype_type_fields.push_back(IntegerType::get(32)); - StructType* StructTy_llvm_dbg_basictype_type = StructType::get(StructTy_llvm_dbg_basictype_type_fields, /*isPacked=*/false); + StructType* StructTy_llvm_dbg_basictype_type = StructType::get(mod->getContext(), StructTy_llvm_dbg_basictype_type_fields, /*isPacked=*/false); mod->addTypeName("llvm.dbg.basictype.type", StructTy_llvm_dbg_basictype_type); std::vectorStructTy_llvm_dbg_compile_unit_type_fields; @@ -54,7 +54,7 @@ void RegisterDwarfSymbols(llvm::Module* mod) { StructTy_llvm_dbg_compile_unit_type_fields.push_back(PointerTy_2); StructTy_llvm_dbg_compile_unit_type_fields.push_back(PointerTy_2); StructTy_llvm_dbg_compile_unit_type_fields.push_back(PointerTy_2); - StructType* StructTy_llvm_dbg_compile_unit_type = StructType::get(StructTy_llvm_dbg_compile_unit_type_fields, /*isPacked=*/false); + StructType* StructTy_llvm_dbg_compile_unit_type = StructType::get(mod->getContext(), StructTy_llvm_dbg_compile_unit_type_fields, /*isPacked=*/false); mod->addTypeName("llvm.dbg.compile_unit.type", StructTy_llvm_dbg_compile_unit_type); std::vectorStructTy_llvm_dbg_compositetype_type_fields; @@ -69,7 +69,7 @@ void RegisterDwarfSymbols(llvm::Module* mod) { StructTy_llvm_dbg_compositetype_type_fields.push_back(IntegerType::get(32)); StructTy_llvm_dbg_compositetype_type_fields.push_back(PointerTy_0); StructTy_llvm_dbg_compositetype_type_fields.push_back(PointerTy_0); - StructType* StructTy_llvm_dbg_compositetype_type = StructType::get(StructTy_llvm_dbg_compositetype_type_fields, /*isPacked=*/false); + StructType* StructTy_llvm_dbg_compositetype_type = StructType::get(mod->getContext(), StructTy_llvm_dbg_compositetype_type_fields, /*isPacked=*/false); mod->addTypeName("llvm.dbg.compositetype.type", StructTy_llvm_dbg_compositetype_type); std::vectorStructTy_llvm_dbg_derivedtype_type_fields; @@ -83,7 +83,7 @@ void RegisterDwarfSymbols(llvm::Module* mod) { StructTy_llvm_dbg_derivedtype_type_fields.push_back(IntegerType::get(64)); StructTy_llvm_dbg_derivedtype_type_fields.push_back(IntegerType::get(32)); StructTy_llvm_dbg_derivedtype_type_fields.push_back(PointerTy_0); - StructType* StructTy_llvm_dbg_derivedtype_type = StructType::get(StructTy_llvm_dbg_derivedtype_type_fields, /*isPacked=*/false); + StructType* StructTy_llvm_dbg_derivedtype_type = StructType::get(mod->getContext(), StructTy_llvm_dbg_derivedtype_type_fields, /*isPacked=*/false); mod->addTypeName("llvm.dbg.derivedtype.type", StructTy_llvm_dbg_derivedtype_type); std::vectorStructTy_llvm_dbg_global_variable_type_fields; @@ -99,7 +99,7 @@ void RegisterDwarfSymbols(llvm::Module* mod) { StructTy_llvm_dbg_global_variable_type_fields.push_back(IntegerType::get(1)); StructTy_llvm_dbg_global_variable_type_fields.push_back(IntegerType::get(1)); StructTy_llvm_dbg_global_variable_type_fields.push_back(PointerTy_0); - StructType* StructTy_llvm_dbg_global_variable_type = StructType::get(StructTy_llvm_dbg_global_variable_type_fields, /*isPacked=*/false); + StructType* StructTy_llvm_dbg_global_variable_type = StructType::get(mod->getContext(), StructTy_llvm_dbg_global_variable_type_fields, /*isPacked=*/false); mod->addTypeName("llvm.dbg.global_variable.type", StructTy_llvm_dbg_global_variable_type); std::vectorStructTy_llvm_dbg_subprogram_type_fields; @@ -114,7 +114,7 @@ void RegisterDwarfSymbols(llvm::Module* mod) { StructTy_llvm_dbg_subprogram_type_fields.push_back(PointerTy_0); StructTy_llvm_dbg_subprogram_type_fields.push_back(IntegerType::get(1)); StructTy_llvm_dbg_subprogram_type_fields.push_back(IntegerType::get(1)); - StructType* StructTy_llvm_dbg_subprogram_type = StructType::get(StructTy_llvm_dbg_subprogram_type_fields, /*isPacked=*/false); + StructType* StructTy_llvm_dbg_subprogram_type = StructType::get(mod->getContext(), StructTy_llvm_dbg_subprogram_type_fields, /*isPacked=*/false); mod->addTypeName("llvm.dbg.subprogram.type", StructTy_llvm_dbg_subprogram_type); std::vectorStructTy_llvm_dbg_variable_type_fields; @@ -124,7 +124,7 @@ void RegisterDwarfSymbols(llvm::Module* mod) { StructTy_llvm_dbg_variable_type_fields.push_back(PointerTy_0); StructTy_llvm_dbg_variable_type_fields.push_back(IntegerType::get(32)); StructTy_llvm_dbg_variable_type_fields.push_back(PointerTy_0); - StructType* StructTy_llvm_dbg_variable_type = StructType::get(StructTy_llvm_dbg_variable_type_fields, /*isPacked=*/false); + StructType* StructTy_llvm_dbg_variable_type = StructType::get(mod->getContext(), StructTy_llvm_dbg_variable_type_fields, /*isPacked=*/false); mod->addTypeName("llvm.dbg.variable.type", StructTy_llvm_dbg_variable_type); std::vectorFuncTy_3_args; diff --git a/gen/main.cpp b/gen/main.cpp index 2e113ce7..43e48e2b 100644 --- a/gen/main.cpp +++ b/gen/main.cpp @@ -483,11 +483,7 @@ LDC_TARGETS FeaturesStr = Features.getString(); } -#if LLVM_REV < 77946 - std::auto_ptr target(theTarget->createTargetMachine(mod, FeaturesStr)); -#else std::auto_ptr target(theTarget->createTargetMachine(mod.getTargetTriple(), FeaturesStr)); -#endif assert(target.get() && "Could not allocate target machine!"); gTargetMachine = target.get(); gTargetData = gTargetMachine->getTargetData(); diff --git a/gen/nested.cpp b/gen/nested.cpp index f51d167f..e81d097e 100644 --- a/gen/nested.cpp +++ b/gen/nested.cpp @@ -447,7 +447,7 @@ void DtoCreateNestedContext(FuncDeclaration* fd) { } } - const LLStructType* frameType = LLStructType::get(types); + const LLStructType* frameType = LLStructType::get(gIR->context(), types); gIR->module->addTypeName(std::string("nest.") + fd->toChars(), frameType); Logger::cout() << "frameType = " << *frameType << '\n'; diff --git a/gen/rttibuilder.cpp b/gen/rttibuilder.cpp index dc39bc75..c83e8f6a 100644 --- a/gen/rttibuilder.cpp +++ b/gen/rttibuilder.cpp @@ -142,7 +142,7 @@ void RTTIBuilder::push_funcptr(FuncDeclaration* fd, Type* castto) void RTTIBuilder::finalize(IrGlobal* tid) { // create the inititalizer - LLConstant* tiInit = LLConstantStruct::get(&inits[0], inits.size(), false); + LLConstant* tiInit = LLConstantStruct::get(gIR->context(), &inits[0], inits.size(), false); // refine global type llvm::cast(tid->type.get())->refineAbstractTypeTo(tiInit->getType()); @@ -154,5 +154,5 @@ void RTTIBuilder::finalize(IrGlobal* tid) LLConstant* RTTIBuilder::get_constant() { // just return the inititalizer - return LLConstantStruct::get(&inits[0], inits.size(), false); + return LLConstantStruct::get(gIR->context(), &inits[0], inits.size(), false); } diff --git a/gen/runtime.cpp b/gen/runtime.cpp index 1108439b..9676c97e 100644 --- a/gen/runtime.cpp +++ b/gen/runtime.cpp @@ -124,7 +124,7 @@ static const LLType* rt_ptr(const LLType* t) static const LLType* rt_array(const LLType* elemty) { - return llvm::StructType::get(DtoSize_t(), rt_ptr(elemty), NULL); + return llvm::StructType::get(gIR->context(), DtoSize_t(), rt_ptr(elemty), NULL); } static const LLType* rt_dg1() @@ -133,7 +133,7 @@ static const LLType* rt_dg1() types.push_back(rt_ptr(LLType::Int8Ty)); types.push_back(rt_ptr(LLType::Int8Ty)); const llvm::FunctionType* fty = llvm::FunctionType::get(LLType::Int32Ty, types, false); - return llvm::StructType::get(rt_ptr(LLType::Int8Ty), rt_ptr(fty), NULL); + return llvm::StructType::get(gIR->context(), rt_ptr(LLType::Int8Ty), rt_ptr(fty), NULL); } static const LLType* rt_dg2() @@ -143,7 +143,7 @@ static const LLType* rt_dg2() types.push_back(rt_ptr(LLType::Int8Ty)); types.push_back(rt_ptr(LLType::Int8Ty)); const llvm::FunctionType* fty = llvm::FunctionType::get(LLType::Int32Ty, types, false); - return llvm::StructType::get(rt_ptr(LLType::Int8Ty), rt_ptr(fty), NULL); + return llvm::StructType::get(gIR->context(), rt_ptr(LLType::Int8Ty), rt_ptr(fty), NULL); } static void LLVM_D_BuildRuntimeModule() @@ -169,9 +169,9 @@ static void LLVM_D_BuildRuntimeModule() else realTy = LLType::DoubleTy; - const LLType* cfloatTy = llvm::StructType::get(floatTy, floatTy, NULL); - const LLType* cdoubleTy = llvm::StructType::get(doubleTy, doubleTy, NULL); - const LLType* crealTy = llvm::StructType::get(realTy, realTy, NULL); + const LLType* cfloatTy = llvm::StructType::get(gIR->context(), floatTy, floatTy, NULL); + const LLType* cdoubleTy = llvm::StructType::get(gIR->context(), doubleTy, doubleTy, NULL); + const LLType* crealTy = llvm::StructType::get(gIR->context(), realTy, realTy, NULL); Logger::println("building aggr types"); const LLType* voidPtrTy = rt_ptr(byteTy); diff --git a/gen/statements.cpp b/gen/statements.cpp index 1d1c0378..7240db75 100644 --- a/gen/statements.cpp +++ b/gen/statements.cpp @@ -825,7 +825,7 @@ void SwitchStatement::toIR(IRState* p) std::vector types; types.push_back(DtoSize_t()); types.push_back(elemPtrTy); - const llvm::StructType* sTy = llvm::StructType::get(types); + const llvm::StructType* sTy = llvm::StructType::get(gIR->context(), types); std::vector sinits; sinits.push_back(DtoConstSize_t(inits.size())); sinits.push_back(arrPtr); diff --git a/gen/structs.cpp b/gen/structs.cpp index 2bb46890..0f2d5313 100644 --- a/gen/structs.cpp +++ b/gen/structs.cpp @@ -362,7 +362,7 @@ LLType* DtoUnpaddedStructType(Type* dty) { } types.push_back(fty); } - LLType* Ty = LLStructType::get(types); + LLType* Ty = LLStructType::get(gIR->context(), types); cache.insert(std::make_pair(dty, Ty)); return Ty; } diff --git a/gen/tocall.cpp b/gen/tocall.cpp index 0474c167..b7331735 100644 --- a/gen/tocall.cpp +++ b/gen/tocall.cpp @@ -160,11 +160,11 @@ void DtoBuildDVarArgList(std::vector& args, std::vectorcontext(), gah, true); } } } - const LLStructType* vtype = LLStructType::get(vtypes); + const LLStructType* vtype = LLStructType::get(gIR->context(), vtypes); if (Logger::enabled()) Logger::cout() << "d-variadic argument struct type:\n" << *vtype << '\n'; @@ -207,7 +207,7 @@ void DtoBuildDVarArgList(std::vector& args, std::vectorgetNumElements())); pinits.push_back(llvm::ConstantExpr::getBitCast(typeinfomem, getPtrToType(typeinfotype))); const LLType* tiarrty = DtoType(Type::typeinfo->type->arrayOf()); - tiinits = LLConstantStruct::get(pinits); + tiinits = LLConstantStruct::get(gIR->context(), pinits); LLValue* typeinfoarrayparam = new llvm::GlobalVariable(*gIR->module, tiarrty, true, llvm::GlobalValue::InternalLinkage, tiinits, "._arguments.array"); diff --git a/gen/todebug.cpp b/gen/todebug.cpp index 325e46d4..d4543394 100644 --- a/gen/todebug.cpp +++ b/gen/todebug.cpp @@ -20,7 +20,7 @@ using namespace llvm::dwarf; #define DBG_NULL ( LLConstant::getNullValue(DBG_TYPE) ) -#define DBG_TYPE ( getPtrToType(llvm::StructType::get(NULL,NULL)) ) +#define DBG_TYPE ( getPtrToType(llvm::StructType::get(gIR->context(),NULL,NULL)) ) #define DBG_CAST(X) ( llvm::ConstantExpr::getBitCast(X, DBG_TYPE) ) #define DBG_TAG(X) ( llvm::ConstantExpr::getAdd( DtoConstUint( X ), DtoConstUint( llvm::LLVMDebugVersion ) ) ) diff --git a/gen/toir.cpp b/gen/toir.cpp index 08f5c0c5..f1776607 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -2517,7 +2517,7 @@ LLConstant* StructLiteralExp::toConstElem(IRState* p) constvals[i] = llvm::cast(values[i]); // return constant struct - return LLConstantStruct::get(constvals, sd->ir.irStruct->packed); + return LLConstantStruct::get(gIR->context(), constvals, sd->ir.irStruct->packed); } ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/gen/tollvm.cpp b/gen/tollvm.cpp index 64090b92..5023226c 100644 --- a/gen/tollvm.cpp +++ b/gen/tollvm.cpp @@ -817,11 +817,11 @@ const LLStructType* DtoInterfaceInfoType() vtbltypes.push_back(DtoSize_t()); const LLType* byteptrptrty = getPtrToType(getPtrToType(LLType::Int8Ty)); vtbltypes.push_back(byteptrptrty); - types.push_back(LLStructType::get(vtbltypes)); + types.push_back(LLStructType::get(gIR->context(), vtbltypes)); // int offset types.push_back(LLType::Int32Ty); // create type - gIR->interfaceInfoType = LLStructType::get(types); + gIR->interfaceInfoType = LLStructType::get(gIR->context(), types); return gIR->interfaceInfoType; } @@ -838,20 +838,20 @@ const LLStructType* DtoMutexType() { // CRITICAL_SECTION.sizeof == 68 std::vector types(17, LLType::Int32Ty); - return LLStructType::get(types); + return LLStructType::get(gIR->context(), types); } // FreeBSD else if (global.params.os == OSFreeBSD) { // Just a pointer - return LLStructType::get(DtoSize_t(), NULL); + return LLStructType::get(gIR->context(), DtoSize_t(), NULL); } // pthread_fastlock std::vector types2; types2.push_back(DtoSize_t()); types2.push_back(LLType::Int32Ty); - const LLStructType* fastlock = LLStructType::get(types2); + const LLStructType* fastlock = LLStructType::get(gIR->context(), types2); // pthread_mutex std::vector types1; @@ -860,7 +860,7 @@ const LLStructType* DtoMutexType() types1.push_back(getVoidPtrType()); types1.push_back(LLType::Int32Ty); types1.push_back(fastlock); - const LLStructType* pmutex = LLStructType::get(types1); + const LLStructType* pmutex = LLStructType::get(gIR->context(), types1); // D_CRITICAL_SECTION LLOpaqueType* opaque = LLOpaqueType::get(); @@ -869,7 +869,7 @@ const LLStructType* DtoMutexType() types.push_back(pmutex); // resolve type - pmutex = LLStructType::get(types); + pmutex = LLStructType::get(gIR->context(), types); LLPATypeHolder pa(pmutex); opaque->refineAbstractTypeTo(pa.get()); pmutex = isaStruct(pa.get()); @@ -895,7 +895,7 @@ const LLStructType* DtoModuleReferenceType() types.push_back(DtoType(Module::moduleinfo->type)); // resolve type - const LLStructType* st = LLStructType::get(types); + const LLStructType* st = LLStructType::get(gIR->context(), types); LLPATypeHolder pa(st); opaque->refineAbstractTypeTo(pa.get()); st = isaStruct(pa.get()); @@ -917,7 +917,7 @@ LLValue* DtoAggrPair(const LLType* type, LLValue* V1, LLValue* V2, const char* n LLValue* DtoAggrPair(LLValue* V1, LLValue* V2, const char* name) { - const LLType* t = LLStructType::get(V1->getType(), V2->getType(), NULL); + const LLType* t = LLStructType::get(gIR->context(), V1->getType(), V2->getType(), NULL); return DtoAggrPair(t, V1, V2, name); } diff --git a/gen/toobj.cpp b/gen/toobj.cpp index 778a0310..c8fbbe06 100644 --- a/gen/toobj.cpp +++ b/gen/toobj.cpp @@ -405,7 +405,7 @@ void assemble(const llvm::sys::Path& asmpath, const llvm::sys::Path& objpath) // the following code generates functions and needs to output // debug info. these macros are useful for that -#define DBG_TYPE ( getPtrToType(llvm::StructType::get(NULL,NULL)) ) +#define DBG_TYPE ( getPtrToType(llvm::StructType::get(gIR->context(),NULL,NULL)) ) #define DBG_CAST(X) ( llvm::ConstantExpr::getBitCast(X, DBG_TYPE) ) // build module ctor @@ -811,7 +811,7 @@ void Module::genmoduleinfo() std::vector magictypes; magictypes.push_back(LLType::Int32Ty); magictypes.push_back(getPtrToType(magicfty)); - const LLStructType* magicsty = LLStructType::get(magictypes); + const LLStructType* magicsty = LLStructType::get(gIR->context(), magictypes); // make the constant element std::vector magicconstants; diff --git a/gen/typinf.cpp b/gen/typinf.cpp index 9d3e42da..9974f16c 100644 --- a/gen/typinf.cpp +++ b/gen/typinf.cpp @@ -16,7 +16,6 @@ #include #include "gen/llvm.h" -#include "gen/llvm-version.h" #include "mars.h" #include "module.h" @@ -318,11 +317,7 @@ void DtoResolveTypeInfo(TypeInfoDeclaration* tid) mdVals[TD_Confirm] = llvm::cast(irg->value); mdVals[TD_Type] = llvm::UndefValue::get(DtoType(tid->tinfo)); // Construct the metadata -#if LLVM_REV < 77733 - llvm::MetadataBase* metadata = gIR->context().getMDNode(mdVals, TD_NumFields); -#else llvm::MetadataBase* metadata = llvm::MDNode::get(gIR->context(), mdVals, TD_NumFields); -#endif // Insert it into the module llvm::NamedMDNode::Create(metaname, &metadata, 1, gIR->module); } diff --git a/ir/irclass.cpp b/ir/irclass.cpp index 4b24d348..931b3886 100644 --- a/ir/irclass.cpp +++ b/ir/irclass.cpp @@ -5,7 +5,6 @@ #include "declaration.h" #include "mtype.h" -#include "gen/llvm-version.h" #include "gen/irstate.h" #include "gen/logger.h" #include "gen/tollvm.h" @@ -87,11 +86,7 @@ LLGlobalVariable * IrStruct::getClassInfoSymbol() mdVals[CD_Finalize] = LLConstantInt::get(LLType::Int1Ty, hasDestructor); mdVals[CD_CustomDelete] = LLConstantInt::get(LLType::Int1Ty, hasCustomDelete); // Construct the metadata -#if LLVM_REV < 77733 - llvm::MetadataBase* metadata = gIR->context().getMDNode(mdVals, CD_NumFields); -#else llvm::MetadataBase* metadata = llvm::MDNode::get(gIR->context(), mdVals, CD_NumFields); -#endif // Insert it into the module std::string metaname = CD_PREFIX + initname; llvm::NamedMDNode::Create(metaname, &metadata, 1, gIR->module); @@ -177,7 +172,7 @@ LLConstant * IrStruct::getVtblInit() } // build the constant struct - constVtbl = LLConstantStruct::get(constants, false); + constVtbl = LLConstantStruct::get(gIR->context(), constants, false); #if 0 IF_LOG Logger::cout() << "constVtbl type: " << *constVtbl->getType() << std::endl; @@ -321,7 +316,7 @@ LLConstant * IrStruct::createClassDefaultInitializer() addBaseClassInits(constants, cd, offset, field_index); // build the constant - llvm::Constant* definit = LLConstantStruct::get(constants, false); + llvm::Constant* definit = LLConstantStruct::get(gIR->context(), constants, false); return definit; } @@ -389,7 +384,7 @@ llvm::GlobalVariable * IrStruct::getInterfaceVtbl(BaseClass * b, bool new_instan } // build the vtbl constant - llvm::Constant* vtbl_constant = LLConstantStruct::get(constants, false); + llvm::Constant* vtbl_constant = LLConstantStruct::get(gIR->context(), constants, false); // create the global variable to hold it llvm::GlobalValue::LinkageTypes _linkage = DtoExternalLinkage(aggrdecl); @@ -488,7 +483,7 @@ LLConstant * IrStruct::getClassInfoInterfaces() // create Interface struct LLConstant* inits[3] = { ci, vtb, off }; - LLConstant* entry = LLConstantStruct::get(inits, 3); + LLConstant* entry = LLConstantStruct::get(gIR->context(), inits, 3); constants.push_back(entry); } diff --git a/ir/irstruct.cpp b/ir/irstruct.cpp index cceea3f2..7a2abc2e 100644 --- a/ir/irstruct.cpp +++ b/ir/irstruct.cpp @@ -195,7 +195,7 @@ LLConstant * IrStruct::createStructDefaultInitializer() } // build constant struct - llvm::Constant* definit = LLConstantStruct::get(constants, packed); + llvm::Constant* definit = LLConstantStruct::get(gIR->context(), constants, packed); #if 0 IF_LOG Logger::cout() << "final default initializer: " << *definit << std::endl; #endif @@ -384,7 +384,7 @@ LLConstant * IrStruct::createStructInitializer(StructInitializer * si) // build constant assert(!constants.empty()); - llvm::Constant* c = LLConstantStruct::get(&constants[0], constants.size(), packed); + llvm::Constant* c = LLConstantStruct::get(gIR->context(), &constants[0], constants.size(), packed); IF_LOG Logger::cout() << "final struct initializer: " << *c << std::endl; return c; } diff --git a/ir/irtype.cpp b/ir/irtype.cpp index 998d6a84..dec49e02 100644 --- a/ir/irtype.cpp +++ b/ir/irtype.cpp @@ -92,17 +92,17 @@ const llvm::Type * IrTypeBasic::basic2llvm(Type* t) case Tcomplex32: t2 = llvm::Type::FloatTy; - return llvm::StructType::get(t2, t2, NULL); + return llvm::StructType::get(gIR->context(), t2, t2, NULL); case Tcomplex64: t2 = llvm::Type::DoubleTy; - return llvm::StructType::get(t2, t2, NULL); + return llvm::StructType::get(gIR->context(), t2, t2, NULL); case Tcomplex80: t2 = (global.params.cpu == ARCHx86 || global.params.cpu == ARCHx86_64) ? llvm::Type::X86_FP80Ty : llvm::Type::DoubleTy; - return llvm::StructType::get(t2, t2, NULL); + return llvm::StructType::get(gIR->context(), t2, t2, NULL); case Tbool: return llvm::Type::Int1Ty; @@ -204,7 +204,7 @@ const llvm::Type * IrTypeArray::array2llvm(Type * t) elemType = llvm::PointerType::get(elemType, 0); // create struct type - const llvm::Type* at = llvm::StructType::get(DtoSize_t(), elemType, NULL); + const llvm::Type* at = llvm::StructType::get(gIR->context(), DtoSize_t(), elemType, NULL); // name dynamic array types Type::sir->getState()->module->addTypeName(t->toChars(), at); diff --git a/ir/irtypeclass.cpp b/ir/irtypeclass.cpp index 3e599c80..7763ff07 100644 --- a/ir/irtypeclass.cpp +++ b/ir/irtypeclass.cpp @@ -258,7 +258,7 @@ const llvm::Type* IrTypeClass::buildType() fatal(); // build the llvm type - const llvm::Type* st = llvm::StructType::get(defaultTypes, false); + const llvm::Type* st = llvm::StructType::get(gIR->context(), defaultTypes, false); // refine type llvm::cast(pa.get())->refineAbstractTypeTo(st); @@ -324,7 +324,7 @@ const llvm::Type* IrTypeClass::buildVtblType(Type* first, Array* vtbl_array) } // build the vtbl llvm type - return llvm::StructType::get(types, false); + return llvm::StructType::get(gIR->context(), types, false); } ////////////////////////////////////////////////////////////////////////////// diff --git a/ir/irtypefunction.cpp b/ir/irtypefunction.cpp index a6a9d1dc..32100bcb 100644 --- a/ir/irtypefunction.cpp +++ b/ir/irtypefunction.cpp @@ -39,7 +39,7 @@ const llvm::Type * IrTypeDelegate::buildType() const LLType* i8ptr = getVoidPtrType(); const LLType* func = DtoFunctionType(dtype->nextOf(), NULL, Type::tvoid->pointerTo()); const LLType* funcptr = getPtrToType(func); - const LLStructType* dgtype = LLStructType::get(i8ptr, funcptr, NULL); + const LLStructType* dgtype = LLStructType::get(gIR->context(), i8ptr, funcptr, NULL); gIR->module->addTypeName(dtype->toChars(), dgtype); llvm::cast(pa.get())->refineAbstractTypeTo(dgtype); diff --git a/ir/irtypestruct.cpp b/ir/irtypestruct.cpp index 37ecc43a..19d10627 100644 --- a/ir/irtypestruct.cpp +++ b/ir/irtypestruct.cpp @@ -219,7 +219,7 @@ const llvm::Type* IrTypeStruct::buildType() } // build the llvm type - const llvm::Type* st = llvm::StructType::get(defaultTypes, packed); + const llvm::Type* st = llvm::StructType::get(gIR->context(), defaultTypes, packed); // refine type llvm::cast(pa.get())->refineAbstractTypeTo(st);