[llvm] [mlir] [llvm][OpenMP] Add implicit cast to omp.atomic.read (PR #114659)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 14 03:53:33 PST 2025


================
@@ -265,6 +265,32 @@ computeOpenMPScheduleType(ScheduleKind ClauseKind, bool HasChunks,
   return Result;
 }
 
+/// Emit an implicit cast to convert \p XRead to type of variable \p V
+static llvm::Value *emitImplicitCast(IRBuilder<> &Builder, llvm::Value *XRead,
+                                     llvm::Value *V) {
+  llvm::Type *XReadType = XRead->getType();
+  llvm::Type *VType = V->getType();
+  if (llvm::AllocaInst *vAlloca = dyn_cast<llvm::AllocaInst>(V))
+    VType = vAlloca->getAllocatedType();
----------------
NimishMishra wrote:

Because the type of atomic pointer by default is `ptr`. We would like to know the real type (i.e. `AllocatedType`) in order to know whether we need a conversion or an extraction (in case of complex type).

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


More information about the llvm-commits mailing list