LLVM  9.0.0svn
SyntheticCountsUtils.h
Go to the documentation of this file.
1 //===- SyntheticCountsUtils.h - utilities for count propagation--*- 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 // This file defines utilities for synthetic counts propagation.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_ANALYSIS_SYNTHETIC_COUNTS_UTILS_H
14 #define LLVM_ANALYSIS_SYNTHETIC_COUNTS_UTILS_H
15 
16 #include "llvm/ADT/STLExtras.h"
19 
20 namespace llvm {
21 
22 class CallGraph;
23 class Function;
24 
25 /// Class with methods to propagate synthetic entry counts.
26 ///
27 /// This class is templated on the type of the call graph and designed to work
28 /// with the traditional per-module callgraph and the summary callgraphs used in
29 /// ThinLTO. This contains only static methods and alias templates.
30 template <typename CallGraphType> class SyntheticCountsUtils {
31 public:
34  using NodeRef = typename CGT::NodeRef;
35  using EdgeRef = typename CGT::EdgeRef;
36  using SccTy = std::vector<NodeRef>;
37 
38  // Not all EdgeRef have information about the source of the edge. Hence
39  // NodeRef corresponding to the source of the EdgeRef is explicitly passed.
42 
43  static void propagate(const CallGraphType &CG, GetProfCountTy GetProfCount,
44  AddCountTy AddCount);
45 
46 private:
47  static void propagateFromSCC(const SccTy &SCC, GetProfCountTy GetProfCount,
48  AddCountTy AddCount);
49 };
50 } // namespace llvm
51 
52 #endif
This class represents lattice values for constants.
Definition: AllocatorList.h:23
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:116
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:78
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.