[PATCH] D87802: [MBFIWrapper] Add a new function getBlockProfileCount
Guozhi Wei via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 21 17:09:52 PDT 2020
Carrot updated this revision to Diff 293297.
Carrot marked an inline comment as done.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87802/new/
https://reviews.llvm.org/D87802
Files:
llvm/include/llvm/CodeGen/MBFIWrapper.h
llvm/lib/CodeGen/MBFIWrapper.cpp
llvm/lib/CodeGen/MachineBlockPlacement.cpp
Index: llvm/lib/CodeGen/MachineBlockPlacement.cpp
===================================================================
--- llvm/lib/CodeGen/MachineBlockPlacement.cpp
+++ llvm/lib/CodeGen/MachineBlockPlacement.cpp
@@ -418,7 +418,7 @@
/// The return value is used to model tail duplication cost.
BlockFrequency getBlockCountOrFrequency(const MachineBasicBlock *BB) {
if (UseProfileCount) {
- auto Count = MBFI->getMBFI().getBlockProfileCount(BB);
+ auto Count = MBFI->getBlockProfileCount(BB);
if (Count)
return *Count;
else
Index: llvm/lib/CodeGen/MBFIWrapper.cpp
===================================================================
--- llvm/lib/CodeGen/MBFIWrapper.cpp
+++ llvm/lib/CodeGen/MBFIWrapper.cpp
@@ -30,6 +30,18 @@
MergedBBFreq[MBB] = F;
}
+Optional<uint64_t>
+MBFIWrapper::getBlockProfileCount(const MachineBasicBlock *MBB) const {
+ auto I = MergedBBFreq.find(MBB);
+
+ // Modified block frequency also impacts profile count. So we should compute
+ // profile count from new block frequency if it has been changed.
+ if (I != MergedBBFreq.end())
+ return MBFI.getProfileCountFromFreq(I->second.getFrequency());
+
+ return MBFI.getBlockProfileCount(MBB);
+}
+
raw_ostream & MBFIWrapper::printBlockFreq(raw_ostream &OS,
const MachineBasicBlock *MBB) const {
return MBFI.printBlockFreq(OS, getBlockFreq(MBB));
Index: llvm/include/llvm/CodeGen/MBFIWrapper.h
===================================================================
--- llvm/include/llvm/CodeGen/MBFIWrapper.h
+++ llvm/include/llvm/CodeGen/MBFIWrapper.h
@@ -28,6 +28,8 @@
BlockFrequency getBlockFreq(const MachineBasicBlock *MBB) const;
void setBlockFreq(const MachineBasicBlock *MBB, BlockFrequency F);
+ Optional<uint64_t> getBlockProfileCount(const MachineBasicBlock *MBB) const;
+
raw_ostream &printBlockFreq(raw_ostream &OS,
const MachineBasicBlock *MBB) const;
raw_ostream &printBlockFreq(raw_ostream &OS,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87802.293297.patch
Type: text/x-patch
Size: 2029 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200922/560d94fc/attachment.bin>
More information about the llvm-commits
mailing list