[AArch64][LFI] Consolidate LFI metadata and automate addressing-mode/base mapping#6
Draft
nickdesaulniers wants to merge 11 commits into
Draft
Conversation
…base mapping Refactor AArch64 Lightweight Fault Isolation(LFI) metadata TableGen architecture to automate scalar variant and SIMD post-index mappings. This approach improves upon the previous design by centralizing all suffix-to-base instruction conversions into a single, unified LFIScalarVariant helper class. This eliminates the need for scattered, multiclass-specific string substitutions. Furthermore, size and scale checks have been fully prefixed (e.g., matching LDR/STR or LDP/STP structures), resolving previous prefix collisions where doubleword instructions were incorrectly classified. - Move LFI-specific TableGen classes into a dedicated, isolated target file: AArch64LFIInstrFormats.td. - Introduce a unified LFIScalarVariant base class that dynamically resolves an instruction's addressing mode (AddrMode) and base register-offset instruction (RoWInst) at TableGen compile-time. - Centralize the LFIInst instruction cast inside LFIInstruction to simplify LFIInst definitions across all subclasses. - Automate SIMD post-index writeback scaling via TableGen, removing over 200 lines of manual foreach mapping loops in AArch64LFI.td. - Maintain a clean separation of concerns, leaving AArch64InstrFormats.td focused strictly on core memory layout properties for the MemInfoTable. - Synchronize structure fields in AArch64MCLFIRewriter.cpp with TableGen's generated searchable primary keys.
eb6e583 to
f2b56f1
Compare
zyedidia
pushed a commit
that referenced
this pull request
Jul 7, 2026
A `breakpoint set -P <class>` with an invalid-UTF-8 class name crashes lldb with `EXC_BAD_ACCESS`. The class name is passed through unmodified, so the byte sequence `\xd0p` (an incomplete two-byte UTF-8 sequence) reaches the Python layer: ``` ./bin/lldb -b -o $'breakpoint set -P \xd0p -f main.cpp' ./bin/lldb ... PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ Stack dump: #4 PythonDictionary::GetItem(PythonObject const&) const #6 PythonDictionary::GetItemForKey(PythonObject const&) const llvm#7 PythonObject::ResolveNameWithDictionary(StringRef, PythonDictionary const&) llvm#9 ScriptedPythonInterface::CreatePluginObject<...>(...) ``` `ResolveNameWithDictionary` builds a `PythonString` from the class name and looks it up in the module dictionary. When the name is not valid UTF-8, `PyUnicode_FromStringAndSize` returns `NULL`, so the `PythonString` is left with `m_py_obj == NULL`. `GetItemForKey` forwards that object to `GetItem`, which passed the `NULL` `PyObject *` straight to `PyDict_GetItemWithError`. Debugging the crashing lldb under lldb shows the `NULL` key arriving in `GetItem`: ``` (lldb) break set -n lldb_private::python::PythonDictionary::GetItem (lldb) run --no-use-colors -b -s /tmp/bp_cmds.txt * stop reason = breakpoint 1.1 (lldb) up (lldb) frame variable key.m_py_obj (PyObject *) key.m_py_obj = nullptr ``` Continuing lands on the dereference of that `NULL` inside CPython: ``` (lldb) continue * stop reason = EXC_BAD_ACCESS (code=1, address=0x8) frame #0: PyDict_GetItemWithError + 40 -> ldr x8, [x1, #0x8] ``` `x1` holds the key argument, which is `NULL`, so reading the type field at offset `0x8` faults at address `0x8`. `GetItem` already guards against an invalid dictionary (`!IsValid()`); extend that guard to reject an invalid key as well and return `nullDeref()`. `GetItemForKey` consumes the error and returns an empty `PythonObject`, so existing callers such as `ResolveNameWithDictionary` keep working and the breakpoint command now fails cleanly instead of crashing. This was found by `lldb-commandinterpreter-fuzzer`. Adds `PythonDataObjectsTest.TestPythonDictionaryGetItemWithInvalidKey`, which feeds an invalid-UTF-8 key to `GetItem`. Without the fix the test dereferences the `NULL` key and crashes (`SIGSEGV`).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor AArch64 Lightweight Fault Isolation(LFI) metadata TableGen architecture
to automate scalar variant and SIMD post-index mappings.
This approach improves upon the previous design by centralizing all
suffix-to-base instruction conversions into a single, unified
LFIScalarVariant helper class. This eliminates the need for scattered,
multiclass-specific string substitutions. Furthermore, size and scale
checks have been fully prefixed (e.g., matching LDR/STR or LDP/STP
structures), resolving previous prefix collisions where doubleword
instructions were incorrectly classified.
AArch64LFIInstrFormats.td.
an instruction's addressing mode (AddrMode) and base register-offset
instruction (RoWInst) at TableGen compile-time.
LFIInst definitions across all subclasses.
lines of manual foreach mapping loops in AArch64LFI.td.
focused strictly on core memory layout properties for the MemInfoTable.
generated searchable primary keys.