• MachineScheduler blocks reordering of side-effecting instructions with loads/stores via a barrier chain. • MachineSink can still sink a ds_load across a workgroup fence, raising correctness concerns. • hasSideEffects only captures non-operand side effects; mayLoad/mayStore should signal memory barriers. • AMDGPU barriers often omit mayLoad/mayStore flags, relying on IntrNoMem, risking unintended reordering. • To enforce ordering, anchor instructions should use memory-effect flags instead of generic side effects. • The community debates whether marking ATOMIC_FENCE with mayLoad/mayStore is necessary or acceptable.

Article Summaries:

  • jayfoad 1 In MachineIR, is it allowed to reorder two instruction where one hasSideEffects and the other one mayLoad or mayStore? MachineScheduler will not do this because anything with side effects satisfies isGlobalMemoryObject and will become the new BarrierChain, and all loads and stores get dependencies to the barrier chain (see ScheduleDAGInstrs.cpp). [AMDGPU] Invalid sink of ds_load across workgroup fence · Issue #181708 · llvm/llvm-project · GitHub shows a case where MachineSink will do this. Is it wrong? Or do we need add something to the instructions to prevent this, like marking ATOM

Sources: