[all-commits] [llvm/llvm-project] f621b6: Support scalable offset in CFI.

Petr Penzin via All-commits all-commits at lists.llvm.org
Wed Dec 3 22:13:19 PST 2025


  Branch: refs/heads/users/ppenzin/ra_saverestore_offsets
  Home:   https://github.com/llvm/llvm-project
  Commit: f621b6515740a279d51fc4ced44967b103987d13
      https://github.com/llvm/llvm-project/commit/f621b6515740a279d51fc4ced44967b103987d13
  Author: Mikhail Gudim <mgudim at ventanamicro.com>
  Date:   2025-12-03 (Wed, 03 Dec 2025)

  Changed paths:
    M llvm/include/llvm/MC/MCDwarf.h
    M llvm/include/llvm/MC/MCStreamer.h
    M llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
    M llvm/lib/CodeGen/CFIInstrInserter.cpp
    M llvm/lib/CodeGen/MIRParser/MILexer.cpp
    M llvm/lib/CodeGen/MIRParser/MILexer.h
    M llvm/lib/CodeGen/MIRParser/MIParser.cpp
    M llvm/lib/CodeGen/MachineOperand.cpp
    M llvm/lib/MC/MCDwarf.cpp
    M llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
    M llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.h
    M llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
    A llvm/test/CodeGen/MIR/RISCV/cfi-llvm-def-cfa-reg-scalable-offset.mir
    A llvm/test/CodeGen/MIR/RISCV/cfi-llvm-reg-at-scalable-offset-from-cfa.mir
    A llvm/test/CodeGen/MIR/RISCV/cfi-llvm-reg-at-scalable-offset-from-reg.mir
    A llvm/test/CodeGen/RISCV/cfi-llvm-def-cfa-reg-scalable-offset.mir
    A llvm/test/CodeGen/RISCV/cfi-llvm-reg-at-scalable-offset-from-cfa.mir
    A llvm/test/CodeGen/RISCV/cfi-llvm-reg-at-scalable-offset-from-reg.mir
    M llvm/test/CodeGen/RISCV/rvv/get-vlen-debugloc.mir
    M llvm/test/CodeGen/RISCV/rvv/wrong-stack-offset-for-rvv-object.mir
    M llvm/test/CodeGen/RISCV/rvv/zvlsseg-spill.mir

  Log Message:
  -----------
  Support scalable offset in CFI.

Currently, targets with scalable vectors (AArch64, RISCV) handle
scalable offsets in cfi using cfi_escape expression. The problem is that
CFIInstrInserter doesn't understand these expressions.

We define new "pseudo" cfi instructions to support scalable offsets in
CFI:

(1) llvm_def_cfa_reg_scalable_offset - creates the new rule for calculating
cfa: `deref(Reg + ScalableOffset * x + FixedOffset)` where `x` is the
"scale" runtime constant.

(2) llvm_reg_at_scalable_offset_from_cfa - creates the new rule to calculate
previoius value of register `deref(cfa + ScalableOffset * x +
FixedOffset)` where `x` is the "scale" runtime constant.

(3) llvm_reg_at_scalable_offset_from_reg - creates the new rule to calculate previous value
of register `deref(Reg2 + ScalableOffset * x +
FixedOffset)`. This rule is to be used when
offset from cfa is not known, but intead fixed offset from `Reg2` is
known.

All of these cfi_instructions will be "lowered" to escape expressions
during final assembly emission. But during `CFIInstrInserter` these are
not lowered yet, so their semantics can be understood without decoding
cfi expressions. Since (1) and (2) depend on how target calculates
scalable offsets, their lowering is target-dependent.


  Commit: f8b004910c604138bba0724176980727953208dd
      https://github.com/llvm/llvm-project/commit/f8b004910c604138bba0724176980727953208dd
  Author: Mikhail Gudim <mgudim at ventanamicro.com>
  Date:   2025-12-03 (Wed, 03 Dec 2025)

  Changed paths:
    A llvm/test/CodeGen/RISCV/cfi-inserter-scalable-offset.mir

  Log Message:
  -----------
  Add a test showing that scalable offsets are not handled.

Currently we encode scalable offsets in CFIs using cfi_escape. But
CFIInstrInserter can't handle cfi_escape.


  Commit: 12dfd4994538e87537dfe392a89445a3f90f4b22
      https://github.com/llvm/llvm-project/commit/12dfd4994538e87537dfe392a89445a3f90f4b22
  Author: Mikhail Gudim <mgudim at ventanamicro.com>
  Date:   2025-12-03 (Wed, 03 Dec 2025)

  Changed paths:
    M llvm/lib/CodeGen/CFIInstrInserter.cpp
    M llvm/test/CodeGen/RISCV/cfi-inserter-scalable-offset.mir

  Log Message:
  -----------
  [CFIInstrInserter] Support scalable offsets.

Add support for scalable offsets.


Compare: https://github.com/llvm/llvm-project/compare/f621b6515740%5E...12dfd4994538

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