1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 04:02:41 +01:00
llvm-mirror/include/llvm/Analysis/SyntheticCountsUtils.h
Easwaran Raman 18789746d3 Remove CallGraphTraits and use equivalent methods in GraphTraits
Summary:
D42698 adds child_edge_{begin|end} and children_edges to GraphTraits
which are used here. The reason for this change is to make it easy to
use count propagation on ModulesummaryIndex. As it stands,
CallGraphTraits is in Analysis while ModuleSummaryIndex is in IR.

Reviewers: davidxl, dberlin

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D42703

llvm-svn: 323994
2018-02-01 19:40:35 +00:00

53 lines
1.8 KiB
C++

//===- SyntheticCountsUtils.h - utilities for count propagation--*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines utilities for synthetic counts propagation.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_ANALYSIS_SYNTHETIC_COUNTS_UTILS_H
#define LLVM_ANALYSIS_SYNTHETIC_COUNTS_UTILS_H
#include "llvm/ADT/STLExtras.h"
#include "llvm/Analysis/CallGraph.h"
#include "llvm/Support/ScaledNumber.h"
namespace llvm {
class CallGraph;
class Function;
/// Class with methods to propagate synthetic entry counts.
///
/// This class is templated on the type of the call graph and designed to work
/// with the traditional per-module callgraph and the summary callgraphs used in
/// ThinLTO. This contains only static methods and alias templates.
template <typename CallGraphType> class SyntheticCountsUtils {
public:
using Scaled64 = ScaledNumber<uint64_t>;
using CGT = GraphTraits<CallGraphType>;
using NodeRef = typename CGT::NodeRef;
using EdgeRef = typename CGT::EdgeRef;
using SccTy = std::vector<NodeRef>;
using GetRelBBFreqTy = function_ref<Optional<Scaled64>(EdgeRef)>;
using GetCountTy = function_ref<uint64_t(NodeRef)>;
using AddCountTy = function_ref<void(NodeRef, uint64_t)>;
static void propagate(const CallGraphType &CG, GetRelBBFreqTy GetRelBBFreq,
GetCountTy GetCount, AddCountTy AddCount);
private:
static void propagateFromSCC(const SccTy &SCC, GetRelBBFreqTy GetRelBBFreq,
GetCountTy GetCount, AddCountTy AddCount);
};
} // namespace llvm
#endif