diff options
author | Matthias Braun <matze@braunis.de> | 2023-10-05 11:40:17 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-05 11:40:17 -0700 |
commit | 5181156b3743df29dc840e15990d9202b3501f60 (patch) | |
tree | fd52778d4b80a77887cb856ab7ec85436512abc6 /llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp | |
parent | ea2036e1e56b720d7da8d46f62263ba46c126522 (diff) | |
download | llvm-5181156b3743df29dc840e15990d9202b3501f60.zip llvm-5181156b3743df29dc840e15990d9202b3501f60.tar.gz llvm-5181156b3743df29dc840e15990d9202b3501f60.tar.bz2 |
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.
Diffstat (limited to 'llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp b/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp index b1cbe52..76b7285 100644 --- a/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp +++ b/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp @@ -228,7 +228,7 @@ void MachineBlockFrequencyInfo::view(const Twine &Name, bool isSimple) const { BlockFrequency MachineBlockFrequencyInfo::getBlockFreq(const MachineBasicBlock *MBB) const { - return MBFI ? MBFI->getBlockFreq(MBB) : 0; + return MBFI ? MBFI->getBlockFreq(MBB) : BlockFrequency(0); } std::optional<uint64_t> MachineBlockFrequencyInfo::getBlockProfileCount( @@ -241,7 +241,7 @@ std::optional<uint64_t> MachineBlockFrequencyInfo::getBlockProfileCount( } std::optional<uint64_t> -MachineBlockFrequencyInfo::getProfileCountFromFreq(uint64_t Freq) const { +MachineBlockFrequencyInfo::getProfileCountFromFreq(BlockFrequency Freq) const { if (!MBFI) return std::nullopt; @@ -263,7 +263,7 @@ void MachineBlockFrequencyInfo::onEdgeSplit( auto NewSuccFreq = MBFI->getBlockFreq(&NewPredecessor) * MBPI.getEdgeProbability(&NewPredecessor, &NewSuccessor); - MBFI->setBlockFreq(&NewSuccessor, NewSuccFreq.getFrequency()); + MBFI->setBlockFreq(&NewSuccessor, NewSuccFreq); } const MachineFunction *MachineBlockFrequencyInfo::getFunction() const { @@ -286,6 +286,6 @@ MachineBlockFrequencyInfo::printBlockFreq(raw_ostream &OS, return MBFI ? MBFI->printBlockFreq(OS, MBB) : OS; } -uint64_t MachineBlockFrequencyInfo::getEntryFreq() const { - return MBFI ? MBFI->getEntryFreq() : 0; +BlockFrequency MachineBlockFrequencyInfo::getEntryFreq() const { + return MBFI ? MBFI->getEntryFreq() : BlockFrequency(0); } |