[llvm] [llvm][llvm-profgen] Fix printing bogus trace info on 32-bit (PR #226965)

David Spickett via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 28 04:38:11 PDT 2026


https://github.com/DavidSpickett created https://github.com/llvm/llvm-project/pull/226965

And as a result, fix llvm/test/tools/llvm-profgen/AArch64/cs-bogus-trace.test when run on Arm 32-bit:
https://lab.llvm.org/buildbot/#/builders/122/builds/59

Fixes #225569 / 28fec94991905d8dd8a08658e9590e13b7fe1af5.

`x` is for an unsigned integer but the argument given for it is a uint64_t. This worked on 64-bit (maybe it's passed in a register), but not on 32-bit where we got strange values printed.

Use format_hex instead, so we don't have to choose a format code.

>From c3a32047f19434bc8cf72795c1276d2b9a395be8 Mon Sep 17 00:00:00 2001
From: David Spickett <david.spickett at arm.com>
Date: Mon, 28 Sep 2026 11:33:32 +0000
Subject: [PATCH] [llvm][llvm-profgen] Fix printing bogus trace info on 32-bit

And as a result, fix llvm/test/tools/llvm-profgen/AArch64/cs-bogus-trace.test
when run on Arm 32-bit:
https://lab.llvm.org/buildbot/#/builders/122/builds/59

Fixes #225569 / 28fec94991905d8dd8a08658e9590e13b7fe1af5.

`x` is for an unsigned integer but the argument given for it
is a uint64_t. This worked on 64-bit (maybe it's passed in a
register), but not on 32-bit where we got strange values printed.

Use format_hex instead, so we don't have to choose a format code.
---
 llvm/tools/llvm-profgen/PerfReader.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/tools/llvm-profgen/PerfReader.cpp b/llvm/tools/llvm-profgen/PerfReader.cpp
index 4c266b4f3d9aa..521c0ce0e3c25 100644
--- a/llvm/tools/llvm-profgen/PerfReader.cpp
+++ b/llvm/tools/llvm-profgen/PerfReader.cpp
@@ -932,8 +932,8 @@ void HybridPerfReader::parseSample(TraceStream &TraceIt, uint64_t Count) {
           NumBogusTrace++;
           if (ShowDetailedWarning)
             WithColor::warning()
-                << "Bogus trace: stack tip = " << format("%#010x", StackLeaf)
-                << ", LBR tip = " << format("%#010x\n", LBRLeaf);
+                << "Bogus trace: stack tip = " << format_hex(StackLeaf, 10)
+                << ", LBR tip = " << format_hex(LBRLeaf, 10) << "\n";
           return;
         }
         // Canonicalize stack leaf to avoid 'random' IP from leaf frame skew LBR



More information about the llvm-commits mailing list