[clang] [CIR] Proper lowering of atomic sync scope to LLVM (PR #173393)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 6 10:48:17 PST 2026


================
@@ -1721,13 +1721,17 @@ mlir::LogicalResult CIRToLLVMLoadOpLowering::matchAndRewrite(
 
   // TODO: nontemporal.
   assert(!cir::MissingFeatures::opLoadStoreNontemporal());
-  std::optional<llvm::StringRef> syncScope =
-      getLLVMSyncScope(op.getSyncScope());
+
+  std::optional<std::string> llvmSyncScope;
+  if (std::optional<cir::SyncScopeKind> syncScope = op.getSyncScope())
+    llvmSyncScope =
+        lowerMod->getTargetLoweringInfo().getLLVMSyncScope(*syncScope);
----------------
andykaylor wrote:

I think a target lowering pass such as you are suggesting would be good. I would like to see calling convention handling implemented as a more general MLIR pass that could be shared with Flang (and any other MLIR-based front end), similar to the goals of the [ABI lowering library](https://discourse.llvm.org/t/rfc-an-abi-lowering-library-for-llvm/84495) that was started last year. @adams381 is going to be starting work on this very soon.

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


More information about the cfe-commits mailing list