LLVM  8.0.1
SyntheticCountsUtils.h
Go to the documentation of this file.
1 //===- SyntheticCountsUtils.h - utilities for count propagation--*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines utilities for synthetic counts propagation.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_ANALYSIS_SYNTHETIC_COUNTS_UTILS_H
15 #define LLVM_ANALYSIS_SYNTHETIC_COUNTS_UTILS_H
16 
17 #include "llvm/ADT/STLExtras.h"
20 
21 namespace llvm {
22 
23 class CallGraph;
24 class Function;
25 
26 /// Class with methods to propagate synthetic entry counts.
27 ///
28 /// This class is templated on the type of the call graph and designed to work
29 /// with the traditional per-module callgraph and the summary callgraphs used in
30 /// ThinLTO. This contains only static methods and alias templates.
31 template <typename CallGraphType> class SyntheticCountsUtils {
32 public:
35  using NodeRef = typename CGT::NodeRef;
36  using EdgeRef = typename CGT::EdgeRef;
37  using SccTy = std::vector<NodeRef>;
38 
39  // Not all EdgeRef have information about the source of the edge. Hence
40  // NodeRef corresponding to the source of the EdgeRef is explicitly passed.
43 
44  static void propagate(const CallGraphType &CG, GetProfCountTy GetProfCount,
45  AddCountTy AddCount);
46 
47 private:
48  static void propagateFromSCC(const SccTy &SCC, GetProfCountTy GetProfCount,
49  AddCountTy AddCount);
50 };
51 } // namespace llvm
52 
53 #endif
This class represents lattice values for constants.
Definition: AllocatorList.h:24
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:117
This file provides interfaces used to build and manipulate a call graph, which is a very useful tool ...
typename GraphType::UnknownGraphTypeError NodeRef
Definition: GraphTraits.h:79
static void propagate(const CallGraphType &CG, GetProfCountTy GetProfCount, AddCountTy AddCount)
Propgate synthetic entry counts on a callgraph CG.
std::vector< NodeRef > SccTy
typename CGT::EdgeRef EdgeRef
typename CGT::NodeRef NodeRef
Class with methods to propagate synthetic entry counts.