[all-commits] [llvm/llvm-project] 60977b: [RISCV][Zicfilp] Emit .note.gnu.property section f...

Ming-Yi Lai via All-commits all-commits at lists.llvm.org
Thu Jun 25 00:12:44 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 60977b5a37fb775b2b8292e3d34ce4cff7934c45
      https://github.com/llvm/llvm-project/commit/60977b5a37fb775b2b8292e3d34ce4cff7934c45
  Author: Ming-Yi Lai <ming-yi.lai at mediatek.com>
  Date:   2026-06-25 (Thu, 25 Jun 2026)

  Changed paths:
    M llvm/include/llvm/TargetParser/RISCVTargetParser.h
    M llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
    M llvm/test/CodeGen/RISCV/branch-relaxation-rv32.ll
    M llvm/test/CodeGen/RISCV/branch-relaxation-rv64.ll
    M llvm/test/CodeGen/RISCV/calls-cf-branch.ll
    M llvm/test/CodeGen/RISCV/jumptable-swguarded.ll
    M llvm/test/CodeGen/RISCV/lpad-setjmp.ll
    M llvm/test/CodeGen/RISCV/lpad.ll
    M llvm/test/CodeGen/RISCV/nest-register.ll
    A llvm/test/CodeGen/RISCV/note-gnu-property-zicfilp-error.ll
    A llvm/test/CodeGen/RISCV/note-gnu-property-zicfilp-unlabeled.ll
    M llvm/test/CodeGen/RISCV/rv64-trampoline-cfi.ll
    M llvm/test/CodeGen/RISCV/tail-calls.ll

  Log Message:
  -----------
  [RISCV][Zicfilp] Emit .note.gnu.property section for Zicfilp CFI unlabeled scheme (#141468)

RISC-V Zicfilp-based CFI needs to let the linker/loader know if the
binary is built with the mechanism enabled to support proper
link-time/load-time management of this feature. The information is
encoded as a bit in the `.note.gnu.property` section. This patch
implements emitting the section for RISC-V targets when Zicfilp-based
CFI with the "unlabeled" label scheme is enabled.

When Clang receives the `-fcf-protection=branch` flag, which enables
forward-edge CFI protection, it adds the `cf-protection-branch`
attribute to the LLVM module. Additionally, if a branch label scheme is
needed, another attribute (`cf-branch-label-scheme`) is added to
indicate it. For RISC-V targets, the `cf-protection-branch` attribute
indicates the adoption of Zicfilp-based forward-edge CFI protection, and
the `cf-branch-label-scheme` attribute selects how the "label" operands
of the Zicfilp `lpad` insns are produced. This patch emits the proper
`.note.gnu.property` feature bit when the RISC-V backend sees that the
LLVM module has the `cf-protection-branch` attribute set to `1`, and the
`cf-branch-label-scheme` attribute set to `unlabeled`, so
linkers/loaders know that the object file is built with Zicfilp-based
forward-edge CFI protection with the "unlabeled" scheme.

-----

Co-authored-by: Piyou chen <piyou.chen at sifive.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list