Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Set DOES_NOT_RETURN flag in fgFindJumpTargets
Browse files Browse the repository at this point in the history
  • Loading branch information
benaadams committed Oct 11, 2016
1 parent 914774c commit 7cb8db3
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/jit/flowgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4269,6 +4269,7 @@ void Compiler::fgFindJumpTargets(const BYTE* codeAddr, IL_OFFSET codeSize, BYTE*
const bool isForceInline = (info.compFlags & CORINFO_FLG_FORCEINLINE) != 0;
const bool makeInlineObservations = (compInlineResult != nullptr);
const bool isInlining = compIsForInlining();
unsigned retBlocks = 0;

if (makeInlineObservations)
{
Expand Down Expand Up @@ -4638,6 +4639,7 @@ void Compiler::fgFindJumpTargets(const BYTE* codeAddr, IL_OFFSET codeSize, BYTE*
break;

case CEE_JMP:
retBlocks++;

#if !defined(_TARGET_X86_) && !defined(_TARGET_ARM_)
if (!isInlining)
Expand Down Expand Up @@ -4730,6 +4732,8 @@ void Compiler::fgFindJumpTargets(const BYTE* codeAddr, IL_OFFSET codeSize, BYTE*
fgObserveInlineConstants(opcode, pushedStack, isInlining);
}
break;
case CEE_RET:
retBlocks++;

default:
break;
Expand Down Expand Up @@ -4772,6 +4776,19 @@ void Compiler::fgFindJumpTargets(const BYTE* codeAddr, IL_OFFSET codeSize, BYTE*

if (isInlining)
{
if (retBlocks == 0)
{
// If there are no return blocks we know it does not return, however if there
// return blocks we don't know it returns as it may be counting unreachable code.
// So only make the CALLEE_DOES_NOT_RETURN observations if no returns.

if (!compInlineResult->UsesLegacyPolicy())
{
// Mark the call node as "no return" as it can impact caller's code quality.
impInlineInfo->iciCall->gtCallMoreFlags |= GTF_CALL_M_DOES_NOT_RETURN;
}
}

// Assess profitability...
CORINFO_METHOD_INFO* methodInfo = &impInlineInfo->inlineCandidateInfo->methInfo;
compInlineResult->DetermineProfitability(methodInfo);
Expand Down

0 comments on commit 7cb8db3

Please sign in to comment.