From 2fe681729428771a18ccd296d7b7c9d4633327a6 Mon Sep 17 00:00:00 2001 From: Alexey Prokhin Date: Sun, 31 Oct 2010 12:23:35 +0300 Subject: [PATCH] Fixed a druntime crash in _d_delclass --- gen/llvmhelpers.cpp | 6 ++++++ gen/runtime.cpp | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gen/llvmhelpers.cpp b/gen/llvmhelpers.cpp index 84587cc0..0ac4e9c1 100644 --- a/gen/llvmhelpers.cpp +++ b/gen/llvmhelpers.cpp @@ -60,6 +60,12 @@ void DtoDeleteClass(LLValue* inst) llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_delclass"); // build args LLSmallVector arg; +#if DMDV2 + // druntime wants a pointer to object + LLValue *ptr = DtoRawAlloca(inst->getType(), 0, "objectPtr"); + DtoStore(inst, ptr); + inst = ptr; +#endif arg.push_back(DtoBitCast(inst, fn->getFunctionType()->getParamType(0), ".tmp")); // call gIR->CreateCallOrInvoke(fn, arg.begin(), arg.end()); diff --git a/gen/runtime.cpp b/gen/runtime.cpp index 6edb4d5a..30d90899 100644 --- a/gen/runtime.cpp +++ b/gen/runtime.cpp @@ -456,11 +456,16 @@ static void LLVM_D_BuildRuntimeModule() llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname3, M); } - // void _d_delclass(Object p) + // D1: void _d_delclass(Object p) + // D2: void _d_delclass(Object* p) { llvm::StringRef fname("_d_delclass"); std::vector types; +#if DMDV2 + types.push_back(rt_ptr(objectTy)); +#else types.push_back(objectTy); +#endif const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); }