[llvm] [AArch64][PAC][GISel] Add missing clobbering info to LOADgotAUTH (PR #157433)
Anatoly Trosinenko via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 8 05:11:09 PDT 2025
atrosinenko wrote:
Here is an example of incorrect code generation:
```c
extern unsigned long pac_field_mask;
static void f() {}
unsigned long get_non_signed_function_pointer(void) {
return ((unsigned long)f) & ~pac_field_mask;
}
```
Compiled at `-O0` optimization level with `clang -target aarch64-linux-pauthtest -march=v8.3-a -Xclang -fptrauth-elf-got -S -o- example.c`:
```
get_non_signed_function_pointer: // @get_non_signed_function_pointer
.cfi_startproc
// %bb.0: // %entry
// implicit-def: $x16
// implicit-def: $x17
adrp x16, f
add x16, x16, :lo12:f
paciza x16
adrp x17, :got_auth:pac_field_mask
add x17, x17, :got_auth_lo12:pac_field_mask
ldr x16, [x17]
autda x16, x17
mov x17, x16
xpacd x17
cmp x16, x17
b.eq .Lauth_success_0
brk #0xc472
.Lauth_success_0:
mov x8, x16
ldr x8, [x8]
bic x0, x16, x8
ret
```
<details>
<summary>With this patch applied</summary>
```
get_non_signed_function_pointer: // @get_non_signed_function_pointer
.cfi_startproc
// %bb.0: // %entry
sub sp, sp, #16
.cfi_def_cfa_offset 16
// implicit-def: $x16
// implicit-def: $x17
adrp x16, f
add x16, x16, :lo12:f
paciza x16
str x16, [sp, #8] // 8-byte Folded Spill
adrp x17, :got_auth:pac_field_mask
add x17, x17, :got_auth_lo12:pac_field_mask
ldr x16, [x17]
autda x16, x17
mov x17, x16
xpacd x17
cmp x16, x17
b.eq .Lauth_success_0
brk #0xc472
.Lauth_success_0:
mov x8, x16
ldr x16, [sp, #8] // 8-byte Folded Reload
ldr x8, [x8]
bic x0, x16, x8
add sp, sp, #16
.cfi_def_cfa_offset 0
ret
```
</details>
Compiled with `-fglobal-isel` with `clang -target aarch64-linux-pauthtest -march=v8.3-a -Xclang -fptrauth-elf-got -S -o- example.c -O1 -fglobal-isel`:
```
get_non_signed_function_pointer: // @get_non_signed_function_pointer
.cfi_startproc
// %bb.0: // %entry
adrp x16, f
add x16, x16, :lo12:f
paciza x16
adrp x17, :got_auth:pac_field_mask
add x17, x17, :got_auth_lo12:pac_field_mask
ldr x16, [x17]
autda x16, x17
mov x17, x16
xpacd x17
cmp x16, x17
b.eq .Lauth_success_0
brk #0xc472
.Lauth_success_0:
mov x8, x16
ldr x8, [x8]
bic x0, x16, x8
ret
```
<details>
<summary>With this patch applied</summary>
```
get_non_signed_function_pointer: // @get_non_signed_function_pointer
.cfi_startproc
// %bb.0: // %entry
adrp x16, f
add x16, x16, :lo12:f
paciza x16
mov x8, x16
adrp x17, :got_auth:pac_field_mask
add x17, x17, :got_auth_lo12:pac_field_mask
ldr x16, [x17]
autda x16, x17
mov x17, x16
xpacd x17
cmp x16, x17
b.eq .Lauth_success_0
brk #0xc472
.Lauth_success_0:
mov x9, x16
ldr x9, [x9]
bic x0, x8, x9
ret
```
</details>
https://github.com/llvm/llvm-project/pull/157433
More information about the llvm-commits
mailing list