1 //===- bolt/Passes/MCF.h ----------------------------------------*- C++ -*-===// 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 #ifndef BOLT_PASSES_MCF_H 10 #define BOLT_PASSES_MCF_H 11 12 #include "bolt/Passes/BinaryPasses.h" 13 #include "llvm/Support/CommandLine.h" 14 15 namespace llvm { 16 namespace bolt { 17 18 class DataflowInfoManager; 19 20 /// Implement the idea in "SamplePGO - The Power of Profile Guided Optimizations 21 /// without the Usability Burden" by Diego Novillo to make basic block counts 22 /// equal if we show that A dominates B, B post-dominates A and they are in the 23 /// same loop and same loop nesting level. 24 void equalizeBBCounts(DataflowInfoManager &Info, BinaryFunction &BF); 25 26 /// Fill edge counts based on the basic block count. Used in nonLBR mode when 27 /// we only have bb count. 28 class EstimateEdgeCounts : public BinaryFunctionPass { 29 void runOnFunction(BinaryFunction &BF); 30 31 public: EstimateEdgeCounts(const cl::opt<bool> & PrintPass)32 explicit EstimateEdgeCounts(const cl::opt<bool> &PrintPass) 33 : BinaryFunctionPass(PrintPass) {} 34 getName()35 const char *getName() const override { return "estimate-edge-counts"; } 36 37 /// Pass entry point 38 Error runOnFunctions(BinaryContext &BC) override; 39 }; 40 41 } // end namespace bolt 42 } // end namespace llvm 43 44 #endif // BOLT_PASSES_MCF_H 45