[flang] [llvm] [mlir] [OpenMPIRBuilder] Emit __atomic_load and __atomic_compare_exchange libcalls for complex types in atomic update (PR #92364)

Tom Eccles via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 25 07:08:43 PDT 2024


================
@@ -7943,6 +7943,83 @@ Value *OpenMPIRBuilder::emitRMWOpAsInstruction(Value *Src1, Value *Src2,
   llvm_unreachable("Unsupported atomic update operation");
 }
 
+std::pair<llvm::LoadInst *, llvm::AllocaInst *>
+OpenMPIRBuilder::EmitAtomicLoadLibcall(Value *X, Type *XElemTy,
+                                       llvm::AtomicOrdering AO,
+                                       uint64_t AtomicSizeInBits) {
+  LLVMContext &Ctx = Builder.getContext();
+  Type *SizedIntTy = Type::getIntNTy(Ctx, AtomicSizeInBits * 8);
----------------
tblah wrote:

Why the multiplication by 8 here? The argument is named "atomic size in *bits*". If the atomic is 64 bits long, don't we want to use `i64` not `i512`? If this is about getting a larger alignment could this have a name to reflect that e.g. `AlignAsTy`.

Also, as the above example illustrates, do we need to check if a supported type was returned?

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


More information about the llvm-commits mailing list