[clang] [CIR] Add support for atomic-to-non-atomic cast (PR #193784)

Chibuoyim Ogbonna via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 23 09:26:28 PDT 2026


================
@@ -257,6 +301,36 @@ mlir::Value AtomicInfo::convertRValueToInt(RValue rvalue, bool cmpxchg) const {
   return nullptr;
 }
 
+RValue AtomicInfo::convertToValueOrAtomic(mlir::Value intVal,
+                                          AggValueSlot resultSlot,
+                                          SourceLocation loc, bool asValue,
+                                          bool cmpxchg) const {
+  // Try not to in some easy cases.
+  assert((mlir::isa<cir::IntType, cir::PointerType, cir::FPTypeInterface>(
+             intVal.getType())) &&
+         "Expected integer, pointer or floating point value when converting "
+         "result.");
+  if (getEvaluationKind() == TEK_Scalar &&
+      (((!lvalue.isBitField() ||
+         lvalue.getBitFieldInfo().size == valueSizeInBits) &&
+        !hasPadding()) ||
+       !asValue)) {
----------------
bruteforceboy wrote:

nit: is it possible to simplify this check? it's a bit hard to read.

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


More information about the cfe-commits mailing list