comparison gen/tollvm.cpp @ 209:c4c9b4ac021b trunk

[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
author lindquist
date Wed, 14 May 2008 01:22:40 +0200
parents e0b6040585b4
children 1d6cfdbc97f0
comparison
equal deleted inserted replaced
208:086e1aa99557 209:c4c9b4ac021b
701 llvm::Value* mem = gIR->ir->CreateCall(fn, arg.begin(), arg.end(), ".gc_mem"); 701 llvm::Value* mem = gIR->ir->CreateCall(fn, arg.begin(), arg.end(), ".gc_mem");
702 // cast 702 // cast
703 return DtoBitCast(mem, getPtrToType(DtoType(newtype)), ".gc_mem"); 703 return DtoBitCast(mem, getPtrToType(DtoType(newtype)), ".gc_mem");
704 } 704 }
705 705
706 void DtoDeleteMemory(llvm::Value* ptr)
707 {
708 // get runtime function
709 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_delmemory");
710 // build args
711 llvm::SmallVector<llvm::Value*,1> arg;
712 arg.push_back(DtoBitCast(ptr, getVoidPtrType(), ".tmp"));
713 // call
714 llvm::CallInst::Create(fn, arg.begin(), arg.end(), "", gIR->scopebb());
715 }
716
717 void DtoDeleteClass(llvm::Value* inst)
718 {
719 // get runtime function
720 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_delclass");
721 // build args
722 llvm::SmallVector<llvm::Value*,1> arg;
723 arg.push_back(DtoBitCast(inst, fn->getFunctionType()->getParamType(0), ".tmp"));
724 // call
725 llvm::CallInst::Create(fn, arg.begin(), arg.end(), "", gIR->scopebb());
726 }
727
728 void DtoDeleteArray(DValue* arr)
729 {
730 // get runtime function
731 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_delarray");
732 // build args
733 llvm::SmallVector<llvm::Value*,2> arg;
734 arg.push_back(DtoArrayLen(arr));
735 arg.push_back(DtoBitCast(DtoArrayPtr(arr), getVoidPtrType(), ".tmp"));
736 // call
737 llvm::CallInst::Create(fn, arg.begin(), arg.end(), "", gIR->scopebb());
738 }
739
706 ////////////////////////////////////////////////////////////////////////////////////////// 740 //////////////////////////////////////////////////////////////////////////////////////////
707 741
708 void DtoAssert(Loc* loc, DValue* msg) 742 void DtoAssert(Loc* loc, DValue* msg)
709 { 743 {
710 std::vector<llvm::Value*> args; 744 std::vector<llvm::Value*> args;