Skip to content

[AArch64][LFI] Consolidate LFI metadata into centralized type-safe mapping tables#5

Draft
nickdesaulniers wants to merge 11 commits into
lfi-project:llvm-pr/lfi/aarch64-rewriter-3from
nickdesaulniers:aarch64_lfi2
Draft

[AArch64][LFI] Consolidate LFI metadata into centralized type-safe mapping tables#5
nickdesaulniers wants to merge 11 commits into
lfi-project:llvm-pr/lfi/aarch64-rewriter-3from
nickdesaulniers:aarch64_lfi2

Conversation

@nickdesaulniers

Copy link
Copy Markdown

Refactor the AArch64 Lightweight Fault Isolation (LFI) metadata TableGen
architecture by moving all variant mapping relationships into explicit,
centralized lookup tables inside AArch64LFI.td.

This approach keeps core target files completely untouched by LFI
mapping metadata. Instead of dynamically resolving base instruction
names from subclass records, this design declares all mappings
explicitly in centralized tables (LFIVariantTable, PairVariantTable,
SIMDPostTable). This design guarantees 100% compile-time type safety;
TableGen verifies that all mapped variant and base instructions are
valid records, failing immediately at build-time if there are any typos.

  • Isolate LFI table entry structures (LFIVariantEntry, LFIPairVariantEntry,
    LFISIMDPostEntry) and LFIAddrMode constants into AArch64LFIInstrFormats.td.
  • Completely strip all LFI variant, pair, and SIMD metadata fields (HasLFIVariant,
    HasPairVariant, HasSIMDPost) from AArch64InstrFormats.td, leaving core formats
    focused strictly on memory layout properties for the MemInfoTable.
  • Introduce concise, type-safe helper multiclasses (LFIFamily, LFIPairFamily,
    LFIPrefetchFamily) in AArch64LFI.td to explicitly and cleanly declare all GPR,
    FPR, and Prefetch variant mappings.
  • Maintain type-safe SIMD post-index writeback scaling by mapping over 200 SIMD
    instructions via loops over structural family definitions in AArch64LFI.td.
  • Synchronize structure fields in AArch64MCLFIRewriter.cpp with TableGen's
    generated searchable primary keys.

zyedidia and others added 11 commits May 12, 2026 19:09
…pping tables

Refactor the AArch64 Lightweight Fault Isolation (LFI) metadata TableGen
architecture by moving all variant mapping relationships into explicit,
centralized lookup tables inside AArch64LFI.td.

This approach keeps core target files completely untouched by LFI
mapping metadata. Instead of dynamically resolving base instruction
names from subclass records, this design declares all mappings
explicitly in centralized tables (LFIVariantTable, PairVariantTable,
SIMDPostTable). This design guarantees 100% compile-time type safety;
TableGen verifies that all mapped variant and base instructions are
valid records, failing immediately at build-time if there are any typos.

- Isolate LFI table entry structures (LFIVariantEntry, LFIPairVariantEntry,
  LFISIMDPostEntry) and LFIAddrMode constants into AArch64LFIInstrFormats.td.
- Completely strip all LFI variant, pair, and SIMD metadata fields (HasLFIVariant,
  HasPairVariant, HasSIMDPost) from AArch64InstrFormats.td, leaving core formats
  focused strictly on memory layout properties for the MemInfoTable.
- Introduce concise, type-safe helper multiclasses (LFIFamily, LFIPairFamily,
  LFIPrefetchFamily) in AArch64LFI.td to explicitly and cleanly declare all GPR,
  FPR, and Prefetch variant mappings.
- Maintain type-safe SIMD post-index writeback scaling by mapping over 200 SIMD
  instructions via loops over structural family definitions in AArch64LFI.td.
- Synchronize structure fields in AArch64MCLFIRewriter.cpp with TableGen's
  generated searchable primary keys.
@nickdesaulniers nickdesaulniers marked this pull request as draft May 21, 2026 21:08
@zyedidia zyedidia force-pushed the llvm-pr/lfi/aarch64-rewriter-3 branch from eb6e583 to f2b56f1 Compare June 2, 2026 20:10
zyedidia pushed a commit that referenced this pull request Jul 7, 2026
…lvm#207008)

`Evaluate_DW_OP_convert` dereferenced `eval_ctx.dwarf_cu` (the
`DWARFExpression` Delegate) whenever the operand DIE offset was
non-zero,
and unconditionally read `eval_ctx.stack.back()`.  When a DWARF
expression is evaluated without a DWARF unit (as the
lldb-dwarf-expression-fuzzer does), two operand shapes crash:

- `DW_OP_convert` with a non-zero offset calls
  `dwarf_cu->GetDIEBitSizeAndSign(...)` on a null Delegate.
- `DW_OP_convert` with nothing on the stack reads the back of an empty
  vector.

The unit test feeds both with `dwarf_cu == nullptr` and crashes:

```
[ RUN      ] DWARFExpression.DW_OP_convert
 #2 SignalHandler(int, __siginfo*, void*)
 #4 DWARFExpression::Evaluate(...)
 #5 Evaluate(ArrayRef<unsigned char>, ...)
```

(SIGSEGV, the process aborts.)

Bail out with an error when the stack is empty, and when a non-zero DIE
offset is requested without a DWARF unit, instead of crashing.

Extends `DWARFExpression.DW_OP_convert` with these two cases, which
crash
without the fix.

---------

Co-authored-by: Michael Buch <michaelbuch12@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants