For the tests, I think we should just add the barrier and see if that fixes the issue. Clears implying a barrier seems like something that would be fairly painful to debug in an actual application though; it's probably worth spending a bit of time to figure out the correct behaviour. Perhaps someone with Windows 10+ on an AMD and/or NVIDIA GPU could try running test_cs_uav_store() in a loop for a while?
I gave it a try on real AMD hardware, and I couldn't get it to trigger. However, I also couldn't get it to trigger if I replaced the UAV clear with a compute shader, and I couldn't get either one to trigger the bug on radv, even with mesa compiled to the same version that's in the tests. Attaching my best attempt for reference.
[scratch.diff](/uploads/c9244cb9679f14befd71485d7575baa8/scratch.diff)