//===--- SyntheticCountsUtils.cpp - synthetic counts propagation utils ---===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file defines utilities for propagating synthetic counts. // //===----------------------------------------------------------------------===// #include "llvm/Analysis/SyntheticCountsUtils.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/SCCIterator.h" #include "llvm/Analysis/CallGraph.h" #include "llvm/IR/ModuleSummaryIndex.h" usingnamespacellvm; // Given an SCC, propagate entry counts along the edge of the SCC nodes. template <typename CallGraphType> void SyntheticCountsUtils<CallGraphType>::propagateFromSCC( const SccTy &SCC, GetProfCountTy GetProfCount, AddCountTy AddCount) { … } /// Propgate synthetic entry counts on a callgraph \p CG. /// /// This performs a reverse post-order traversal of the callgraph SCC. For each /// SCC, it first propagates the entry counts to the nodes within the SCC /// through call edges and updates them in one shot. Then the entry counts are /// propagated to nodes outside the SCC. This requires \p GraphTraits /// to have a specialization for \p CallGraphType. template <typename CallGraphType> void SyntheticCountsUtils<CallGraphType>::propagate(const CallGraphType &CG, GetProfCountTy GetProfCount, AddCountTy AddCount) { … } template class llvm::SyntheticCountsUtils<const CallGraph *>; template class llvm::SyntheticCountsUtils<ModuleSummaryIndex *>;