[llvm] [BOLT][AArch64] Handle OpNegateRAState to enable optimizing binaries with pac-ret hardening (PR #120064)

Paschalis Mpeis via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 9 09:05:54 PDT 2025


================
@@ -0,0 +1,57 @@
+# Checking that we generate an OpNegateRAState CFI after the split point,
+# when splitting a region with signed RA state.
+
+# REQUIRES: system-linux
+
+# RUN: %clang %cflags -o %t %s
+# RUN: %clang %s %cflags -Wl,-q -o %t
+# RUN: link_fdata --no-lbr %s %t %t.fdata
+# RUN: llvm-bolt %t -o %t.bolt --data %t.fdata -split-functions \
+# RUN: --print-only foo --print-split --print-all 2>&1 | FileCheck %s
+
+# Checking that we don't see any OpNegateRAState CFIs before the insertion pass.
+# CHECK-NOT: OpNegateRAState
+# CHECK: Binary Function "foo" after insert-negate-ra-state-pass
+
+# CHECK:       paciasp
+# CHECK-NEXT:  OpNegateRAState
+
+# CHECK: -------   HOT-COLD SPLIT POINT   -------
+
----------------
paschalis-mpeis wrote:

Essentially we check that line [21](https://github.com/llvm/llvm-project/pull/120064/files#diff-06755537aa4ea126cdb68779bb3f27e36c96328b62f495fce1bd2ebfed35e15bR21) adds a negate, as we are now in a new (cold) function, correct?

To make the below block mapping more clear, you can add some dummy instructions to both `.Lfallthrough` and `.LLcold_bb1` blocks, right before their returns, ie, `mov x1, #1` and `move x1, #2` respectively.

Then add a comment explaning the assembly setup and that we check for added negate.

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


More information about the llvm-commits mailing list