[llvm] [AArch64][PAC] Protect the entire function if pac-ret+leaf is passed (PR #140895)

Anatoly Trosinenko via llvm-commits llvm-commits at lists.llvm.org
Tue May 27 09:03:18 PDT 2025


================
@@ -74,19 +74,19 @@ define hidden noundef i32 @baz_async(i32 noundef %a) #0 uwtable(async) {
 ; CHECK-V8A-NEXT:    bl _Z3bari
 ; CHECK-V8A-NEXT:    ldr x30, [sp], #16 // 8-byte Folded Reload
 ; CHECK-V8A-NEXT:    .cfi_def_cfa_offset 0
+; CHECK-V8A-NEXT:    .cfi_restore w30
 ; CHECK-V8A-NEXT:    hint #29
 ; CHECK-V8A-NEXT:    .cfi_negate_ra_state
-; CHECK-V8A-NEXT:    .cfi_restore w30
 ; CHECK-V8A-NEXT:    b _Z3bari
 ; CHECK-V8A-NEXT:  .LBB1_2: // %if.else
 ; CHECK-V8A-NEXT:    .cfi_restore_state
 ; CHECK-V8A-NEXT:    bl _Z4quuxi
 ; CHECK-V8A-NEXT:    add w0, w0, #1
 ; CHECK-V8A-NEXT:    ldr x30, [sp], #16 // 8-byte Folded Reload
 ; CHECK-V8A-NEXT:    .cfi_def_cfa_offset 0
+; CHECK-V8A-NEXT:    .cfi_restore w30
----------------
atrosinenko wrote:

My first thought was the same, but then I spotted that spilling a _signed_ LR cannot be expressed with the standard CFI instructions (such as `.cfi_offset w30, -16`) anyway and that a special pseudo register is defined in DWARF on AArch64 for that purpose. Here I assume that `.cfi_offset` and `.cfi_restore` imply the same level of "precision" of the register contents and only differ in where these contents are currently stored.

For that reason I hoped that it may be possible to keep the code in `emitEpilogue` a bit more simple. I'm not sure, though, maybe it is safer to assume that the debugger considers register contents as **exactly** the same after `.cfi_restore` while other rules are more hint-ish.

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


More information about the llvm-commits mailing list