[llvm] [PtrAuth] Add ConstantPtrAuth comparator to FunctionComparator.cpp (PR #159480)
Anatoly Trosinenko via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 7 09:10:36 PDT 2025
atrosinenko wrote:
In a call instruction like this
```llvm
call void ptrauth (ptr @baz, i32 0)(ptr null)
```
a signed pointer to `@baz` is constructed and then an indirect call is performed via this pointer without "undoing" signing operation first with `@llvm.ptrauth.auth` or by passing a "ptrauth" call operand bundle. IIRC it is not an UB, but calling a signed-but-neither-authenticated-nor-stripped function pointer is intended to crash by design.
This is probably acceptable in this kind of tests (except for that I'm not sure if calling signed null pointer in `f_ptr_null` is not an UB due to the original pointer being `null`), but a simple transformation seems to make this IR look much more commonplace:
```llvm
call void @callee(ptr ptrauth (ptr @baz, i32 0))
```
This way, `ptrauth` constant provides an *argument* for the `@callee` function (which is called directly). Furthermore, since `@callee` is free to use its argument however it wants, there should not be an UB due to signed `null` pointer anymore. I'm not familiar with FunctionComparator, but brief testing on my side suggests the tests still behave as expected (`opt` crashes without the patch and the functions get merged as expected with the patch applied).
https://github.com/llvm/llvm-project/pull/159480
More information about the llvm-commits
mailing list