[llvm] [NVPTX] Add syncscope support for cmpxchg (PR #140812)

via llvm-commits llvm-commits at lists.llvm.org
Fri May 30 09:33:37 PDT 2025


================
@@ -2327,18 +2327,20 @@ TargetLoweringBase::getAtomicMemOperandFlags(const Instruction &AI,
 
 Instruction *TargetLoweringBase::emitLeadingFence(IRBuilderBase &Builder,
                                                   Instruction *Inst,
-                                                  AtomicOrdering Ord) const {
+                                                  AtomicOrdering Ord,
+                                                  SyncScope::ID SSID) const {
   if (isReleaseOrStronger(Ord) && Inst->hasAtomicStore())
-    return Builder.CreateFence(Ord);
+    return Builder.CreateFence(Ord, SSID);
----------------
gonzalobg wrote:

Why is it incorrect to read the scope from the `Instruction *Inst` here ? (and similar for `emitTrailingFence` below)
That'd avoid having to ass `SyncScope::ID SSID` as an argument to all the APIs.

I'd expect the fences added around atomics to always have the same syncscope as the atomic (otherwise the synchronization would not be correct).

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


More information about the llvm-commits mailing list