[flang-commits] [flang] [flang][debug] Support IndexType. (PR #113921)

Abid Qadeer via flang-commits flang-commits at lists.llvm.org
Mon Oct 28 08:02:08 PDT 2024


https://github.com/abidh created https://github.com/llvm/llvm-project/pull/113921

None

>From 0b91a42c72cac74d776d6fa7bc65e6b659ea013e Mon Sep 17 00:00:00 2001
From: Abid Qadeer <haqadeer at amd.com>
Date: Thu, 24 Oct 2024 11:20:04 +0100
Subject: [PATCH] [flang][debug] Support IndexType.

---
 flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp |  3 +++
 flang/test/Transforms/debug-index-type.fir            | 10 ++++++++++
 2 files changed, 13 insertions(+)
 create mode 100644 flang/test/Transforms/debug-index-type.fir

diff --git a/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp b/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
index e387e27533a006..2685290de3b74a 100644
--- a/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
+++ b/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
@@ -583,6 +583,9 @@ DebugTypeGenerator::convertType(mlir::Type Ty, mlir::LLVM::DIFileAttr fileAttr,
     return convertVectorType(vecTy, fileAttr, scope, declOp);
   } else if (mlir::isa<mlir::NoneType>(Ty)) {
     return mlir::LLVM::DINullTypeAttr::get(context);
+  } else if (mlir::isa<mlir::IndexType>(Ty)) {
+    return genBasicType(context, mlir::StringAttr::get(context, "integer"), 64,
+                        llvm::dwarf::DW_ATE_signed);
   } else if (auto boxTy = mlir::dyn_cast_or_null<fir::BoxType>(Ty)) {
     auto elTy = boxTy.getElementType();
     if (auto seqTy = mlir::dyn_cast_or_null<fir::SequenceType>(elTy))
diff --git a/flang/test/Transforms/debug-index-type.fir b/flang/test/Transforms/debug-index-type.fir
new file mode 100644
index 00000000000000..20bd8471d7cf64
--- /dev/null
+++ b/flang/test/Transforms/debug-index-type.fir
@@ -0,0 +1,10 @@
+// RUN: fir-opt --add-debug-info --mlir-print-debuginfo %s | FileCheck %s
+
+module attributes {dlti.dl_spec = #dlti.dl_spec<>} {
+  func.func private @str(%arg0: index) -> i32 loc(#loc1)
+}
+#loc1 = loc("test.f90":5:1)
+
+// CHECK: #[[INT32_TY:.*]] = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "integer", sizeInBits = 32, encoding = DW_ATE_signed>
+// CHECK: #[[INT64_TY:.*]] = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "integer", sizeInBits = 64, encoding = DW_ATE_signed>
+// CHECK: #llvm.di_subroutine_type<{{.*}}types = #[[INT32_TY]], #[[INT64_TY]]>



More information about the flang-commits mailing list