mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-05 01:20:51 +03:00
Possible fix for issue #938.
The functions for all arrayops are compiler-generated but the functions which are also defined in druntime are never emitted. This prevents inlining of the function body and causes issue #938. The fix is to emit the arrayops if inlining is enabled and otherwise use the druntime provided implementations. An alternative approach could be to always emit the arrayops and never use the druntime version.
This commit is contained in:
parent
f104af4462
commit
f1c4cf92ff
2 changed files with 4 additions and 3 deletions
|
@ -13,6 +13,7 @@
|
||||||
#include "gen/llvmhelpers.h"
|
#include "gen/llvmhelpers.h"
|
||||||
#include "gen/logger.h"
|
#include "gen/logger.h"
|
||||||
#include "gen/tollvm.h"
|
#include "gen/tollvm.h"
|
||||||
|
#include "gen/optimizer.h"
|
||||||
#include "ir/irtypeaggr.h"
|
#include "ir/irtypeaggr.h"
|
||||||
#include "llvm/ADT/SmallString.h"
|
#include "llvm/ADT/SmallString.h"
|
||||||
#include "llvm/Support/FileSystem.h"
|
#include "llvm/Support/FileSystem.h"
|
||||||
|
@ -42,7 +43,7 @@ Module *ldc::DIBuilder::getDefinedModule(Dsymbol *s)
|
||||||
// array operations as well
|
// array operations as well
|
||||||
else if (FuncDeclaration* fd = s->isFuncDeclaration())
|
else if (FuncDeclaration* fd = s->isFuncDeclaration())
|
||||||
{
|
{
|
||||||
if (fd->isArrayOp && !isDruntimeArrayOp(fd))
|
if (fd->isArrayOp && (willInline() || !isDruntimeArrayOp(fd)))
|
||||||
return IR->dmodule;
|
return IR->dmodule;
|
||||||
}
|
}
|
||||||
// otherwise use the symbol's module
|
// otherwise use the symbol's module
|
||||||
|
|
|
@ -733,7 +733,7 @@ static llvm::GlobalValue::LinkageTypes lowerFuncLinkage(FuncDeclaration* fdecl)
|
||||||
|
|
||||||
// Generated array op functions behave like templates in that they might be
|
// Generated array op functions behave like templates in that they might be
|
||||||
// emitted into many different modules.
|
// emitted into many different modules.
|
||||||
if (fdecl->isArrayOp && !isDruntimeArrayOp(fdecl))
|
if (fdecl->isArrayOp && (willInline() || !isDruntimeArrayOp(fdecl)))
|
||||||
return templateLinkage;
|
return templateLinkage;
|
||||||
|
|
||||||
// A body-less declaration always needs to be marked as external in LLVM
|
// A body-less declaration always needs to be marked as external in LLVM
|
||||||
|
@ -782,7 +782,7 @@ void DtoDefineFunction(FuncDeclaration* fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip array ops implemented in druntime
|
// Skip array ops implemented in druntime
|
||||||
if (fd->isArrayOp && isDruntimeArrayOp(fd))
|
if (fd->isArrayOp && !willInline() && isDruntimeArrayOp(fd))
|
||||||
{
|
{
|
||||||
IF_LOG Logger::println("No code generation for array op %s implemented in druntime", fd->toChars());
|
IF_LOG Logger::println("No code generation for array op %s implemented in druntime", fd->toChars());
|
||||||
fd->ir.setDefined();
|
fd->ir.setDefined();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue