@@ -322,7 +322,8 @@ UnifiedStatsReporter::UnifiedStatsReporter(StringRef ProgramName,
322
322
bool FineGrainedTimers,
323
323
bool TraceEvents,
324
324
bool ProfileEvents,
325
- bool ProfileEntities)
325
+ bool ProfileEntities,
326
+ bool PrintZeroStats)
326
327
: UnifiedStatsReporter(ProgramName,
327
328
auxName (ModuleName,
328
329
InputName,
@@ -331,7 +332,8 @@ UnifiedStatsReporter::UnifiedStatsReporter(StringRef ProgramName,
331
332
OptType),
332
333
Directory,
333
334
SM, CSM, FineGrainedTimers,
334
- TraceEvents, ProfileEvents, ProfileEntities)
335
+ TraceEvents, ProfileEvents, ProfileEntities,
336
+ PrintZeroStats)
335
337
{
336
338
}
337
339
@@ -343,7 +345,8 @@ UnifiedStatsReporter::UnifiedStatsReporter(StringRef ProgramName,
343
345
bool FineGrainedTimers,
344
346
bool TraceEvents,
345
347
bool ProfileEvents,
346
- bool ProfileEntities)
348
+ bool ProfileEntities,
349
+ bool PrintZeroStats)
347
350
: currentProcessExitStatusSet(false ),
348
351
currentProcessExitStatus(EXIT_FAILURE),
349
352
StatsFilename(Directory),
@@ -358,7 +361,8 @@ UnifiedStatsReporter::UnifiedStatsReporter(StringRef ProgramName,
358
361
ClangSourceMgr(CSM),
359
362
RecursiveTimers(std::make_unique<RecursionSafeTimers>()),
360
363
FineGrainedTimers(FineGrainedTimers),
361
- IsFlushingTracesAndProfiles(false )
364
+ IsFlushingTracesAndProfiles(false ),
365
+ IsPrintingZeroStats(PrintZeroStats)
362
366
{
363
367
path::append (StatsFilename, makeStatsFileName (ProgramName, AuxName));
364
368
path::append (TraceFilename, makeTraceFileName (ProgramName, AuxName));
@@ -430,7 +434,8 @@ UnifiedStatsReporter::publishAlwaysOnStatsToLLVM() {
430
434
#define FRONTEND_STATISTIC (TY, NAME ) \
431
435
do { \
432
436
static Statistic Stat = {#TY, #NAME, #NAME}; \
433
- Stat = 0 ; \
437
+ if (IsPrintingZeroStats) \
438
+ Stat = 0 ; \
434
439
Stat += (C).NAME ; \
435
440
} while (0 );
436
441
#include " swift/Basic/Statistics.def"
@@ -441,7 +446,8 @@ UnifiedStatsReporter::publishAlwaysOnStatsToLLVM() {
441
446
#define DRIVER_STATISTIC (NAME ) \
442
447
do { \
443
448
static Statistic Stat = {" Driver" , #NAME, #NAME}; \
444
- Stat = 0 ; \
449
+ if (IsPrintingZeroStats) \
450
+ Stat = 0 ; \
445
451
Stat += (C).NAME ; \
446
452
} while (0 );
447
453
#include " swift/Basic/Statistics.def"
@@ -458,7 +464,7 @@ UnifiedStatsReporter::printAlwaysOnStatsAndTimers(raw_ostream &OS) {
458
464
auto &C = getFrontendCounters ();
459
465
#define FRONTEND_STATISTIC (TY, NAME ) \
460
466
do { \
461
- if (C.NAME ) { \
467
+ if (C.NAME || IsPrintingZeroStats) { \
462
468
OS << delim << " \t\" " #TY " ." #NAME " \" : " << C.NAME ; \
463
469
delim = " ,\n " ; \
464
470
} \
@@ -470,7 +476,7 @@ UnifiedStatsReporter::printAlwaysOnStatsAndTimers(raw_ostream &OS) {
470
476
auto &C = getDriverCounters ();
471
477
#define DRIVER_STATISTIC (NAME ) \
472
478
do { \
473
- if (C.NAME ) { \
479
+ if (C.NAME || IsPrintingZeroStats) { \
474
480
OS << delim << " \t\" Driver." #NAME " \" : " << C.NAME ; \
475
481
delim = " ,\n " ; \
476
482
} \
0 commit comments