mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-10-15 13:27:00 +02: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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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" },
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user