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

Sirui Mu via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 6 06:40:18 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);
----------------
Lancern wrote:

A simple idea would be something like a "TargetLoweringPass" that lowers CIR from a target-agnostic form to a target-specific form. This pass runs before CIR-to-LLVM lowering and CIR-to-MLIR lowering. I could also imagine that the ABI lowering pass (including calling convention lowering) could also be part of this pass.

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


More information about the cfe-commits mailing list