[PATCH] D84427: [llvm][NFC] refactor setBlockFrequency for clarity.
Mircea Trofin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 28 13:04:35 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1e027b77f056: [llvm][NFC] refactor setBlockFrequency for clarity. (authored by mtrofin).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D84427/new/
https://reviews.llvm.org/D84427
Files:
llvm/include/llvm/CodeGen/MachineBlockFrequencyInfo.h
llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp
llvm/lib/CodeGen/MachineSink.cpp
Index: llvm/lib/CodeGen/MachineSink.cpp
===================================================================
--- llvm/lib/CodeGen/MachineSink.cpp
+++ llvm/lib/CodeGen/MachineSink.cpp
@@ -347,11 +347,9 @@
<< printMBBReference(*Pair.first) << " -- "
<< printMBBReference(*NewSucc) << " -- "
<< printMBBReference(*Pair.second) << '\n');
- if (MBFI) {
- auto NewSuccFreq = MBFI->getBlockFreq(Pair.first) *
- MBPI->getEdgeProbability(Pair.first, NewSucc);
- MBFI->setBlockFreq(NewSucc, NewSuccFreq.getFrequency());
- }
+ if (MBFI)
+ MBFI->onEdgeSplit(*Pair.first, *NewSucc, *MBPI);
+
MadeChange = true;
++NumSplit;
} else
Index: llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp
===================================================================
--- llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp
+++ llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp
@@ -247,10 +247,15 @@
return MBFI->isIrrLoopHeader(MBB);
}
-void MachineBlockFrequencyInfo::setBlockFreq(const MachineBasicBlock *MBB,
- uint64_t Freq) {
+void MachineBlockFrequencyInfo::onEdgeSplit(
+ const MachineBasicBlock &NewPredecessor,
+ const MachineBasicBlock &NewSuccessor,
+ const MachineBranchProbabilityInfo &MBPI) {
assert(MBFI && "Expected analysis to be available");
- MBFI->setBlockFreq(MBB, Freq);
+ auto NewSuccFreq = MBFI->getBlockFreq(&NewPredecessor) *
+ MBPI.getEdgeProbability(&NewPredecessor, &NewSuccessor);
+
+ MBFI->setBlockFreq(&NewSuccessor, NewSuccFreq.getFrequency());
}
const MachineFunction *MachineBlockFrequencyInfo::getFunction() const {
Index: llvm/include/llvm/CodeGen/MachineBlockFrequencyInfo.h
===================================================================
--- llvm/include/llvm/CodeGen/MachineBlockFrequencyInfo.h
+++ llvm/include/llvm/CodeGen/MachineBlockFrequencyInfo.h
@@ -74,7 +74,11 @@
bool isIrrLoopHeader(const MachineBasicBlock *MBB) const;
- void setBlockFreq(const MachineBasicBlock *MBB, uint64_t Freq);
+ /// incrementally calculate block frequencies when we split edges, to avoid
+ /// full CFG traversal.
+ void onEdgeSplit(const MachineBasicBlock &NewPredecessor,
+ const MachineBasicBlock &NewSuccessor,
+ const MachineBranchProbabilityInfo &MBPI);
const MachineFunction *getFunction() const;
const MachineBranchProbabilityInfo *getMBPI() const;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84427.281338.patch
Type: text/x-patch
Size: 2576 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200728/97038092/attachment.bin>
More information about the llvm-commits
mailing list