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/CodeGen/MBFIWrapper.h" 15#include "llvm/CodeGen/MachineBlockFrequencyInfo.h" 16 17using namespace llvm; 18 19BlockFrequency MBFIWrapper::getBlockFreq(const MachineBasicBlock *MBB) const { 20 auto I = MergedBBFreq.find(MBB); 21 22 if (I != MergedBBFreq.end()) 23 return I->second; 24 25 return MBFI.getBlockFreq(MBB); 26} 27 28void MBFIWrapper::setBlockFreq(const MachineBasicBlock *MBB, 29 BlockFrequency F) { 30 MergedBBFreq[MBB] = F; 31} 32 33raw_ostream & MBFIWrapper::printBlockFreq(raw_ostream &OS, 34 const MachineBasicBlock *MBB) const { 35 return MBFI.printBlockFreq(OS, getBlockFreq(MBB)); 36} 37 38raw_ostream & MBFIWrapper::printBlockFreq(raw_ostream &OS, 39 const BlockFrequency Freq) const { 40 return MBFI.printBlockFreq(OS, Freq); 41} 42 43void MBFIWrapper::view(const Twine &Name, bool isSimple) { 44 MBFI.view(Name, isSimple); 45} 46 47uint64_t MBFIWrapper::getEntryFreq() const { 48 return MBFI.getEntryFreq(); 49} 50