diff --git a/llvm/include/llvm/ADT/Statistic.h b/llvm/include/llvm/ADT/Statistic.h --- a/llvm/include/llvm/ADT/Statistic.h +++ b/llvm/include/llvm/ADT/Statistic.h @@ -53,7 +53,7 @@ const char *const Name; const char *const Desc; - std::atomic Value; + std::atomic Value; std::atomic Initialized; constexpr TrackingStatistic(const char *DebugType, const char *Name, @@ -65,12 +65,12 @@ const char *getName() const { return Name; } const char *getDesc() const { return Desc; } - unsigned getValue() const { return Value.load(std::memory_order_relaxed); } + uint64_t getValue() const { return Value.load(std::memory_order_relaxed); } // Allow use of this class as the value itself. - operator unsigned() const { return getValue(); } + operator uint64_t() const { return getValue(); } - const TrackingStatistic &operator=(unsigned Val) { + const TrackingStatistic &operator=(uint64_t Val) { Value.store(Val, std::memory_order_relaxed); return init(); } @@ -95,22 +95,22 @@ return Value.fetch_sub(1, std::memory_order_relaxed); } - const TrackingStatistic &operator+=(unsigned V) { + const TrackingStatistic &operator+=(uint64_t V) { if (V == 0) return *this; Value.fetch_add(V, std::memory_order_relaxed); return init(); } - const TrackingStatistic &operator-=(unsigned V) { + const TrackingStatistic &operator-=(uint64_t V) { if (V == 0) return *this; Value.fetch_sub(V, std::memory_order_relaxed); return init(); } - void updateMax(unsigned V) { - unsigned PrevMax = Value.load(std::memory_order_relaxed); + void updateMax(uint64_t V) { + uint64_t PrevMax = Value.load(std::memory_order_relaxed); // Keep trying to update max until we succeed or another thread produces // a bigger max than us. while (V > PrevMax && !Value.compare_exchange_weak( @@ -200,7 +200,7 @@ /// during it's execution. It will return the value at the point that it is /// read. However, it will prevent new statistics from registering until it /// completes. -const std::vector> GetStatistics(); +const std::vector> GetStatistics(); /// Reset the statistics. This can be used to zero and de-register the /// statistics in order to measure a compilation. diff --git a/llvm/lib/Support/Statistic.cpp b/llvm/lib/Support/Statistic.cpp --- a/llvm/lib/Support/Statistic.cpp +++ b/llvm/lib/Support/Statistic.cpp @@ -192,7 +192,7 @@ // Print all of the statistics. for (TrackingStatistic *Stat : Stats.Stats) - OS << format("%*u %-*s - %s\n", MaxValLen, Stat->getValue(), + OS << format("%*" PRIu64 " %-*s - %s\n", MaxValLen, Stat->getValue(), MaxDebugTypeLen, Stat->getDebugType(), Stat->getDesc()); OS << '\n'; // Flush the output stream. @@ -253,9 +253,9 @@ #endif } -const std::vector> llvm::GetStatistics() { +const std::vector> llvm::GetStatistics() { sys::SmartScopedLock Reader(*StatLock); - std::vector> ReturnStats; + std::vector> ReturnStats; for (const auto &Stat : StatInfo->statistics()) ReturnStats.emplace_back(Stat->getName(), Stat->getValue()); diff --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp b/llvm/lib/Transforms/Scalar/NewGVN.cpp --- a/llvm/lib/Transforms/Scalar/NewGVN.cpp +++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp @@ -3351,7 +3351,7 @@ // instruction set, propagating value numbers, marking things touched, etc, // until the set of touched instructions is completely empty. void NewGVN::iterateTouchedInstructions() { - unsigned int Iterations = 0; + uint64_t Iterations = 0; // Figure out where touchedinstructions starts int FirstInstr = TouchedInstructions.find_first(); // Nothing set, nothing to iterate, just return. diff --git a/llvm/unittests/ADT/StatisticTest.cpp b/llvm/unittests/ADT/StatisticTest.cpp --- a/llvm/unittests/ADT/StatisticTest.cpp +++ b/llvm/unittests/ADT/StatisticTest.cpp @@ -11,7 +11,7 @@ #include "gtest/gtest.h" using namespace llvm; -using OptionalStatistic = Optional>; +using OptionalStatistic = Optional>; namespace { #define DEBUG_TYPE "unittest" @@ -21,7 +21,7 @@ #if LLVM_ENABLE_STATS static void -extractCounters(const std::vector> &Range, +extractCounters(const std::vector> &Range, OptionalStatistic &S1, OptionalStatistic &S2) { for (const auto &S : Range) { if (S.first == "Counter") @@ -36,20 +36,21 @@ EnableStatistics(); Counter = 0; - EXPECT_EQ(Counter, 0u); + EXPECT_EQ(Counter, 0ull); Counter++; Counter++; + Counter += (std::numeric_limits::max() - 3); #if LLVM_ENABLE_STATS - EXPECT_EQ(Counter, 2u); + EXPECT_EQ(Counter, std::numeric_limits::max() - 1); #else - EXPECT_EQ(Counter, 0u); + EXPECT_EQ(Counter, 0ull); #endif AlwaysCounter = 0; - EXPECT_EQ(AlwaysCounter, 0u); + EXPECT_EQ(AlwaysCounter, 0ull); AlwaysCounter++; ++AlwaysCounter; - EXPECT_EQ(AlwaysCounter, 2u); + EXPECT_EQ(AlwaysCounter, 2ull); } TEST(StatisticTest, Assign) {