From 7d2a0a84a741ff3308dee6f43aa1c17ee64bde67 Mon Sep 17 00:00:00 2001 From: Tomas Lindquist Olsen Date: Wed, 4 Feb 2009 02:10:23 +0100 Subject: [PATCH] Removed some dead code. Fixed assertion filenames for imported template instances. Fixes #152 . --- gen/llvmhelpers.cpp | 9 +++++++-- gen/llvmhelpers.h | 2 +- gen/toir.cpp | 4 ++-- gen/toobj.cpp | 5 +++-- ir/irfunction.cpp | 3 --- ir/irfunction.h | 3 --- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/gen/llvmhelpers.cpp b/gen/llvmhelpers.cpp index c4b954da..18dd481b 100644 --- a/gen/llvmhelpers.cpp +++ b/gen/llvmhelpers.cpp @@ -109,7 +109,7 @@ llvm::AllocaInst* DtoAlloca(const LLType* lltype, LLValue* arraysize, const std: // ASSERT HELPER ////////////////////////////////////////////////////////////////////////////////////////*/ -void DtoAssert(Loc* loc, DValue* msg) +void DtoAssert(Module* M, Loc* loc, DValue* msg) { std::vector args; @@ -124,7 +124,12 @@ void DtoAssert(Loc* loc, DValue* msg) } // file param - args.push_back(DtoLoad(gIR->dmodule->ir.irModule->fileName)); + + // we might be generating for an imported template function + if (!M->ir.irModule) + M->ir.irModule = new IrModule(M, M->srcfile->toChars()); + + args.push_back(DtoLoad(M->ir.irModule->fileName)); // line param LLConstant* c = DtoConstUint(loc->linnum); diff --git a/gen/llvmhelpers.h b/gen/llvmhelpers.h index cd959c6e..5363d96f 100644 --- a/gen/llvmhelpers.h +++ b/gen/llvmhelpers.h @@ -16,7 +16,7 @@ llvm::AllocaInst* DtoAlloca(const LLType* lltype, const std::string& name = ""); llvm::AllocaInst* DtoAlloca(const LLType* lltype, LLValue* arraysize, const std::string& name = ""); // assertion generator -void DtoAssert(Loc* loc, DValue* msg); +void DtoAssert(Module* M, Loc* loc, DValue* msg); // return the LabelStatement from the current function with the given identifier or NULL if not found LabelStatement* DtoLabelStatement(Identifier* ident); diff --git a/gen/toir.cpp b/gen/toir.cpp index 7cffd4cc..6ee7d329 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -1768,7 +1768,7 @@ DValue* AssertExp::toElem(IRState* p) // call assert runtime functions p->scope() = IRScope(assertbb,endbb); - DtoAssert(&loc, msg ? msg->toElem(p) : NULL); + DtoAssert(p->func()->decl->getModule(), &loc, msg ? msg->toElem(p) : NULL); // rewrite the scope p->scope() = IRScope(endbb,oldend); @@ -1943,7 +1943,7 @@ DValue* HaltExp::toElem(IRState* p) // FIXME: DMD inserts a trap here... we probably should as well !?! #if 1 - DtoAssert(&loc, NULL); + DtoAssert(p->func()->decl->getModule(), &loc, NULL); #else // call the new (?) trap intrinsic p->ir->CreateCall(GET_INTRINSIC_DECL(trap),""); diff --git a/gen/toobj.cpp b/gen/toobj.cpp index cf9c12f6..c6bedfb0 100644 --- a/gen/toobj.cpp +++ b/gen/toobj.cpp @@ -99,8 +99,9 @@ void Module::genobjfile(int multiobj) ir.module = new llvm::Module(mname); // module ir state - // might already exist via import, just overwrite... - //FIXME: is there a good reason for overwriting? + // might already exist via import, just overwrite since + // the global created for the filename must belong to the right llvm module + // FIXME: but shouldn't this always get reset between modules? like other IrSymbols this->ir.irModule = new IrModule(this, srcfile->toChars()); // set target stuff diff --git a/ir/irfunction.cpp b/ir/irfunction.cpp index 37258854..8c139ada 100644 --- a/ir/irfunction.cpp +++ b/ir/irfunction.cpp @@ -33,9 +33,6 @@ IrFunction::IrFunction(FuncDeclaration* fd) dwarfSubProg = NULL; - srcfileArg = NULL; - msgArg = NULL; - nextUnique.push(0); } diff --git a/ir/irfunction.h b/ir/irfunction.h index e611a84d..bd1a4296 100644 --- a/ir/irfunction.h +++ b/ir/irfunction.h @@ -30,9 +30,6 @@ struct IrFunction : IrBase llvm::Constant* dwarfSubProg; - llvm::AllocaInst* srcfileArg; - llvm::AllocaInst* msgArg; - // pushes a unique label scope of the given name void pushUniqueLabelScope(const char* name); // pops a label scope