[flang-commits] [flang] [llvm] [mlir] [flang][llvm][OpenMP] Add implicit casts to omp.atomic (PR #131603)
Kiran Chandramohan via flang-commits
flang-commits at lists.llvm.org
Thu May 1 05:25:51 PDT 2025
================
@@ -2889,9 +2889,55 @@ static void genAtomicRead(lower::AbstractConverter &converter,
fir::getBase(converter.genExprAddr(fromExpr, stmtCtx));
mlir::Value toAddress = fir::getBase(converter.genExprAddr(
*semantics::GetExpr(assignmentStmtVariable), stmtCtx));
- genAtomicCaptureStatement(converter, fromAddress, toAddress,
- leftHandClauseList, rightHandClauseList,
- elementType, loc);
+
+ if (fromAddress.getType() != toAddress.getType()) {
+ // Emit an implicit cast
+ mlir::Type toType = fir::unwrapRefType(toAddress.getType());
+ mlir::Type fromType = fir::unwrapRefType(fromAddress.getType());
+ fir::FirOpBuilder &builder = converter.getFirOpBuilder();
+ auto oldIP = builder.saveInsertionPoint();
+ builder.setInsertionPointToStart(builder.getAllocaBlock());
+ mlir::Value alloca = builder.create<fir::AllocaOp>(loc, fromType);
----------------
kiranchandramohan wrote:
Please add a comment for the need for this alloca.
https://github.com/llvm/llvm-project/pull/131603
More information about the flang-commits
mailing list