Skip to content

Commit 5d0f1d5

Browse files
committed
[Stats] Force the printing of 0 counters
This matches the behavior of `printAlwaysOnStatsAndTimers`, which we use in a release build. This fixes the diverging behavior, and ensures process-stats-dir can handle comparing deltas between runs where one of the runs had a 0 counter.
1 parent 570c364 commit 5d0f1d5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/Basic/Statistic.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,11 +419,14 @@ UnifiedStatsReporter::noteCurrentProcessExitStatus(int status) {
419419

420420
void
421421
UnifiedStatsReporter::publishAlwaysOnStatsToLLVM() {
422+
// NOTE: We do `Stat = 0` below to force LLVM to register the statistic,
423+
// ensuring we print counters, even if 0.
422424
if (FrontendCounters) {
423425
auto &C = getFrontendCounters();
424426
#define FRONTEND_STATISTIC(TY, NAME) \
425427
do { \
426428
static Statistic Stat = {#TY, #NAME, #NAME}; \
429+
Stat = 0; \
427430
Stat += (C).NAME; \
428431
} while (0);
429432
#include "swift/Basic/Statistics.def"
@@ -434,6 +437,7 @@ UnifiedStatsReporter::publishAlwaysOnStatsToLLVM() {
434437
#define DRIVER_STATISTIC(NAME) \
435438
do { \
436439
static Statistic Stat = {"Driver", #NAME, #NAME}; \
440+
Stat = 0; \
437441
Stat += (C).NAME; \
438442
} while (0);
439443
#include "swift/Basic/Statistics.def"

0 commit comments

Comments
 (0)