[llvm] [llvm-objdump] Add support for symbolizing PGOBBAddrMap Info (PR #76386)

Micah Weston via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 5 13:36:25 PST 2024


================
@@ -1638,18 +1685,27 @@ disassembleObject(ObjectFile &Obj, const ObjectFile &DbgObj,
   LLVM_DEBUG(LVP.dump());
 
   std::unordered_map<uint64_t, BBAddrMap> AddrToBBAddrMap;
+  std::unordered_map<uint64_t, PGOAnalysisMap> AddrToPGOBBAddrMap;
   auto ReadBBAddrMap = [&](std::optional<unsigned> SectionIndex =
                                std::nullopt) {
     AddrToBBAddrMap.clear();
     if (const auto *Elf = dyn_cast<ELFObjectFileBase>(&Obj)) {
-      auto BBAddrMapsOrErr = Elf->readBBAddrMap(SectionIndex);
+      std::vector<PGOAnalysisMap> PGOAnalyses;
+      auto BBAddrMapsOrErr = Elf->readBBAddrMap(SectionIndex, &PGOAnalyses);
       if (!BBAddrMapsOrErr) {
         reportWarning(toString(BBAddrMapsOrErr.takeError()), Obj.getFileName());
         return;
       }
       for (auto &FunctionBBAddrMap : *BBAddrMapsOrErr)
         AddrToBBAddrMap.emplace(FunctionBBAddrMap.Addr,
                                 std::move(FunctionBBAddrMap));
+      for (size_t I = 0; I < (*BBAddrMapsOrErr).size(); ++I) {
+        AddrToBBAddrMap.emplace((*BBAddrMapsOrErr)[I].Addr,
+                                std::move((*BBAddrMapsOrErr)[I]));
+        if (PGOAnalyses.size() > 0)
+          AddrToPGOBBAddrMap.emplace((*BBAddrMapsOrErr)[I].Addr,
----------------
red1bluelost wrote:

Careful, you are using a value that was just moved out of two lines earlier. Save Addr before moving.

https://github.com/llvm/llvm-project/pull/76386


More information about the llvm-commits mailing list