[clang] [llvm] [HLSL][DXIL][SPIRV] Added DeviceMemoryBarrier() and AllMemoryBarrier() intrinsics (PR #190633)

Sietze Riemersma via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 6 12:58:39 PDT 2026


================
@@ -2928,18 +2928,19 @@ bool SPIRVInstructionSelector::selectBarrierInst(MachineInstr &I,
          "Device Scope must set UniformMemory and ImageMemory semantic "
          "in Barrier instruction");
 
-  Register MemSemReg = buildI32Constant(MemSem, I);
-  Register ScopeReg = buildI32Constant(Scope, I);
   MachineBasicBlock &BB = *I.getParent();
-  auto MI =
-      BuildMI(BB, I, I.getDebugLoc(), TII.get(BarrierType)).addUse(ScopeReg);
+  auto MI = BuildMI(BB, I, I.getDebugLoc(), TII.get(BarrierType));
 
   // OpControlBarrier needs to also set Execution Scope
   if (WithGroupSync) {
-    MI.addUse(ScopeReg);
+    Register ExecReg = buildI32Constant(SPIRV::Scope::Workgroup, I);
+    MI.addUse(ExecReg);
----------------
KungFuDonkey wrote:

This used to be fine for group memory barrier, which defines the scope twice for work group (once for exec scope and once for memory scope). With the addition of the other barriers, the exec scope is now always workgroup (WithGroupSync), and the memory scope can differ from Device (DeviceMemoryBarrier, AllMemoryBarrier) to Workgroup (GroupMemoryBarrier)


https://github.com/llvm/llvm-project/pull/190633


More information about the cfe-commits mailing list