[llvm] [Sample Profile] make page size configurable for ProfiledBinary (PR #164773)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 23 01:28:08 PDT 2025
https://github.com/wjx951753 created https://github.com/llvm/llvm-project/pull/164773
Replace hardcoded 1024 page size with cofigurable Pagesize parameter.
>From af57e02900130f6b68c7b15f3ecc58d45aba11ab Mon Sep 17 00:00:00 2001
From: wjx <wangjiaxin35 at huawei.com>
Date: Thu, 23 Oct 2025 16:08:39 +0800
Subject: [PATCH] [Sample Profile] make page size configurable for
ProfiledBinary
---
llvm/tools/llvm-profgen/ProfiledBinary.cpp | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/llvm/tools/llvm-profgen/ProfiledBinary.cpp b/llvm/tools/llvm-profgen/ProfiledBinary.cpp
index 94728ce4abffe..a230238c8a218 100644
--- a/llvm/tools/llvm-profgen/ProfiledBinary.cpp
+++ b/llvm/tools/llvm-profgen/ProfiledBinary.cpp
@@ -70,6 +70,11 @@ static cl::opt<bool>
cl::desc("Generate the profile for Linux kernel binary."),
cl::cat(ProfGenCategory));
+static cl::opt<uint64_t>
+ Pagesize("page-size",
+ cl::desc("page size"), cl::init(0x1000),
+ cl::desc("target system pagee size."));
+
namespace sampleprof {
static const Target *getTarget(const ObjectFile *Obj) {
@@ -330,7 +335,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.
- uint64_t PageSize = 0x1000;
+ uint64_t PageSize = Pagesize;
for (const typename ELFT::Phdr &Phdr : PhdrRange) {
if (Phdr.p_type == ELF::PT_LOAD) {
if (!FirstLoadableAddress)
More information about the llvm-commits
mailing list