Skip to content

[BOLT] Only parse probes for profiled functions in profile-write-pseudo-probes mode #106365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions bolt/lib/Rewrite/PseudoProbeRewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -92,7 +93,7 @@ class PseudoProbeRewriter final : public MetadataRewriter {

Error PseudoProbeRewriter::preCFGInitializer() {
if (opts::ProfileWritePseudoProbes)
parsePseudoProbe();
parsePseudoProbe(true);

return Error::success();
}
Expand All @@ -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");
Expand Down Expand Up @@ -137,6 +138,7 @@ void PseudoProbeRewriter::parsePseudoProbe() {
SmallVector<StringRef, 0> Suffixes(
{".destroy", ".resume", ".llvm.", ".cold", ".warm"});
for (const BinaryFunction *F : BC.getAllBinaryFunctions()) {
bool HasProfile = F->hasProfileAvailable();
for (const MCSymbol *Sym : F->getSymbols()) {
StringRef SymName = Sym->getName();
for (auto Name : {std::optional(NameResolver::restore(SymName)),
Expand All @@ -146,6 +148,8 @@ void PseudoProbeRewriter::parsePseudoProbe() {
SymName = *Name;
uint64_t GUID = Function::getGUID(SymName);
FuncStartAddrs[GUID] = F->getAddress();
if (ProfiledOnly && HasProfile)
GuidFilter.insert(GUID);
}
}
}
Expand Down
Loading