Mercurial > projects > ldc
comparison gen/tollvm.cpp @ 207:e0b6040585b4 trunk
[svn r223] Fixed: assert with message could be broken.
Fixed: array length exp could fail on slice.
author | lindquist |
---|---|
date | Tue, 13 May 2008 21:40:39 +0200 |
parents | 9d44ec83acd1 |
children | c4c9b4ac021b |
comparison
equal
deleted
inserted
replaced
206:cd2c9f4010e4 | 207:e0b6040585b4 |
---|---|
710 std::vector<llvm::Value*> args; | 710 std::vector<llvm::Value*> args; |
711 llvm::Constant* c; | 711 llvm::Constant* c; |
712 | 712 |
713 // func | 713 // func |
714 const char* fname = msg ? "_d_assert_msg" : "_d_assert"; | 714 const char* fname = msg ? "_d_assert_msg" : "_d_assert"; |
715 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, fname); | |
716 | |
717 c = DtoConstString(loc->filename); | |
715 | 718 |
716 // msg param | 719 // msg param |
717 if (msg) args.push_back(msg->getRVal()); | 720 if (msg) |
721 { | |
722 if (DSliceValue* s = msg->isSlice()) | |
723 { | |
724 llvm::AllocaInst* alloc = gIR->func()->msgArg; | |
725 if (!alloc) | |
726 { | |
727 alloc = new llvm::AllocaInst(c->getType(), ".assertmsg", gIR->topallocapoint()); | |
728 DtoSetArray(alloc, DtoArrayLen(s), DtoArrayPtr(s)); | |
729 gIR->func()->msgArg = alloc; | |
730 } | |
731 args.push_back(alloc); | |
732 } | |
733 else | |
734 { | |
735 args.push_back(msg->getRVal()); | |
736 } | |
737 } | |
718 | 738 |
719 // file param | 739 // file param |
720 c = DtoConstString(loc->filename); | |
721 llvm::AllocaInst* alloc = gIR->func()->srcfileArg; | 740 llvm::AllocaInst* alloc = gIR->func()->srcfileArg; |
722 if (!alloc) | 741 if (!alloc) |
723 { | 742 { |
724 alloc = new llvm::AllocaInst(c->getType(), "srcfile", gIR->topallocapoint()); | 743 alloc = new llvm::AllocaInst(c->getType(), ".srcfile", gIR->topallocapoint()); |
725 gIR->func()->srcfileArg = alloc; | 744 gIR->func()->srcfileArg = alloc; |
726 } | 745 } |
727 llvm::Value* ptr = DtoGEPi(alloc, 0,0, "tmp"); | 746 llvm::Value* ptr = DtoGEPi(alloc, 0,0, "tmp"); |
728 DtoStore(c->getOperand(0), ptr); | 747 DtoStore(c->getOperand(0), ptr); |
729 ptr = DtoGEPi(alloc, 0,1, "tmp"); | 748 ptr = DtoGEPi(alloc, 0,1, "tmp"); |
733 // line param | 752 // line param |
734 c = DtoConstUint(loc->linnum); | 753 c = DtoConstUint(loc->linnum); |
735 args.push_back(c); | 754 args.push_back(c); |
736 | 755 |
737 // call | 756 // call |
738 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, fname); | |
739 llvm::CallInst* call = llvm::CallInst::Create(fn, args.begin(), args.end(), "", gIR->scopebb()); | 757 llvm::CallInst* call = llvm::CallInst::Create(fn, args.begin(), args.end(), "", gIR->scopebb()); |
740 } | 758 } |
741 | 759 |
742 ////////////////////////////////////////////////////////////////////////////////////////// | 760 ////////////////////////////////////////////////////////////////////////////////////////// |
743 | 761 |