Lines Matching full:profile
10 // reads a profile file generated by a sampling profiler (e.g. Linux Perf -
12 // profile information in the given profile.
99 #define DEBUG_TYPE "sample-profile"
103 "Number of functions inlined with context sensitive profile");
105 "Number of functions not inlined with context sensitive profile");
107 "Number of functions with CFG mismatched profile");
108 STATISTIC(NumMatchedProfile, "Number of functions with CFG matched profile");
123 "sample-profile-file", cl::init(""), cl::value_desc("filename"),
124 cl::desc("Profile file loaded by -sample-profile"), cl::Hidden);
130 "sample-profile-remapping-file", cl::init(""), cl::value_desc("filename"),
131 cl::desc("Profile remapping file loaded by -sample-profile"), cl::Hidden);
134 "salvage-stale-profile", cl::Hidden, cl::init(false),
135 cl::desc("Salvage stale profile by fuzzy matching and use the remapped "
136 "location for sample profile query."));
138 SalvageUnusedProfile("salvage-unused-profile", cl::Hidden, cl::init(false),
139 cl::desc("Salvage unused profile by matching with new "
143 "report-profile-staleness", cl::Hidden, cl::init(false),
144 cl::desc("Compute and report stale profile statistical metrics."));
147 "persist-profile-staleness", cl::Hidden, cl::init(false),
148 cl::desc("Compute stale profile statistical metrics and write it into the "
152 "profile-sample-accurate", cl::Hidden, cl::init(false),
153 cl::desc("If the sample profile is accurate, we will mark all un-sampled "
158 "profile-sample-block-accurate", cl::Hidden, cl::init(false),
159 cl::desc("If the sample profile is accurate, we will mark all un-sampled "
164 "profile-accurate-for-symsinlist", cl::Hidden, cl::init(true),
165 cl::desc("For symbols in profile symbol list, regard their profiles to "
166 "be accurate. It may be overriden by profile-sample-accurate. "));
169 "sample-profile-merge-inlinee", cl::Hidden, cl::init(true),
170 cl::desc("Merge past inlinee's profile to outline version if sample "
171 "profile loader decided not to inline a call site. It will "
172 "only be enabled when top-down order of profile loading is "
176 "sample-profile-top-down-load", cl::Hidden, cl::init(true),
177 cl::desc("Do profile annotation and inlining for functions in top-down "
178 "order of call graph during sample profile loading. It only "
185 "-sample-profile-top-down-load is on."));
188 "sample-profile-inline-size", cl::Hidden, cl::init(false),
189 cl::desc("Inline cold call sites in profile loader if it's beneficial "
199 "--sample-profile-merge-inlinee)."));
207 "sample-profile-inline-growth-limit", cl::Hidden, cl::init(12),
208 cl::desc("The size growth ratio limit for proirity-based sample profile "
212 "sample-profile-inline-limit-min", cl::Hidden, cl::init(100),
214 "proirity-based sample profile loader inlining."));
217 "sample-profile-inline-limit-max", cl::Hidden, cl::init(10000),
219 "proirity-based sample profile loader inlining."));
222 "sample-profile-hot-inline-threshold", cl::Hidden, cl::init(3000),
223 cl::desc("Hot callsite threshold for proirity-based sample profile loader "
227 "sample-profile-cold-inline-threshold", cl::Hidden, cl::init(45),
232 "sample-profile-icp-relative-hotness", cl::Hidden, cl::init(25),
235 "call promotion in proirity-based sample profile loader inlining."));
238 "sample-profile-icp-relative-hotness-skip", cl::Hidden, cl::init(1),
254 cl::desc("Reject the profile if the mismatch percent is higher than the "
258 "sample-profile-prioritized-inline", cl::Hidden,
259 cl::desc("Use call site prioritized inlining for sample profile loader."
263 "sample-profile-use-preinliner", cl::Hidden,
264 cl::desc("Use the preinliner decisions stored in profile context."));
267 "sample-profile-recursive-inline", cl::Hidden,
271 "sample-profile-remove-probe", cl::Hidden, cl::init(false),
272 cl::desc("Remove pseudo-probe after sample profile annotation."));
275 "sample-profile-inline-replay", cl::init(""), cl::value_desc("filename"),
278 "by inlining from sample profile loader."),
282 "sample-profile-inline-replay-scope",
291 "callers in remarks during sample profile inlining."),
295 "sample-profile-inline-replay-fallback",
305 cl::desc("How sample profile inline replay treats sites that don't come "
312 "sample-profile-inline-replay-format",
323 cl::desc("How sample profile inline replay file is formatted"), cl::Hidden);
326 MaxNumPromotions("sample-profile-icp-max-prom", cl::init(3), cl::Hidden,
328 "call callsite in sample profile loader"));
335 "annotate-sample-profile-inline-phase", cl::Hidden, cl::init(false),
337 "sample-profile inline pass name."));
368 // original local name. In sample profile, the suffixes of function in GUIDToFuncNameMapper()
429 // Call site distribution factor to prorate the profile samples for a
460 /// Sample profile pass.
462 /// This pass reads profile data from the file specified by
463 /// -sample-profile-file and annotates every affected function with the
464 /// profile information found in that file.
538 /// Map from function name to profile name generated by call-graph based
539 /// profile fuzzy matching(--salvage-unused-profile).
547 /// Profile tracker for different context.
559 /// used to generate the current profile.
562 /// Total number of samples collected in this profile.
584 // populated, depends on whether the profile uses MD5. Because the name table
589 // For symbol in profile symbol list, whether to regard their profiles
590 // to be accurate. It is mainly decided by existance of profile symbol
591 // list and -profile-accurate-for-symsinlist flag, but it can be
592 // overriden by -profile-sample-accurate or profile-sample-accurate
599 // A helper to implement the sample profile matching algorithm.
667 // For non-CS profile, if a direct call/invoke instruction is inlined in in getInstWeight()
668 // profile (findCalleeFunctionSamples returns non-empty result), but not in getInstWeight()
671 // For CS profile, the callsite count of previously inlined callees is in getInstWeight()
742 // For CSSPGO, we only use target context profile's entry count in findIndirectCallFunctionSamples()
799 /// If the profile count for the promotion candidate \p Candidate is
802 /// NOMORE_ICP_MAGICNUM count values in the value profile of \p Inst, we
808 // No valid value profile so no promoted targets have been recorded in doesHistoryAllowICP()
831 /// Update indirect call target profile metadata for \p Inst.
835 /// we expect to use it to update the total count in the value profile.
847 // OldSum is the existing total count in the value profile data. in updateIDTMetaData()
858 // Initialize ValueCountMap with existing value profile data. in updateIDTMetaData()
863 // If the target already exists in value profile, decrease the total in updateIDTMetaData()
872 // counts in the value profile. in updateIDTMetaData()
883 // Keep the count as NOMORE_ICP_MAGICNUM in the profile and decrease in updateIDTMetaData()
947 R->second->hasFnAttribute("use-sample-profile") && in tryPromoteAndInlineCandidate()
950 // in the value profile metadata so the target won't be promoted again. in tryPromoteAndInlineCandidate()
960 // distribution will be used to scale down non-promoted profile target in tryPromoteAndInlineCandidate()
967 // point since the original distribution combined with the callee profile in tryPromoteAndInlineCandidate()
1055 // For AutoFDO profile, retrieve candidate profiles by walking over in findExternalInlineCandidate()
1072 // For CSSPGO profile, retrieve candidate profile by walking over the in findExternalInlineCandidate()
1073 // trie built for context profile. Note that also take call targets in findExternalInlineCandidate()
1074 // even if callee doesn't have a corresponding context profile. in findExternalInlineCandidate()
1091 // profile annotation cannot be done until backend compilation in ThinLTO. in findExternalInlineCandidate()
1100 // Import hot child context profile associted with callees. Note that this in findExternalInlineCandidate()
1102 // based child context profile again effectively allow us to use the max of in findExternalInlineCandidate()
1121 /// - If a callsite is not inlined, merge the its profile to the outline
1122 /// version (if --sample-profile-merge-inlinee is true), or scale the
1123 /// counters of standalone function based on the profile of inlined
1124 /// instances (if --sample-profile-merge-inlinee is false).
1136 // Profile symbol list is ignored when profile-sample-accurate is on. in inlineHotFunctions()
1139 !F.hasFnAttribute("profile-sample-accurate"))) && in inlineHotFunctions()
1140 "ProfAccForSymsInList should be false when profile-sample-accurate " in inlineHotFunctions()
1223 // For CS profile, profile for not inlined context will be merged when in inlineHotFunctions()
1224 // base profile is being retrieved. in inlineHotFunctions()
1302 // Find the callee's profile. For indirect call, find hottest target profile. in getInlineCandidate()
1380 // stores the decision in profile, and also adjust/merge context profile in shouldInlineCandidate()
1381 // aiming at better context-sensitive post-inline profile quality, assuming in shouldInlineCandidate()
1383 // we replay that inline decision under `sample-profile-use-preinliner`. in shouldInlineCandidate()
1385 // context profile for not inlined calls are merged by preinliner already. in shouldInlineCandidate()
1397 // even if the function is hot based on sample profile data. This is to in shouldInlineCandidate()
1411 // Profile symbol list is ignored when profile-sample-accurate is on. in inlineHotFunctionsWithPriority()
1414 !F.hasFnAttribute("profile-sample-accurate"))) && in inlineHotFunctionsWithPriority()
1415 "ProfAccForSymsInList should be false when profile-sample-accurate " in inlineHotFunctionsWithPriority()
1432 // Cap the size growth from profile guided inlining. This is needed even in inlineHotFunctionsWithPriority()
1489 // Attach function profile for promoted indirect callee, and update in inlineHotFunctionsWithPriority()
1533 // For CS profile, profile for not inlined context will be merged when in inlineHotFunctionsWithPriority()
1534 // base profile is being retrieved. in inlineHotFunctionsWithPriority()
1562 // Do not merge a context that is already duplicated into the base profile. in promoteMergeNotInlinedContextSamples()
1569 // sample nested callee profile instead of slicing the original in promoteMergeNotInlinedContextSamples()
1570 // inlinee's profile. We want to do merge exactly once by filtering out in promoteMergeNotInlinedContextSamples()
1579 // This allows OutlineFS's profile to be used for annotation during in promoteMergeNotInlinedContextSamples()
1582 // If outlined function does not exist in the profile, add it to a in promoteMergeNotInlinedContextSamples()
1583 // separate map so that it does not rehash the original profile. in promoteMergeNotInlinedContextSamples()
1588 // Set outlined profile to be synthetic to not bias the inliner. in promoteMergeNotInlinedContextSamples()
1653 // original indirect call site in the profile, including both in generateMDProfMetadata()
1672 // Set profile metadata (possibly annotated by LTO prelink) to zero or in generateMDProfMetadata()
1754 // OverwriteExistingWeights. In ThinLTO, the profile annotation is done in generateMDProfMetadata()
1800 dbgs() << "Profile is invalid due to CFG mismatch for Function " in emitAnnotations()
1837 // the profile. This makes sure functions missing from the profile still in buildProfiledCallGraph()
1856 "together with -sample-profile-top-down-load.\n"; in buildFunctionOrder()
1860 // Disable ProfileMergeInlinee if profile is not loaded in top down order, in buildFunctionOrder()
1861 // because the profile for a function may be used for the profile in buildFunctionOrder()
1862 // annotation of its outline copy before the profile merging of its in buildFunctionOrder()
1882 // profile can enable the inlining of indirect call targets by allowing in buildFunctionOrder()
1886 // profile, thus may cause potential inlining to be overlooked. The in buildFunctionOrder()
1888 // on the profile to favor more inlining. This is only a problem with CS in buildFunctionOrder()
1889 // profile. in buildFunctionOrder()
1904 // to-be-dropped A, will have no profile to consume when its outlined in buildFunctionOrder()
1905 // version is compiled. This can lead to a profile-less prelink in buildFunctionOrder()
1914 // the static call graph is constructed based on profile data, where in buildFunctionOrder()
1919 // an SCC order incompatible with profile-defined one. Using strictly in buildFunctionOrder()
1920 // profile order ensures a maximum inlining experience. On the other hand, in buildFunctionOrder()
1922 // context in the profile. in buildFunctionOrder()
1961 std::string Msg = "Could not open profile: " + EC.message(); in doInitialization()
1967 // set module before reading the profile so reader may be able to only in doInitialization()
1971 std::string Msg = "profile reading failed: " + EC.message(); in doInitialization()
1978 // While profile-sample-accurate is on, ignore symbol list. in doInitialization()
2006 // Apply tweaks if context-sensitive or probe-based profile is available. in doInitialization()
2020 // For CSSPGO, we also allow recursive inline to best use context profile. in doInitialization()
2029 // Enable stale profile matching by default for probe-based profile. in doInitialization()
2040 // Non-CS profile should be fine without a function size budget for the in doInitialization()
2041 // inliner since the contexts in the profile are either all from inlining in doInitialization()
2062 "Pseudo-probe-based profile requires SampleProfileProbePass"; in doInitialization()
2092 "Only support for probe-based profile"); in rejectHighStalenessProfile()
2120 "The input profile significantly mismatches current source code. " in rejectHighStalenessProfile()
2121 "Please recollect profile to avoid performance regression."; in rejectHighStalenessProfile()
2157 // Compute the total number of samples collected in this profile. in runOnModule()
2189 // Stale profile matching. in runOnModule()
2198 "FuncNameToProfNameMap is not empty when --salvage-unused-profile is " in runOnModule()
2230 if (ProfileSampleAccurate || F.hasFnAttribute("profile-sample-accurate")) { in runOnFunction()
2232 // functions without profile will be regarded as cold. in runOnFunction()
2234 // profile-sample-accurate is a user assertion which has a higher precedence in runOnFunction()
2235 // than symbol list. When profile-sample-accurate is on, ignore symbol list. in runOnFunction()
2240 // PSL -- profile symbol list include all the symbols in sampled binary. in runOnFunction()
2252 // shows up in the profile, no matter as outline function, inline instance in runOnFunction()