Skip to content

Commit 10ed740

Browse files
authored
Add loop alignment stats to JitLogCsv (#50624)
* Add loop alignment stats * Include the stats only in DEBUG mode * jit format
1 parent 6578f25 commit 10ed740

File tree

5 files changed

+28
-1
lines changed

5 files changed

+28
-1
lines changed

Diff for: src/coreclr/jit/compiler.cpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -8255,7 +8255,12 @@ void JitTimer::PrintCsvHeader()
82558255
fprintf(s_csvFile, "\"Min Opts\",");
82568256
fprintf(s_csvFile, "\"Loops\",");
82578257
fprintf(s_csvFile, "\"Loops Cloned\",");
8258-
8258+
#if FEATURE_LOOP_ALIGN
8259+
#ifdef DEBUG
8260+
fprintf(s_csvFile, "\"Alignment Candidates\",");
8261+
fprintf(s_csvFile, "\"Loops Aligned\",");
8262+
#endif // DEBUG
8263+
#endif // FEATURE_LOOP_ALIGN
82598264
for (int i = 0; i < PHASE_NUMBER_OF; i++)
82608265
{
82618266
fprintf(s_csvFile, "\"%s\",", PhaseNames[i]);
@@ -8329,6 +8334,12 @@ void JitTimer::PrintCsvMethodStats(Compiler* comp)
83298334
fprintf(s_csvFile, "%u,", comp->opts.MinOpts());
83308335
fprintf(s_csvFile, "%u,", comp->optLoopCount);
83318336
fprintf(s_csvFile, "%u,", comp->optLoopsCloned);
8337+
#if FEATURE_LOOP_ALIGN
8338+
#ifdef DEBUG
8339+
fprintf(s_csvFile, "%u,", comp->loopAlignCandidates);
8340+
fprintf(s_csvFile, "%u,", comp->loopsAligned);
8341+
#endif // DEBUG
8342+
#endif // FEATURE_LOOP_ALIGN
83328343
unsigned __int64 totCycles = 0;
83338344
for (int i = 0; i < PHASE_NUMBER_OF; i++)
83348345
{

Diff for: src/coreclr/jit/compiler.h

+5
Original file line numberDiff line numberDiff line change
@@ -6435,6 +6435,11 @@ class Compiler
64356435
LoopDsc* optLoopTable; // loop descriptor table
64366436
unsigned char optLoopCount; // number of tracked loops
64376437

6438+
#ifdef DEBUG
6439+
unsigned char loopAlignCandidates; // number of loops identified for alignment
6440+
unsigned char loopsAligned; // number of loops actually aligned
6441+
#endif // DEBUG
6442+
64386443
bool optRecordLoop(BasicBlock* head,
64396444
BasicBlock* first,
64406445
BasicBlock* top,

Diff for: src/coreclr/jit/emit.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -4650,6 +4650,10 @@ void emitter::emitLoopAlignment()
46504650

46514651
JITDUMP("Adding 'align' instruction of %d bytes in G_M%03u_IG%02u.\n", paddingBytes, emitComp->compMethodID,
46524652
emitCurIG->igNum);
4653+
4654+
#ifdef DEBUG
4655+
emitComp->loopAlignCandidates++;
4656+
#endif // DEBUG
46534657
}
46544658

46554659
//-----------------------------------------------------------------------------

Diff for: src/coreclr/jit/emitxarch.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -9434,6 +9434,8 @@ BYTE* emitter::emitOutputAlign(insGroup* ig, instrDesc* id, BYTE* dst)
94349434
{
94359435
assert(paddingToAdd == paddingNeeded);
94369436
}
9437+
9438+
emitComp->loopsAligned++;
94379439
#endif
94389440

94399441
return emitOutputNOP(dst, paddingToAdd);

Diff for: src/coreclr/jit/optimizer.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ void Compiler::optInit()
2727
optLoopCount = 0;
2828
optLoopTable = nullptr;
2929

30+
#ifdef DEBUG
31+
loopAlignCandidates = 0;
32+
loopsAligned = 0;
33+
#endif
34+
3035
/* Keep track of the number of calls and indirect calls made by this method */
3136
optCallCount = 0;
3237
optIndirectCallCount = 0;

0 commit comments

Comments
 (0)