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

Alexey Moksyakov via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 23 08:19:45 PDT 2025


yavtuk wrote:

@maksfb as workaround we can try the following


     cl::Hidden, cl::cat(BoltCategory));

+static cl::opt<bool> ForceFuncEntryPoint(
+    "force-func-entry-point",
+    cl::desc("force entry point for function at 0 offset"),
+    cl::init(false),
+    cl::Hidden, cl::cat(BoltCategory));
+
+
 static cl::opt<std::string>
     BoltID("bolt-id",
            cl::desc("add any string to tag this execution in the "
@@ -1319,6 +1326,10 @@ void RewriteInstance::discoverFileObjects() {
       continue;
     }
     const auto EntryOffset = Address - BF->getAddress();
+    if (opts::ForceFuncEntryPoint && !EntryOffset) {
+      BF->markCodeAtOffset(EntryOffset);
+      continue;
+    }
     if (Type == MarkerSymType::CODE) {
       BF->markCodeAtOffset(EntryOffset);
       continue;

# | Binary Function "foo" after building cfg {
# |   Number      : 2
# |   State       : CFG constructed
# |   Address     : 0x10260
# |   Size        : 0x4
# |   MaxSize     : 0x4
# |   Offset      : 0x260
# |   Section     : .text
# |   Orc Section : .local.text.foo
# |   LSDA        : 0x0
# |   IsSimple    : 1
# |   IsMultiEntry: 0
# |   IsSplit     : 0
# |   BB Count    : 1
# |   Hash        : 8aa3f4604e30044c
# |   BB Layout   : .LBB01
# | }
# | .LBB01 (1 instructions, align : 1)
# |   Entry Point
# |     00000000:       ret
# |
# | DWARF CFI Instructions:
# |     <empty>
# | End of Function "foo"



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


More information about the llvm-commits mailing list