From 3d8e2e5e5c99ba61986122e57af49db8d14ac775 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Thu, 24 Oct 2013 00:24:55 +0200 Subject: [PATCH 1/3] Add virtual destructor to GarbageCollect2Stack to silence GCC warning. --- gen/passes/GarbageCollect2Stack.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/gen/passes/GarbageCollect2Stack.cpp b/gen/passes/GarbageCollect2Stack.cpp index 7b70d67831..21cb96fca0 100644 --- a/gen/passes/GarbageCollect2Stack.cpp +++ b/gen/passes/GarbageCollect2Stack.cpp @@ -146,6 +146,7 @@ namespace { : TypeInfoArgNr(typeInfoArgNr), SafeToDelete(safeToDelete), ReturnsArray(returnsArray) {} + virtual ~FunctionInfo() {} }; class ArrayFI : public FunctionInfo { From 1f597405241cebc134d17580ee5472b06ee2a0bd Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Thu, 24 Oct 2013 00:25:36 +0200 Subject: [PATCH 2/3] _d_allocclass -> "_d_newclass". The define is a leftover from the times when we supported both D1 and D2. --- gen/classes.cpp | 2 +- gen/passes/GarbageCollect2Stack.cpp | 4 ++-- gen/passes/SimplifyDRuntimeCalls.cpp | 2 +- gen/runtime.cpp | 4 ++-- gen/runtime.h | 1 - 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/gen/classes.cpp b/gen/classes.cpp index 2e8e13b678..7587409963 100644 --- a/gen/classes.cpp +++ b/gen/classes.cpp @@ -106,7 +106,7 @@ DValue* DtoNewClass(Loc loc, TypeClass* tc, NewExp* newexp) // default allocator else { - llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, _d_allocclass); + llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_newclass"); LLConstant* ci = DtoBitCast(tc->sym->ir.irAggr->getClassInfoSymbol(), DtoType(ClassDeclaration::classinfo->type)); mem = gIR->CreateCallOrInvoke(fn, ci, ".newclass_gc_alloc").getInstruction(); mem = DtoBitCast(mem, DtoType(tc), ".newclass_gc"); diff --git a/gen/passes/GarbageCollect2Stack.cpp b/gen/passes/GarbageCollect2Stack.cpp index 21cb96fca0..6d5cb97f7d 100644 --- a/gen/passes/GarbageCollect2Stack.cpp +++ b/gen/passes/GarbageCollect2Stack.cpp @@ -252,7 +252,7 @@ namespace { } }; - // FunctionInfo for _d_allocclass + // FunctionInfo for _d_newclass class AllocClassFI : public FunctionInfo { public: virtual bool analyze(CallSite CS, const Analysis& A) { @@ -360,7 +360,7 @@ GarbageCollect2Stack::GarbageCollect2Stack() KnownFunctions["_d_allocmemoryT"] = &AllocMemoryT; KnownFunctions["_d_newarrayvT"] = &NewArrayVT; KnownFunctions["_d_newarrayT"] = &NewArrayT; - KnownFunctions[_d_allocclass] = &AllocClass; + KnownFunctions["_d_newclass"] = &AllocClass; } static void RemoveCall(CallSite CS, const Analysis& A) { diff --git a/gen/passes/SimplifyDRuntimeCalls.cpp b/gen/passes/SimplifyDRuntimeCalls.cpp index 6747c37752..fe0b735092 100644 --- a/gen/passes/SimplifyDRuntimeCalls.cpp +++ b/gen/passes/SimplifyDRuntimeCalls.cpp @@ -363,7 +363,7 @@ void SimplifyDRuntimeCalls::InitOptimizations() { Optimizations["_d_newarraymT"] = &Allocation; Optimizations["_d_newarraymiT"] = &Allocation; Optimizations["_d_newarraymvT"] = &Allocation; - Optimizations[_d_allocclass] = &Allocation; + Optimizations["_d_newclass"] = &Allocation; } diff --git a/gen/runtime.cpp b/gen/runtime.cpp index e1e65be8fc..55c74787ad 100644 --- a/gen/runtime.cpp +++ b/gen/runtime.cpp @@ -426,9 +426,9 @@ static void LLVM_D_BuildRuntimeModule() llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); } - // Object _d_allocclass(ClassInfo ci) + // Object _d_newclass(const ClassInfo ci) { - llvm::StringRef fname(_d_allocclass); + llvm::StringRef fname("_d_newclass"); LLType *types[] = { classInfoTy }; LLFunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) diff --git a/gen/runtime.h b/gen/runtime.h index f64e3ae460..cd052f8d35 100644 --- a/gen/runtime.h +++ b/gen/runtime.h @@ -30,7 +30,6 @@ llvm::Function* LLVM_D_GetRuntimeFunction(llvm::Module* target, const char* name llvm::GlobalVariable* LLVM_D_GetRuntimeGlobal(llvm::Module* target, const char* name); -#define _d_allocclass "_d_newclass" #define _adEq "_adEq2" #define _adCmp "_adCmp2" From b052b3044237c9bb5095d2f34cf17b718b58df9b Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Thu, 24 Oct 2013 00:27:09 +0200 Subject: [PATCH 3/3] Correct signature of _d_newclass runtime call. Fixes programs trying to directly access it (e.g. the GtkD bindings). Not sure why this didn't come up earlier. --- gen/runtime.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gen/runtime.cpp b/gen/runtime.cpp index 55c74787ad..60b748f181 100644 --- a/gen/runtime.cpp +++ b/gen/runtime.cpp @@ -430,7 +430,7 @@ static void LLVM_D_BuildRuntimeModule() { llvm::StringRef fname("_d_newclass"); LLType *types[] = { classInfoTy }; - LLFunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); + LLFunctionType* fty = llvm::FunctionType::get(objectTy, types, false); llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) ->setAttributes(Attr_NoAlias); }