diff --git a/gen/aa.cpp b/gen/aa.cpp index 1f370611..67e6a4d4 100644 --- a/gen/aa.cpp +++ b/gen/aa.cpp @@ -93,16 +93,15 @@ DValue* DtoAAIndex(Loc& loc, Type* type, DValue* aa, DValue* key, bool lvalue) gIR->scope() = IRScope(failbb, okbb); - std::vector args; - - // module param LLValue *moduleInfoSymbol = gIR->func()->decl->getModule()->moduleInfoSymbol(); LLType *moduleInfoType = DtoType(Module::moduleinfo->type); - args.push_back(DtoBitCast(moduleInfoSymbol, getPtrToType(moduleInfoType))); - // line param - LLConstant* c = DtoConstUint(loc.linnum); - args.push_back(c); + LLValue* args[] = { + // module param + DtoBitCast(moduleInfoSymbol, getPtrToType(moduleInfoType)), + // line param + DtoConstUint(loc.linnum) + }; // call llvm::Function* errorfn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_array_bounds"); @@ -201,10 +200,7 @@ DValue *DtoAARemove(Loc& loc, DValue* aa, DValue* key) pkey = DtoBitCast(pkey, funcTy->getParamType(2)); // build arg vector - LLSmallVector args; - args.push_back(aaval); - args.push_back(keyti); - args.push_back(pkey); + LLValue* args[] = { aaval, keyti, pkey }; // call runtime LLCallSite call = gIR->CreateCallOrInvoke(func, args); diff --git a/gen/arrays.cpp b/gen/arrays.cpp index bbebb884..854ec972 100644 --- a/gen/arrays.cpp +++ b/gen/arrays.cpp @@ -215,10 +215,11 @@ void DtoArrayAssign(DValue *array, DValue *value, int op) Type *elemType = t->nextOf()->toBasetype(); LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, op == TOKconstruct ? "_d_arrayctor" : "_d_arrayassign"); - LLSmallVector args; - args.push_back(DtoTypeInfoOf(elemType)); - args.push_back(DtoAggrPaint(DtoSlice(value), fn->getFunctionType()->getParamType(1))); - args.push_back(DtoAggrPaint(DtoSlice(array), fn->getFunctionType()->getParamType(2))); + LLValue* args[] = { + DtoTypeInfoOf(elemType), + DtoAggrPaint(DtoSlice(value), fn->getFunctionType()->getParamType(1)), + DtoAggrPaint(DtoSlice(array), fn->getFunctionType()->getParamType(2)) + }; LLCallSite call = gIR->CreateCallOrInvoke(fn, args, ".array"); call.setCallingConv(llvm::CallingConv::C); @@ -238,11 +239,12 @@ void DtoArraySetAssign(Loc &loc, DValue *array, DValue *value, int op) LLValue *len = DtoArrayLen(array); LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, op == TOKconstruct ? "_d_arraysetctor" : "_d_arraysetassign"); - LLSmallVector args; - args.push_back(DtoBitCast(ptr, getVoidPtrType())); - args.push_back(DtoBitCast(makeLValue(loc, value), getVoidPtrType())); - args.push_back(len); - args.push_back(DtoTypeInfoOf(array->type->toBasetype()->nextOf()->toBasetype())); + LLValue* args[] = { + DtoBitCast(ptr, getVoidPtrType()), + DtoBitCast(makeLValue(loc, value), getVoidPtrType()), + len, + DtoTypeInfoOf(array->type->toBasetype()->nextOf()->toBasetype()) + }; LLCallSite call = gIR->CreateCallOrInvoke(fn, args, ".newptr"); call.setCallingConv(llvm::CallingConv::C); @@ -614,6 +616,7 @@ DSliceValue* DtoNewMulDimDynArray(Loc& loc, Type* arrayType, DValue** dims, size LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, fnname); std::vector args; + args.reserve(ndims+2); args.push_back(arrayTypeInfo); args.push_back(DtoConstSize_t(ndims)); @@ -647,11 +650,11 @@ DSliceValue* DtoResizeDynArray(Type* arrayType, DValue* array, LLValue* newdim) // call runtime LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, zeroInit ? "_d_arraysetlengthT" : "_d_arraysetlengthiT" ); - LLSmallVector args; - args.push_back(DtoTypeInfoOf(arrayType)); - args.push_back(newdim); - - args.push_back(DtoBitCast(array->getLVal(), fn->getFunctionType()->getParamType(2))); + LLValue* args[] = { + DtoTypeInfoOf(arrayType), + newdim, + DtoBitCast(array->getLVal(), fn->getFunctionType()->getParamType(2)) + }; LLValue* newArray = gIR->CreateCallOrInvoke(fn, args, ".gc_mem").getInstruction(); return getSlice(arrayType, newArray); @@ -673,10 +676,11 @@ void DtoCatAssignElement(Loc& loc, Type* arrayType, DValue* array, Expression* e DValue *expVal = exp->toElem(gIR); LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_arrayappendcTX"); - LLSmallVector args; - args.push_back(DtoTypeInfoOf(arrayType)); - args.push_back(DtoBitCast(array->getLVal(), fn->getFunctionType()->getParamType(1))); - args.push_back(DtoConstSize_t(1)); + LLValue* args[] = { + DtoTypeInfoOf(arrayType), + DtoBitCast(array->getLVal(), fn->getFunctionType()->getParamType(1)), + DtoConstSize_t(1) + }; LLValue* appendedArray = gIR->CreateCallOrInvoke(fn, args, ".appendedArray").getInstruction(); appendedArray = DtoAggrPaint(appendedArray, DtoType(arrayType)); @@ -772,11 +776,12 @@ DSliceValue* DtoAppendDChar(DValue* arr, Expression* exp, const char *func) // Prepare arguments LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, func); - LLSmallVector args; - // ref string x - args.push_back(DtoBitCast(arr->getLVal(), fn->getFunctionType()->getParamType(0))); - // dchar c - args.push_back(DtoBitCast(valueToAppend->getRVal(), fn->getFunctionType()->getParamType(1))); + LLValue* args[] = { + // ref string x + DtoBitCast(arr->getLVal(), fn->getFunctionType()->getParamType(0)), + // dchar c + DtoBitCast(valueToAppend->getRVal(), fn->getFunctionType()->getParamType(1)) + }; // Call function LLValue* newArray = gIR->CreateCallOrInvoke(fn, args, ".appendedArray").getInstruction(); @@ -818,16 +823,11 @@ static LLValue* DtoArrayEqCmp_impl(Loc& loc, const char* func, DValue* l, DValue l = DtoCastArray(loc, l, commonType); r = DtoCastArray(loc, r, commonType); - LLValue* lmem; - LLValue* rmem; LLSmallVector args; // get values, reinterpret cast to void[] - lmem = DtoAggrPaint(l->getRVal(), DtoArrayType(LLType::getInt8Ty(gIR->context()))); - args.push_back(lmem); - - rmem = DtoAggrPaint(r->getRVal(), DtoArrayType(LLType::getInt8Ty(gIR->context()))); - args.push_back(rmem); + args.push_back(DtoAggrPaint(l->getRVal(), DtoArrayType(LLType::getInt8Ty(gIR->context())))); + args.push_back(DtoAggrPaint(r->getRVal(), DtoArrayType(LLType::getInt8Ty(gIR->context())))); // pass array typeinfo ? if (useti) { @@ -896,10 +896,11 @@ LLValue* DtoArrayCastLength(LLValue* len, LLType* elemty, LLType* newelemty) if (esz == nsz) return len; - LLSmallVector args; - args.push_back(len); - args.push_back(LLConstantInt::get(DtoSize_t(), esz, false)); - args.push_back(LLConstantInt::get(DtoSize_t(), nsz, false)); + LLValue* args[] = { + len, + LLConstantInt::get(DtoSize_t(), esz, false), + LLConstantInt::get(DtoSize_t(), nsz, false) + }; LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_array_cast_len"); return gIR->CreateCallOrInvoke(fn, args, "tmp").getInstruction(); diff --git a/gen/classes.cpp b/gen/classes.cpp index 5a268b48..1bd326d7 100644 --- a/gen/classes.cpp +++ b/gen/classes.cpp @@ -232,8 +232,9 @@ void DtoFinalizeClass(LLValue* inst) // get runtime function llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_callfinalizer"); // build args - LLSmallVector arg; - arg.push_back(DtoBitCast(inst, fn->getFunctionType()->getParamType(0), ".tmp")); + LLValue* arg[] = { + DtoBitCast(inst, fn->getFunctionType()->getParamType(0), ".tmp") + }; // call gIR->CreateCallOrInvoke(fn, arg, ""); } @@ -369,8 +370,6 @@ DValue* DtoDynamicCastObject(DValue* val, Type* _to) llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_d_dynamic_cast"); LLFunctionType* funcTy = func->getFunctionType(); - std::vector args; - // Object o LLValue* obj = val->getRVal(); obj = DtoBitCast(obj, funcTy->getParamType(0)); @@ -434,8 +433,6 @@ DValue* DtoDynamicCastInterface(DValue* val, Type* _to) llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_d_interface_cast"); LLFunctionType* funcTy = func->getFunctionType(); - std::vector args; - // void* p LLValue* ptr = val->getRVal(); ptr = DtoBitCast(ptr, funcTy->getParamType(0)); diff --git a/gen/complex.cpp b/gen/complex.cpp index f8875945..94db9e6e 100644 --- a/gen/complex.cpp +++ b/gen/complex.cpp @@ -23,10 +23,8 @@ llvm::StructType* DtoComplexType(Type* type) { Type* t = type->toBasetype(); LLType* base = DtoComplexBaseType(t); - llvm::SmallVector types; - types.push_back(base); - types.push_back(base); - return llvm::StructType::get(gIR->context(), types); + LLType* types[] = { base, base }; + return llvm::StructType::get(gIR->context(), types, false); } LLType* DtoComplexBaseType(Type* t) @@ -62,11 +60,10 @@ LLConstant* DtoConstComplex(Type* _ty, longdouble re, longdouble im) case Tcomplex80: base = Type::tfloat80; break; } - std::vector inits; - inits.push_back(DtoConstFP(base, re)); - inits.push_back(DtoConstFP(base, im)); + LLConstant * inits[] = { DtoConstFP(base, re), DtoConstFP(base, im) }; - return llvm::ConstantStruct::get(DtoComplexType(_ty), inits); + return llvm::ConstantStruct::get(DtoComplexType(_ty), + llvm::ArrayRef(inits)); } ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/gen/todebug.cpp b/gen/todebug.cpp index f542a675..9898ec7e 100644 --- a/gen/todebug.cpp +++ b/gen/todebug.cpp @@ -356,9 +356,11 @@ static llvm::DIType dwarfArrayType(Type* type) { llvm::DIFile file = DtoDwarfFile(Loc(gIR->dmodule, 0)); - std::vector elems; - elems.push_back(dwarfMemberType(0, Type::tsize_t, file, "length", 0)); - elems.push_back(dwarfMemberType(0, t->nextOf()->pointerTo(), file, "ptr", global.params.is64bit?8:4)); + llvm::Value* elems[] = { + dwarfMemberType(0, Type::tsize_t, file, "length", 0), + dwarfMemberType(0, t->nextOf()->pointerTo(), file, "ptr", + global.params.is64bit ? 8 : 4) + }; return gIR->dibuilder.createStructType ( diff --git a/gen/tollvm.cpp b/gen/tollvm.cpp index 38c5b9ae..e6e14777 100644 --- a/gen/tollvm.cpp +++ b/gen/tollvm.cpp @@ -480,7 +480,7 @@ LLValue* DtoGEP1(LLValue* ptr, LLValue* i0, const char* var, llvm::BasicBlock* b LLValue* DtoGEP(LLValue* ptr, LLValue* i0, LLValue* i1, const char* var, llvm::BasicBlock* bb) { - LLValue* v[2] = { i0, i1 }; + LLValue* v[] = { i0, i1 }; return llvm::GetElementPtrInst::Create(ptr, v, var?var:"tmp", bb?bb:gIR->scopebb()); } @@ -495,7 +495,7 @@ LLValue* DtoGEPi1(LLValue* ptr, unsigned i, const char* var, llvm::BasicBlock* b LLValue* DtoGEPi(LLValue* ptr, unsigned i0, unsigned i1, const char* var, llvm::BasicBlock* bb) { - LLValue* v[2] = { DtoConstUint(i0), DtoConstUint(i1) }; + LLValue* v[] = { DtoConstUint(i0), DtoConstUint(i1) }; return llvm::GetElementPtrInst::Create(ptr, v, var?var:"tmp", bb?bb:gIR->scopebb()); } @@ -503,7 +503,7 @@ LLValue* DtoGEPi(LLValue* ptr, unsigned i0, unsigned i1, const char* var, llvm:: LLConstant* DtoGEPi(LLConstant* ptr, unsigned i0, unsigned i1) { - LLValue* v[2] = { DtoConstUint(i0), DtoConstUint(i1) }; + LLValue* v[] = { DtoConstUint(i0), DtoConstUint(i1) }; return llvm::ConstantExpr::getGetElementPtr(ptr, v, true); } @@ -632,7 +632,7 @@ LLConstant* DtoConstFP(Type* t, longdouble value) if(llty == LLType::getFloatTy(gIR->context()) || llty == LLType::getDoubleTy(gIR->context())) return LLConstantFP::get(llty, value); else if(llty == LLType::getX86_FP80Ty(gIR->context())) { - uint64_t bits[] = {0, 0}; + uint64_t bits[] = { 0, 0 }; bits[0] = *reinterpret_cast(&value); bits[1] = *reinterpret_cast(reinterpret_cast(&value) + 1); #if LDC_LLVM_VER >= 303 @@ -666,7 +666,7 @@ LLConstant* DtoConstString(const char* str) #endif llvm::GlobalVariable* gvar = new llvm::GlobalVariable( *gIR->module, init->getType(), true, llvm::GlobalValue::InternalLinkage, init, ".str"); - LLConstant* idxs[2] = { DtoConstUint(0), DtoConstUint(0) }; + LLConstant* idxs[] = { DtoConstUint(0), DtoConstUint(0) }; return DtoConstSlice( DtoConstSize_t(s.size()), llvm::ConstantExpr::getGetElementPtr(gvar, idxs, true), @@ -685,7 +685,7 @@ LLConstant* DtoConstStringPtr(const char* str, const char* section) llvm::GlobalVariable* gvar = new llvm::GlobalVariable( *gIR->module, init->getType(), true, llvm::GlobalValue::InternalLinkage, init, ".str"); if (section) gvar->setSection(section); - LLConstant* idxs[2] = { DtoConstUint(0), DtoConstUint(0) }; + LLConstant* idxs[] = { DtoConstUint(0), DtoConstUint(0) }; return llvm::ConstantExpr::getGetElementPtr(gvar, idxs, true); }