Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imply NoInlining when only NoOptimization is set #111308

Merged
merged 6 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1117,9 +1117,9 @@ private uint getMethodAttribsInternal(MethodDesc method)
// TODO: Cache inlining hits
// Check for an inlining directive.

if (method.IsNoInlining)
if (method.IsNoInlining || method.IsNoOptimization)
{
/* Function marked as not inlineable */
// NoOptimization implies NoInlining.
result |= CorInfoFlag.CORINFO_FLG_DONT_INLINE;
}
else if (method.IsAggressiveInlining)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@ private bool TryGetMethodConstantValue(MethodDesc method, out int constant, int
if (returnType is < TypeFlags.Boolean or > TypeFlags.UInt32
|| method.IsIntrinsic
|| method.IsNoInlining
|| method.IsNoOptimization
|| _nestedILProvider.GetMethodIL(method) is not MethodIL methodIL)
{
constant = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ public bool CanInline(MethodDesc caller, MethodDesc callee)
return false;
}

if (callee.IsNoInlining)
if (callee.IsNoInlining || callee.IsNoOptimization)
{
// NoOptimization implies NoInlining
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1299,10 +1299,12 @@ private bool canTailCall(CORINFO_METHOD_STRUCT_* callerHnd, CORINFO_METHOD_STRUC
return false;
}

// Do not tailcall from methods that are marked as noinline (people often use no-inline
// Do not tailcall from methods that are marked as NoInlining (people often use no-inline
// to mean "I want to always see this method in stacktrace")
if (caller.IsNoInlining)
{
// NOTE: we don't have to handle NoOptimization here, because JIT is not expected
// to emit fast tail calls if optimizations are disabled.
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -833,8 +833,11 @@ private bool canTailCall(CORINFO_METHOD_STRUCT_* callerHnd, CORINFO_METHOD_STRUC

if (caller.IsNoInlining)
{
// Do not tailcall from methods that are marked as noinline (people often use no-inline
// Do not tailcall from methods that are marked as NoInlining (people often use no-inline
// to mean "I want to always see this method in stacktrace")
//
// NOTE: we don't have to handle NoOptimization here, because JIT is not expected
// to emit fast tail calls if optimizations are disabled.
result = false;
}
}
Expand Down
11 changes: 7 additions & 4 deletions src/coreclr/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8200,17 +8200,20 @@ bool CEEInfo::canTailCall (CORINFO_METHOD_HANDLE hCaller,

if (!pCaller->IsNoMetadata())
{
// Do not tailcall from methods that are marked as noinline (people often use no-inline
// Do not tailcall from methods that are marked as NoInlining (people often use no-inline
// to mean "I want to always see this method in stacktrace")
DWORD dwImplFlags = 0;
IfFailThrow(pCaller->GetMDImport()->GetMethodImplProps(callerToken, NULL, &dwImplFlags));

if (IsMiNoInlining(dwImplFlags))
{
result = false;
szFailReason = "Caller is marked as no inline";
szFailReason = "Caller is marked as NoInlining";
goto exit;
}

// NOTE: we don't have to handle NoOptimization here, because JIT is not expected
// to emit fast tail calls if optimizations are disabled.
}

// Methods with StackCrawlMark depend on finding their caller on the stack.
Expand Down Expand Up @@ -12613,8 +12616,8 @@ CorJitResult invokeCompileMethod(EEJitManager *jitMgr,
flags.Set(CORJIT_FLAGS::CORJIT_FLAG_MIN_OPT);
}

// Always emit frames for methods marked no-inline (see #define ETW_EBP_FRAMED in the JIT)
if (IsMiNoInlining(dwImplFlags))
// Always emit frames for methods marked NoInlining or NoOptimization (see #define ETW_EBP_FRAMED in the JIT)
if (IsMiNoInlining(dwImplFlags) || IsMiNoOptimization(dwImplFlags))
{
flags.Set(CORJIT_FLAGS::CORJIT_FLAG_FRAMED);
}
Expand Down
5 changes: 2 additions & 3 deletions src/coreclr/vm/methodtablebuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5219,9 +5219,8 @@ MethodTableBuilder::InitNewMethodDesc(
}
}

// Turn off inlining for any calls
// that are marked in the metadata as not being inlineable.
if(IsMiNoInlining(pMethod->GetImplAttrs()))
// Turn off inlining for any calls that are marked in the metadata as NoInlining or NoOptimization.
if (IsMiNoInlining(pMethod->GetImplAttrs()) || IsMiNoOptimization(pMethod->GetImplAttrs()))
{
pNewMD->SetNotInline(true);
}
Expand Down
Loading