[PR #623] [CLOSED] shader_disasm: hand llvm-mc its input in lines of 64 bytes (OLD-10020) #664

Closed
opened 2026-11-26 20:18:38 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/623
Author: @jarvixaiassistant-glitch
Created: 11/24/2026
Status: ❌ Closed

Base: main ← Head: fix/old-10020-shader-disasm-input-lines


📝 Commits (1)

  • 0b04572 shader_disasm: hand llvm-mc its input in lines of 64 bytes, not one long line

📊 Changes

2 files changed (+94 additions, -5 deletions)

View changed files

➕ tests/test_shader_disasm_input_lines.py (+84 -0)
📝 tools/shader_disasm.py (+10 -5)

📄 Description

Claimed in the coordination issue as: OLD-10020

What and why

Carries forward old-pr/10020 (draft #289) onto main (21625bca8), preserving beamdotdev's original commit verbatim per CONTRIBUTING.md:

  • Splits the hex-byte stdin passed to llvm-mc --disassemble in tools/shader_disasm.py (disasm()) into lines of 64 bytes ("\n".join(" ".join(f"0x{b:02x}" for b in code[i:i + 64]) for i in range(0, len(code), 64))) instead of a single line.
  • Verified against upstream LLVM (llvm/tools/llvm-mc/Disassembler.cpp): SkipToToken() strips " \t\r\n," and byteArrayFromString() accumulates bytes continuously across newlines into a single ByteArray (only [, ], or EOF flush printInsts()), so multi-dword RDNA2 instructions spanning a 64-byte line boundary decode byte-identically while avoiding llvm::SourceMgr quadratic line scanning on long single-line inputs (reported 58.6 s → 0.2 s on a 90 KB shader).
  • Adds tests/test_shader_disasm_input_lines.py (stdlib-only, stubs subprocess.run, no llvm-mc or game data required).
  • Audited by JARVIX's 4-model review pipeline (Antigravity + DeepSeek-V4-Pro + NVIDIA NIM Nemotron-3.5-Lightning & Nemotron-3-Ultra-550B); confirmed clean across empty b"", bytearray/memoryview, boundary sizes (1, 63, 64, 65, 128, 129), and downstream callers (NO_HARDENING_NEEDED).

Tested

All synthetic CPU/stdlib/docs checks on Windows 11 x64, Python 3.12.14, Node v24.19.0 (no game files, no llvm-mc installed locally):

  • python -I tests/test_shader_disasm_input_lines.py -v — 4/4 passed
  • python -I tests/test_ci_registration.py — 15/15 passed
  • python -I tests/test_runtime_paths.py — 5/5 passed
  • python -I scripts/check_no_game_data.py — passed (0 forbidden tracked extensions)
  • python -m compileall -q make_game.py tools tests — passed
  • python -I tests/test_text_write_line_endings.py, tests/test_report_paths.py, tests/test_i18n_index.py, and all tests/test_docs_*.py — passed
  • node --test tests/test_viewer_streaming.cjs — passed

GPUs tested: n/a (CPU disassembler input formatting / unit tests only)

AI-assisted: yes (JARVIX multi-model team: Antigravity + DeepSeek-V4-Pro + NVIDIA NIM Nemotron-3.5-Lightning & Nemotron-3-Ultra-550B)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (N/A — llvm-mc stdin line wrapping only; no shader-translator rule changed.)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/623 **Author:** [@jarvixaiassistant-glitch](https://github.com/jarvixaiassistant-glitch) **Created:** 11/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/old-10020-shader-disasm-input-lines` --- ### 📝 Commits (1) - [`0b04572`](https://github.com/ubiquitarianism/leonida/commit/0b04572d9c0d6fc424ea5e6ab971bdf0a67d58ac) shader_disasm: hand llvm-mc its input in lines of 64 bytes, not one long line ### 📊 Changes **2 files changed** (+94 additions, -5 deletions) <details> <summary>View changed files</summary> ➕ `tests/test_shader_disasm_input_lines.py` (+84 -0) 📝 `tools/shader_disasm.py` (+10 -5) </details> ### 📄 Description Claimed in the coordination issue as: OLD-10020 ### What and why Carries forward `old-pr/10020` (draft #289) onto `main` (`21625bca8`), preserving `beamdotdev`'s original commit verbatim per `CONTRIBUTING.md`: - Splits the hex-byte stdin passed to `llvm-mc --disassemble` in `tools/shader_disasm.py` (`disasm()`) into lines of 64 bytes (`"\n".join(" ".join(f"0x{b:02x}" for b in code[i:i + 64]) for i in range(0, len(code), 64))`) instead of a single line. - Verified against upstream LLVM (`llvm/tools/llvm-mc/Disassembler.cpp`): `SkipToToken()` strips `" \t\r\n,"` and `byteArrayFromString()` accumulates bytes continuously across newlines into a single `ByteArray` (only `[`, `]`, or EOF flush `printInsts()`), so multi-dword RDNA2 instructions spanning a 64-byte line boundary decode byte-identically while avoiding `llvm::SourceMgr` quadratic line scanning on long single-line inputs (reported 58.6 s → 0.2 s on a 90 KB shader). - Adds `tests/test_shader_disasm_input_lines.py` (stdlib-only, stubs `subprocess.run`, no `llvm-mc` or game data required). - Audited by JARVIX's 4-model review pipeline (Antigravity + DeepSeek-V4-Pro + NVIDIA NIM Nemotron-3.5-Lightning & Nemotron-3-Ultra-550B); confirmed clean across empty `b""`, `bytearray`/`memoryview`, boundary sizes (1, 63, 64, 65, 128, 129), and downstream callers (`NO_HARDENING_NEEDED`). ### Tested All synthetic CPU/stdlib/docs checks on Windows 11 x64, Python 3.12.14, Node v24.19.0 (no game files, no `llvm-mc` installed locally): - `python -I tests/test_shader_disasm_input_lines.py -v` — 4/4 passed - `python -I tests/test_ci_registration.py` — 15/15 passed - `python -I tests/test_runtime_paths.py` — 5/5 passed - `python -I scripts/check_no_game_data.py` — passed (0 forbidden tracked extensions) - `python -m compileall -q make_game.py tools tests` — passed - `python -I tests/test_text_write_line_endings.py`, `tests/test_report_paths.py`, `tests/test_i18n_index.py`, and all `tests/test_docs_*.py` — passed - `node --test tests/test_viewer_streaming.cjs` — passed GPUs tested: n/a (CPU disassembler input formatting / unit tests only) AI-assisted: yes (JARVIX multi-model team: Antigravity + DeepSeek-V4-Pro + NVIDIA NIM Nemotron-3.5-Lightning & Nemotron-3-Ultra-550B) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. *(N/A — `llvm-mc` stdin line wrapping only; no shader-translator rule changed.)* --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:18:38 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#664
No description provided.