mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-04-30 15:10:59 +03:00
Return void*
from _d_allocclass so LLVM doesn't do weird things with it...
This allows `-instcombine` followed by `-gvn` to do devirtualization, so add `-gvn` in strategic places in the default pass order.
This commit is contained in:
parent
34fbdb6271
commit
465f15eda0
3 changed files with 10 additions and 6 deletions
|
@ -135,6 +135,7 @@ static void addPassesForOptLevel(PassManager& pm) {
|
||||||
addPass(pm, createFunctionAttrsPass());
|
addPass(pm, createFunctionAttrsPass());
|
||||||
addPass(pm, createTailCallEliminationPass());
|
addPass(pm, createTailCallEliminationPass());
|
||||||
addPass(pm, createCFGSimplificationPass());
|
addPass(pm, createCFGSimplificationPass());
|
||||||
|
addPass(pm, createGVNPass());
|
||||||
}
|
}
|
||||||
|
|
||||||
// -inline
|
// -inline
|
||||||
|
@ -145,10 +146,13 @@ static void addPassesForOptLevel(PassManager& pm) {
|
||||||
// Run some optimizations to clean up after inlining.
|
// Run some optimizations to clean up after inlining.
|
||||||
addPass(pm, createScalarReplAggregatesPass());
|
addPass(pm, createScalarReplAggregatesPass());
|
||||||
addPass(pm, createInstructionCombiningPass());
|
addPass(pm, createInstructionCombiningPass());
|
||||||
|
// -instcombine + gvn == devirtualization :)
|
||||||
|
addPass(pm, createGVNPass());
|
||||||
|
|
||||||
// Inline again, to catch things like foreach delegates
|
// Inline again, to catch things like now nonvirtual
|
||||||
// passed to inlined opApply's where the function wasn't
|
// function calls, foreach delegates passed to inlined
|
||||||
// known during the first inliner pass.
|
// opApply's, etc. where the actual function being called
|
||||||
|
// wasn't known during the first inliner pass.
|
||||||
addPass(pm, createFunctionInliningPass());
|
addPass(pm, createFunctionInliningPass());
|
||||||
|
|
||||||
// Run clean-up again.
|
// Run clean-up again.
|
||||||
|
|
|
@ -329,7 +329,7 @@ static void LLVM_D_BuildRuntimeModule()
|
||||||
std::string fname("_d_allocclass");
|
std::string fname("_d_allocclass");
|
||||||
std::vector<const LLType*> types;
|
std::vector<const LLType*> types;
|
||||||
types.push_back(classInfoTy);
|
types.push_back(classInfoTy);
|
||||||
const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false);
|
const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false);
|
||||||
llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)
|
llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)
|
||||||
->setAttributes(Attr_NoAlias);
|
->setAttributes(Attr_NoAlias);
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ private
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
extern (C) Object _d_allocclass(ClassInfo ci)
|
extern (C) void* _d_allocclass(ClassInfo ci)
|
||||||
{
|
{
|
||||||
void* p;
|
void* p;
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ extern (C) Object _d_allocclass(ClassInfo ci)
|
||||||
//(cast(byte*) p)[0 .. ci.init.length] = ci.init[];
|
//(cast(byte*) p)[0 .. ci.init.length] = ci.init[];
|
||||||
|
|
||||||
debug(PRINTF) printf("initialization done\n");
|
debug(PRINTF) printf("initialization done\n");
|
||||||
return cast(Object) p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue