LLVM  13.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 
17 using namespace llvm;
18 
20  auto I = MergedBBFreq.find(MBB);
21 
22  if (I != MergedBBFreq.end())
23  return I->second;
24 
25  return MBFI.getBlockFreq(MBB);
26 }
27 
29  BlockFrequency F) {
30  MergedBBFreq[MBB] = F;
31 }
32 
35  auto I = MergedBBFreq.find(MBB);
36 
37  // Modified block frequency also impacts profile count. So we should compute
38  // profile count from new block frequency if it has been changed.
39  if (I != MergedBBFreq.end())
40  return MBFI.getProfileCountFromFreq(I->second.getFrequency());
41 
42  return MBFI.getBlockProfileCount(MBB);
43 }
44 
46  const MachineBasicBlock *MBB) const {
47  return MBFI.printBlockFreq(OS, getBlockFreq(MBB));
48 }
49 
51  const BlockFrequency Freq) const {
52  return MBFI.printBlockFreq(OS, Freq);
53 }
54 
55 void MBFIWrapper::view(const Twine &Name, bool isSimple) {
56  MBFI.view(Name, isSimple);
57 }
58 
59 uint64_t MBFIWrapper::getEntryFreq() const {
60  return MBFI.getEntryFreq();
61 }
llvm
Definition: AllocatorList.h:23
llvm::MBFIWrapper::view
void view(const Twine &Name, bool isSimple=true)
Definition: MBFIWrapper.cpp:55
llvm::MachineBlockFrequencyInfo::getBlockProfileCount
Optional< uint64_t > getBlockProfileCount(const MachineBasicBlock *MBB) const
Definition: MachineBlockFrequencyInfo.cpp:234
llvm::MachineBlockFrequencyInfo::getProfileCountFromFreq
Optional< uint64_t > getProfileCountFromFreq(uint64_t Freq) const
Definition: MachineBlockFrequencyInfo.cpp:244
llvm::MachineBlockFrequencyInfo::view
void view(const Twine &Name, bool isSimple=true) const
Pop up a ghostview window with the current block frequency propagation rendered using dot.
Definition: MachineBlockFrequencyInfo.cpp:224
MBFIWrapper.h
llvm::Optional< uint64_t >
llvm::MBFIWrapper::setBlockFreq
void setBlockFreq(const MachineBasicBlock *MBB, BlockFrequency F)
Definition: MBFIWrapper.cpp:28
llvm::MachineBlockFrequencyInfo::getBlockFreq
BlockFrequency getBlockFreq(const MachineBasicBlock *MBB) const
getblockFreq - Return block frequency.
Definition: MachineBlockFrequencyInfo.cpp:230
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::MBFIWrapper::printBlockFreq
raw_ostream & printBlockFreq(raw_ostream &OS, const MachineBasicBlock *MBB) const
Definition: MBFIWrapper.cpp:45
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:50
llvm::MBFIWrapper::getEntryFreq
uint64_t getEntryFreq() const
Definition: MBFIWrapper.cpp:59
llvm::MachineBasicBlock
Definition: MachineBasicBlock.h:95
llvm::BlockFrequency
Definition: BlockFrequency.h:24
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::MachineBlockFrequencyInfo::printBlockFreq
raw_ostream & printBlockFreq(raw_ostream &OS, const BlockFrequency Freq) const
Definition: MachineBlockFrequencyInfo.cpp:278
MBB
MachineBasicBlock & MBB
Definition: AArch64SLSHardening.cpp:74
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:80
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::MBFIWrapper::getBlockProfileCount
Optional< uint64_t > getBlockProfileCount(const MachineBasicBlock *MBB) const
Definition: MBFIWrapper.cpp:34
isSimple
static bool isSimple(Instruction *I)
Definition: SLPVectorizer.cpp:524
llvm::MachineBlockFrequencyInfo::getEntryFreq
uint64_t getEntryFreq() const
Divide a block's BlockFrequency::getFrequency() value by this value to obtain the entry block - relat...
Definition: MachineBlockFrequencyInfo.cpp:289
llvm::MBFIWrapper::getBlockFreq
BlockFrequency getBlockFreq(const MachineBasicBlock *MBB) const
Definition: MBFIWrapper.cpp:19
MachineBlockFrequencyInfo.h