[llvm] [BOLT] Fix logs with no hex convension (PR #112650)

via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 16 19:44:32 PDT 2024


https://github.com/linsinan1995 created https://github.com/llvm/llvm-project/pull/112650

Add `utohexstr` to ensure that offsets/addresses are correctly formatted as hexadecimal values.

>From 39c27b0bb9bf81966dfb83a5fc4df92fdaa91147 Mon Sep 17 00:00:00 2001
From: sinan <sinan.lin at linux.alibaba.com>
Date: Thu, 17 Oct 2024 10:26:00 +0800
Subject: [PATCH] [BOLT] Fix logs with no hex convension

Add `utohexstr` to ensure that offsets/addresses are correctly
formatted as hexadecimal values.
---
 bolt/include/bolt/Core/DIEBuilder.h | 2 +-
 bolt/lib/Core/BinaryContext.cpp     | 4 ++--
 bolt/lib/Rewrite/DWARFRewriter.cpp  | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/bolt/include/bolt/Core/DIEBuilder.h b/bolt/include/bolt/Core/DIEBuilder.h
index e5b057ea1e42b7..d1acba0f26c78f 100644
--- a/bolt/include/bolt/Core/DIEBuilder.h
+++ b/bolt/include/bolt/Core/DIEBuilder.h
@@ -314,7 +314,7 @@ class DIEBuilder {
 
     BC.errs()
         << "BOLT-ERROR: unable to find TypeUnit for Type Unit at offset 0x"
-        << DU.getOffset() << "\n";
+        << Twine::utohexstr(DU.getOffset()) << "\n";
     return nullptr;
   }
 
diff --git a/bolt/lib/Core/BinaryContext.cpp b/bolt/lib/Core/BinaryContext.cpp
index 1347047e1b7060..f246750209d6c4 100644
--- a/bolt/lib/Core/BinaryContext.cpp
+++ b/bolt/lib/Core/BinaryContext.cpp
@@ -1294,8 +1294,8 @@ bool BinaryContext::handleAArch64Veneer(uint64_t Address, bool MatchOnly) {
     Veneer->getOrCreateLocalLabel(Address);
     Veneer->setMaxSize(TotalSize);
     Veneer->updateState(BinaryFunction::State::Disassembled);
-    LLVM_DEBUG(dbgs() << "BOLT-DEBUG: handling veneer function at 0x" << Address
-                      << "\n");
+    LLVM_DEBUG(dbgs() << "BOLT-DEBUG: handling veneer function at 0x"
+                      << Twine::utohexstr(Address) << "\n");
     return true;
   };
 
diff --git a/bolt/lib/Rewrite/DWARFRewriter.cpp b/bolt/lib/Rewrite/DWARFRewriter.cpp
index f9cb1b3895e79b..1b5ba8b49d3637 100644
--- a/bolt/lib/Rewrite/DWARFRewriter.cpp
+++ b/bolt/lib/Rewrite/DWARFRewriter.cpp
@@ -1362,7 +1362,7 @@ void DWARFRewriter::updateDWARFObjectAddressRanges(
                Die.getTag() == dwarf::DW_TAG_compile_unit)) {
     if (opts::Verbosity >= 1)
       errs() << "BOLT-WARNING: cannot update ranges for DIE in Unit offset 0x"
-             << Unit.getOffset() << '\n';
+             << Twine::utohexstr(Unit.getOffset()) << '\n';
   }
 }
 



More information about the llvm-commits mailing list