[PATCH] D148385: [RISCV] Implement KCFI operand bundle lowering for RV64

Sami Tolvanen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 14 15:14:05 PDT 2023


samitolvanen created this revision.
Herald added subscribers: jobnoorman, luke, VincentWu, ormris, vkmr, frasercrmck, evandro, luismarques, apazos, sameer.abuasal, pengfei, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya, arichardson.
Herald added a project: All.
samitolvanen requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, pcwang-thead, eopXD, MaskRay.
Herald added projects: clang, LLVM.

Similarly to the target-specific lowering added in D119296 <https://reviews.llvm.org/D119296>, implement
KCFI operand bundle lowering for RV64. Compared to the generic
lowering pass, this ensures we always emit a predictable instruction
sequence for indirect call checks, and that the checks are emitted
immediately before the call.

Note that unlike the generic pass, this patch emits an `ebreak`
instruction for error handling to match the Linux kernel's `BUG()`
implementation. Just like for X86, we also emit trap locations to a
`.kcfi_traps` section as we cannot embed additional information to the
trap instruction itself.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D148385

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/lib/Target/RISCV/CMakeLists.txt
  llvm/lib/Target/RISCV/RISCV.h
  llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVISelLowering.h
  llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfo.h
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVKCFI.cpp
  llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
  llvm/test/CodeGen/RISCV/O0-pipeline.ll
  llvm/test/CodeGen/RISCV/O3-pipeline.ll
  llvm/test/CodeGen/RISCV/kcfi-patchable-function-prefix.ll
  llvm/test/CodeGen/RISCV/kcfi.ll
  llvm/utils/gn/secondary/llvm/lib/Target/RISCV/BUILD.gn

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148385.513763.patch
Type: text/x-patch
Size: 22755 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230414/5f672962/attachment-0001.bin>


More information about the cfe-commits mailing list