Skip to content

Commit

Permalink
[llvm-debuginfo-analyzer] Fix format string-type mismatch in LVScope
Browse files Browse the repository at this point in the history
Fix mismatch between `%d`/`%x` format strings and `uint64_t` type.
This fixes incorrect printing of "Scope Sizes" on 32-bit platforms
where this leads to `llvm::print()` misreading vararg.

Fixes #58758

Differential Revision: https://reviews.llvm.org/D137400
  • Loading branch information
mgorny committed Nov 4, 2022
1 parent c14df22 commit 7292d05
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
5 changes: 3 additions & 2 deletions llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,8 @@ void LVScopeCompileUnit::addSize(LVScope *Scope, LVOffset Lower,
LVOffset Upper) {
LLVM_DEBUG({
dbgs() << format(
"CU [0x%08x], Scope [0x%08x], Range [0x%08x:0x%08x], Size = %d\n",
"CU [0x%08" PRIx64 "], Scope [0x%08" PRIx64 "], Range [0x%08" PRIx64
":0x%08" PRIx64 "], Size = %" PRId64 "\n",
getOffset(), Scope->getOffset(), Lower, Upper, Upper - Lower);
});

Expand Down Expand Up @@ -1548,7 +1549,7 @@ void LVScopeCompileUnit::printScopeSize(const LVScope *Scope, raw_ostream &OS) {
// implementation-defined rounding inside printing functions.
float Percentage =
rint((float(Size) / CUContributionSize) * 100.0 * 100.0) / 100.0;
OS << format("%10d (%6.2f%%) : ", Size, Percentage);
OS << format("%10" PRId64 " (%6.2f%%) : ", Size, Percentage);
Scope->print(OS);

// Keep record of the total sizes at each lexical level.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
; REQUIRES: x86-registered-target

; FIXME: Test failure https://reviews.llvm.org/D125783
; UNSUPPORTED: arm

; Test case 6 - Full logical view

; test.cpp
Expand Down

0 comments on commit 7292d05

Please sign in to comment.