[llvm] [SHT_LLVM_BB_ADDR_MAP][obj2yaml] Implements PGOAnalysisMap for elf2yaml and tests. (PR #80924)
Rahman Lavaee via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 10 23:36:56 PST 2024
================
@@ -934,10 +937,39 @@ ELFDumper<ELFT>::dumpBBAddrMapSection(const Elf_Shdr *Shdr) {
uint64_t Metadata = Data.getULEB128(Cur);
BBEntries.push_back({ID, Offset, Size, Metadata});
}
+ TotalNumBlocks += BBEntries.size();
BBRanges.push_back({BaseAddress, /*NumBlocks=*/{}, BBEntries});
}
Entries.push_back(
{Version, Feature, /*NumBBRanges=*/{}, std::move(BBRanges)});
+
+ ELFYAML::PGOAnalysisMapEntry &PGOAnalysis = PGOAnalyses.emplace_back();
+ if (FeatureOrErr->hasPGOAnalysis()) {
+ FoundPGOAnalysis = true;
+
+ if (FeatureOrErr->FuncEntryCount)
+ PGOAnalysis.FuncEntryCount = Data.getULEB128(Cur);
+
+ if (FeatureOrErr->hasPGOAnalysisBBData()) {
+ auto &PGOBBEntries = PGOAnalysis.PGOBBEntries.emplace();
+ for (uint64_t BlockIndex = 0; Cur && BlockIndex < TotalNumBlocks;
+ ++BlockIndex) {
+ auto &PGOBBEntry = PGOBBEntries.emplace_back();
+ if (FeatureOrErr->BBFreq)
+ PGOBBEntry.BBFreq = Data.getULEB128(Cur);
+
+ if (FeatureOrErr->BrProb) {
+ auto &SuccEntries = PGOBBEntry.Successors.emplace();
+ uint64_t SuccCount = Data.getULEB128(Cur);
+ for (uint64_t SuccIdx = 0; SuccIdx < SuccCount; ++SuccIdx) {
----------------
rlavaee wrote:
Cur must be checked in the condition here.
https://github.com/llvm/llvm-project/pull/80924
More information about the llvm-commits
mailing list