# HG changeset patch # User lindquist # Date 1210707639 -7200 # Node ID e0b6040585b4e560ccd3b0719b8273d23b36328a # Parent cd2c9f4010e486cdc50410432948fa066973386e [svn r223] Fixed: assert with message could be broken. Fixed: array length exp could fail on slice. diff -r cd2c9f4010e4 -r e0b6040585b4 gen/toir.cpp --- a/gen/toir.cpp Tue May 13 18:07:03 2008 +0200 +++ b/gen/toir.cpp Tue May 13 21:40:39 2008 +0200 @@ -2121,10 +2121,7 @@ } else { - llvm::Value* zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false); - llvm::Value* ptr = DtoGEP(u->getRVal(),zero,zero,"tmp",p->scopebb()); - ptr = new llvm::LoadInst(ptr, "tmp", p->scopebb()); - return new DImValue(type, ptr); + return new DImValue(type, DtoArrayLen(u)); } } diff -r cd2c9f4010e4 -r e0b6040585b4 gen/tollvm.cpp --- a/gen/tollvm.cpp Tue May 13 18:07:03 2008 +0200 +++ b/gen/tollvm.cpp Tue May 13 21:40:39 2008 +0200 @@ -712,16 +712,35 @@ // func const char* fname = msg ? "_d_assert_msg" : "_d_assert"; + llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, fname); + + c = DtoConstString(loc->filename); // msg param - if (msg) args.push_back(msg->getRVal()); + if (msg) + { + if (DSliceValue* s = msg->isSlice()) + { + llvm::AllocaInst* alloc = gIR->func()->msgArg; + if (!alloc) + { + alloc = new llvm::AllocaInst(c->getType(), ".assertmsg", gIR->topallocapoint()); + DtoSetArray(alloc, DtoArrayLen(s), DtoArrayPtr(s)); + gIR->func()->msgArg = alloc; + } + args.push_back(alloc); + } + else + { + args.push_back(msg->getRVal()); + } + } // file param - c = DtoConstString(loc->filename); llvm::AllocaInst* alloc = gIR->func()->srcfileArg; if (!alloc) { - alloc = new llvm::AllocaInst(c->getType(), "srcfile", gIR->topallocapoint()); + alloc = new llvm::AllocaInst(c->getType(), ".srcfile", gIR->topallocapoint()); gIR->func()->srcfileArg = alloc; } llvm::Value* ptr = DtoGEPi(alloc, 0,0, "tmp"); @@ -735,7 +754,6 @@ args.push_back(c); // call - llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, fname); llvm::CallInst* call = llvm::CallInst::Create(fn, args.begin(), args.end(), "", gIR->scopebb()); } diff -r cd2c9f4010e4 -r e0b6040585b4 ir/irfunction.cpp --- a/ir/irfunction.cpp Tue May 13 18:07:03 2008 +0200 +++ b/ir/irfunction.cpp Tue May 13 21:40:39 2008 +0200 @@ -26,6 +26,7 @@ dwarfSubProg = NULL; srcfileArg = NULL; + msgArg = NULL; inVolatile = false; } diff -r cd2c9f4010e4 -r e0b6040585b4 ir/irfunction.h --- a/ir/irfunction.h Tue May 13 18:07:03 2008 +0200 +++ b/ir/irfunction.h Tue May 13 21:40:39 2008 +0200 @@ -23,6 +23,7 @@ llvm::Constant* dwarfSubProg; llvm::AllocaInst* srcfileArg; + llvm::AllocaInst* msgArg; bool inVolatile;