[llvm] [BOLT] Correctly handle entry point at FDE boundaries (PR #176173)

Paschalis Mpeis via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 30 06:24:19 PDT 2026


================
@@ -0,0 +1,78 @@
+## Promote unmarked code after a CFI-bounded predecessor into __BOLT_UNMARKED_TAIL.
+## Covers:
+##   1) FDE-only region (no symtab entry; BOLT names it __BOLT_FDE_FUNC* or .text/N)
+##   2) Named function (FDE range == symbol size) -> named_sub + tail
+## Caller is in a separate section; -Wl,-q keeps PC-relative relocs on the bl.
+
+# 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 --print-disasm -v=1 2>&1 | FileCheck %s
+
+# CHECK: Binary Function "{{(__BOLT_FDE_FUNC.*|\.text/[0-9]+)}}" after disassembly
+# CHECK: Size        : 0x14
+# CHECK: MaxSize     : 0x14
+# CHECK: Binary Function "{{.*}}__BOLT_UNMARKED_TAIL{{.*}}" after disassembly
+# CHECK: Size        : 0x8
+# CHECK: MaxSize     : 0x8
+
+# CHECK: Binary Function "named_sub" after disassembly
+# CHECK: Size        : 0x14
+# CHECK: MaxSize     : 0x14
+# CHECK: Binary Function "{{.*}}__BOLT_UNMARKED_TAIL{{.*}}" after disassembly
+# CHECK: Size        : 0x10
+# CHECK: MaxSize     : 0x10
+
+# CHECK-COUNT-2: bl	__BOLT_UNMARKED_TAILat{{.*}}
+
+	.section	.text.fdeonly,"ax", at progbits
+
+## Scenario 1: FDE-only predecessor (no symbol table entry).
+.Lfde_sub:
+	.cfi_startproc
+	stp	x29, x30, [sp, #-16]!
+	mov	x29, sp
+	mov	w0, #42
+	ldp	x29, x30, [sp], #16
+	ret
+	.cfi_endproc
+
+.Ltail_after_fde:
+	nop
+	ret
----------------
paschalis-mpeis wrote:

How about trailing filler nops or zero padding? This is currently ignored, correct?

```armasm
.Ltail_after_fde:
	nop
	ret
    nop
    nop
```

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


More information about the llvm-commits mailing list