LLVM 20.0.0git
MBFIWrapper.cpp
Go to the documentation of this file.
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.
11//
12//===----------------------------------------------------------------------===//
13
16#include <optional>
17
18using namespace llvm;
19
21 auto I = MergedBBFreq.find(MBB);
22
23 if (I != MergedBBFreq.end())
24 return I->second;
25
26 return MBFI.getBlockFreq(MBB);
27}
28
31 MergedBBFreq[MBB] = F;
32}
33
34std::optional<uint64_t>
36 auto I = MergedBBFreq.find(MBB);
37
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);
42
43 return MBFI.getBlockProfileCount(MBB);
44}
45
47 MBFI.view(Name, isSimple);
48}
49
MachineBasicBlock & MBB
std::string Name
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
static bool isSimple(Instruction *I)
std::optional< uint64_t > getBlockProfileCount(const MachineBasicBlock *MBB) const
Definition: MBFIWrapper.cpp:35
BlockFrequency getBlockFreq(const MachineBasicBlock *MBB) const
Definition: MBFIWrapper.cpp:20
void view(const Twine &Name, bool isSimple=true)
Definition: MBFIWrapper.cpp:46
void setBlockFreq(const MachineBasicBlock *MBB, BlockFrequency F)
Definition: MBFIWrapper.cpp:29
BlockFrequency getEntryFreq() const
Definition: MBFIWrapper.cpp:50
void view(const Twine &Name, bool isSimple=true) const
Pop up a ghostview window with the current block frequency propagation rendered using dot.
BlockFrequency getBlockFreq(const MachineBasicBlock *MBB) const
getblockFreq - Return block frequency.
std::optional< uint64_t > getProfileCountFromFreq(BlockFrequency Freq) const
BlockFrequency getEntryFreq() const
Divide a block's BlockFrequency::getFrequency() value by this value to obtain the entry block - relat...
std::optional< uint64_t > getBlockProfileCount(const MachineBasicBlock *MBB) const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18