[BOLT][NFC] Fix debug messages
authorAmir Ayupov <aaupov@fb.com>
Tue, 6 Jun 2023 22:49:00 +0000 (15:49 -0700)
committerAmir Ayupov <aaupov@fb.com>
Tue, 6 Jun 2023 22:50:58 +0000 (15:50 -0700)
Fix debug printing, making it easier to compare two debug logs side by side:
- `BinaryFunction::addRelocation`: print function name instead of `this` ptr,
- `DataAggregator::doTrace`: remove duplicated function name.

Reviewed By: #bolt, maksfb

Differential Revision: https://reviews.llvm.org/D152314

bolt/lib/Core/BinaryFunction.cpp
bolt/lib/Profile/DataAggregator.cpp

index 47c6b7eddaf8376f09c6270a6679710bcea7ebd3..cef35f1934612c7cdd5615edd3ed7f65270ed6c4 100644 (file)
@@ -4509,7 +4509,7 @@ void BinaryFunction::addRelocation(uint64_t Address, MCSymbol *Symbol,
          "address is outside of the function");
   uint64_t Offset = Address - getAddress();
   LLVM_DEBUG(dbgs() << "BOLT-DEBUG: addRelocation in "
-                    << formatv("{0}@{1:x} against {2}\n", this, Offset,
+                    << formatv("{0}@{1:x} against {2}\n", *this, Offset,
                                Symbol->getName()));
   bool IsCI = BC.isAArch64() && isInConstantIsland(Address);
   std::map<uint64_t, Relocation> &Rels =
index a61ca1be65dc49e5d08d53d485d5bc812d7a2db6..22bb9b73e6e7320b3a202f7df52f5e63fab58630 100644 (file)
@@ -791,23 +791,23 @@ bool DataAggregator::doTrace(const LBREntry &First, const LBREntry &Second,
   BinaryFunction *FromFunc = getBinaryFunctionContainingAddress(First.To);
   BinaryFunction *ToFunc = getBinaryFunctionContainingAddress(Second.From);
   if (!FromFunc || !ToFunc) {
-    LLVM_DEBUG(
-        dbgs() << "Out of range trace starting in " << FromFunc->getPrintName()
-               << " @ " << Twine::utohexstr(First.To - FromFunc->getAddress())
-               << " and ending in " << ToFunc->getPrintName() << " @ "
-               << ToFunc->getPrintName() << " @ "
-               << Twine::utohexstr(Second.From - ToFunc->getAddress()) << '\n');
+    LLVM_DEBUG({
+      dbgs() << "Out of range trace starting in " << FromFunc->getPrintName()
+             << formatv(" @ {0:x}", First.To - FromFunc->getAddress())
+             << " and ending in " << ToFunc->getPrintName()
+             << formatv(" @ {0:x}\n", Second.From - ToFunc->getAddress());
+    });
     NumLongRangeTraces += Count;
     return false;
   }
   if (FromFunc != ToFunc) {
     NumInvalidTraces += Count;
-    LLVM_DEBUG(
-        dbgs() << "Invalid trace starting in " << FromFunc->getPrintName()
-               << " @ " << Twine::utohexstr(First.To - FromFunc->getAddress())
-               << " and ending in " << ToFunc->getPrintName() << " @ "
-               << ToFunc->getPrintName() << " @ "
-               << Twine::utohexstr(Second.From - ToFunc->getAddress()) << '\n');
+    LLVM_DEBUG({
+      dbgs() << "Invalid trace starting in " << FromFunc->getPrintName()
+             << formatv(" @ {0:x}", First.To - FromFunc->getAddress())
+             << " and ending in " << ToFunc->getPrintName()
+             << formatv(" @ {0:x}\n", Second.From - ToFunc->getAddress());
+    });
     return false;
   }