[llvm] Fix https://github.com/llvm/llvm-project/issues/75998 (PR #82661)

via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 23 00:47:35 PST 2024


https://github.com/ostannard requested changes to this pull request.

I don't think changing the `AltOrders` actually prevents the removed registers in all cases, in this case `r12` is still used:
```c
typedef void(func)(void);

void foo(func *fptr_arg) {
  register func *fptr_r12 asm("r12") = fptr_arg;

  // Force the function pointer into r12, and clobber lr to force a stack frame
  // to be created.
  asm("" : "+r" (fptr_r12) : : "lr");

  // Indirect tail call through r12.
  fptr_r12();
}
```

```
$ /work/llvm/build/bin/clang --target=arm-none-eabi -march=armv8.1-m.main -c indirect-tail.c -o - -S -O1 -mbranch-protection=pac-ret
...
        ldr     r12, [sp], #4
        pop.w   {r7, lr}
        aut     r12, lr, sp
        bx      r12
...
```

I recently fixed a similar issue in AArch64 (#81020), would that method of creating multiple pseudo-instructions with different register classes work here too?

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


More information about the llvm-commits mailing list