[flang-commits] [flang] c07abf7 - [flang][debug] Support fir::ReferenceType. (#113480)

via flang-commits flang-commits at lists.llvm.org
Thu Oct 24 03:38:21 PDT 2024


Author: Abid Qadeer
Date: 2024-10-24T11:38:17+01:00
New Revision: c07abf727220e3bd2c78b129a683ad79f735e43c

URL: https://github.com/llvm/llvm-project/commit/c07abf727220e3bd2c78b129a683ad79f735e43c
DIFF: https://github.com/llvm/llvm-project/commit/c07abf727220e3bd2c78b129a683ad79f735e43c.diff

LOG: [flang][debug] Support fir::ReferenceType. (#113480)

Added: 
    flang/test/Transforms/debug-ref-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 71e534b4f2e2a3..84f7873a9fd009 100644
--- a/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
+++ b/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
@@ -511,6 +511,11 @@ DebugTypeGenerator::convertType(mlir::Type Ty, mlir::LLVM::DIFileAttr fileAttr,
                                 /*hasDescriptor=*/false);
   } else if (auto recTy = mlir::dyn_cast_or_null<fir::RecordType>(Ty)) {
     return convertRecordType(recTy, fileAttr, scope, declOp);
+  } else if (auto refTy = mlir::dyn_cast_if_present<fir::ReferenceType>(Ty)) {
+    auto elTy = refTy.getEleTy();
+    return convertPointerLikeType(elTy, fileAttr, scope, declOp,
+                                  /*genAllocated=*/false,
+                                  /*genAssociated=*/false);
   } 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-ref-type.fir b/flang/test/Transforms/debug-ref-type.fir
new file mode 100644
index 00000000000000..2b3af485385d8a
--- /dev/null
+++ b/flang/test/Transforms/debug-ref-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 @_FortranAioBeginExternalListOutput(i8) -> !fir.ref<i8> loc(#loc1)
+}
+#loc1 = loc("test.f90":5:1)
+
+// CHECK: #[[INT8_TY:.*]] = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "integer", sizeInBits = 8, encoding = DW_ATE_signed>
+// CHECK: #[[REF_TY:.*]] = #llvm.di_derived_type<tag = DW_TAG_pointer_type, name = "", baseType = #[[INT8_TY]]{{.*}}>
+// CHECK: #llvm.di_subroutine_type<{{.*}}types = #[[REF_TY]], #[[INT8_TY]]>


        


More information about the flang-commits mailing list