================ @@ -433,6 +433,44 @@ using CandidateQueue = PriorityQueue<InlineCandidate, std::vector<InlineCandidate>, CandidateComparer>; +// Profile matching statstics. +class ProfileMatchStats { + const Module &M; + SampleProfileReader &Reader; + const PseudoProbeManager *ProbeManager; + +public: + ProfileMatchStats(const Module &M, SampleProfileReader &Reader, + const PseudoProbeManager *ProbeManager) + : M(M), Reader(Reader), ProbeManager(ProbeManager) {} + + uint64_t NumMismatchedCallsites = 0; + uint64_t TotalProfiledCallsites = 0; + uint64_t MismatchedCallsiteSamples = 0; + uint64_t NumMismatchedFuncHash = 0; + uint64_t TotalProfiledFunc = 0; + uint64_t MismatchedFuncHashSamples = 0; + uint64_t TotalFunctionSamples = 0; + + // A map from function name to a set of mismatched callsite locations. + StringMap<std::set<LineLocation>> FuncMismatchedCallsites; + + void countMismatchedSamples(const FunctionSamples &FS); + void countProfileMismatches( + const Function &F, const std::map<LineLocation, StringRef> &IRAnchors, + const std::map<LineLocation, std::unordered_set<FunctionId>> + &ProfileAnchors); + void countMismatchedCallsites( + const Function &F, const std::map<LineLocation, StringRef> &IRAnchors, + const std::map<LineLocation, std::unordered_set<FunctionId>> + &ProfileAnchors, + const LocToLocMap &IRToProfileLocationMap); + void countMismatchedCallsiteSamples(const FunctionSamples &FS); + void countMismatchedCallsiteSamples(); + void copyUnchangedCallsiteMismatches( + const StringMap<std::set<LineLocation>> &InputMismatchedCallsites); +}; ---------------- WenleiHe wrote:
These functions needs some comments as they are somewhat similar but with subtle differences. https://github.com/llvm/llvm-project/pull/79090 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits