[PATCH] D85649: [AArch64] PAC/BTI code generation for LLVM generated functions

Momchil Velikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 10 07:00:00 PDT 2020


chill created this revision.
chill added reviewers: danielkiss, pcc, ostannard, asl, nickdesaulniers, peter.smith, ab, tamas.petz.
Herald added subscribers: llvm-commits, hiraditya, kristof.beyls.
Herald added a project: LLVM.
chill requested review of this revision.

PAC/BTI-related codegen in the AArch64 backend is controlled by
a set of LLVM IR function attributes, added to the function by Clang,
based on command-line options and GCC-style function attributes.
However, functions, generated in the LLVM middle end (for example,
`asan.module.ctor` or `__llvm_gcov_write_out`) do not get any attributes
and the backend incorrectly does not do any PAC/BTI code generation.

This patch record the default state of PAC/BTI codegen in a set of
LLVM IR module-level attributes, based on command-line options:

- "sign-return-address", if present,  means generate code to sign return addresses with defaults begin using A-key on functions which spill LR.
- "sign-return-address-all", if present, extends the return address signing, enabled by "sign-return-address" to functions, which do not spill LR as well.
- "sign-return-address-with-bkey", if present, modified the default, established by "sign-return-address" to using to B-key.

Module-level attributes are overridden by function level attributes.
All the decision making about whether to not to generate PAC and/or
BTI code is factored out into `AArch64FunctionInfo`, there shouldn't be
any places left, other than `AArch64FunctionInfo`, which directly
examine PAC/BTI attributes, except `AArch64AsmPrinter.cpp`, which
is/will-be handled by a separate patch.


https://reviews.llvm.org/D85649

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  llvm/lib/Target/AArch64/AArch64BranchTargets.cpp
  llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
  llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp
  llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h
  llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp
  llvm/test/CodeGen/AArch64/pacbti-llvm-generated-funcs-1.ll
  llvm/test/CodeGen/AArch64/pacbti-llvm-generated-funcs-2.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85649.284341.patch
Type: text/x-patch
Size: 24604 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200810/ad284019/attachment-0001.bin>


More information about the llvm-commits mailing list