mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:30:53 +01:00
[PR #1283] [CLOSED] shader_ir: read a listing a line at a time (TOOLS-DISASM-BOUNDED-LISTING) #1315
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1315
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1283
Author: @Moriz82
Created: 11/24/2026
Status: ❌ Closed
Base:
main← Head:split/tools-disasm-bounded-listing📝 Commits (1)
47d9c3bshader_ir: read a listing a line at a time (TOOLS-DISASM-BOUNDED-LISTING)📊 Changes
1 file changed (+35 additions, -0 deletions)
View changed files
📝
tests/test_shader_ir.py(+35 -0)📄 Description
Rebased onto
bfef489cat47d9c3b8. Main already streams listings and retains the diagnostic offsets. This diff adds the large-tail and empty-file checks, which pass with the current parser. The shader IR suite passed 41 tests.Claimed in the coordination issue as: TOOLS-DISASM-BOUNDED-LISTING (claim).
Part of the split of #984 into small pull requests.
Depends on: none
Overlaps: #984 is the parent integration. #623 (open, OLD-10020) hands llvm-mc its input in lines of 64 bytes in
tools/shader_disasm.py; that also bounds what llvm-mc repeats under each message, so the integration's own change to that line (one dword per line) is left to #623 and is not repeated here. This pull request is the reader's side,tools/shader_ir.py, which #623 does not touch. #365 (open) rewords the docstring of the same file, 230 lines above this hunk. Both merge cleanly with this branch (each applied to the base and merged three-way).What and why
shader_ir.parse_fileread the whole listing into one string, split it into lines and, after the instructions, joined the lines again to count theinvalid instruction encodingmessages. The messages can be far larger than the instructions: llvm-mc prints its whole input line under every word it cannot decode, andshader_disasm.pygives it the program as one line and writes its messages to the end of the listing. A program of N bytes with B undecodable words leaves about 5·N·B bytes of messages (plus the caret lines), andparse_fileheld about twice the file in memory to read the few instructions at its start. Every tool that parses listings goes through it, the translator included.parse_filenow reads one line at a time. The messages after; ---are counted and dropped. Nothing else changes:str.splitlines()split the whole text (each line of the file is passed through it), so a listing with a form feed or another of its separators parses as before;With #623 new listings get short message lines. Listings written before it, and any program with very many undecodable words, still have long tails, and those are the ones this is for.
Tested
Linux (CachyOS, kernel 7.3.5), Python 3.14. One commit on
6293c1c4f.python3 -I tests/test_shader_ir.py: 41 tests pass (39 before, 2 new). The newtest_long_message_tail_is_counted_a_line_at_a_timewrites a synthetic listing of two instructions and 400 messages that each repeat a 2,048-byte input line (4,519,727 bytes), and requirestracemalloc's peak duringparse_fileto stay under a quarter of the file size. Peak with this change: 172,394 bytes (Python 3.14 reads through a 128 KiB buffer). The other new test covers an empty file and a last line without a newline.tools/shader_ir.py(an export of6293c1c4fwith only the test file replaced): 1 failure, that test,9229703 not less than 1129931. The other 40 pass there.; ---, message lines, lines with form feed, NEL, U+2028 and U+001E, joined with LF, CRLF or CR, with and without a final newline) give equal dictionaries, key order included, from the base'sparse_fileand this one.parse_file:tests/test_cf_ref.py(26),tests/test_cf_ref_edge_fixes.py(5),tests/test_wave_diff.py(12),tests/test_sampler_source_census.py(30),tests/test_wave32_pixel_scan.py(13),tests/test_rdna2spirv_decode.py(25),tests/semantic/test_missing_encoding.py(3) andtests/test_shader_ir_parse.py(3): all pass.ci.ymlruns it (compileall, everytests/test_*.pyoutsidetests/semantic, the semantic suite, the tracked-file guard), on the committed tree: one failing file,tests/test_imhex_patterns.py, which fails on the base commit too and is the only one there. Semantic suite: 470 files, 6,168 tests, 0 files failed, the same counts as the base.python3 -I scripts/check_no_game_data.py: passes.Not run: a real corpus (no listing of a game shader was read for this), native Windows or macOS, the runtime build (no C++ or build file changes).
GPUs tested: none (a text parser).
AI-assisted: yes (Claude Code). The numbers above come from runs on the machine named.
Checklist
6293c1c4f, one commit.docs/design.md.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.