@@ -322,7 +322,8 @@ UnifiedStatsReporter::UnifiedStatsReporter(StringRef ProgramName,
322322 bool FineGrainedTimers,
323323 bool TraceEvents,
324324 bool ProfileEvents,
325- bool ProfileEntities)
325+ bool ProfileEntities,
326+ bool PrintZeroStats)
326327 : UnifiedStatsReporter(ProgramName,
327328 auxName (ModuleName,
328329 InputName,
@@ -331,7 +332,8 @@ UnifiedStatsReporter::UnifiedStatsReporter(StringRef ProgramName,
331332 OptType),
332333 Directory,
333334 SM, CSM, FineGrainedTimers,
334- TraceEvents, ProfileEvents, ProfileEntities)
335+ TraceEvents, ProfileEvents, ProfileEntities,
336+ PrintZeroStats)
335337{
336338}
337339
@@ -343,7 +345,8 @@ UnifiedStatsReporter::UnifiedStatsReporter(StringRef ProgramName,
343345 bool FineGrainedTimers,
344346 bool TraceEvents,
345347 bool ProfileEvents,
346- bool ProfileEntities)
348+ bool ProfileEntities,
349+ bool PrintZeroStats)
347350 : currentProcessExitStatusSet(false ),
348351 currentProcessExitStatus(EXIT_FAILURE),
349352 StatsFilename(Directory),
@@ -358,7 +361,8 @@ UnifiedStatsReporter::UnifiedStatsReporter(StringRef ProgramName,
358361 ClangSourceMgr(CSM),
359362 RecursiveTimers(std::make_unique<RecursionSafeTimers>()),
360363 FineGrainedTimers(FineGrainedTimers),
361- IsFlushingTracesAndProfiles(false )
364+ IsFlushingTracesAndProfiles(false ),
365+ IsPrintingZeroStats(PrintZeroStats)
362366{
363367 path::append (StatsFilename, makeStatsFileName (ProgramName, AuxName));
364368 path::append (TraceFilename, makeTraceFileName (ProgramName, AuxName));
@@ -430,7 +434,8 @@ UnifiedStatsReporter::publishAlwaysOnStatsToLLVM() {
430434#define FRONTEND_STATISTIC (TY, NAME ) \
431435 do { \
432436 static Statistic Stat = {#TY, #NAME, #NAME}; \
433- Stat = 0 ; \
437+ if (IsPrintingZeroStats) \
438+ Stat = 0 ; \
434439 Stat += (C).NAME ; \
435440 } while (0 );
436441#include " swift/Basic/Statistics.def"
@@ -441,7 +446,8 @@ UnifiedStatsReporter::publishAlwaysOnStatsToLLVM() {
441446#define DRIVER_STATISTIC (NAME ) \
442447 do { \
443448 static Statistic Stat = {" Driver" , #NAME, #NAME}; \
444- Stat = 0 ; \
449+ if (IsPrintingZeroStats) \
450+ Stat = 0 ; \
445451 Stat += (C).NAME ; \
446452 } while (0 );
447453#include " swift/Basic/Statistics.def"
@@ -458,7 +464,7 @@ UnifiedStatsReporter::printAlwaysOnStatsAndTimers(raw_ostream &OS) {
458464 auto &C = getFrontendCounters ();
459465#define FRONTEND_STATISTIC (TY, NAME ) \
460466 do { \
461- if (C.NAME ) { \
467+ if (C.NAME || IsPrintingZeroStats) { \
462468 OS << delim << " \t\" " #TY " ." #NAME " \" : " << C.NAME ; \
463469 delim = " ,\n " ; \
464470 } \
@@ -470,7 +476,7 @@ UnifiedStatsReporter::printAlwaysOnStatsAndTimers(raw_ostream &OS) {
470476 auto &C = getDriverCounters ();
471477#define DRIVER_STATISTIC (NAME ) \
472478 do { \
473- if (C.NAME ) { \
479+ if (C.NAME || IsPrintingZeroStats) { \
474480 OS << delim << " \t\" Driver." #NAME " \" : " << C.NAME ; \
475481 delim = " ,\n " ; \
476482 } \
0 commit comments