27 template <
typename CallGraphType>
29 const SccTy &SCC, GetRelBBFreqTy GetRelBBFreq, GetCountTy GetCount,
30 AddCountTy AddCount) {
35 for (
auto &Node : SCC)
40 for (
const auto &Node : SCCNodes) {
41 for (
auto &
E : children_edges<CallGraphType>(Node)) {
42 if (SCCNodes.count(CGT::edge_dest(
E)))
58 for (
auto &
E : SCCEdges) {
59 auto OptRelFreq = GetRelBBFreq(
E.second);
62 Scaled64 RelFreq = OptRelFreq.getValue();
63 auto Caller =
E.first;
64 auto Callee = CGT::edge_dest(
E.second);
65 RelFreq *=
Scaled64(GetCount(Caller), 0);
66 uint64_t AdditionalCount = RelFreq.
toInt<uint64_t>();
67 AdditionalCounts[
Callee] += AdditionalCount;
71 for (
auto &Entry : AdditionalCounts)
72 AddCount(Entry.first, Entry.second);
75 for (
auto &
E : NonSCCEdges) {
76 auto OptRelFreq = GetRelBBFreq(
E.second);
79 Scaled64 RelFreq = OptRelFreq.getValue();
80 auto Caller =
E.first;
81 auto Callee = CGT::edge_dest(
E.second);
82 RelFreq *=
Scaled64(GetCount(Caller), 0);
95 template <
typename CallGraphType>
100 std::vector<SccTy> SCCs;
109 for (
auto &SCC :
reverse(SCCs))
110 propagateFromSCC(SCC, GetRelBBFreq, GetCount, AddCount);
This builds on the llvm/ADT/GraphTraits.h file to find the strongly connected components (SCCs) of a ...
Compute iterated dominance frontiers using a linear time algorithm.
An efficient, type-erasing, non-owning reference to a callable.
static void propagate(const CallGraphType &CG, GetRelBBFreqTy GetRelBBFreq, GetCountTy GetCount, AddCountTy AddCount)
Propgate synthetic entry counts on a callgraph CG.
scc_iterator< T > scc_begin(const T &G)
Construct the begin iterator for a deduced graph type T.
auto reverse(ContainerTy &&C, typename std::enable_if< has_rbegin< ContainerTy >::value >::type *=nullptr) -> decltype(make_range(C.rbegin(), C.rend()))
This file provides interfaces used to build and manipulate a call graph, which is a very useful tool ...
amdgpu Simplify well known AMD library false Value * Callee
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
IntT toInt() const
Convert to the given integer type.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
void emplace_back(ArgTypes &&... Args)
ScaledNumber< uint64_t > Scaled64
Class with methods to propagate synthetic entry counts.