[llvm] [BOLT] hugify: fix conflict with --no-huge-pages (PR #205497)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 24 01:02:59 PDT 2026
https://github.com/DmitriiMartynov created https://github.com/llvm/llvm-project/pull/205497
There is a conflict between --hugify and --no-huge-pages options.
Both of these options change page alignment in different ways.
In the case of using both options simultaneously, the "--no-huge-pages" option is skipped.
>From f8d3d7226e07064afe9f9477dcdf094a9eb6ae33 Mon Sep 17 00:00:00 2001
From: Dmitrii Martynov <martynovdmitryvladimirovich at yandex.ru>
Date: Tue, 5 May 2026 06:50:58 -0400
Subject: [PATCH] [BOLT] hugify: fix conflict with --no-huge-pages
There is a conflict between --hugify and --no-huge-pages options.
Both of these options change page alignment in different ways.
In the case of using both options simultaneously, the "--no-huge-pages" option
is skipped.
---
bolt/lib/Core/BinaryContext.cpp | 11 ++++++++++-
bolt/test/runtime/hugify.c | 23 +++++++++++++++++++----
2 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/bolt/lib/Core/BinaryContext.cpp b/bolt/lib/Core/BinaryContext.cpp
index 43ce56ef083b5..4902a8e7fa91b 100644
--- a/bolt/lib/Core/BinaryContext.cpp
+++ b/bolt/lib/Core/BinaryContext.cpp
@@ -158,7 +158,16 @@ BinaryContext::BinaryContext(std::unique_ptr<MCContext> Ctx,
MIA(std::move(MIA)), MIB(std::move(MIB)), MRI(std::move(MRI)),
DisAsm(std::move(DisAsm)), Logger(Logger), InitialDynoStats(isAArch64()) {
RegularPageSize = isAArch64() ? RegularPageSizeAArch64 : RegularPageSizeX86;
- PageAlign = opts::NoHugePages ? RegularPageSize : HugePageSize;
+ if (opts::Hugify) {
+ PageAlign = HugePageSize;
+ if (opts::NoHugePages) {
+ this->errs() << "BOLT-WARNING: a conflict between --hugify and "
+ "--no-huge-pages options, --no-huge-pages was skipped\n";
+ opts::NoHugePages = false;
+ }
+ } else {
+ PageAlign = opts::NoHugePages ? RegularPageSize : HugePageSize;
+ }
}
BinaryContext::~BinaryContext() {
diff --git a/bolt/test/runtime/hugify.c b/bolt/test/runtime/hugify.c
index a4a718a1160df..85c6c2122eeed 100644
--- a/bolt/test/runtime/hugify.c
+++ b/bolt/test/runtime/hugify.c
@@ -14,15 +14,25 @@ RUN: %clang %cflags -no-pie %s -o %t.nopie.exe -Wl,-q
RUN: %clang %cflags -fpic %s -o %t.pie.exe -Wl,-q
RUN: llvm-bolt %t.nopie.exe --lite=0 -o %t.nopie --hugify
+RUN: llvm-bolt %t.nopie.exe --lite=0 -o %t.nopie.nhp --hugify \
+RUN: --no-huge-pages=true 2>&1 | FileCheck %s -check-prefix=CHECK-WARNING
RUN: llvm-bolt %t.pie.exe --lite=0 -o %t.pie --hugify
+RUN: llvm-bolt %t.pie.exe --lite=0 -o %t.pie.nhp --hugify -no-huge-pages=true \
+RUN: 2>&1 | FileCheck %s -check-prefix=CHECK-WARNING
RUN: llvm-nm --numeric-sort --print-armap %t.nopie | \
RUN: FileCheck %s -check-prefix=CHECK-NM
-RUN: %t.nopie | FileCheck %s -check-prefix=CHECK-NOPIE
+RUN: %t.nopie | FileCheck %s -check-prefix=CHECK
+RUN: %t.nopie.nhp | FileCheck %s -check-prefix=CHECK
+RUN: llvm-readelf -lS %t.nopie | FileCheck %s -check-prefix=CHECK-ALIGNMENT
+RUN: llvm-readelf -lS %t.nopie.nhp | FileCheck %s -check-prefix=CHECK-ALIGNMENT
RUN: llvm-nm --numeric-sort --print-armap %t.pie | \
RUN: FileCheck %s -check-prefix=CHECK-NM
-RUN: %t.pie | FileCheck %s -check-prefix=CHECK-PIE
+RUN: %t.pie | FileCheck %s -check-prefix=CHECK
+RUN: %t.pie.nhp | FileCheck %s -check-prefix=CHECK
+RUN: llvm-readelf -lS %t.pie | FileCheck %s -check-prefix=CHECK-ALIGNMENT
+RUN: llvm-readelf -lS %t.pie.nhp | FileCheck %s -check-prefix=CHECK-ALIGNMENT
CHECK-NM: W __hot_start
CHECK-NM-NEXT: T _start
@@ -31,8 +41,13 @@ CHECK-NM: W __hot_end
CHECK-NM: t __bolt_hugify_start_program
CHECK-NM-NEXT: W __bolt_runtime_start
-CHECK-NOPIE: Hello world
+COM: .text section must have a hugepage alignment
+COM: at least one R-E segment must have a hugepage alignment
+CHECK-ALIGNMENT: {{.*}} .text PROGBITS {{[0-9a-f]+}}00000 {{.*}} 2097152
+CHECK-ALIGNMENT: LOAD 0x{{.*}} R E 0x200000
-CHECK-PIE: Hello world
+CHECK: Hello world
+
+CHECK-WARNING: BOLT-WARNING: a conflict between --hugify and --no-huge-pages options, --no-huge-pages was skipped
*/
More information about the llvm-commits
mailing list