Skip to content

Commit 4fcf028

Browse files
committed
add checking storage to getBaseRef
1 parent 7cca8e4 commit 4fcf028

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

flang/lib/Optimizer/OpenACC/Support/FIROpenACCTypeInterfaces.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,14 @@ getBaseRef(mlir::TypedValue<mlir::acc::PointerLikeType> varPtr) {
352352
// calculation op.
353353
mlir::Value baseRef =
354354
llvm::TypeSwitch<mlir::Operation *, mlir::Value>(op)
355+
.Case<fir::DeclareOp>([&](auto op) {
356+
// If this declare binds a view with an underlying storage operand,
357+
// treat that storage as the base reference. Otherwise, fall back
358+
// to the declared memref.
359+
if (auto storage = op.getStorage())
360+
return storage;
361+
return op.getMemref();
362+
})
355363
.Case<hlfir::DesignateOp>([&](auto op) {
356364
// Get the base object.
357365
return op.getMemref();

0 commit comments

Comments
 (0)