diff --git a/gen/functions.cpp b/gen/functions.cpp index 4a09ea3f..7896865e 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -528,7 +528,7 @@ void DtoDeclareFunction(FuncDeclaration* fdecl) // calling convention if (!vafunc && fdecl->llvmInternal != LLVMintrinsic) - func->setCallingConv(DtoCallingConv(f->linkage)); + func->setCallingConv(DtoCallingConv(fdecl->loc, f->linkage)); else // fall back to C, it should be the right thing to do func->setCallingConv(llvm::CallingConv::C); diff --git a/gen/llvmhelpers.h b/gen/llvmhelpers.h index 6764f7a9..cd959c6e 100644 --- a/gen/llvmhelpers.h +++ b/gen/llvmhelpers.h @@ -113,7 +113,7 @@ void DtoOverloadedIntrinsicName(TemplateInstance* ti, TemplateDeclaration* td, s //////////////////////////////////////////// /// convert DMD calling conv to LLVM -unsigned DtoCallingConv(LINK l); +unsigned DtoCallingConv(Loc loc, LINK l); /// TypeFunction* DtoTypeFunction(DValue* fnval); diff --git a/gen/tocall.cpp b/gen/tocall.cpp index a3af9fa3..faecfbe6 100644 --- a/gen/tocall.cpp +++ b/gen/tocall.cpp @@ -33,7 +33,7 @@ TypeFunction* DtoTypeFunction(DValue* fnval) ////////////////////////////////////////////////////////////////////////////////////////// -unsigned DtoCallingConv(LINK l) +unsigned DtoCallingConv(Loc loc, LINK l) { if (l == LINKc || l == LINKcpp || l == LINKintrinsic) return llvm::CallingConv::C; @@ -50,7 +50,10 @@ unsigned DtoCallingConv(LINK l) else if (l == LINKwindows) return llvm::CallingConv::X86_StdCall; else - assert(0 && "Unsupported calling convention"); + { + error(loc, "unsupported calling convention"); + fatal(); + } } ////////////////////////////////////////////////////////////////////////////////////////// @@ -235,7 +238,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions* bool nestedcall = tf->usesNest; bool dvarargs = (tf->linkage == LINKd && tf->varargs == 1); - unsigned callconv = DtoCallingConv(tf->linkage); + unsigned callconv = DtoCallingConv(loc, tf->linkage); // get callee llvm value LLValue* callable = DtoCallableValue(fnval); diff --git a/gen/toobj.cpp b/gen/toobj.cpp index 64472570..cf9c12f6 100644 --- a/gen/toobj.cpp +++ b/gen/toobj.cpp @@ -417,7 +417,7 @@ llvm::Function* build_module_ctor() const llvm::FunctionType* fnTy = llvm::FunctionType::get(LLType::VoidTy,argsTy,false); assert(gIR->module->getFunction(name) == NULL); llvm::Function* fn = llvm::Function::Create(fnTy, llvm::GlobalValue::InternalLinkage, name, gIR->module); - fn->setCallingConv(DtoCallingConv(LINKd)); + fn->setCallingConv(DtoCallingConv(0, LINKd)); llvm::BasicBlock* bb = llvm::BasicBlock::Create("entry", fn); IRBuilder<> builder(bb); @@ -432,7 +432,7 @@ llvm::Function* build_module_ctor() for (size_t i=0; ictors[i]->ir.irFunc->func; llvm::CallInst* call = builder.CreateCall(f,""); - call->setCallingConv(DtoCallingConv(LINKd)); + call->setCallingConv(DtoCallingConv(0, LINKd)); } // debug info end @@ -462,7 +462,7 @@ static llvm::Function* build_module_dtor() const llvm::FunctionType* fnTy = llvm::FunctionType::get(LLType::VoidTy,argsTy,false); assert(gIR->module->getFunction(name) == NULL); llvm::Function* fn = llvm::Function::Create(fnTy, llvm::GlobalValue::InternalLinkage, name, gIR->module); - fn->setCallingConv(DtoCallingConv(LINKd)); + fn->setCallingConv(DtoCallingConv(0, LINKd)); llvm::BasicBlock* bb = llvm::BasicBlock::Create("entry", fn); IRBuilder<> builder(bb); @@ -477,7 +477,7 @@ static llvm::Function* build_module_dtor() for (size_t i=0; idtors[i]->ir.irFunc->func; llvm::CallInst* call = builder.CreateCall(f,""); - call->setCallingConv(DtoCallingConv(LINKd)); + call->setCallingConv(DtoCallingConv(0, LINKd)); } // debug info end @@ -507,7 +507,7 @@ static llvm::Function* build_module_unittest() const llvm::FunctionType* fnTy = llvm::FunctionType::get(LLType::VoidTy,argsTy,false); assert(gIR->module->getFunction(name) == NULL); llvm::Function* fn = llvm::Function::Create(fnTy, llvm::GlobalValue::InternalLinkage, name, gIR->module); - fn->setCallingConv(DtoCallingConv(LINKd)); + fn->setCallingConv(DtoCallingConv(0, LINKd)); llvm::BasicBlock* bb = llvm::BasicBlock::Create("entry", fn); IRBuilder<> builder(bb); @@ -522,7 +522,7 @@ static llvm::Function* build_module_unittest() for (size_t i=0; iunitTests[i]->ir.irFunc->func; llvm::CallInst* call = builder.CreateCall(f,""); - call->setCallingConv(DtoCallingConv(LINKd)); + call->setCallingConv(DtoCallingConv(0, LINKd)); } // debug info end