[llvm] Do not use R12 for indirect tail calls with PACBTI (PR #82661)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 17 08:13:43 PDT 2024
ostannard wrote:
> The attribute that needs to be set explicitly for AArch64 to work is branch-protection-pauth-lr in fact, not sign-return-address. I am not sure why sign-return-address is even in the test. The test passes without it being used for any of the functions.
That AArch64 change was for a bug in `branch-protection-pauth-lr`, which is a new feature added in Armv9.5-A, and doesn't have an equivalent in M-profile. For M-profile PAC/BTI, we only have `sign-return-address` and `branch-target-enforcement`, and I don't think the latter is relevant to this bug.
> Why the codegen is not correct when it set as a module attribute I am not sure.
I can't really help with this if you don't tell me _what_ codegen is incorrect. Do you have an IR file for which LLVM continues to generate code which incorrectly uses `r12` in the prologue, or something else?
> I think what clang needs to generate is
> ```
> !4 = !{i32 8, !"sign-return-address", i32 1}
> !5 = !{i32 8, !"sign-return-address-all", i32 1}
> ```
> then the codegen is correct. Would you agree?
The `sign-return-address-all` flag should cause the PAC/AUT instructions to be used in all functions, not just ones which spill `lr` to the stack. That isn't enabled by `-mbranch-protection=standard`, instead it should only be turned on by `-mbranch-protection=pac-ret+leaf`.
https://github.com/llvm/llvm-project/pull/82661
More information about the llvm-commits
mailing list