[flang-commits] [flang] [flang] Fixed designator codegen for contiguous boxes. (PR #139003)
via flang-commits
flang-commits at lists.llvm.org
Fri May 9 01:16:06 PDT 2025
================
@@ -753,9 +754,24 @@ std::pair<mlir::Value, mlir::Value> hlfir::genVariableFirBaseShapeAndParams(
}
if (entity.isScalar())
return {fir::getBase(exv), mlir::Value{}};
+
+ // Contiguous variables that are represented with a box
+ // may require the shape to be extracted from the box (i.e. evx),
+ // because they itself may not have shape specified.
+ // This happens during late propagationg of contiguous
+ // attribute, e.g.:
+ // %9:2 = hlfir.declare %6
+ // {fortran_attrs = #fir.var_attrs<contiguous>} :
+ // (!fir.box<!fir.array<?x?x...>>) ->
+ // (!fir.box<!fir.array<?x?x...>>, !fir.box<!fir.array<?x?x...>>)
+ // The extended value is an ArrayBoxValue with base being
+ // the raw address of the array.
if (auto variableInterface = entity.getIfVariableInterface())
- return {fir::getBase(exv),
- asEmboxShape(loc, builder, exv, variableInterface.getShape())};
+ if (mlir::isa<fir::BaseBoxType>(fir::getBase(exv).getType()) ||
+ !mlir::isa<fir::BaseBoxType>(entity.getType()) ||
+ variableInterface.getShape())
----------------
jeanPerier wrote:
If the CONTIGUOUS variable has custom lower bounds, I think there will be a `fir.shift` returned by `variableInterface.getShape()` instead of the needed fir.shift_shape.
https://github.com/llvm/llvm-project/pull/139003
More information about the flang-commits
mailing list