Skip to content

Commit ffcd1c5

Browse files
authored
Trust single-edge synthetic profile (#116054)
1 parent 9703a2e commit ffcd1c5

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

src/coreclr/jit/compiler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6477,6 +6477,7 @@ class Compiler
64776477
bool fgPgoSynthesized;
64786478
bool fgPgoDynamic;
64796479
bool fgPgoConsistent;
6480+
bool fgPgoSingleEdge = false;
64806481

64816482
#ifdef DEBUG
64826483
bool fgPgoDeferredInconsistency;

src/coreclr/jit/fgprofile.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ bool Compiler::fgHaveSufficientProfileWeights()
8989
case ICorJitInfo::PgoSource::Blend:
9090
return true;
9191

92+
case ICorJitInfo::PgoSource::Synthesis:
93+
// Single-edge methods always have sufficient profile data.
94+
// Assuming we don't synthesize value and class profile data (which we don't currently).
95+
return fgPgoSingleEdge;
96+
9297
case ICorJitInfo::PgoSource::Static:
9398
{
9499
// We sometimes call this very early, eg evaluating the prejit root.
@@ -134,6 +139,12 @@ bool Compiler::fgHaveTrustedProfileWeights()
134139
case ICorJitInfo::PgoSource::Blend:
135140
case ICorJitInfo::PgoSource::Text:
136141
return true;
142+
143+
case ICorJitInfo::PgoSource::Synthesis:
144+
// Single-edge methods with synthetic profile are trustful.
145+
// Assuming we don't synthesize value and class profile data (which we don't currently).
146+
return fgPgoSingleEdge;
147+
137148
default:
138149
return false;
139150
}

src/coreclr/jit/fgprofilesynthesis.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,17 @@ void ProfileSynthesis::Run(ProfileSynthesisOption option)
148148
m_comp->fgPgoSynthesized = true;
149149
m_comp->fgPgoConsistent = !m_approximate;
150150

151+
// A simple check whether the current method has more than one edge.
152+
m_comp->fgPgoSingleEdge = true;
153+
for (BasicBlock* const block : m_comp->Blocks())
154+
{
155+
if (block->NumSucc() > 1)
156+
{
157+
m_comp->fgPgoSingleEdge = false;
158+
break;
159+
}
160+
}
161+
151162
m_comp->Metrics.ProfileSynthesizedBlendedOrRepaired++;
152163

153164
if (m_approximate)

0 commit comments

Comments
 (0)