[llvm] [BOLT][WIP] Always treat function entry as code (PR #160161)

via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 22 11:07:31 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-bolt

Author: Maksim Panchenko (maksfb)

<details>
<summary>Changes</summary>

If an address has both, a data marker "$d" and a function entry point associated with it, treat it as code.

---
Full diff: https://github.com/llvm/llvm-project/pull/160161.diff


2 Files Affected:

- (modified) bolt/lib/Rewrite/RewriteInstance.cpp (-3) 
- (added) bolt/test/AArch64/function-data-marker.s (+25) 


``````````diff
diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index a6e4dbc9c192f..014fa43f82867 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -917,9 +917,6 @@ void RewriteInstance::discoverFileObjects() {
     bool IsData = false;
     uint64_t LastAddr = 0;
     for (const auto &SymInfo : SortedSymbols) {
-      if (LastAddr == SymInfo.Address) // don't repeat markers
-        continue;
-
       MarkerSymType MarkerType = BC->getMarkerType(SymInfo.Symbol);
 
       // Treat ST_Function as code.
diff --git a/bolt/test/AArch64/function-data-marker.s b/bolt/test/AArch64/function-data-marker.s
new file mode 100644
index 0000000000000..35e31e9fc1731
--- /dev/null
+++ b/bolt/test/AArch64/function-data-marker.s
@@ -0,0 +1,25 @@
+## TODO
+
+# RUN: %clang %cflags %s -o %t.exe -nostdlib -fuse-ld=lld -Wl,-q
+# RUN: llvm-bolt %t.exe -o %t.bolt --print-cfg --print-only=foo 2>&1 | FileCheck %s
+
+# BOLT-WARNING: function symbol foo lacks code marker
+
+.text
+.balign 4
+
+.global _start
+.type _start, %function
+_start:
+  bl foo
+  ret
+.size _start, .-_start
+
+## Data marker is emitted immediately before the function.
+.global foo
+.type foo, %function
+$d:
+foo:
+  ret
+.size foo, .-foo
+

``````````

</details>


https://github.com/llvm/llvm-project/pull/160161


More information about the llvm-commits mailing list