[flang-commits] [flang] [acc][flang] Checking scalar like variables when there's storage operand to fir.declare (PR #163439)

Razvan Lupusoru via flang-commits flang-commits at lists.llvm.org
Tue Oct 14 13:50:01 PDT 2025


================
@@ -353,6 +353,14 @@ getBaseRef(mlir::TypedValue<mlir::acc::PointerLikeType> varPtr) {
   // calculation op.
   mlir::Value baseRef =
       llvm::TypeSwitch<mlir::Operation *, mlir::Value>(op)
+          .Case<fir::DeclareOp>([&](auto op) {
+            // If this declare binds a view with an underlying storage operand,
+            // treat that storage as the base reference. Otherwise, fall back
+            // to the declared memref.
+            if (auto storage = op.getStorage())
+              return storage;
+            return op.getMemref();
----------------
razvanlupusoru wrote:

This is not desirable because in FIR, having access to the fir.declare as the "base reference" allows us to get all of the Fortran properties. I would suggest returning `varPtr` instead.

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


More information about the flang-commits mailing list