Shader tests: LLVM's verifier over every module the tests emit #68
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/68"
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?
Imported from uiliannn/VItoriaBr. Originally posted by lcg007xd-c on 2026-11-25T21:34:22Z.
What
The DXIL we emit is LLVM bitcode, so LLVM's own verifier can check it on any platform. Today a broken module is caught only by
dxil.dll, and only on Windows. That covers the class of bug the README mentions: a phi or value that does not dominate its uses.This adds a test-only hook where
Shader::finishwrites the bitcode, right next to thecensushook. WhenVICTORY_LLVM_OPTnames anoptbinary, every module any test emits goes throughopt -passes=verify. A rejected module fails the test that made it, with LLVM's message, and the module is saved to the temp directory forllvm-dis. When the variable is unset, nothing happens. The Windows job is unchanged.Details:
i8is 8-bit aligned. Plainopt/llvm-disrefuse it ("i8 must be 8-bit aligned"), so the check passes DXIL's layout as-data-layout.optthat can't read the module at all (too old, or something else namedopt) is reported once and then not asked again.portablejob setsVICTORY_LLVM_OPTto the newestopton the runner image, if there is one, and prints its version.Tests
the_verifier_rejects_a_use_its_definition_does_not_dominatebuilds a two-armed diamond with the bitcode writer. It checks that the phi version verifies and that the version reading the arm's value directly is rejected ("Instruction does not dominate all uses!"). So the hook is shown to really run, not just to be silent.opt),VICTORY_LLVM_OPT=opt cargo teston the portable crates passes.optran on 99 modules from thevictory-shadertests and added about 2 s.--target x86_64-pc-windows-msvc) are clean.Not tested: which LLVM the
ubuntu-latestimage has, and whether that version reads DXIL. I only had LLVM 23 here. This PR's CI log will show it on the "VICTORY_LLVM_OPT=" line. If it can't read the modules, the tests still pass, and the step only says so once.Note: the Windows
checkjob fails on current main for an unrelated reason (5668b8b, missingLayout::bytes_from), which #64 fixes.🤖 Generated with Claude Code
Imported from uiliannn/VItoriaBr. Originally posted by lmouz823-lang on 2026-11-28T08:26:27Z.
I can take native Windows validation of the verifier hook at exact head
a062b942493def27c41eea0ce84f0f0bdfc90bd9. I will inspect the external-tool and compatibility paths, run actual LLVM verification with valid and invalid controls where the required tool is available, and report missing/incompatible-tool coverage explicitly. Any justified small regression or fix will include a normal-entry reproduction, a negative control, restored-source verification and precise LLVM/module counts. AI-assisted with Codex.Imported from uiliannn/VItoriaBr. Originally posted by lmouz823-lang on 2026-11-28T08:54:26Z.
Windows CPU verification for head
a062b942493def27c41eea0ce84f0f0bdfc90bd9is complete. I found a diagnostic-file overwrite issue and included a small follow-up patch below.Actual LLVM verification
I used Rust 1.98.1 on
x86_64-pc-windows-msvcand the official LLVM 23.1.6 Windows portable archive. Its SHA256 matched the digest in the official release asset metadata,16af05919cf36958dfb4ddaa4fc4d9d4ff577f5daeb76bc112ea49cd8ced82b2.VICTORY_LLVM_OPTpointed directly to itsopt.exe. The commands ran withVICTORY_STRICT_TESTS=1and withoutVICTORY_BLESSorVICTORY_WARP. LLVM releaseAfter removing all temporary diagnostic instrumentation and cleaning the
victory-shaderpackage in an isolated target directory, the final source rebuilt and produced these results. Independent review also corrected the parameterized fixture operand name fromtwotorhs. The final reviewed source was package-cleaned, freshly compiled in 19.68 seconds, and exercised again through all selections and tool-availability cases below.emit::llvm_verify::tests::emit::lower::tests::The original test accepted the valid diamond and rejected the non-dominating definition using real LLVM. The new test also checks a valid module through
check, then catches the expected rejection panics for two different broken modules. It reads both retained files after both failures and compares each file with its own input bytes.A separate, temporary diagnostic run of the lowering group recorded 23
Shader::finishhook invocations and 23 successful realoptcalls. These are call counts. Distinct bitcode modules were not counted. The temporary markers were removed andshader.rswas restored byte-for-byte before the final rebuild and runs above.Diagnostic preservation fix and regression controls
The current
victory-broken-{pid}.bcfilename is reused within one test process. With the new regression applied to the original implementation, both rejections reported the same path and the test failed. Inspecting the retained file showed the second module'sadd i32 1, 3, confirming that it had overwritten the first diagnostic. This control ran in a fresh child process with its own temporary directory.The patch adds an atomic per-process sequence and opens each diagnostic with
create_new. Existing paths are skipped. A write failure closes the newly created file before attempting to remove it.checkretains its existing panic and unusable-tool behavior.As a second negative control, temporarily returning immediately from
checkleft the original direct-verifytest passing, while the new regression failed withthe hook accepted a broken module. The bypass was removed before the final rebuild. The upstream test changes no process-global environment variables and removes only the two distinct files created by these calls.Tool-unavailable behavior and skipped coverage
These cases were exercised in separate processes with strict tests enabled.
VICTORY_LLVM_OPTunsetThe unset and incompatible cases provide no LLVM verification coverage. The incompatible command is fault injection. The final real-LLVM runs had none of these omission diagnostics.
The lowering group's existing ignored case is
a_missing_value_stays_missing_through_two_live_joins. Its declared reason isours marks joins read through joins only with VICTORY_STRICT_JOINS (40 programs stop otherwise). It remained ignored. An initial local group wrapper expected zero ignored tests and rejected the upstream 16-pass/1-ignored result. Its expectation was corrected to that declared ignored case before acceptance. This validation covers the selected CPU tests. GPU execution,dxil.dllvalidation, game performance, other platforms, and the full workspace test suite were not exercised.Quality checks
cargo clippy --locked -p victory-shader --all-targets -- -D warnings, standalone Rustfmt checks for both the original and finalllvm_verify.rs,git diff --check, andcargo run --locked -p xtask -- policypassed. The asset policy checked 197 files.An additional
cargo fmt --all -- --checkreturned exit 1 for formatting differences in 75 existing files. Each reported file's Git blob was checked against this PR's head and was identical. The changedllvm_verify.rswas absent from that output and passed its own format check.The final patch changes one file, with 77 insertions and 10 deletions. It can be exercised through the normal test entry points with a compatible real
optconfigured.AI assistance from Codex covered the audit, patch, execution and this report.
Complete diagnostic-retention patch against this head
Pull request closed