[llvm-branch-commits] [clang] [clang] Define ptrauth_sign_constant builtin. (PR #93904)

Ahmed Bougacha via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri May 31 13:43:07 PDT 2024


ahmedbougacha wrote:

> Why do we want a separate builtin, as opposed to just constant-folding calls to __builtin_ptrauth_sign?

That's a good question.  Mechanically, I assumed constant-evaluating `__builtin_ptrauth_sign_unauthenticated` would be a challenge, but looking around it doesn't seem particularly difficult.

Conceptually though, the distinction does seem useful, because we treat `__builtin_ptrauth_sign_unauthenticated` as dangerous (because in general we can't guarantee that it won't get lowered to a signing oracle), and only to be used carefully, when absolutely necessary (e.g., in a dynamic loader.)
`__builtin_ptrauth_sign_constant` is safe, because we do always have safe ways to materialize signed constants (with the constants in IR, and either relocations or safe pseudos in the backend.)   (but cc @rjmccall @ahatanak for the real clang perspective ;)

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


More information about the llvm-branch-commits mailing list