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

JIT: initial implementation of profile synthesis #82926

Merged
merged 4 commits into from
Mar 6, 2023
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
2 changes: 2 additions & 0 deletions src/coreclr/jit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ set( JIT_SOURCES
fginline.cpp
fgopt.cpp
fgprofile.cpp
fgprofilesynthesis.cpp
Copy link
Member

Choose a reason for hiding this comment

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

I think you need to add fgprofilesynthesis.h in the JIT_HEADERS section, below

Copy link
Member Author

Choose a reason for hiding this comment

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

added

fgstmt.cpp
flowgraph.cpp
forwardsub.cpp
Expand Down Expand Up @@ -295,6 +296,7 @@ set( JIT_HEADERS
emitjmps.h
emitpub.h
error.h
fgprofilesynthesis.h
gentree.h
gentreeopsdef.h
gtlist.h
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/jit/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1431,15 +1431,15 @@ BasicBlock* Compiler::bbNewBasicBlock(BBjumpKinds jumpKind)
/* Give the block a number, set the ancestor count and weight */

++fgBBcount;
++fgBBNumMax;

if (compIsForInlining())
{
block->bbNum = ++impInlineInfo->InlinerCompiler->fgBBNumMax;
fgBBNumMax = block->bbNum;
}
else
{
block->bbNum = fgBBNumMax;
block->bbNum = ++fgBBNumMax;
}

if (compRationalIRForm)
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class CSE_DataFlow; // defined in OptCSE.cpp
class OptBoolsDsc; // defined in optimizer.cpp
struct RelopImplicationInfo; // defined in redundantbranchopts.cpp
struct JumpThreadInfo; // defined in redundantbranchopts.cpp
class ProfileSynthesis; // defined in profilesynthesis.h
#ifdef DEBUG
struct IndentStack;
#endif
Expand Down Expand Up @@ -1993,6 +1994,7 @@ class Compiler
friend class SharedTempsScope;
friend class CallArgs;
friend class IndirectCallTransformer;
friend class ProfileSynthesis;

#ifdef FEATURE_HW_INTRINSICS
friend struct HWIntrinsicInfo;
Expand Down
16 changes: 16 additions & 0 deletions src/coreclr/jit/fgprofile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#pragma hdrstop
#endif

#include "fgprofilesynthesis.h"

// Flowgraph Profile Support

//------------------------------------------------------------------------
Expand Down Expand Up @@ -2425,6 +2427,20 @@ PhaseStatus Compiler::fgIncorporateProfileData()
return PhaseStatus::MODIFIED_EVERYTHING;
}

#ifdef DEBUG
// Optionally just run synthesis
//
if ((JitConfig.JitSynthesizeCounts() > 0) && !compIsForInlining())
{
if ((JitConfig.JitSynthesizeCounts() == 1) || ((JitConfig.JitSynthesizeCounts() == 2) && !fgHaveProfileData()))
{
JITDUMP("Synthesizing profile data\n");
ProfileSynthesis::Run(this, ProfileSynthesisOption::AssignLikelihoods);
return PhaseStatus::MODIFIED_EVERYTHING;
}
}
#endif

// Do we have profile data?
//
if (!fgHaveProfileData())
Expand Down
Loading