@@ -88,7 +88,7 @@ MaxSamples("max-samples",
88
88
cl::cat(AggregatorCategory));
89
89
90
90
extern cl::opt<opts::ProfileFormatKind> ProfileFormat;
91
- extern cl::opt<bool > ProfileUsePseudoProbes ;
91
+ extern cl::opt<bool > ProfileWritePseudoProbes ;
92
92
extern cl::opt<std::string> SaveProfile;
93
93
94
94
cl::opt<bool > ReadPreAggregated (
@@ -2300,7 +2300,7 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
2300
2300
yaml::bolt::BinaryProfile BP;
2301
2301
2302
2302
const MCPseudoProbeDecoder *PseudoProbeDecoder =
2303
- opts::ProfileUsePseudoProbes ? BC.getPseudoProbeDecoder () : nullptr ;
2303
+ opts::ProfileWritePseudoProbes ? BC.getPseudoProbeDecoder () : nullptr ;
2304
2304
2305
2305
// Fill out the header info.
2306
2306
BP.Header .Version = 1 ;
@@ -2415,25 +2415,27 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
2415
2415
Fragments.insert (BF);
2416
2416
for (const BinaryFunction *F : Fragments) {
2417
2417
const uint64_t FuncAddr = F->getAddress ();
2418
- const auto &FragmentProbes =
2419
- llvm::make_range (ProbeMap.lower_bound (FuncAddr),
2420
- ProbeMap.lower_bound (FuncAddr + F->getSize ()));
2421
- for (const auto &[OutputAddress, Probes] : FragmentProbes) {
2418
+ for (const MCDecodedPseudoProbe &Probe :
2419
+ ProbeMap.find (FuncAddr, FuncAddr + F->getSize ())) {
2420
+ const uint32_t OutputAddress = Probe.getAddress ();
2422
2421
const uint32_t InputOffset = BAT->translate (
2423
2422
FuncAddr, OutputAddress - FuncAddr, /* IsBranchSrc=*/ true );
2424
2423
const unsigned BlockIndex = getBlock (InputOffset).second ;
2425
- for (const MCDecodedPseudoProbe &Probe : Probes)
2426
- YamlBF.Blocks [BlockIndex].PseudoProbes .emplace_back (
2427
- yaml::bolt::PseudoProbeInfo{Probe.getGuid (), Probe.getIndex (),
2428
- Probe.getType ()});
2424
+ YamlBF.Blocks [BlockIndex].PseudoProbes .emplace_back (
2425
+ yaml::bolt::PseudoProbeInfo{Probe.getGuid (), Probe.getIndex (),
2426
+ Probe.getType ()});
2429
2427
}
2430
2428
}
2431
2429
}
2432
- // Drop blocks without a hash, won't be useful for stale matching.
2433
- llvm::erase_if (YamlBF.Blocks ,
2434
- [](const yaml::bolt::BinaryBasicBlockProfile &YamlBB) {
2435
- return YamlBB.Hash == (yaml::Hex64)0 ;
2436
- });
2430
+ // Skip printing if there's no profile data
2431
+ llvm::erase_if (
2432
+ YamlBF.Blocks , [](const yaml::bolt::BinaryBasicBlockProfile &YamlBB) {
2433
+ auto HasCount = [](const auto &SI) { return SI.Count ; };
2434
+ bool HasAnyCount = YamlBB.ExecCount ||
2435
+ llvm::any_of (YamlBB.Successors , HasCount) ||
2436
+ llvm::any_of (YamlBB.CallSites , HasCount);
2437
+ return !HasAnyCount;
2438
+ });
2437
2439
BP.Functions .emplace_back (YamlBF);
2438
2440
}
2439
2441
}
0 commit comments