diff options
Diffstat (limited to 'llvm/lib/Analysis/SyntheticCountsUtils.cpp')
-rw-r--r-- | llvm/lib/Analysis/SyntheticCountsUtils.cpp | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/llvm/lib/Analysis/SyntheticCountsUtils.cpp b/llvm/lib/Analysis/SyntheticCountsUtils.cpp index 386396bcff3..c2d7bb11a4c 100644 --- a/llvm/lib/Analysis/SyntheticCountsUtils.cpp +++ b/llvm/lib/Analysis/SyntheticCountsUtils.cpp @@ -26,8 +26,7 @@ using namespace llvm; // Given an SCC, propagate entry counts along the edge of the SCC nodes. template <typename CallGraphType> void SyntheticCountsUtils<CallGraphType>::propagateFromSCC( - const SccTy &SCC, GetRelBBFreqTy GetRelBBFreq, GetCountTy GetCount, - AddCountTy AddCount) { + const SccTy &SCC, GetProfCountTy GetProfCount, AddCountTy AddCount) { DenseSet<NodeRef> SCCNodes; SmallVector<std::pair<NodeRef, EdgeRef>, 8> SCCEdges, NonSCCEdges; @@ -54,17 +53,13 @@ void SyntheticCountsUtils<CallGraphType>::propagateFromSCC( // This ensures that the order of // traversal of nodes within the SCC doesn't affect the final result. - DenseMap<NodeRef, uint64_t> AdditionalCounts; + DenseMap<NodeRef, Scaled64> AdditionalCounts; for (auto &E : SCCEdges) { - auto OptRelFreq = GetRelBBFreq(E.second); - if (!OptRelFreq) + auto OptProfCount = GetProfCount(E.first, E.second); + if (!OptProfCount) continue; - Scaled64 RelFreq = OptRelFreq.getValue(); - auto Caller = E.first; auto Callee = CGT::edge_dest(E.second); - RelFreq *= Scaled64(GetCount(Caller), 0); - uint64_t AdditionalCount = RelFreq.toInt<uint64_t>(); - AdditionalCounts[Callee] += AdditionalCount; + AdditionalCounts[Callee] += OptProfCount.getValue(); } // Update the counts for the nodes in the SCC. @@ -73,14 +68,11 @@ void SyntheticCountsUtils<CallGraphType>::propagateFromSCC( // Now update the counts for nodes outside the SCC. for (auto &E : NonSCCEdges) { - auto OptRelFreq = GetRelBBFreq(E.second); - if (!OptRelFreq) + auto OptProfCount = GetProfCount(E.first, E.second); + if (!OptProfCount) continue; - Scaled64 RelFreq = OptRelFreq.getValue(); - auto Caller = E.first; auto Callee = CGT::edge_dest(E.second); - RelFreq *= Scaled64(GetCount(Caller), 0); - AddCount(Callee, RelFreq.toInt<uint64_t>()); + AddCount(Callee, OptProfCount.getValue()); } } @@ -94,8 +86,7 @@ void SyntheticCountsUtils<CallGraphType>::propagateFromSCC( template <typename CallGraphType> void SyntheticCountsUtils<CallGraphType>::propagate(const CallGraphType &CG, - GetRelBBFreqTy GetRelBBFreq, - GetCountTy GetCount, + GetProfCountTy GetProfCount, AddCountTy AddCount) { std::vector<SccTy> SCCs; @@ -107,7 +98,7 @@ void SyntheticCountsUtils<CallGraphType>::propagate(const CallGraphType &CG, // The scc iterator returns the scc in bottom-up order, so reverse the SCCs // and call propagateFromSCC. for (auto &SCC : reverse(SCCs)) - propagateFromSCC(SCC, GetRelBBFreq, GetCount, AddCount); + propagateFromSCC(SCC, GetProfCount, AddCount); } template class llvm::SyntheticCountsUtils<const CallGraph *>; |