Repository navigation
shader: prove formatted load descriptor words across a join - #3486
Merged
Merged
Conversation
lukaslw-lab
approved these changes
Nov 30, 2026
lukaslw-lab
left a comment
Contributor
There was a problem hiding this comment.
Reviewed 4a1e9685 by reading the diff; not built or run.
Verdict: approve. The predecessor proof is a sound reaching-definition check, and stricter than the block proof it sits behind. One SHOULD, which can follow. No MUST.
- SHOULD: this widens a scope #2461 (321e63a) kept on purpose: "Graphics stages keep the previous rule. Descriptor words loaded in another block than the formatted load stay refused." The new path accepts a cross-block load in every stage, and calls
formatted_pointer_copywithout the block proof'skind == 'cs'guard (gfx2hlsl.py:7882vs:7918). So a pixel shader whose table pointer is copied in a block above is now accepted, while theFORMATTED*cases uses[8:9]directly. Say so in the body and add one pixel case with a copy, or keep the guard for the copy. - Writers:
descriptor_scalar_writes(destinations,vcc, a VOP3v_cmpdestination) plusscalar_destinations(movrelgives'any'). Av_readlane_b32reload is a writer that is not ans_load, so it refuses. That is conservative. - Stricter than the block proof: the immediate offset must equal
first[2], onlyglc/dlcare allowed, an SGPR soffset refuses (_lit_u32gives None), and the high word must bes_mov_b32 s<hi>, 0on every path. - The
formatted_pointer_copyrefactor keeps the old behaviour: an entry-reaching path addsNone, and bothlen != 1andindex is Nonestill return None.
Tests: the compute join plus three refusals, the pixel dwordx8 join (stride and format from the second descriptor) plus forward-arm and back-edge refusals, and the word-0 mutation all reach the new function. CI ran both files on Linux and in binary mode with llvm-mc-15 in the gfx1013 job (both ok), so the new encodings match the assembler. That closes the body's first "Not run" item.
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.
Refs #3478 (item 3).
What changes
buffer_load_format_*past the entry block was accepted only when the descriptor load sat in the same block (formatted_descriptor_from_block). A load in an earlier block that dominates the use was refused withformatted buffer load requires descriptor words proven in the entry block or a local table load.formatted_descriptor_from_predecessor(tools/startup/gfx2hlsl.py) adds a second proof. It runs only after the existing checks inmubuf_format: all four words still carry the loaded symbol, the source is a hardware table, and the block proof failed. It accepts when:s_load_dwordx4/8/16is the last writer of all four descriptor words on every incoming path. Any other writer of any word on any path, back edges included, is a second writer and refuses. A path that carries the entry value refuses;glc/dlcmodifiers, a destination covering the four words at the expected position, an immediate offset equal to the descriptor's table offset, and a 64-bit SGPR base;s_mov_b32 s<hi>, 0;s_mov_b32copy, with no write on any path;formatted_pointer_copyis refactored onto the shareddescriptor_last_writerswalk.Refusal texts and conditions are unchanged. One existing control changed meaning: the compute case
s_branch 0followed by the load ("at a branch target there is no local descriptor load to prove") is removed and replaced by an accepted join case, since that is the shape the proof now accepts.This does not touch "buffer load through a modified descriptor" (#3100): that control is unchanged and the new path is reached only when all four words are unmodified.
Tests
New controls:
startup_gfx2hlsl_compute_check.py): join accepted with the same manifest; refused with a word-3 write on one arm, with high word = 1, and with the entry pointer rewritten (s_mov_b32 s6, s6).startup_gfx2hlsl_join_symbols_check.py):s_load_dwordx8join accepted, stride and format taken from the second descriptor; refused with a word-3 write on a forward arm and on a back edge.Passed (17, 0 FAIL): gfx2hlsl_compute, gfx2hlsl_join_symbols, gfx2hlsl_load_desc, gfx2hlsl_compute_spill, gfx2hlsl_readfirstlane_load_recompute, gfx2hlsl_readfirstlane_uniform, gfx2hlsl_tbuffer_16f, gfx2hlsl_heap_record, gfx2hlsl_handler_arity, buffer_address, buffer_format_word3_table, gfx2hlsl_refusals, gfx2hlsl_op_refusals, gfx2hlsl_spill_branches, gfx2hlsl_compute_mask_spill, mesh57_skeleton, vertex_fetch_formats controls.
Mutation: with the predecessor proof walking word 0 only, compute_check fails (
accepted, expected a refusal naming 'local table load') and join_symbols fails (FORMATTED_REWRITE accepted). Restored, both pass.Not run
binary <llvm-mc>modes of compute and join_symbols:llvm-mcis not installed on our host, so the newSOURCE_L_JOINandFORMATTED*word encodings are not checked against an assembler.startup_mubuf_descriptor_checkand thestartup_compute_store_*ctests (need built binaries).gfx2hlsl.py. They merge without conflict; the combined tree was not tested.