diff --git a/gen/aa.cpp b/gen/aa.cpp index 9e3a0418fe..d770f28422 100644 --- a/gen/aa.cpp +++ b/gen/aa.cpp @@ -93,18 +93,15 @@ DValue* DtoAAIndex(Loc& loc, Type* type, DValue* aa, DValue* key, bool lvalue) gIR->scope() = IRScope(failbb, okbb); - LLValue *moduleInfoSymbol = gIR->func()->decl->getModule()->moduleInfoSymbol(); - LLType *moduleInfoType = DtoType(Module::moduleinfo->type); - LLValue* args[] = { - // module param - DtoBitCast(moduleInfoSymbol, getPtrToType(moduleInfoType)), + // file param + DtoModuleFileName(gIR->func()->decl->getModule(), loc), // line param DtoConstUint(loc.linnum) }; // call - llvm::Function* errorfn = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_d_array_bounds"); + llvm::Function* errorfn = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_d_arraybounds"); gIR->CreateCallOrInvoke(errorfn, args); // the function does not return diff --git a/gen/arrays.cpp b/gen/arrays.cpp index 221155bd0a..51b0293f85 100644 --- a/gen/arrays.cpp +++ b/gen/arrays.cpp @@ -1167,18 +1167,16 @@ void DtoArrayBoundsCheck(Loc& loc, DValue* arr, DValue* index, DValue* lowerBoun std::vector args; + // file param Module* funcmodule = gIR->func()->decl->getModule(); - // module param - LLValue *moduleInfoSymbol = funcmodule->moduleInfoSymbol(); - LLType *moduleInfoType = DtoType(Module::moduleinfo->type); - args.push_back(DtoBitCast(moduleInfoSymbol, getPtrToType(moduleInfoType))); + args.push_back(DtoModuleFileName(funcmodule, loc)); // line param LLConstant* c = DtoConstUint(loc.linnum); args.push_back(c); // call - llvm::Function* errorfn = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_d_array_bounds"); + llvm::Function* errorfn = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_d_arraybounds"); gIR->CreateCallOrInvoke(errorfn, args); // the function does not return diff --git a/gen/llvmhelpers.cpp b/gen/llvmhelpers.cpp index a9ace1b2dc..57610cffc7 100644 --- a/gen/llvmhelpers.cpp +++ b/gen/llvmhelpers.cpp @@ -188,18 +188,7 @@ void DtoAssert(Module* M, Loc& loc, DValue* msg) } // file param - - // we might be generating for an imported template function - const char* cur_file = M->srcfile->name->toChars(); - if (loc.filename && strcmp(loc.filename, cur_file) != 0) - { - args.push_back(DtoConstString(loc.filename)); - } - else - { - IrModule* irmod = getIrModule(M); - args.push_back(DtoLoad(irmod->fileName)); - } + args.push_back(DtoModuleFileName(M, loc)); // line param args.push_back(DtoConstUint(loc.linnum)); @@ -214,6 +203,25 @@ void DtoAssert(Module* M, Loc& loc, DValue* msg) gIR->ir->CreateUnreachable(); } +/****************************************************************************************/ +/*//////////////////////////////////////////////////////////////////////////////////////// +// Module file name +////////////////////////////////////////////////////////////////////////////////////////*/ + +LLValue *DtoModuleFileName(Module* M, const Loc& loc) +{ + // we might be generating for an imported template function + const char* cur_file = M->srcfile->name->toChars(); + if (loc.filename && strcmp(loc.filename, cur_file) != 0) + { + return DtoConstString(loc.filename); + } + else + { + IrModule* irmod = getIrModule(M); + return DtoLoad(irmod->fileName); + } +} /****************************************************************************************/ /*//////////////////////////////////////////////////////////////////////////////////////// diff --git a/gen/llvmhelpers.h b/gen/llvmhelpers.h index a8d3cfeea9..70f1ec0646 100644 --- a/gen/llvmhelpers.h +++ b/gen/llvmhelpers.h @@ -59,6 +59,9 @@ LLValue* DtoGcMalloc(Loc& loc, LLType* lltype, const char* name = ""); // assertion generator void DtoAssert(Module* M, Loc& loc, DValue* msg); +// returns module file name +LLValue* DtoModuleFileName(Module* M, const Loc& loc); + // return the LabelStatement from the current function with the given identifier or NULL if not found LabelStatement* DtoLabelStatement(Identifier* ident); diff --git a/gen/runtime.cpp b/gen/runtime.cpp index 97a2364d6d..825b521dfe 100644 --- a/gen/runtime.cpp +++ b/gen/runtime.cpp @@ -357,25 +357,25 @@ static void LLVM_D_BuildRuntimeModule() ///////////////////////////////////////////////////////////////////////////////////// // void _d_assert( char[] file, uint line ) + // void _d_arraybounds(ModuleInfo* m, uint line) { llvm::StringRef fname("_d_assert"); + llvm::StringRef fname2("_d_arraybounds"); LLType *types[] = { stringTy, intTy }; LLFunctionType* fty = llvm::FunctionType::get(voidTy, types, false); llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); + llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); } - // void _d_array_bounds(ModuleInfo* m, uint line) // void _d_switch_error(ModuleInfo* m, uint line) { - llvm::StringRef fname("_d_array_bounds"); - llvm::StringRef fname2("_d_switch_error"); + llvm::StringRef fname("_d_switch_error"); LLType *types[] = { moduleInfoPtrTy, intTy }; LLFunctionType* fty = llvm::FunctionType::get(voidTy, types, false); llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); - llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); } // void _d_assert_msg(string msg, string file, uint line)