diff --git a/gen/arrays.cpp b/gen/arrays.cpp index cadb228817..ee542ff5de 100644 --- a/gen/arrays.cpp +++ b/gen/arrays.cpp @@ -70,18 +70,14 @@ LLStructType* DtoArrayType(Type* arrayTy) if (elemty == LLType::getVoidTy(gIR->context())) elemty = LLType::getInt8Ty(gIR->context()); - llvm::SmallVector elems; - elems.push_back(DtoSize_t()); - elems.push_back(getPtrToType(elemty)); - return LLStructType::get(gIR->context(), llvm::makeArrayRef(elems)); + llvm::Type *elems[] = { DtoSize_t(), getPtrToType(elemty) }; + return llvm::StructType::get(gIR->context(), elems, false); } LLStructType* DtoArrayType(LLType* t) { - llvm::SmallVector elems; - elems.push_back(DtoSize_t()); - elems.push_back(getPtrToType(t)); - return LLStructType::get(gIR->context(), llvm::makeArrayRef(elems)); + llvm::Type *elems[] = { DtoSize_t(), getPtrToType(t) }; + return llvm::StructType::get(gIR->context(), elems, false); } ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/gen/functions.cpp b/gen/functions.cpp index 9e8d525c18..b582148a50 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -72,10 +72,8 @@ llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nesttype, else { Type* rt = f->next; -#if LDC_LLVM_VER >= 303 - llvm::Attribute a; -#elif LDC_LLVM_VER == 302 - llvm::Attributes a; +#if LDC_LLVM_VER >= 302 + llvm::AttrBuilder attrBuilder; #else llvm::Attributes a = None; #endif @@ -121,8 +119,17 @@ llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nesttype, if (f->isref) t = t->pointerTo(); #endif +#if LDC_LLVM_VER >= 302 + attrBuilder.addAttribute(DtoShouldExtend(t)); +#else a = DtoShouldExtend(t); +#endif } +#if LDC_LLVM_VER >= 303 + llvm::Attribute a = llvm::Attribute::get(gIR->context(), attrBuilder); +#elif LDC_LLVM_VER == 302 + llvm::Attributes a = llvm::Attributes::get(gIR->context(), attrBuilder); +#endif #if DMDV2 fty.ret = new IrFuncTyArg(rt, f->isref, a); #else @@ -202,10 +209,8 @@ llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nesttype, #endif Type* argtype = arg->type; -#if LDC_LLVM_VER >= 303 - llvm::Attribute a; -#elif LDC_LLVM_VER == 302 - llvm::Attributes a; +#if LDC_LLVM_VER >= 302 + llvm::AttrBuilder attrBuilder; #else llvm::Attributes a = None; #endif @@ -222,9 +227,9 @@ llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nesttype, else if (abi->passByVal(byref ? argtype->pointerTo() : argtype)) { #if LDC_LLVM_VER >= 303 - if (!byref) a = llvm::Attribute::get(gIR->context(), llvm::AttrBuilder(a).addAttribute(llvm::Attribute::ByVal)); + if (!byref) attrBuilder.addAttribute(llvm::Attribute::ByVal); #elif LDC_LLVM_VER == 302 - if (!byref) a = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder(a).addAttribute(llvm::Attributes::ByVal)); + if (!byref) attrBuilder.addAttribute(llvm::Attributes::ByVal); #else if (!byref) a |= llvm::Attribute::ByVal; #endif @@ -234,15 +239,17 @@ llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nesttype, // sext/zext else if (!byref) { -#if LDC_LLVM_VER >= 303 - a = llvm::Attribute::get(gIR->context(), llvm::AttrBuilder(a).addAttributes(DtoShouldExtend(argtype))); -#elif LDC_LLVM_VER == 302 - a = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder(a).addAttributes(DtoShouldExtend(argtype))); +#if LDC_LLVM_VER >= 302 + attrBuilder.addAttribute(DtoShouldExtend(argtype)); #else a |= DtoShouldExtend(argtype); #endif } - +#if LDC_LLVM_VER >= 303 + llvm::Attribute a = llvm::Attribute::get(gIR->context(), attrBuilder); +#elif LDC_LLVM_VER == 302 + llvm::Attributes a = llvm::Attributes::get(gIR->context(), attrBuilder); +#endif fty.args.push_back(new IrFuncTyArg(argtype, byref, a)); lidx++; } diff --git a/gen/tollvm.cpp b/gen/tollvm.cpp index 7834bcec67..28ce5d961d 100644 --- a/gen/tollvm.cpp +++ b/gen/tollvm.cpp @@ -43,7 +43,9 @@ bool DtoIsPassedByRef(Type* type) } #if LDC_LLVM_VER >= 303 -llvm::Attribute DtoShouldExtend(Type* type) +llvm::Attribute::AttrKind DtoShouldExtend(Type* type) +#elif LDC_LLVM_VER == 302 +llvm::Attributes::AttrVal DtoShouldExtend(Type* type) #else llvm::Attributes DtoShouldExtend(Type* type) #endif @@ -56,9 +58,9 @@ llvm::Attributes DtoShouldExtend(Type* type) case Tint8: case Tint16: #if LDC_LLVM_VER >= 303 - return llvm::Attribute::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attribute::SExt)); + return llvm::Attribute::SExt; #elif LDC_LLVM_VER == 302 - return llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::SExt)); + return llvm::Attributes::SExt; #else return llvm::Attribute::SExt; #endif @@ -66,18 +68,18 @@ llvm::Attributes DtoShouldExtend(Type* type) case Tuns8: case Tuns16: #if LDC_LLVM_VER >= 303 - return llvm::Attribute::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attribute::ZExt)); + return llvm::Attribute::ZExt; #elif LDC_LLVM_VER == 302 - return llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::ZExt)); + return llvm::Attributes::ZExt; #else return llvm::Attribute::ZExt; #endif } } #if LDC_LLVM_VER >= 303 - return llvm::Attribute(); + return llvm::Attribute::None; #elif LDC_LLVM_VER == 302 - return llvm::Attributes(); + return llvm::Attributes::None; #else return llvm::Attribute::None; #endif diff --git a/gen/tollvm.h b/gen/tollvm.h index 0cd00dab5a..1e5539311a 100644 --- a/gen/tollvm.h +++ b/gen/tollvm.h @@ -35,7 +35,9 @@ bool DtoIsPassedByRef(Type* type); // should argument be zero or sign extended #if LDC_LLVM_VER >= 303 -llvm::Attribute DtoShouldExtend(Type* type); +llvm::Attribute::AttrKind DtoShouldExtend(Type* type); +#elif LDC_LLVM_VER == 302 +llvm::Attributes::AttrVal DtoShouldExtend(Type* type); #else llvm::Attributes DtoShouldExtend(Type* type); #endif diff --git a/ir/irtype.cpp b/ir/irtype.cpp index 0fa6df0ce4..3797af1076 100644 --- a/ir/irtype.cpp +++ b/ir/irtype.cpp @@ -57,10 +57,8 @@ IrTypeBasic* IrTypeBasic::get(Type* dt) LLType* IrTypeBasic::getComplexType(llvm::LLVMContext& ctx, LLType* type) { - llvm::SmallVector types; - types.push_back(type); - types.push_back(type); - return llvm::StructType::get(ctx, types); + llvm::Type *types[] = { type, type }; + return llvm::StructType::get(ctx, types, false); } ////////////////////////////////////////////////////////////////////////////// @@ -257,10 +255,8 @@ IrTypeArray* IrTypeArray::get(Type* dt) // just as for pointers. if (!dt->irtype) { - llvm::SmallVector types; - types.push_back(DtoSize_t()); - types.push_back(llvm::PointerType::get(elemType, 0)); - LLType* at = llvm::StructType::get(llvm::getGlobalContext(), types/*, t->toChars()*/); + llvm::Type *types[] = { DtoSize_t(), llvm::PointerType::get(elemType, 0) }; + LLType* at = llvm::StructType::get(llvm::getGlobalContext(), types, false); dt->irtype = new IrTypeArray(dt, at); } diff --git a/ir/irtypefunction.cpp b/ir/irtypefunction.cpp index 66fda0c280..747311e560 100644 --- a/ir/irtypefunction.cpp +++ b/ir/irtypefunction.cpp @@ -72,10 +72,9 @@ IrTypeDelegate* IrTypeDelegate::get(Type* dt) "picked up random pre-existing type?" ); - llvm::SmallVector types; - types.push_back(getVoidPtrType()); - types.push_back(getPtrToType(dt->nextOf()->irtype->getLLType())); - LLStructType* lt = LLStructType::get(gIR->context(), types); + llvm::Type *types[] = { getVoidPtrType(), + getPtrToType(dt->nextOf()->irtype->getLLType()) }; + LLStructType* lt = LLStructType::get(gIR->context(), types, false); dt->irtype = new IrTypeDelegate(dt, lt); }