[compiler-rt] [compiler-rt][ARM] Add missing PACBTI support to assembly aeabi functions (PR #142400)

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 6 07:06:42 PDT 2025


================
@@ -37,6 +42,12 @@ DEFINE_COMPILERRT_FUNCTION(__aeabi_cdcmpeq)
         movs r0, #0xF
         lsls r0, r0, #31
         pop {r0-r3, pc}
+#else
+#if defined(__ARM_FEATURE_PAC_DEFAULT)
+        pop {r0-r3, r12, lr}
+        aut r12, lr, sp
+        beq 2f
----------------
smithp35 wrote:

Now that I look at this again, I think we can use the non-pacbti code path from after the `aut`. Which should preserve the comment and original code structure. It just looks like the condition on the branch is EQ rather than NE.

I could have missed something important though.

I think if you remove
```
beq 2f
b __aeabi_cmple
```
and put the #endif after the `pop {ro-r3, lr}` then this is sufficient.

For example, getting rid of the conditional code we have for PACBTI:
```
        PACBTI_LANDING
        push {r0-r3, r12, lr}
        bl __aeabi_cdcmpeq_check_nan
        cmp r0, #1
        pop {r0-r3, r12, lr}
        aut r12, lr, sp
        beq 2f
        b __aeabi_cdcmple
2:      mov r12, #APSR_C
        msr APSR_nzcvq, r12
```
versus
```
        PACBTI_LANDING
        push {r0-r3, lr}
        bl __aeabi_cdcmpeq_check_nan
        cmp r0, #1
        pop {r0-r3, lr}

        // NaN has been ruled out, so __aeabi_cdcmple can't trap
        // Use "it ne" + unconditional branch to guarantee a supported relocation if
        // __aeabi_cdcmple is in a different section for some builds.
        IT(ne)
        bne __aeabi_cdcmple
        mov r12, #APSR_C
        msr APSR_nzcvq, r12
```

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


More information about the llvm-commits mailing list