From 5181156b3743df29dc840e15990d9202b3501f60 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Thu, 5 Oct 2023 11:40:17 -0700 Subject: Use BlockFrequency type in more places (NFC) (#68266) The `BlockFrequency` class abstracts `uint64_t` frequency values. Use it more consistently in various APIs and disable implicit conversion to make usage more consistent and explicit. - Use `BlockFrequency Freq` parameter for `setBlockFreq`, `getProfileCountFromFreq` and `setBlockFreqAndScale` functions. - Return `BlockFrequency` in `getEntryFreq()` functions. - While on it change some `const BlockFrequency& Freq` parameters to plain `BlockFreqency Freq`. - Mark `BlockFrequency(uint64_t)` constructor as explicit. - Add missing `BlockFrequency::operator!=`. - Remove `uint64_t BlockFreqency::getMaxFrequency()`. - Add `BlockFrequency BlockFrequency::max()` function. --- llvm/unittests/Support/BlockFrequencyTest.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'llvm/unittests/Support/BlockFrequencyTest.cpp') diff --git a/llvm/unittests/Support/BlockFrequencyTest.cpp b/llvm/unittests/Support/BlockFrequencyTest.cpp index cf5cf92..d0374b0 100644 --- a/llvm/unittests/Support/BlockFrequencyTest.cpp +++ b/llvm/unittests/Support/BlockFrequencyTest.cpp @@ -11,6 +11,7 @@ #include "llvm/Support/DataTypes.h" #include "gtest/gtest.h" #include +#include using namespace llvm; @@ -106,12 +107,12 @@ TEST(BlockFrequencyTest, Saturate) { Freq /= BranchProbability(1, 2); EXPECT_EQ(Freq.getFrequency(), UINT64_MAX); - Freq = 0x1000000000000000ULL; + Freq = BlockFrequency(UINT64_C(0x1000000000000000)); Freq /= BranchProbability(10000, 170000); EXPECT_EQ(Freq.getFrequency(), UINT64_MAX); // Try to cheat the multiplication overflow check. - Freq = 0x00000001f0000001ull; + Freq = BlockFrequency(UINT64_C(0x00000001f0000001)); Freq /= BranchProbability(1000, 0xf000000f); EXPECT_EQ(33527736066704712ULL, Freq.getFrequency()); } -- cgit v1.1