Skip to content

shader: pin the per-lane heap index at its waterfall mark - #3315

Open
SimSalabimse wants to merge 1 commit into
R0Y00:mainfrom
SimSalabimse:cursor/heap-record-index-temp-edb4
Open

SimSalabimse wants to merge 1 commit into
R0Y00:mainfrom
SimSalabimse:cursor/heap-record-index-temp-edb4

Conversation

@SimSalabimse

Copy link
Copy Markdown
Contributor

Closes #3304.

The per-lane heap-record lowering in gfx2hlsl.py (from #2861) read the index SGPR at the s_load, not at the waterfall mark. If that SGPR was written between the mark and the load, the load silently picked record 0 (rh[0]).

What changed

  • tools/startup/gfx2hlsl.py: copy the index SGPR into a temporary when the mark is made, and have the load read that copy. An expression that still names the original SGPR after a write is refused instead of lowered.
  • tests/startup_compute_waterfall_heap_check.py: mark-time pin cases, including a clobber between the mark and the load, v_lshrrev bounds, an unbounded v_mov copy, and a stale-capture refusal. Both mutants from the issue now fail the check.
  • docs/experiments.md: one sentence on the temporary and the refusal.

Tests

  • Linux: startup_compute_waterfall_heap_check.py and the issue's repro.
  • Windows test PC (NVIDIA, 32-lane waves), at 74b4ded9, ctest -j 1 -R "waterfall_heap|startup_gfx2hlsl_" (audio device tests excluded): 391/391 passed, twice. That includes startup_compute_waterfall_heap_{oracle,dispatch}_{warp,hardware}.

AI-assisted (Cursor)

The waterfall load read the index SGPR at the s_load, so a write between
the mark and the load selected record 0. Copy the index into a temporary
at the mark, and refuse an expression that still names that SGPR.

Closes R0Y00#3304

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

shader: heap-record lowering reads rh[0] when the index SGPR is overwritten before the load

2 participants