[llvm] [BOLT] Ensure remember and restore CFIs are in the same list (PR #144348)
Paschalis Mpeis via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 7 04:09:28 PDT 2025
================
@@ -0,0 +1,69 @@
+// This test checks that BOLT does not split remember and restore CFI states
+// into different lists, which would cause an assertion failure.
+
+# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
+# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q
+# RUN: llvm-bolt %t.exe -o %t.bolt 2>&1 | FileCheck %s
+
+# CHECK: BOLT-INFO: Target architecture: aarch64
+# CHECK: BOLT-INFO: enabling relocation mode
+# CHECK-NOT: llvm-bolt:
+# CHECK: BOLT-INFO: Starting stub-insertion pass
+
+.text
+.global main
+.type main, %function
+
+main:
+.cfi_startproc
+.cfi_def_cfa_offset 16
+.cfi_offset x30, -8
+.cfi_remember_state
+mov x9, #0x3ff0000000000000
+mov x8, x0
+stp x30, x9, [sp, #-0x10]!
+add x3, sp, #0x8
+mov x0, x1
+mov x1, x2
+mov x2, x8
+bl main
+fcmp d0, #0.0
+b.ne main+0x34
+
+mov w0, wzr
+ldr x30, [sp], #0x10
+.cfi_def_cfa_offset 0
+.cfi_restore x30
+
+ret
+.cfi_restore_state
+.cfi_remember_state
+
+fmov x8, d0
+mov x9, #0x7ff0000000000000
+and x8, x8, #0x7fffffffffffffff
+cmp x8, x9
+b.lt main+0x5c
+fcmp d0, #0.0
+mov w8, #-0x1
+csinc w0, w8, wzr, le
+ldr x30, [sp], #0x10
----------------
paschalis-mpeis wrote:
Thanks for the test! Can you please minimize it a bit more?
You can drop the majority of instructions that don't contribute to the test and keep only a few dummy ones like `mov, x0 xzr`. Some of the blocks could be dropped as well.
Once cleaned up, you can replace the hardcoded relative addresses to temp labels. Maybe `--asum-dump` could give you hints on where to place those labels, alternatively `objdump` would do.
https://github.com/llvm/llvm-project/pull/144348
More information about the llvm-commits
mailing list