[flang-commits] [flang] [flang][debug] Allow non default array lower bounds. (PR #104467)

Abid Qadeer via flang-commits flang-commits at lists.llvm.org
Tue Aug 20 08:11:18 PDT 2024


================
@@ -174,20 +175,22 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertSequenceType(
       elements.push_back(subrangeTy);
     } else {
       auto intTy = mlir::IntegerType::get(context, 64);
-      // FIXME: Only supporting lower bound of 1 at the moment. The
-      // 'SequenceType' has information about the shape but not the shift. In
-      // cases where the conversion originated during the processing of
-      // 'DeclareOp', it may be possible to pass on this information. But the
-      // type conversion should ideally be based on what information present in
-      // the type class so that it works from everywhere (e.g. when it is part
-      // of a module or a derived type.)
+      int64_t shift = 1;
+      if (declOp && declOp.getShift().size() > index) {
+        if (auto defOp = mlir::dyn_cast<mlir::arith::ConstantOp>(
+                declOp.getShift()[index].getDefiningOp())) {
+          if (auto iattr = mlir::dyn_cast<mlir::IntegerAttr>(defOp.getValue()))
+            shift = iattr.getInt();
+        }
+      }
----------------
abidh wrote:

> The case were the lower bound is not a compile time constant is not covered, right? If so, you should probably add a FIXME note here to track this.

That case goes to `if (dim == seqTy.getUnknownExtent())` and there is a FIXME there.

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


More information about the flang-commits mailing list