[flang-commits] [flang] 8239ea3 - [flang][debug] Support IndexType. (#113921)
via flang-commits
flang-commits at lists.llvm.org
Tue Oct 29 05:22:46 PDT 2024
Author: Abid Qadeer
Date: 2024-10-29T12:22:43Z
New Revision: 8239ea3918828ab9c5ea8be1f4100d464f0bf3c0
URL: https://github.com/llvm/llvm-project/commit/8239ea3918828ab9c5ea8be1f4100d464f0bf3c0
DIFF: https://github.com/llvm/llvm-project/commit/8239ea3918828ab9c5ea8be1f4100d464f0bf3c0.diff
LOG: [flang][debug] Support IndexType. (#113921)
Added:
flang/test/Transforms/debug-index-type.fir
Modified:
flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
Removed:
################################################################################
diff --git a/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp b/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
index 1ab6c76dae8eda..8e516734a90879 100644
--- a/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
+++ b/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
@@ -581,6 +581,10 @@ DebugTypeGenerator::convertType(mlir::Type Ty, mlir::LLVM::DIFileAttr fileAttr,
/*genAssociated=*/false);
} else if (auto vecTy = mlir::dyn_cast_or_null<fir::VectorType>(Ty)) {
return convertVectorType(vecTy, fileAttr, scope, declOp);
+ } else if (mlir::isa<mlir::IndexType>(Ty)) {
+ return genBasicType(context, mlir::StringAttr::get(context, "integer"),
+ llvmTypeConverter.getIndexTypeBitwidth(),
+ 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