[PATCH] D90868: [IR] Define @llvm.ptrauth intrinsics.

Ahmed Bougacha via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 5 10:47:27 PST 2020


ab created this revision.
ab added reviewers: pcc, psmith, apazos, kristof.beyls, rjmccall, t.p.northover, chill, danielkiss.
Herald added subscribers: pzheng, jdoerfert.
Herald added a project: LLVM.
ab requested review of this revision.

This defines the core `@llvm.ptrauth.` intrinsics: sign, auth, strip, blend, sign_generic.  This also adds a `docs/PointerAuth.md` which goes into more detail;  let me know if anything needs clarifying.

Most of the intrinsics are straightforward to define, except for blend which can be defined and implemented in various ways.  To follow are straightforward codegen patches for sign, sign_generic, strip, and blend.  auth and resign have a lot more complexity to them.

There are a couple open items for the long-term future.  One would be to switch these to opaque pointer types instead of i64 (though i64 is really more accurate, and would hypothetically allow specialized usage on LP32 platforms, for instance).
Also, adding some more specific intrinsics might be useful for further hardening (e.g., an add-and-resign, or a way to check whether a pointer is correctly signed, without running into the `llvm.ptrauth.auth` UB and traps).
Finally, there are various cases where we need to treat an entire blend + sign/auth/resign sequence as a single operation, so we might want to embed the blend in all intrinsics (concretely, replacing the single i64 discriminators that the intrinsics take with a pair of i32 discriminator and i64 address discriminator - we already need to do that for the constants we use to express relocations).

For a high-level overview, see our llvm-dev RFC: http://lists.llvm.org/pipermail/llvm-dev/2019-October/136091.html, as well as the devmtg talk we did at the same time last year.
For concrete code that builds on this, see last year's staging PR in apple/llvm-project: https://github.com/apple/llvm-project/pull/14  (in particular, the higher level C/C++/Obj-C ABI usage is documented in the clang docs there).  Though we've made changes downstream since then, the general concepts and added constructs are mostly identical.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90868

Files:
  llvm/docs/LangRef.rst
  llvm/docs/PointerAuth.md
  llvm/docs/Reference.rst
  llvm/include/llvm/IR/Intrinsics.td

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90868.301675.patch
Type: text/x-patch
Size: 14310 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201105/95ebe953/attachment.bin>


More information about the llvm-commits mailing list