LLVM  14.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 
14 #include "llvm/ADT/Optional.h"
17 
18 using 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 
30  BlockFrequency F) {
31  MergedBBFreq[MBB] = F;
32 }
33 
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.getFrequency());
42 
43  return MBFI.getBlockProfileCount(MBB);
44 }
45 
47  const MachineBasicBlock *MBB) const {
48  return MBFI.printBlockFreq(OS, getBlockFreq(MBB));
49 }
50 
52  const BlockFrequency Freq) const {
53  return MBFI.printBlockFreq(OS, Freq);
54 }
55 
56 void MBFIWrapper::view(const Twine &Name, bool isSimple) {
57  MBFI.view(Name, isSimple);
58 }
59 
61  return MBFI.getEntryFreq();
62 }
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
Optional.h
llvm::MBFIWrapper::view
void view(const Twine &Name, bool isSimple=true)
Definition: MBFIWrapper.cpp:56
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:29
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:46
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::MBFIWrapper::getEntryFreq
uint64_t getEntryFreq() const
Definition: MBFIWrapper.cpp:60
llvm::MachineBasicBlock
Definition: MachineBasicBlock.h:95
llvm::BlockFrequency
Definition: BlockFrequency.h:24
uint64_t
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:83
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::MBFIWrapper::getBlockProfileCount
Optional< uint64_t > getBlockProfileCount(const MachineBasicBlock *MBB) const
Definition: MBFIWrapper.cpp:35
isSimple
static bool isSimple(Instruction *I)
Definition: SLPVectorizer.cpp:593
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:20
MachineBlockFrequencyInfo.h