mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-07 03:16:05 +03:00
Add new intrinsic LDC_never_inline.
LDC_never_inline is a complementary intrinsic to LDC_allow_inline. It tells the LLVM optimizer to never inline a function. This can be useful if inlining creates incorrect code. A possible application is core.thread.getStackTop().
This commit is contained in:
parent
8a4a2ea38e
commit
0b19b81ac9
5 changed files with 14 additions and 0 deletions
|
@ -930,6 +930,9 @@ struct FuncDeclaration : Declaration
|
||||||
// true if overridden with the pragma(allow_inline); stmt
|
// true if overridden with the pragma(allow_inline); stmt
|
||||||
bool allowInlining;
|
bool allowInlining;
|
||||||
|
|
||||||
|
// true if set with pragma(LDC_no_inline)
|
||||||
|
bool neverInline;
|
||||||
|
|
||||||
// true if has inline assembler
|
// true if has inline assembler
|
||||||
bool inlineAsm;
|
bool inlineAsm;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -103,6 +103,7 @@ FuncDeclaration::FuncDeclaration(Loc loc, Loc endloc, Identifier *id, StorageCla
|
||||||
// LDC
|
// LDC
|
||||||
isArrayOp = false;
|
isArrayOp = false;
|
||||||
allowInlining = false;
|
allowInlining = false;
|
||||||
|
neverInline = false;
|
||||||
availableExternally = true; // assume this unless proven otherwise
|
availableExternally = true; // assume this unless proven otherwise
|
||||||
|
|
||||||
// function types in ldc don't merge if the context parameter differs
|
// function types in ldc don't merge if the context parameter differs
|
||||||
|
|
|
@ -278,6 +278,7 @@ Msgtable msgtable[] =
|
||||||
{ "LDC_va_arg" },
|
{ "LDC_va_arg" },
|
||||||
{ "LDC_verbose" },
|
{ "LDC_verbose" },
|
||||||
{ "LDC_allow_inline" },
|
{ "LDC_allow_inline" },
|
||||||
|
{ "LDC_never_inline" },
|
||||||
{ "LDC_inline_asm" },
|
{ "LDC_inline_asm" },
|
||||||
{ "LDC_inline_ir" },
|
{ "LDC_inline_ir" },
|
||||||
{ "LDC_fence" },
|
{ "LDC_fence" },
|
||||||
|
|
|
@ -3175,6 +3175,10 @@ Statement *PragmaStatement::semantic(Scope *sc)
|
||||||
{
|
{
|
||||||
sc->func->allowInlining = true;
|
sc->func->allowInlining = true;
|
||||||
}
|
}
|
||||||
|
else if (ident == Id::LDC_never_inline)
|
||||||
|
{
|
||||||
|
sc->func->neverInline = true;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
else if (ident == Id::startaddress)
|
else if (ident == Id::startaddress)
|
||||||
|
|
|
@ -815,6 +815,11 @@ void DtoDeclareFunction(FuncDeclaration* fdecl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fdecl->neverInline)
|
||||||
|
{
|
||||||
|
fdecl->ir.irFunc->setNeverInline();
|
||||||
|
}
|
||||||
|
|
||||||
if (fdecl->llvmInternal == LLVMglobal_crt_ctor || fdecl->llvmInternal == LLVMglobal_crt_dtor)
|
if (fdecl->llvmInternal == LLVMglobal_crt_ctor || fdecl->llvmInternal == LLVMglobal_crt_dtor)
|
||||||
{
|
{
|
||||||
AppendFunctionToLLVMGlobalCtorsDtors(func, fdecl->priority, fdecl->llvmInternal == LLVMglobal_crt_ctor);
|
AppendFunctionToLLVMGlobalCtorsDtors(func, fdecl->priority, fdecl->llvmInternal == LLVMglobal_crt_ctor);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue