[llvm] [profgen] Use a 64bit integer for &'ing the loadable address (PR #79930)

Nathan Lanza via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 29 17:45:59 PST 2024


https://github.com/lanza created https://github.com/llvm/llvm-project/pull/79930

For the linux kernel, the loadable segments start at 0xffff... and thus the 32 bit integer here was truncating all the meaningful bits. Grow it to 64 bits.

>From 2ce1ae9c1f85600bd6c0c4b2d6f55d66241d796f Mon Sep 17 00:00:00 2001
From: Nathan Lanza <nathanlanza at gmail.com>
Date: Mon, 29 Jan 2024 17:38:33 -0800
Subject: [PATCH] [profgen] Use a 64bit integer for &'ing the loadable address

For the linux kernel, the loadable segments start at 0xffff... and thus
the 32 bit integer here was truncating all the meaningful bits. Grow it
to 64 bits.
---
 llvm/tools/llvm-profgen/ProfiledBinary.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/tools/llvm-profgen/ProfiledBinary.cpp b/llvm/tools/llvm-profgen/ProfiledBinary.cpp
index b40c5f8cbbe06..f62228627b8f1 100644
--- a/llvm/tools/llvm-profgen/ProfiledBinary.cpp
+++ b/llvm/tools/llvm-profgen/ProfiledBinary.cpp
@@ -317,7 +317,7 @@ void ProfiledBinary::setPreferredTextSegmentAddresses(const ELFFile<ELFT> &Obj,
   // However such info isn't available at post-processing time, assuming
   // 4K page now. Note that we don't use EXEC_PAGESIZE from <linux/param.h>
   // because we may build the tools on non-linux.
-  uint32_t PageSize = 0x1000;
+  uint64_t PageSize = 0x1000;
   for (const typename ELFT::Phdr &Phdr : PhdrRange) {
     if (Phdr.p_type == ELF::PT_LOAD) {
       if (!FirstLoadableAddress)



More information about the llvm-commits mailing list