Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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,9 +1299,9 @@ 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 or NoOptimization (people often use no-inline
// to mean "I want to always see this method in stacktrace")
if (caller.IsNoInlining)
if (caller.IsNoInlining || caller.IsNoOptimization)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to check for NoOptimization here? I would expect that the JIT disables tailcall optimizations when the method is marked NoOptimization.

Copy link
Member Author

@EgorBo EgorBo Jan 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkotas um.. jit is not aware that a call has NoOptimization on it so it does emit tail calls for it, example

ah, ignore me. it's about calls inside the NoOptimization method. So yes, you're right - it's redundant here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -831,9 +831,9 @@ private bool canTailCall(CORINFO_METHOD_STRUCT_* callerHnd, CORINFO_METHOD_STRUC
result = false;
}

if (caller.IsNoInlining)
if (caller.IsNoInlining || caller.IsNoOptimization)
{
// 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 or NoOptimization (people often use no-inline
// to mean "I want to always see this method in stacktrace")
result = false;
}
Expand Down
15 changes: 11 additions & 4 deletions src/coreclr/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8200,15 +8200,22 @@ 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 or NoOptimization (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;
}

if (IsMiNoOptimization(dwImplFlags))
{
result = false;
szFailReason = "Caller is marked as NoOptimization";
goto exit;
}
}
Expand Down Expand Up @@ -12613,8 +12620,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