llvm-profgen: Fix use of stats to be under LLVM_ENABLE_STATS
authorDavid Blaikie <dblaikie@gmail.com>
Sun, 18 Dec 2022 17:46:01 +0000 (17:46 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Sun, 18 Dec 2022 17:46:01 +0000 (17:46 +0000)
This caused a -Wunused-variable warning in a without-assert+with-stats
build (because the stats were included but their use was not).

Stat use is meant to be gated by LLVM_ENABLE_STATS which can be set
independently of assertions.

llvm/tools/llvm-profgen/MissingFrameInferrer.cpp
llvm/tools/llvm-profgen/MissingFrameInferrer.h

index 4a37945..4127fdc 100644 (file)
@@ -269,7 +269,7 @@ bool MissingFrameInferrer::inferMissingFrames(
     assert(UniquePath.back() == From && "broken path");
   }
 
-#ifndef NDEBUG
+#if LLVM_ENABLE_STATS
   if (NumPaths == 1) {
     if (ReachableViaUniquePaths.insert({From, ToFRange->StartAddress}).second)
       TailCallUniReachable++;
index 3a50a64..4680a9a 100644 (file)
@@ -12,6 +12,7 @@
 #include "PerfReader.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/Statistic.h"
 #include <unordered_map>
 #include <unordered_set>
 
@@ -103,7 +104,7 @@ private:
 
   uint32_t CurSearchingDepth = 0;
 
-#ifndef NDEBUG
+#if LLVM_ENABLE_STATS
   DenseSet<std::pair<uint64_t, uint64_t>> ReachableViaUniquePaths;
   DenseSet<std::pair<uint64_t, uint64_t>> Unreachables;
   DenseSet<std::pair<uint64_t, uint64_t>> ReachableViaMultiPaths;