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:
kai 2013-03-11 22:01:34 +01:00
parent 8a4a2ea38e
commit 0b19b81ac9
5 changed files with 14 additions and 0 deletions

View file

@ -930,6 +930,9 @@ struct FuncDeclaration : Declaration
// true if overridden with the pragma(allow_inline); stmt
bool allowInlining;
// true if set with pragma(LDC_no_inline)
bool neverInline;
// true if has inline assembler
bool inlineAsm;
#endif

View file

@ -103,6 +103,7 @@ FuncDeclaration::FuncDeclaration(Loc loc, Loc endloc, Identifier *id, StorageCla
// LDC
isArrayOp = false;
allowInlining = false;
neverInline = false;
availableExternally = true; // assume this unless proven otherwise
// function types in ldc don't merge if the context parameter differs

View file

@ -278,6 +278,7 @@ Msgtable msgtable[] =
{ "LDC_va_arg" },
{ "LDC_verbose" },
{ "LDC_allow_inline" },
{ "LDC_never_inline" },
{ "LDC_inline_asm" },
{ "LDC_inline_ir" },
{ "LDC_fence" },

View file

@ -3175,6 +3175,10 @@ Statement *PragmaStatement::semantic(Scope *sc)
{
sc->func->allowInlining = true;
}
else if (ident == Id::LDC_never_inline)
{
sc->func->neverInline = true;
}
#endif
#if DMDV2
else if (ident == Id::startaddress)

View file

@ -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)
{
AppendFunctionToLLVMGlobalCtorsDtors(func, fdecl->priority, fdecl->llvmInternal == LLVMglobal_crt_ctor);