24#define DEBUG_TYPE "sample-profile-matcher"
30 cl::desc(
"Consider a profile matches a function if the similarity of their "
31 "callee sequences is above the specified percentile."));
35 cl::desc(
"The minimum number of basic blocks required for a function to "
36 "run stale profile call graph matching."));
40 cl::desc(
"The minimum number of call anchors required for a function to "
41 "run stale profile call graph matching."));
46 "Load top-level profiles that the sample reader initially skipped for "
47 "the call-graph matching (only meaningful for extended binary "
57 cl::desc(
"The maximum number of callsites in a function, above which stale "
58 "profile matching will be skipped."));
62void SampleProfileMatcher::findIRAnchors(
const Function &
F,
67 auto FindTopLevelInlinedCallsite = [](
const DILocation *DIL) {
68 assert((DIL && DIL->getInlinedAt()) &&
"No inlined callsite");
72 DIL = DIL->getInlinedAt();
73 }
while (DIL->getInlinedAt());
77 StringRef CalleeName = PrevDIL->getSubprogramLinkageName();
78 return std::make_pair(Callsite, FunctionId(CalleeName));
81 auto GetCanonicalCalleeName = [](
const CallBase *CB) {
82 StringRef CalleeName = UnknownIndirectCallee;
83 if (Function *Callee = CB->getCalledFunction())
91 DILocation *DIL =
I.getDebugLoc();
98 if (DIL->getInlinedAt()) {
99 IRAnchors.emplace(FindTopLevelInlinedCallsite(DIL));
102 StringRef CalleeName;
106 CalleeName = GetCanonicalCalleeName(CB);
108 LineLocation Loc = LineLocation(Probe->Id, 0);
109 IRAnchors.emplace(Loc, FunctionId(CalleeName));
119 if (DIL->getInlinedAt()) {
120 IRAnchors.emplace(FindTopLevelInlinedCallsite(DIL));
125 IRAnchors.emplace(Callsite, FunctionId(CalleeName));
132void SampleProfileMatcher::findProfileAnchors(
const FunctionSamples &FS,
134 auto isInvalidLineOffset = [](uint32_t LineOffset) {
135 return LineOffset & 0x8000;
138 auto InsertAnchor = [](
const LineLocation &Loc,
const FunctionId &CalleeName,
140 auto Ret = ProfileAnchors.try_emplace(Loc, CalleeName);
144 Ret.first->second = FunctionId(UnknownIndirectCallee);
148 for (
const auto &
I :
FS.getBodySamples()) {
149 const LineLocation &Loc =
I.first;
152 for (
const auto &
C :
I.second.getCallTargets())
153 InsertAnchor(Loc,
C.first, ProfileAnchors);
156 for (
const auto &
I :
FS.getCallsiteSamples()) {
157 const LineLocation &Loc =
I.first;
160 for (
const auto &
C :
I.second)
161 InsertAnchor(Loc,
C.first, ProfileAnchors);
165bool SampleProfileMatcher::functionHasProfile(
const FunctionId &IRFuncName,
167 FuncWithoutProfile =
nullptr;
168 auto R = FunctionsWithoutProfile.find(IRFuncName);
169 if (R != FunctionsWithoutProfile.end())
170 FuncWithoutProfile =
R->second;
171 return !FuncWithoutProfile;
174bool SampleProfileMatcher::isProfileUnused(
const FunctionId &ProfileFuncName) {
175 return SymbolMap->find(ProfileFuncName) == SymbolMap->
end();
178bool SampleProfileMatcher::functionMatchesProfile(
180 bool FindMatchedProfileOnly) {
181 if (IRFuncName == ProfileFuncName)
189 if (functionHasProfile(IRFuncName, IRFunc) ||
190 !isProfileUnused(ProfileFuncName))
194 "IR function should be different from profile function to match");
195 return functionMatchesProfile(*IRFunc, ProfileFuncName,
196 FindMatchedProfileOnly);
200SampleProfileMatcher::longestCommonSequence(
const AnchorList &AnchorList1,
202 bool MatchUnusedFunction) {
205 AnchorList1, AnchorList2,
206 [&](
const FunctionId &
A,
const FunctionId &
B) {
207 return functionMatchesProfile(
212 [&](LineLocation
A, LineLocation
B) {
213 MatchedAnchors.try_emplace(
A,
B);
215 return MatchedAnchors;
218void SampleProfileMatcher::matchNonCallsiteLocs(
221 auto InsertMatching = [&](
const LineLocation &From,
const LineLocation &To) {
224 IRToProfileLocationMap.insert({From, To});
228 int32_t LocationDelta = 0;
230 for (
const auto &
IR : IRAnchors) {
231 const auto &Loc =
IR.first;
232 bool IsMatchedAnchor =
false;
234 auto R = MatchedAnchors.find(Loc);
235 if (R != MatchedAnchors.end()) {
236 const auto &Candidate =
R->second;
237 InsertMatching(Loc, Candidate);
239 <<
" is matched from " << Loc <<
" to " << Candidate
241 LocationDelta = Candidate.LineOffset - Loc.
LineOffset;
247 for (
size_t I = (LastMatchedNonAnchors.
size() + 1) / 2;
248 I < LastMatchedNonAnchors.
size();
I++) {
249 const auto &
L = LastMatchedNonAnchors[
I];
250 uint32_t CandidateLineOffset =
L.LineOffset + LocationDelta;
251 LineLocation Candidate(CandidateLineOffset,
L.Discriminator);
252 InsertMatching(L, Candidate);
254 <<
" to " << Candidate <<
"\n");
257 IsMatchedAnchor =
true;
258 LastMatchedNonAnchors.
clear();
262 if (!IsMatchedAnchor) {
263 uint32_t CandidateLineOffset = Loc.
LineOffset + LocationDelta;
264 LineLocation Candidate(CandidateLineOffset, Loc.
Discriminator);
265 InsertMatching(Loc, Candidate);
267 << Candidate <<
"\n");
275void SampleProfileMatcher::getFilteredAnchorList(
278 for (
const auto &
I : IRAnchors) {
279 if (
I.second.stringRef().empty())
281 FilteredIRAnchorsList.emplace_back(
I);
284 for (
const auto &
I : ProfileAnchors)
285 FilteredProfileAnchorList.emplace_back(
I);
305void SampleProfileMatcher::runStaleProfileMatching(
308 bool RunCFGMatching,
bool RunCGMatching) {
309 if (!RunCFGMatching && !RunCGMatching)
313 assert(IRToProfileLocationMap.empty() &&
314 "Run stale profile matching only once per function");
318 getFilteredAnchorList(IRAnchors, ProfileAnchors, FilteredIRAnchorsList,
319 FilteredProfileAnchorList);
321 if (FilteredIRAnchorsList.empty() || FilteredProfileAnchorList.empty())
327 <<
" because the number of callsites in the IR is "
328 << FilteredIRAnchorsList.size()
329 <<
" and in the profile is "
330 << FilteredProfileAnchorList.size() <<
"\n");
345 longestCommonSequence(FilteredIRAnchorsList, FilteredProfileAnchorList,
353 matchNonCallsiteLocs(MatchedAnchors, IRAnchors, IRToProfileLocationMap);
356void SampleProfileMatcher::runOnFunction(
Function &
F) {
363 const auto *FSForMatching = getFlattenedSamplesFor(
F);
366 auto R = FuncToProfileNameMap.find(&
F);
367 if (R != FuncToProfileNameMap.end()) {
368 FSForMatching = getFlattenedSamplesFor(
R->second);
372 FSForMatching = Reader.getSamplesFor(
R->second.stringRef());
382 findIRAnchors(
F, IRAnchors);
386 findProfileAnchors(*FSForMatching, ProfileAnchors);
390 recordCallsiteMatchStates(
F, IRAnchors, ProfileAnchors,
nullptr);
397 !ProbeManager->profileIsValid(
F, *FSForMatching);
398 bool RunCFGMatching =
406 F.addFnAttr(
"profile-checksum-mismatch");
410 auto &IRToProfileLocationMap = getIRToProfileLocationMap(
F);
411 runStaleProfileMatching(
F, IRAnchors, ProfileAnchors, IRToProfileLocationMap,
412 RunCFGMatching, RunCGMatching);
415 recordCallsiteMatchStates(
F, IRAnchors, ProfileAnchors,
416 &IRToProfileLocationMap);
419void SampleProfileMatcher::recordCallsiteMatchStates(
423 bool IsPostMatch = IRToProfileLocationMap !=
nullptr;
424 auto &CallsiteMatchStates =
427 auto MapIRLocToProfileLoc = [&](
const LineLocation &IRLoc) {
429 if (!IRToProfileLocationMap)
431 const auto &ProfileLoc = IRToProfileLocationMap->find(IRLoc);
432 if (ProfileLoc != IRToProfileLocationMap->end())
433 return ProfileLoc->second;
438 for (
const auto &
I : IRAnchors) {
441 const auto &ProfileLoc = MapIRLocToProfileLoc(
I.first);
442 const auto &IRCalleeId =
I.second;
443 const auto &It = ProfileAnchors.find(ProfileLoc);
444 if (It == ProfileAnchors.end())
446 const auto &ProfCalleeId = It->second;
447 if (IRCalleeId == ProfCalleeId) {
448 auto It = CallsiteMatchStates.find(ProfileLoc);
449 if (It == CallsiteMatchStates.end())
450 CallsiteMatchStates.emplace(ProfileLoc, MatchState::InitialMatch);
451 else if (IsPostMatch) {
452 if (It->second == MatchState::InitialMatch)
453 It->second = MatchState::UnchangedMatch;
454 else if (It->second == MatchState::InitialMismatch)
455 It->second = MatchState::RecoveredMismatch;
462 for (
const auto &
I : ProfileAnchors) {
463 const auto &Loc =
I.first;
464 assert(!
I.second.stringRef().empty() &&
"Callees should not be empty");
465 auto It = CallsiteMatchStates.find(Loc);
466 if (It == CallsiteMatchStates.end())
467 CallsiteMatchStates.emplace(Loc, MatchState::InitialMismatch);
468 else if (IsPostMatch) {
471 if (It->second == MatchState::InitialMismatch)
472 It->second = MatchState::UnchangedMismatch;
473 else if (It->second == MatchState::InitialMatch)
474 It->second = MatchState::RemovedMatch;
479void SampleProfileMatcher::countMismatchedFuncSamples(
const FunctionSamples &FS,
481 const auto *FuncDesc = ProbeManager->getDesc(
FS.getGUID());
486 if (ProbeManager->profileIsHashMismatched(*FuncDesc, FS)) {
488 NumStaleProfileFunc++;
493 MismatchedFunctionSamples +=
FS.getTotalSamples();
502 for (
const auto &
I :
FS.getCallsiteSamples())
503 for (
const auto &CS :
I.second)
504 countMismatchedFuncSamples(CS.second,
false);
507void SampleProfileMatcher::countMismatchedCallsiteSamples(
509 auto It = FuncCallsiteMatchStates.find(
FS.getFuncName());
511 if (It == FuncCallsiteMatchStates.end() || It->second.empty())
513 const auto &CallsiteMatchStates = It->second;
515 auto findMatchState = [&](
const LineLocation &Loc) {
516 auto It = CallsiteMatchStates.find(Loc);
517 if (It == CallsiteMatchStates.end())
518 return MatchState::Unknown;
522 auto AttributeMismatchedSamples = [&](
const enum MatchState &State,
524 if (isMismatchState(State))
525 MismatchedCallsiteSamples += Samples;
526 else if (State == MatchState::RecoveredMismatch)
527 RecoveredCallsiteSamples += Samples;
532 for (
const auto &
I :
FS.getBodySamples())
533 AttributeMismatchedSamples(findMatchState(
I.first),
I.second.getSamples());
536 for (
const auto &
I :
FS.getCallsiteSamples()) {
537 auto State = findMatchState(
I.first);
538 uint64_t CallsiteSamples = 0;
539 for (
const auto &CS :
I.second)
540 CallsiteSamples += CS.second.getTotalSamples();
541 AttributeMismatchedSamples(State, CallsiteSamples);
543 if (isMismatchState(State))
549 for (
const auto &CS :
I.second)
550 countMismatchedCallsiteSamples(CS.second);
554void SampleProfileMatcher::countMismatchCallsites(
const FunctionSamples &FS) {
555 auto It = FuncCallsiteMatchStates.find(
FS.getFuncName());
557 if (It == FuncCallsiteMatchStates.end() || It->second.empty())
559 const auto &MatchStates = It->second;
560 [[maybe_unused]]
bool OnInitialState =
561 isInitialState(MatchStates.begin()->second);
562 for (
const auto &
I : MatchStates) {
563 TotalProfiledCallsites++;
565 (OnInitialState ? isInitialState(
I.second) : isFinalState(
I.second)) &&
566 "Profile matching state is inconsistent");
568 if (isMismatchState(
I.second))
569 NumMismatchedCallsites++;
570 else if (
I.second == MatchState::RecoveredMismatch)
571 NumRecoveredCallsites++;
575void SampleProfileMatcher::countCallGraphRecoveredSamples(
577 std::unordered_set<FunctionId> &CallGraphRecoveredProfiles) {
578 if (CallGraphRecoveredProfiles.count(
FS.getFunction())) {
579 NumCallGraphRecoveredFuncSamples +=
FS.getTotalSamples();
583 for (
const auto &CM :
FS.getCallsiteSamples()) {
584 for (
const auto &CS : CM.second) {
585 countCallGraphRecoveredSamples(CS.second, CallGraphRecoveredProfiles);
590void SampleProfileMatcher::computeAndReportProfileStaleness() {
594 std::unordered_set<FunctionId> CallGraphRecoveredProfiles;
596 for (
const auto &
I : FuncToProfileNameMap) {
597 CallGraphRecoveredProfiles.insert(
I.second);
600 NumCallGraphRecoveredProfiledFunc++;
605 for (
const auto &
F : M) {
612 const auto *
FS = Reader.getSamplesFor(
F);
616 TotalFunctionSamples +=
FS->getTotalSamples();
619 countCallGraphRecoveredSamples(*FS, CallGraphRecoveredProfiles);
623 countMismatchedFuncSamples(*FS,
true);
626 countMismatchCallsites(*FS);
627 countMismatchedCallsiteSamples(*FS);
632 errs() <<
"(" << NumStaleProfileFunc <<
"/" << TotalProfiledFunc
633 <<
") of functions' profile are invalid and ("
634 << MismatchedFunctionSamples <<
"/" << TotalFunctionSamples
635 <<
") of samples are discarded due to function hash mismatch.\n";
638 errs() <<
"(" << NumCallGraphRecoveredProfiledFunc <<
"/"
639 << TotalProfiledFunc <<
") of functions' profile are matched and ("
640 << NumCallGraphRecoveredFuncSamples <<
"/" << TotalFunctionSamples
641 <<
") of samples are reused by call graph matching.\n";
644 errs() <<
"(" << (NumMismatchedCallsites + NumRecoveredCallsites) <<
"/"
645 << TotalProfiledCallsites
646 <<
") of callsites' profile are invalid and ("
647 << (MismatchedCallsiteSamples + RecoveredCallsiteSamples) <<
"/"
648 << TotalFunctionSamples
649 <<
") of samples are discarded due to callsite location mismatch.\n";
650 errs() <<
"(" << NumRecoveredCallsites <<
"/"
651 << (NumRecoveredCallsites + NumMismatchedCallsites)
652 <<
") of callsites and (" << RecoveredCallsiteSamples <<
"/"
653 << (RecoveredCallsiteSamples + MismatchedCallsiteSamples)
654 <<
") of samples are recovered by stale profile matching.\n";
658 LLVMContext &Ctx = M.getContext();
663 ProfStatsVec.
emplace_back(
"NumStaleProfileFunc", NumStaleProfileFunc);
664 ProfStatsVec.
emplace_back(
"TotalProfiledFunc", TotalProfiledFunc);
666 MismatchedFunctionSamples);
667 ProfStatsVec.
emplace_back(
"TotalFunctionSamples", TotalFunctionSamples);
671 ProfStatsVec.
emplace_back(
"NumCallGraphRecoveredProfiledFunc",
672 NumCallGraphRecoveredProfiledFunc);
673 ProfStatsVec.
emplace_back(
"NumCallGraphRecoveredFuncSamples",
674 NumCallGraphRecoveredFuncSamples);
677 ProfStatsVec.
emplace_back(
"NumMismatchedCallsites", NumMismatchedCallsites);
678 ProfStatsVec.
emplace_back(
"NumRecoveredCallsites", NumRecoveredCallsites);
679 ProfStatsVec.
emplace_back(
"TotalProfiledCallsites", TotalProfiledCallsites);
681 MismatchedCallsiteSamples);
683 RecoveredCallsiteSamples);
685 auto *MD = MDB.createLLVMStats(ProfStatsVec);
686 auto *NMD = M.getOrInsertNamedMetadata(
"llvm.stats");
691void SampleProfileMatcher::findFunctionsWithoutProfile() {
695 StringSet<> NamesInProfile;
696 if (
auto NameTable = Reader.getNameTable()) {
697 for (
auto Name : *NameTable)
704 if (
F.isDeclaration())
708 const auto *
FS = getFlattenedSamplesFor(
F);
715 if (NamesInProfile.
count(CanonFName))
720 if (PSL && PSL->contains(CanonFName))
724 <<
" is not in profile or profile symbol list.\n");
725 FunctionsWithoutProfile[FunctionId(CanonFName)] = &
F;
729bool SampleProfileMatcher::functionMatchesProfileHelper(
733 float Similarity = 0.0;
740 auto GetBaseName = [&](StringRef FName) {
741 auto FunctionName = FName.str();
742 if (
Demangler.partialDemangle(FunctionName.c_str()))
743 return std::string();
744 size_t BaseNameSize = 0;
748 char *BaseNamePtr =
Demangler.getFunctionBaseName(
nullptr, &BaseNameSize);
749 std::string
Result = (BaseNamePtr && BaseNameSize)
750 ? std::string(BaseNamePtr, BaseNameSize)
755 auto IRBaseName = GetBaseName(IRFunc.
getName());
756 auto ProfBaseName = GetBaseName(ProfFunc.
stringRef());
757 if (!IRBaseName.empty() && IRBaseName == ProfBaseName) {
759 << ProfFunc <<
"(Profile) share the same base name: "
760 << IRBaseName <<
".\n");
764 const auto *FSForMatching = getFlattenedSamplesFor(ProfFunc);
771 DenseSet<StringRef> TopLevelFunc({ProfFunc.
stringRef()});
772 if (std::error_code EC = Reader.read(TopLevelFunc))
774 FSForMatching = Reader.getSamplesFor(ProfFunc.
stringRef());
777 dbgs() <<
"Read top-level function " << ProfFunc
778 <<
" for call-graph matching\n";
793 const auto *FuncDesc = ProbeManager->getDesc(IRFunc);
795 !ProbeManager->profileIsHashMismatched(*FuncDesc, *FSForMatching)) {
797 <<
"(IR) and " << ProfFunc <<
"(Profile) match.\n");
804 findIRAnchors(IRFunc, IRAnchors);
806 findProfileAnchors(*FSForMatching, ProfileAnchors);
810 getFilteredAnchorList(IRAnchors, ProfileAnchors, FilteredIRAnchorsList,
811 FilteredProfileAnchorList);
824 longestCommonSequence(FilteredIRAnchorsList, FilteredProfileAnchorList,
827 Similarity =
static_cast<float>(MatchedAnchors.size()) /
828 FilteredProfileAnchorList.size();
831 <<
"(IR) and " << ProfFunc <<
"(profile) is "
832 <<
format(
"%.2f", Similarity) <<
"\n");
833 assert((Similarity >= 0 && Similarity <= 1.0) &&
834 "Similarity value should be in [0, 1]");
840bool SampleProfileMatcher::functionMatchesProfile(
Function &IRFunc,
842 bool FindMatchedProfileOnly) {
843 auto R = FuncProfileMatchCache.find({&IRFunc, ProfFunc});
844 if (R != FuncProfileMatchCache.end())
847 if (FindMatchedProfileOnly)
850 bool Matched = functionMatchesProfileHelper(IRFunc, ProfFunc);
851 FuncProfileMatchCache[{&IRFunc, ProfFunc}] = Matched;
853 FuncToProfileNameMap[&IRFunc] = ProfFunc;
855 <<
" matches profile:" << ProfFunc <<
"\n");
861void SampleProfileMatcher::UpdateWithSalvagedProfiles() {
862 DenseSet<StringRef> ProfileSalvagedFuncs;
864 for (
auto &
I : FuncToProfileNameMap) {
865 assert(
I.first &&
"New function is null");
866 FunctionId FuncName(
I.first->getName());
867 ProfileSalvagedFuncs.
insert(
I.second.stringRef());
868 FuncNameToProfNameMap->emplace(FuncName,
I.second);
872 SymbolMap->erase(FuncName);
873 SymbolMap->emplace(
I.second,
I.first);
880 Reader.read(ProfileSalvagedFuncs);
881 Reader.setFuncNameToProfNameMap(*FuncNameToProfNameMap);
888 findFunctionsWithoutProfile();
892 std::vector<Function *> TopDownFunctionList;
893 TopDownFunctionList.reserve(M.size());
895 for (
auto *
F : TopDownFunctionList) {
902 UpdateWithSalvagedProfiles();
905 distributeIRToProfileLocationMap();
907 computeAndReportProfileStaleness();
910void SampleProfileMatcher::distributeIRToProfileLocationMap(
912 const auto ProfileMappings = FuncMappings.
find(FS.getFuncName());
913 if (ProfileMappings != FuncMappings.
end()) {
914 FS.setIRToProfileLocationMap(&(ProfileMappings->second));
919 for (
auto &FS : Callees.second) {
920 distributeIRToProfileLocationMap(FS.second);
927void SampleProfileMatcher::distributeIRToProfileLocationMap() {
928 for (
auto &
I : Reader.getProfiles()) {
929 distributeIRToProfileLocationMap(
I.second);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
itanium_demangle::ManglingParser< DefaultAllocator > Demangler
Legalize the Machine IR a function s Machine IR
This file provides the interface for SampleProfileMatcher.
static bool isAvailableExternallyLinkage(LinkageTypes Linkage)
reference emplace_back(ArgTypes &&... Args)
iterator find(StringRef Key)
size_type count(StringRef Key) const
count - Return 1 if the element is in the map, 0 otherwise.
std::pair< typename Base::iterator, bool > insert(StringRef key)
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
std::pair< iterator, bool > insert(const ValueT &V)
This class represents a function that is read from a sample profile.
StringRef stringRef() const
Convert to StringRef.
Representation of the samples collected for a function.
static LLVM_ABI bool ProfileIsCS
static LLVM_ABI bool ProfileIsProbeBased
static StringRef getCanonicalFnName(const Function &F)
Return the canonical name for a function, taking into account suffix elision policy attributes.
static LLVM_ABI bool ProfileIsFS
If this profile uses flow sensitive discriminators.
static LLVM_ABI LineLocation getCallSiteIdentifier(const DILocation *DIL, bool ProfileIsFS=false)
Returns a unique call site identifier for a given debug location of a call instruction.
static LLVM_ABI bool UseMD5
Whether the profile uses MD5 to represent string.
static void flattenProfile(SampleProfileMap &ProfileMap, bool ProfileIsCS=false)
@ C
The default llvm calling convention, compatible with C.
initializer< Ty > init(const Ty &Val)
std::map< LineLocation, FunctionSamplesMap > CallsiteSampleMap
std::unordered_map< LineLocation, LineLocation, LineLocationHash > LocToLocMap
This is an optimization pass for GlobalISel generic memory operations.
cl::opt< bool > ReportProfileStaleness("report-profile-staleness", cl::Hidden, cl::init(false), cl::desc("Compute and report stale profile statistical metrics."))
cl::opt< bool > PersistProfileStaleness("persist-profile-staleness", cl::Hidden, cl::init(false), cl::desc("Compute stale profile statistical metrics and write it into the " "native object file(.llvm_stats section)."))
std::map< LineLocation, FunctionId > AnchorMap
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
static cl::opt< bool > LoadFuncProfileforCGMatching("load-func-profile-for-cg-matching", cl::Hidden, cl::init(true), cl::desc("Load top-level profiles that the sample reader initially skipped for " "the call-graph matching (only meaningful for extended binary " "format)"))
static void buildTopDownFuncOrder(LazyCallGraph &CG, std::vector< Function * > &FunctionOrderList)
@ ThinLTOPreLink
ThinLTO prelink (summary) phase.
static cl::opt< unsigned > MinCallCountForCGMatching("min-call-count-for-cg-matching", cl::Hidden, cl::init(3), cl::desc("The minimum number of call anchors required for a function to " "run stale profile call graph matching."))
LLVM_ABI std::optional< PseudoProbe > extractProbe(const Instruction &Inst)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
static cl::opt< unsigned > MinFuncCountForCGMatching("min-func-count-for-cg-matching", cl::Hidden, cl::init(5), cl::desc("The minimum number of basic blocks required for a function to " "run stale profile call graph matching."))
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
cl::opt< bool > SalvageStaleProfile("salvage-stale-profile", cl::Hidden, cl::init(false), cl::desc("Salvage stale profile by fuzzy matching and use the remapped " "location for sample profile query."))
void longestCommonSequence(AnchorList AnchorList1, AnchorList AnchorList2, llvm::function_ref< bool(const Function &, const Function &)> FunctionMatchesProfile, llvm::function_ref< void(Loc, Loc)> InsertMatching)
std::vector< std::pair< LineLocation, FunctionId > > AnchorList
static bool skipProfileForFunction(const Function &F)
cl::opt< bool > SalvageUnusedProfile("salvage-unused-profile", cl::Hidden, cl::init(false), cl::desc("Salvage unused profile by matching with new " "functions on call graph."))
static cl::opt< unsigned > SalvageStaleProfileMaxCallsites("salvage-stale-profile-max-callsites", cl::Hidden, cl::init(UINT_MAX), cl::desc("The maximum number of callsites in a function, above which stale " "profile matching will be skipped."))
static cl::opt< unsigned > FuncProfileSimilarityThreshold("func-profile-similarity-threshold", cl::Hidden, cl::init(80), cl::desc("Consider a profile matches a function if the similarity of their " "callee sequences is above the specified percentile."))