[flang-commits] [flang] [mlir] [flang][openacc][openmp] Support implicit casting on the atomic interface (PR #114390)

Tom Eccles via flang-commits flang-commits at lists.llvm.org
Mon Nov 4 03:13:06 PST 2024


================
@@ -411,12 +417,22 @@ void genOmpAccAtomicRead(Fortran::lower::AbstractConverter &converter,
   mlir::Value toAddress = fir::getBase(converter.genExprAddr(
       *Fortran::semantics::GetExpr(assignmentStmtVariable), stmtCtx));
   fir::FirOpBuilder &builder = converter.getFirOpBuilder();
-  if (fromAddress.getType() != toAddress.getType())
-    fromAddress =
-        builder.create<fir::ConvertOp>(loc, toAddress.getType(), fromAddress);
-  genOmpAccAtomicCaptureStatement(converter, fromAddress, toAddress,
+  mlir::Value LHSTemp = toAddress;
+  if (fromAddress.getType() != toAddress.getType()) {
+    // Create a temp for implicit type conversion.
+    LHSTemp = builder.create<fir::AllocaOp>(
----------------
tblah wrote:

You can use `fir::FirOpBuilder::getAllocaBlock` to find an appropriate place to insert an alloca.

Putting it here runs the risk of allocating stack space inside of a loop.

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


More information about the flang-commits mailing list