[llvm] [BOLT] Check entry point address is not in constant island (PR #163418)
Asher Dobrescu via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 14 09:08:00 PDT 2025
https://github.com/Asher8118 updated https://github.com/llvm/llvm-project/pull/163418
>From 3fe0d0275ac706c48129f40d022f94191297ccc9 Mon Sep 17 00:00:00 2001
From: Ash Dobrescu <ash.dobrescu at arm.com>
Date: Tue, 14 Oct 2025 15:23:02 +0000
Subject: [PATCH 1/2] [BOLT] Check entry point address is not in constant
island
---
bolt/lib/Core/BinaryContext.cpp | 13 +++++++--
bolt/test/AArch64/constant-island-entry.s | 35 +++++++++++++++++++++++
2 files changed, 46 insertions(+), 2 deletions(-)
create mode 100644 bolt/test/AArch64/constant-island-entry.s
diff --git a/bolt/lib/Core/BinaryContext.cpp b/bolt/lib/Core/BinaryContext.cpp
index dd0d041692484..c35775464751b 100644
--- a/bolt/lib/Core/BinaryContext.cpp
+++ b/bolt/lib/Core/BinaryContext.cpp
@@ -1336,8 +1336,17 @@ void BinaryContext::processInterproceduralReferences() {
<< Function.getPrintName() << " and "
<< TargetFunction->getPrintName() << '\n';
}
- if (uint64_t Offset = Address - TargetFunction->getAddress())
- TargetFunction->addEntryPointAtOffset(Offset);
+ if (uint64_t Offset = Address - TargetFunction->getAddress()) {
+ if (!TargetFunction->isInConstantIsland(Address)) {
+ TargetFunction->addEntryPointAtOffset(Offset);
+ } else {
+ TargetFunction->setIgnored();
+ this->outs() << "BOLT-WARNING: Ignoring entry point at address 0x"
+ << Twine::utohexstr(Address)
+ << " in constant island of function " << *TargetFunction
+ << '\n';
+ }
+ }
continue;
}
diff --git a/bolt/test/AArch64/constant-island-entry.s b/bolt/test/AArch64/constant-island-entry.s
new file mode 100644
index 0000000000000..bd0906d87f15f
--- /dev/null
+++ b/bolt/test/AArch64/constant-island-entry.s
@@ -0,0 +1,35 @@
+// This test checks that we ignore functions which add an entry point that
+// is in a costant island.
+
+# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-linux-gnu %s -o %t.o
+# RUN: %clang %cflags %t.o -pie -Wl,-q -o %t.exe
+# RUN: llvm-bolt %t.exe -o %t.bolt 2>&1 | FileCheck %s
+
+# CHECK: BOLT-WARNING: Ignoring entry point at address 0x{{[0-9a-f]+}} in constant island of function func
+
+.globl func
+.type func, %function
+func:
+ ret
+ nop
+ b .Lafter_constant
+
+.type constant_island, %object
+constant_island:
+ .xword 0xabcdef
+
+.Lafter_constant:
+ ret
+ .size func, .-func
+
+.globl caller
+.type caller, %function
+caller:
+ bl constant_island
+ ret
+
+.globl main
+.type main, %function
+main:
+ bl caller
+ ret
>From c447ccebec7477723d5bfe363f9a5d763e0a60a0 Mon Sep 17 00:00:00 2001
From: Asher Dobrescu <dobrescuira at yahoo.com>
Date: Tue, 14 Oct 2025 17:07:51 +0100
Subject: [PATCH 2/2] Update constant-island-entry.s
---
bolt/test/AArch64/constant-island-entry.s | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bolt/test/AArch64/constant-island-entry.s b/bolt/test/AArch64/constant-island-entry.s
index bd0906d87f15f..5b7b906dbf4ea 100644
--- a/bolt/test/AArch64/constant-island-entry.s
+++ b/bolt/test/AArch64/constant-island-entry.s
@@ -1,7 +1,7 @@
// This test checks that we ignore functions which add an entry point that
// is in a costant island.
-# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-linux-gnu %s -o %t.o
+# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
# RUN: %clang %cflags %t.o -pie -Wl,-q -o %t.exe
# RUN: llvm-bolt %t.exe -o %t.bolt 2>&1 | FileCheck %s
More information about the llvm-commits
mailing list