[flang] [llvm] [Flang][OpenMP] Generate correct present checks for implicit maps of optional allocatables (PR #138210)

via llvm-commits llvm-commits at lists.llvm.org
Thu May 8 04:22:56 PDT 2025


================
@@ -156,9 +156,9 @@ genBoundsOpsFromBox(fir::FirOpBuilder &builder, mlir::Location loc,
         builder.genIfOp(loc, resTypes, info.isPresent, /*withElseRegion=*/true)
             .genThen([&]() {
               mlir::Value box =
-                  !fir::isBoxAddress(info.addr.getType())
+                  !fir::isBoxAddress(info.rawInput.getType())
                       ? info.addr
-                      : builder.create<fir::LoadOp>(loc, info.addr);
+                      : builder.create<fir::LoadOp>(loc, info.rawInput);
----------------
jeanPerier wrote:

Thanks for the details. Isn't the load suposed to not be done on the `addr` of OPTIONAL (there seems to be some guard for optional [here](https://github.com/llvm/llvm-project/blob/82387ec13258f67a530ddb615a49e0f36e8575e1/flang/include/flang/Optimizer/Builder/DirectivesCommon.h#L85), but maybe that is not covering your case).

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


More information about the llvm-commits mailing list