Barrier() failing if there isn't any shared memory used

I have a case where barrier() isn’t causing any synchronization unless there is a single access to shared memory regardless if that access is used or not.

So I have a number of blocks in my computer shader where I access global memory from SSBO both by atomic and non-atomic reads and writes. Each block is protected by a

memoryBarrier();
barrier();

pair. The code works perfectly if I place a write to a single dummy shared variable at the top of the shader that isn’t used anywhere else otherwise it fails because not all memory writes has finished before next block reads. I can’t see any other way than this is a compiler bug. Spir-v disassembly includes the same synchronization in both cases.

It’s a single workgroup with 1024 threads.

Geforce 1080 ti on 531.79

Hi David,

Could you provide a minimal sample code/executable of your application to repro the issue?