diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2021-02-16 20:13:02 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2021-02-16 20:13:02 +0000 |
| commit | b60736ec1405bb0a8dd40989f67ef4c93da068ab (patch) | |
| tree | 5c43fbb7c9fc45f0f87e0e6795a86267dbd12f9d /llvm/lib/CodeGen/MBFIWrapper.cpp | |
| parent | cfca06d7963fa0909f90483b42a6d7d194d01e08 (diff) | |
Diffstat (limited to 'llvm/lib/CodeGen/MBFIWrapper.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/MBFIWrapper.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MBFIWrapper.cpp b/llvm/lib/CodeGen/MBFIWrapper.cpp index 5110f75ebb42..4755defec793 100644 --- a/llvm/lib/CodeGen/MBFIWrapper.cpp +++ b/llvm/lib/CodeGen/MBFIWrapper.cpp @@ -30,6 +30,18 @@ void MBFIWrapper::setBlockFreq(const MachineBasicBlock *MBB, 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)); |
