[llvm-branch-commits] [BOLT] Only parse probes for profiled functions in profile-write-pseudo-probes mode (PR #106365)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Aug 28 03:58:35 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-bolt
Author: Amir Ayupov (aaupov)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/106365.diff
1 Files Affected:
- (modified) bolt/lib/Rewrite/PseudoProbeRewriter.cpp (+7-3)
``````````diff
diff --git a/bolt/lib/Rewrite/PseudoProbeRewriter.cpp b/bolt/lib/Rewrite/PseudoProbeRewriter.cpp
index 228913e6ea1f39..89a7fddbb5d2af 100644
--- a/bolt/lib/Rewrite/PseudoProbeRewriter.cpp
+++ b/bolt/lib/Rewrite/PseudoProbeRewriter.cpp
@@ -72,7 +72,8 @@ class PseudoProbeRewriter final : public MetadataRewriter {
/// Parse .pseudo_probe_desc section and .pseudo_probe section
/// Setup Pseudo probe decoder
- void parsePseudoProbe();
+ /// If \p ProfiledOnly is set, only parse records for functions with profile.
+ void parsePseudoProbe(bool ProfiledOnly = false);
/// PseudoProbe decoder
std::shared_ptr<MCPseudoProbeDecoder> ProbeDecoderPtr;
@@ -92,7 +93,7 @@ class PseudoProbeRewriter final : public MetadataRewriter {
Error PseudoProbeRewriter::preCFGInitializer() {
if (opts::ProfileWritePseudoProbes)
- parsePseudoProbe();
+ parsePseudoProbe(true);
return Error::success();
}
@@ -105,7 +106,7 @@ Error PseudoProbeRewriter::postEmitFinalizer() {
return Error::success();
}
-void PseudoProbeRewriter::parsePseudoProbe() {
+void PseudoProbeRewriter::parsePseudoProbe(bool ProfiledOnly) {
MCPseudoProbeDecoder &ProbeDecoder(*ProbeDecoderPtr);
PseudoProbeDescSection = BC.getUniqueSectionByName(".pseudo_probe_desc");
PseudoProbeSection = BC.getUniqueSectionByName(".pseudo_probe");
@@ -136,6 +137,7 @@ void PseudoProbeRewriter::parsePseudoProbe() {
MCPseudoProbeDecoder::Uint64Map FuncStartAddrs;
SmallVector<StringRef, 3> Suffixes({".llvm.", ".destroy", ".resume"});
for (const BinaryFunction *F : BC.getAllBinaryFunctions()) {
+ bool HasProfile = F->hasProfileAvailable();
for (const MCSymbol *Sym : F->getSymbols()) {
StringRef SymName = NameResolver::restore(Sym->getName());
if (std::optional<StringRef> CommonName =
@@ -144,6 +146,8 @@ void PseudoProbeRewriter::parsePseudoProbe() {
}
uint64_t GUID = Function::getGUID(SymName);
FuncStartAddrs[GUID] = F->getAddress();
+ if (ProfiledOnly && HasProfile)
+ GuidFilter.insert(GUID);
}
}
Contents = PseudoProbeSection->getContents();
``````````
</details>
https://github.com/llvm/llvm-project/pull/106365
More information about the llvm-branch-commits
mailing list