[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / llvm / lib / CodeGen / MBFIWrapper.cpp
blobe9f16329b57f751463a1d99abab7bfe5d8f13cc4
1 //===- MBFIWrapper.cpp - MachineBlockFrequencyInfo wrapper ----------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This class keeps track of branch frequencies of newly created blocks and
10 // tail-merged blocks. Used by the TailDuplication and MachineBlockPlacement.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/CodeGen/MachineBlockFrequencyInfo.h"
15 #include "llvm/CodeGen/MBFIWrapper.h"
16 #include <optional>
18 using namespace llvm;
20 BlockFrequency MBFIWrapper::getBlockFreq(const MachineBasicBlock *MBB) const {
21 auto I = MergedBBFreq.find(MBB);
23 if (I != MergedBBFreq.end())
24 return I->second;
26 return MBFI.getBlockFreq(MBB);
29 void MBFIWrapper::setBlockFreq(const MachineBasicBlock *MBB,
30 BlockFrequency F) {
31 MergedBBFreq[MBB] = F;
34 std::optional<uint64_t>
35 MBFIWrapper::getBlockProfileCount(const MachineBasicBlock *MBB) const {
36 auto I = MergedBBFreq.find(MBB);
38 // Modified block frequency also impacts profile count. So we should compute
39 // profile count from new block frequency if it has been changed.
40 if (I != MergedBBFreq.end())
41 return MBFI.getProfileCountFromFreq(I->second);
43 return MBFI.getBlockProfileCount(MBB);
46 void MBFIWrapper::view(const Twine &Name, bool isSimple) {
47 MBFI.view(Name, isSimple);
50 BlockFrequency MBFIWrapper::getEntryFreq() const { return MBFI.getEntryFreq(); }