[PATCH] D131918: [BOLT][NFC] Extend debug logging in analyzeJumpTable

Amir Ayupov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 15 13:34:12 PDT 2022


Amir updated this revision to Diff 452793.
Amir added a comment.

JTT


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131918/new/

https://reviews.llvm.org/D131918

Files:
  bolt/lib/Core/BinaryContext.cpp


Index: bolt/lib/Core/BinaryContext.cpp
===================================================================
--- bolt/lib/Core/BinaryContext.cpp
+++ bolt/lib/Core/BinaryContext.cpp
@@ -538,8 +538,12 @@
   if (NextJTAddress)
     UpperBound = std::min(NextJTAddress, UpperBound);
 
-  LLVM_DEBUG(dbgs() << "BOLT-DEBUG: analyzeJumpTable in " << BF.getPrintName()
-                    << '\n');
+  LLVM_DEBUG({
+    using JTT = JumpTable::JumpTableType;
+    dbgs() << formatv("BOLT-DEBUG: analyzeJumpTable @{0:x} in {1}, JTT={2}\n",
+                      Address, BF.getPrintName(),
+                      Type == JTT::JTT_PIC ? "PIC" : "Normal");
+  });
   const uint64_t EntrySize = getJumpTableEntrySize(Type);
   for (uint64_t EntryAddress = Address; EntryAddress <= UpperBound - EntrySize;
        EntryAddress += EntrySize) {
@@ -570,7 +574,7 @@
     if (Value == BF.getAddress() + BF.getSize()) {
       addEntryAddress(Value);
       HasUnreachable = true;
-      LLVM_DEBUG(dbgs() << "OK: __builtin_unreachable\n");
+      LLVM_DEBUG(dbgs() << formatv("OK: {0:x} __builtin_unreachable\n", Value));
       continue;
     }
 
@@ -585,12 +589,12 @@
           if (TargetBF) {
             dbgs() << "  ! function containing this address: "
                    << TargetBF->getPrintName() << '\n';
-            if (TargetBF->isFragment())
-              dbgs() << "  ! is a fragment\n";
-            for (BinaryFunction *TargetParent : TargetBF->ParentFragments)
-              dbgs() << "  ! its parent is "
-                     << (TargetParent ? TargetParent->getPrintName() : "(none)")
-                     << '\n';
+            if (TargetBF->isFragment()) {
+              dbgs() << "  ! is a fragment";
+              for (BinaryFunction *Parent : TargetBF->ParentFragments)
+                dbgs() << ", parent: " << Parent->getPrintName();
+              dbgs() << '\n';
+            }
           }
         }
         if (Value == BF.getAddress())
@@ -602,11 +606,12 @@
     // Check there's an instruction at this offset.
     if (TargetBF->getState() == BinaryFunction::State::Disassembled &&
         !TargetBF->getInstructionAtOffset(Value - TargetBF->getAddress())) {
-      LLVM_DEBUG(dbgs() << "FAIL: no instruction at this offset\n");
+      LLVM_DEBUG(dbgs() << formatv("FAIL: no instruction at {0:x}\n", Value));
       break;
     }
 
     ++NumRealEntries;
+    LLVM_DEBUG(dbgs() << formatv("OK: {0:x} real entry\n", Value));
 
     if (TargetBF != &BF)
       BF.setHasIndirectTargetToSplitFragment(true);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131918.452793.patch
Type: text/x-patch
Size: 2532 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220815/5e4b0eef/attachment.bin>


More information about the llvm-commits mailing list