mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-07 03:16:05 +03:00
Call d_delarray_t() instead of _d_delarray()
This commit is contained in:
parent
48d89916ef
commit
44593f6220
2 changed files with 41 additions and 13 deletions
|
@ -82,6 +82,24 @@ void DtoDeleteInterface(LLValue* inst)
|
|||
gIR->CreateCallOrInvoke(fn, arg.begin(), arg.end());
|
||||
}
|
||||
|
||||
#if DMDV2
|
||||
|
||||
void DtoDeleteArray(DValue* arr)
|
||||
{
|
||||
// get runtime function
|
||||
llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_delarray_t");
|
||||
|
||||
// build args
|
||||
LLSmallVector<LLValue*,2> arg;
|
||||
arg.push_back(DtoBitCast(arr->getLVal(), fn->getFunctionType()->getParamType(0)));
|
||||
arg.push_back(DtoBitCast(DtoTypeInfoOf(arr->type->nextOf()), fn->getFunctionType()->getParamType(1)));
|
||||
|
||||
// call
|
||||
gIR->CreateCallOrInvoke(fn, arg.begin(), arg.end());
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void DtoDeleteArray(DValue* arr)
|
||||
{
|
||||
// get runtime function
|
||||
|
@ -89,16 +107,15 @@ void DtoDeleteArray(DValue* arr)
|
|||
|
||||
// build args
|
||||
LLSmallVector<LLValue*,2> arg;
|
||||
#if DMDV2
|
||||
arg.push_back(DtoBitCast(arr->getLVal(), fn->getFunctionType()->getParamType(0)));
|
||||
#else
|
||||
arg.push_back(DtoArrayLen(arr));
|
||||
arg.push_back(DtoBitCast(DtoArrayPtr(arr), getVoidPtrType(), ".tmp"));
|
||||
#endif
|
||||
|
||||
// call
|
||||
gIR->CreateCallOrInvoke(fn, arg.begin(), arg.end());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************************************/
|
||||
/*////////////////////////////////////////////////////////////////////////////////////////
|
||||
// ALLOCA HELPERS
|
||||
|
|
|
@ -442,21 +442,32 @@ static void LLVM_D_BuildRuntimeModule()
|
|||
->setAttributes(Attr_NoAlias);
|
||||
}
|
||||
|
||||
// D1: void _d_delarray(size_t plength, void* pdata)
|
||||
// D2: void _d_delarray(void[]* array)
|
||||
{
|
||||
llvm::StringRef fname("_d_delarray");
|
||||
std::vector<const LLType*> types;
|
||||
#if DMDV2
|
||||
|
||||
// void _d_delarray_t(Array *p, TypeInfo ti)
|
||||
{
|
||||
llvm::StringRef fname("_d_delarray_t");
|
||||
std::vector<const LLType*> types;
|
||||
types.push_back(voidArrayPtrTy);
|
||||
#else
|
||||
types.push_back(sizeTy);
|
||||
types.push_back(voidPtrTy);
|
||||
#endif
|
||||
types.push_back(typeInfoTy);
|
||||
const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false);
|
||||
llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// void _d_delarray(size_t plength, void* pdata)
|
||||
{
|
||||
llvm::StringRef fname("_d_delarray");
|
||||
std::vector<const LLType*> types;
|
||||
types.push_back(sizeTy);
|
||||
types.push_back(voidPtrTy);
|
||||
const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false);
|
||||
llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// D1:
|
||||
// void _d_delmemory(void* p)
|
||||
// void _d_delinterface(void* p)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue