[Mlir-commits] [mlir] [MLIR] Improve translation of DISubrange. (PR #93689)

Abid Qadeer llvmlistbot at llvm.org
Thu May 30 04:23:42 PDT 2024


https://github.com/abidh updated https://github.com/llvm/llvm-project/pull/93689

>From cfa6b5e7bc7ae0e729ad2aff97de0faf6b9b05e6 Mon Sep 17 00:00:00 2001
From: Abid Qadeer <haqadeer at amd.com>
Date: Tue, 28 May 2024 12:12:45 +0100
Subject: [PATCH 1/2] [MLIR] Improve translation of DISubrange.

The DISubrange can take integer, dwarf expressions or variables. The
current translation only handled integers. This PR adds handling of
dwarf expressions and variables.
---
 .../mlir/Dialect/LLVMIR/LLVMAttrDefs.td       |  8 ++--
 mlir/lib/Target/LLVMIR/DebugImporter.cpp      | 29 ++++++++++----
 mlir/lib/Target/LLVMIR/DebugTranslation.cpp   | 19 ++++++++--
 mlir/test/Target/LLVMIR/Import/debug-info.ll  | 23 +++++++----
 mlir/test/Target/LLVMIR/llvmir-debug.mlir     | 38 +++++++++++++++++++
 5 files changed, 95 insertions(+), 22 deletions(-)

diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
index 535cf8dfd2ced..87fa6b388f7a4 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
@@ -625,10 +625,10 @@ def LLVM_DINamespaceAttr : LLVM_Attr<"DINamespace", "di_namespace",
 def LLVM_DISubrangeAttr : LLVM_Attr<"DISubrange", "di_subrange", /*traits=*/[],
                                     "DINodeAttr"> {
   let parameters = (ins
-    OptionalParameter<"IntegerAttr">:$count,
-    OptionalParameter<"IntegerAttr">:$lowerBound,
-    OptionalParameter<"IntegerAttr">:$upperBound,
-    OptionalParameter<"IntegerAttr">:$stride
+    OptionalParameter<"::mlir::Attribute">:$count,
+    OptionalParameter<"::mlir::Attribute">:$lowerBound,
+    OptionalParameter<"::mlir::Attribute">:$upperBound,
+    OptionalParameter<"::mlir::Attribute">:$stride
   );
   let assemblyFormat = "`<` struct(params) `>`";
 }
diff --git a/mlir/lib/Target/LLVMIR/DebugImporter.cpp b/mlir/lib/Target/LLVMIR/DebugImporter.cpp
index 6c011b3c756ff..0010589c5068d 100644
--- a/mlir/lib/Target/LLVMIR/DebugImporter.cpp
+++ b/mlir/lib/Target/LLVMIR/DebugImporter.cpp
@@ -217,21 +217,34 @@ DISubprogramAttr DebugImporter::translateImpl(llvm::DISubprogram *node) {
 }
 
 DISubrangeAttr DebugImporter::translateImpl(llvm::DISubrange *node) {
-  auto getIntegerAttrOrNull = [&](llvm::DISubrange::BoundType data) {
-    if (auto *constInt = llvm::dyn_cast_or_null<llvm::ConstantInt *>(data))
+  auto getAttrOrNull =
+      [&](llvm::DISubrange::BoundType data) -> mlir::Attribute {
+    if (data.isNull())
+      return nullptr;
+
+    if (auto *constInt = llvm::dyn_cast<llvm::ConstantInt *>(data)) {
       return IntegerAttr::get(IntegerType::get(context, 64),
                               constInt->getSExtValue());
-    return IntegerAttr();
+    } else if (auto *expr = llvm::dyn_cast<llvm::DIExpression *>(data)) {
+      return translateExpression(expr);
+    } else if (auto *var = llvm::dyn_cast<llvm::DIVariable *>(data)) {
+      if (auto *local = llvm::dyn_cast<llvm::DILocalVariable>(var))
+        return translate(local);
+      else if (auto *global = llvm::dyn_cast<llvm::DIGlobalVariable>(var))
+        return translate(global);
+      llvm_unreachable("Unknown variable type");
+    }
+    llvm_unreachable("Unknown DISubrange::BoundType");
   };
-  IntegerAttr count = getIntegerAttrOrNull(node->getCount());
-  IntegerAttr upperBound = getIntegerAttrOrNull(node->getUpperBound());
+  auto count = getAttrOrNull(node->getCount());
+  auto upperBound = getAttrOrNull(node->getUpperBound());
   // Either count or the upper bound needs to be present. Otherwise, the
   // metadata is invalid. The conversion might fail due to unsupported DI nodes.
   if (!count && !upperBound)
     return {};
-  return DISubrangeAttr::get(
-      context, count, getIntegerAttrOrNull(node->getLowerBound()), upperBound,
-      getIntegerAttrOrNull(node->getStride()));
+  return DISubrangeAttr::get(context, count,
+                             getAttrOrNull(node->getLowerBound()), upperBound,
+                             getAttrOrNull(node->getStride()));
 }
 
 DISubroutineTypeAttr
diff --git a/mlir/lib/Target/LLVMIR/DebugTranslation.cpp b/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
index dfb7d4952157d..d619cf43fde86 100644
--- a/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
@@ -314,11 +314,24 @@ llvm::DINamespace *DebugTranslation::translateImpl(DINamespaceAttr attr) {
 }
 
 llvm::DISubrange *DebugTranslation::translateImpl(DISubrangeAttr attr) {
-  auto getMetadataOrNull = [&](IntegerAttr attr) -> llvm::Metadata * {
+  auto getMetadataOrNull = [&](Attribute attr) -> llvm::Metadata * {
     if (!attr)
       return nullptr;
-    return llvm::ConstantAsMetadata::get(llvm::ConstantInt::getSigned(
-        llvm::Type::getInt64Ty(llvmCtx), attr.getInt()));
+
+    if (auto intAttr = llvm::dyn_cast<IntegerAttr>(attr)) {
+      return llvm::ConstantAsMetadata::get(llvm::ConstantInt::getSigned(
+          llvm::Type::getInt64Ty(llvmCtx), intAttr.getInt()));
+    } else if (auto exprAttr = llvm::dyn_cast<LLVM::DIExpressionAttr>(attr)) {
+      return translateExpression(exprAttr);
+    } else if (auto localVar =
+                   llvm::dyn_cast<LLVM::DILocalVariableAttr>(attr)) {
+      return translate(localVar);
+    } else if (auto globalVar =
+                   llvm::dyn_cast<LLVM::DIGlobalVariableAttr>(attr)) {
+      return translate(globalVar);
+    } else {
+      llvm_unreachable("Unexpected Attribute value");
+    }
   };
   return llvm::DISubrange::get(llvmCtx, getMetadataOrNull(attr.getCount()),
                                getMetadataOrNull(attr.getLowerBound()),
diff --git a/mlir/test/Target/LLVMIR/Import/debug-info.ll b/mlir/test/Target/LLVMIR/Import/debug-info.ll
index 72c828448d088..0c6a7368b7b88 100644
--- a/mlir/test/Target/LLVMIR/Import/debug-info.ll
+++ b/mlir/test/Target/LLVMIR/Import/debug-info.ll
@@ -161,12 +161,17 @@ define void @derived_type() !dbg !3 {
 
 ; CHECK-DAG: #[[INT:.+]] = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "int">
 ; CHECK-DAG: #[[FILE:.+]] = #llvm.di_file<"debug-info.ll" in "/">
+; CHECK-DAG: #[[VAR:.+]] = #llvm.di_local_variable<{{.*}}name = "size">
+; CHECK-DAG: #[[GV:.+]] = #llvm.di_global_variable<{{.*}}name = "gv"{{.*}}>
 ; CHECK-DAG: #[[COMP1:.+]] = #llvm.di_composite_type<tag = DW_TAG_array_type, name = "array1", line = 10, baseType = #[[INT]], sizeInBits = 128, alignInBits = 32>
 ; CHECK-DAG: #[[COMP2:.+]] = #llvm.di_composite_type<{{.*}}, file = #[[FILE]], scope = #[[FILE]], baseType = #[[INT]]>
 ; CHECK-DAG: #[[COMP3:.+]] = #llvm.di_composite_type<{{.*}}, flags = Vector, elements = #llvm.di_subrange<count = 4 : i64>>
 ; CHECK-DAG: #[[COMP4:.+]] = #llvm.di_composite_type<{{.*}}, flags = Vector, elements = #llvm.di_subrange<lowerBound = 0 : i64, upperBound = 4 : i64, stride = 1 : i64>>
-; CHECK-DAG: #[[COMP5:.+]] = #llvm.di_composite_type<{{.*}}, flags = Vector>
-; CHECK-DAG: #llvm.di_subroutine_type<types = #[[COMP1]], #[[COMP2]], #[[COMP3]], #[[COMP4]], #[[COMP5]]>
+; CHECK-DAG: #[[COMP5:.+]] = #llvm.di_composite_type<{{.*}}, name = "var_elements"{{.*}}elements = #llvm.di_subrange<count = #[[VAR]], stride = #[[GV]]>>
+; CHECK-DAG: #[[COMP6:.+]] = #llvm.di_composite_type<{{.*}}, name = "expr_elements"{{.*}}elements = #llvm.di_subrange<count = #llvm.di_expression<[DW_OP_push_object_address, DW_OP_plus_uconst(16), DW_OP_deref]>>>
+; CHECK-DAG: #llvm.di_subroutine_type<types = #[[COMP1]], #[[COMP2]], #[[COMP3]], #[[COMP4]], #[[COMP5]], #[[COMP6]]>
+
+ at gv = external global i64
 
 define void @composite_type() !dbg !3 {
   ret void
@@ -179,7 +184,7 @@ define void @composite_type() !dbg !3 {
 !2 = !DIFile(filename: "debug-info.ll", directory: "/")
 !3 = distinct !DISubprogram(name: "composite_type", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1, type: !4)
 !4 = !DISubroutineType(types: !5)
-!5 = !{!7, !8, !9, !10, !18}
+!5 = !{!7, !8, !9, !10, !18, !22}
 !6 = !DIBasicType(name: "int")
 !7 = !DICompositeType(tag: DW_TAG_array_type, name: "array1", line: 10, size: 128, align: 32, baseType: !6)
 !8 = !DICompositeType(tag: DW_TAG_array_type, name: "array2", file: !2, scope: !2, baseType: !6)
@@ -189,12 +194,16 @@ define void @composite_type() !dbg !3 {
 !12 = !DISubrange(lowerBound: 0, upperBound: 4, stride: 1)
 !13 = !{!11}
 !14 = !{!12}
-
-; Verifies that unsupported subrange nodes are skipped.
-!15 = !DISubrange(count: !16)
+!15 = !DISubrange(count: !16, stride: !23)
 !16 = !DILocalVariable(scope: !3, name: "size")
 !17 = !{!15}
-!18 = !DICompositeType(tag: DW_TAG_array_type, name: "unsupported_elements", flags: DIFlagVector, elements: !17, baseType: !6)
+!18 = !DICompositeType(tag: DW_TAG_array_type, name: "var_elements", flags: DIFlagVector, elements: !17, baseType: !6)
+!19 = !DISubrange(count: !20)
+!20 = !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 16, DW_OP_deref)
+!21 = !{!19}
+!22 = !DICompositeType(tag: DW_TAG_array_type, name: "expr_elements", flags: DIFlagVector, elements: !21, baseType: !6)
+!23 = !DIGlobalVariable(name: "gv", scope: !1, file: !2, line: 3, type: !6, isLocal: false, isDefinition: false)
+
 
 ; // -----
 
diff --git a/mlir/test/Target/LLVMIR/llvmir-debug.mlir b/mlir/test/Target/LLVMIR/llvmir-debug.mlir
index e5c233bc5e9bb..1913a5564d929 100644
--- a/mlir/test/Target/LLVMIR/llvmir-debug.mlir
+++ b/mlir/test/Target/LLVMIR/llvmir-debug.mlir
@@ -519,3 +519,41 @@ llvm.func @fn_with_composite() {
 // CHECK-SAME: associated: !DIExpression(DW_OP_lit0, DW_OP_eq)
 // CHECK-SAME: allocated: !DIExpression(DW_OP_lit0, DW_OP_ne)
 // CHECK-SAME: rank: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 16, DW_OP_deref)
+
+// -----
+
+// Test that Subrange works with expression and variables.
+
+#di_basic_type = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "int">
+#di_file = #llvm.di_file<"debug-info.ll" in "/">
+#di_compile_unit = #llvm.di_compile_unit<id = distinct[1]<>, sourceLanguage = DW_LANG_Fortran95, file = #di_file, isOptimized = false, emissionKind = Full>
+#di_composite_type = #llvm.di_composite_type<tag = DW_TAG_array_type, name = "expr_elements", baseType = #di_basic_type, flags = Vector, elements = #llvm.di_subrange<count = #llvm.di_expression<[DW_OP_push_object_address, DW_OP_plus_uconst(16), DW_OP_deref]>>>
+#di_subroutine_type = #llvm.di_subroutine_type<types = #di_basic_type, #di_composite_type>
+#di_subprogram = #llvm.di_subprogram<id = distinct[2]<>, compileUnit = #di_compile_unit, scope = #di_file, name = "subranges", file = #di_file, subprogramFlags = Definition, type = #di_subroutine_type>
+#di_local_variable = #llvm.di_local_variable<scope = #di_subprogram, name = "size">
+#gv1 = #llvm.di_global_variable<scope = #di_compile_unit, name = "gv", file = #di_file, line = 3, type = #di_basic_type>
+#gve1 = #llvm.di_global_variable_expression<var = #gv1, expr = <>>
+#di_composite_type1 = #llvm.di_composite_type<tag = DW_TAG_array_type, name = "var_elements", baseType = #di_basic_type, flags = Vector, elements = #llvm.di_subrange<count = #di_local_variable, stride = #gv1>>
+#di_local_variable1 = #llvm.di_local_variable<scope = #di_subprogram, name = "size", type = #di_composite_type1>
+#loc1 = loc("test.f90": 1:1)
+#loc2 = loc(fused<#di_subprogram>[#loc1])
+
+module attributes {} {
+  llvm.mlir.global external @gv() {dbg_expr = #gve1} : i64
+
+  llvm.func @subranges(%arg: !llvm.ptr) {
+    llvm.intr.dbg.declare #di_local_variable1 = %arg : !llvm.ptr
+    llvm.return
+  } loc(#loc2)
+}
+
+// CHECK-LABEL: define void @subranges
+// CHECK: ![[GV:[0-9]+]] = {{.*}}!DIGlobalVariable(name: "gv"{{.*}})
+// CHECK: !DICompositeType(tag: DW_TAG_array_type, name: "expr_elements"{{.*}}elements: ![[ELEMENTS1:[0-9]+]])
+// CHECK: ![[ELEMENTS1]] = !{![[ELEMENT1:[0-9]+]]}
+// CHECK: ![[ELEMENT1]] = !DISubrange(count: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 16, DW_OP_deref))
+
+// CHECK: !DICompositeType(tag: DW_TAG_array_type, name: "var_elements"{{.*}}elements: ![[ELEMENTS2:[0-9]+]])
+// CHECK: ![[ELEMENTS2]] = !{![[ELEMENT2:[0-9]+]]}
+// CHECK: ![[ELEMENT2]] = !DISubrange(count: ![[SR2:[0-9]+]], stride: ![[GV:[0-9]+]])
+// CHECK: ![[SR2]] = !DILocalVariable(name: "size"{{.*}})

>From c6f1cdf8f4540de6c1bc9855f2ccffe5f148950b Mon Sep 17 00:00:00 2001
From: Abid Qadeer <haqadeer at amd.com>
Date: Thu, 30 May 2024 12:06:16 +0100
Subject: [PATCH 2/2] Handle review comments.

1. Handle formatting nits.
2. Use TypeSwitch instead of multiple if/else
3. Respect 80 column limit in tests.
---
 mlir/lib/Target/LLVMIR/DebugImporter.cpp    | 17 +++++-----
 mlir/lib/Target/LLVMIR/DebugTranslation.cpp | 33 ++++++++++--------
 mlir/test/Target/LLVMIR/llvmir-debug.mlir   | 37 +++++++++++++--------
 3 files changed, 50 insertions(+), 37 deletions(-)

diff --git a/mlir/lib/Target/LLVMIR/DebugImporter.cpp b/mlir/lib/Target/LLVMIR/DebugImporter.cpp
index 0010589c5068d..e1e444753ae33 100644
--- a/mlir/lib/Target/LLVMIR/DebugImporter.cpp
+++ b/mlir/lib/Target/LLVMIR/DebugImporter.cpp
@@ -221,23 +221,22 @@ DISubrangeAttr DebugImporter::translateImpl(llvm::DISubrange *node) {
       [&](llvm::DISubrange::BoundType data) -> mlir::Attribute {
     if (data.isNull())
       return nullptr;
-
-    if (auto *constInt = llvm::dyn_cast<llvm::ConstantInt *>(data)) {
+    if (auto *constInt = llvm::dyn_cast<llvm::ConstantInt *>(data))
       return IntegerAttr::get(IntegerType::get(context, 64),
                               constInt->getSExtValue());
-    } else if (auto *expr = llvm::dyn_cast<llvm::DIExpression *>(data)) {
+    if (auto *expr = llvm::dyn_cast<llvm::DIExpression *>(data))
       return translateExpression(expr);
-    } else if (auto *var = llvm::dyn_cast<llvm::DIVariable *>(data)) {
+    if (auto *var = llvm::dyn_cast<llvm::DIVariable *>(data)) {
       if (auto *local = llvm::dyn_cast<llvm::DILocalVariable>(var))
         return translate(local);
-      else if (auto *global = llvm::dyn_cast<llvm::DIGlobalVariable>(var))
+      if (auto *global = llvm::dyn_cast<llvm::DIGlobalVariable>(var))
         return translate(global);
-      llvm_unreachable("Unknown variable type");
+      return nullptr;
     }
-    llvm_unreachable("Unknown DISubrange::BoundType");
+    return nullptr;
   };
-  auto count = getAttrOrNull(node->getCount());
-  auto upperBound = getAttrOrNull(node->getUpperBound());
+  mlir::Attribute count = getAttrOrNull(node->getCount());
+  mlir::Attribute upperBound = getAttrOrNull(node->getUpperBound());
   // Either count or the upper bound needs to be present. Otherwise, the
   // metadata is invalid. The conversion might fail due to unsupported DI nodes.
   if (!count && !upperBound)
diff --git a/mlir/lib/Target/LLVMIR/DebugTranslation.cpp b/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
index d619cf43fde86..6f5abac6d8040 100644
--- a/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
@@ -318,20 +318,25 @@ llvm::DISubrange *DebugTranslation::translateImpl(DISubrangeAttr attr) {
     if (!attr)
       return nullptr;
 
-    if (auto intAttr = llvm::dyn_cast<IntegerAttr>(attr)) {
-      return llvm::ConstantAsMetadata::get(llvm::ConstantInt::getSigned(
-          llvm::Type::getInt64Ty(llvmCtx), intAttr.getInt()));
-    } else if (auto exprAttr = llvm::dyn_cast<LLVM::DIExpressionAttr>(attr)) {
-      return translateExpression(exprAttr);
-    } else if (auto localVar =
-                   llvm::dyn_cast<LLVM::DILocalVariableAttr>(attr)) {
-      return translate(localVar);
-    } else if (auto globalVar =
-                   llvm::dyn_cast<LLVM::DIGlobalVariableAttr>(attr)) {
-      return translate(globalVar);
-    } else {
-      llvm_unreachable("Unexpected Attribute value");
-    }
+    llvm::Metadata *metadata =
+        llvm::TypeSwitch<Attribute, llvm::Metadata *>(attr)
+            .Case<IntegerAttr>([&](IntegerAttr intAttr) {
+              return llvm::ConstantAsMetadata::get(llvm::ConstantInt::getSigned(
+                  llvm::Type::getInt64Ty(llvmCtx), intAttr.getInt()));
+            })
+            .Case<LLVM::DIExpressionAttr>([&](LLVM::DIExpressionAttr expr) {
+              return translateExpression(expr);
+            })
+            .Case<LLVM::DILocalVariableAttr>(
+                [&](LLVM::DILocalVariableAttr local) {
+                  return translate(local);
+                })
+            .Case<LLVM::DIGlobalVariableAttr>(
+                [&](LLVM::DIGlobalVariableAttr global) {
+                  return translate(global);
+                })
+            .Default([&](Attribute attr) { return nullptr; });
+    return metadata;
   };
   return llvm::DISubrange::get(llvmCtx, getMetadataOrNull(attr.getCount()),
                                getMetadataOrNull(attr.getLowerBound()),
diff --git a/mlir/test/Target/LLVMIR/llvmir-debug.mlir b/mlir/test/Target/LLVMIR/llvmir-debug.mlir
index 1913a5564d929..415a2f775612a 100644
--- a/mlir/test/Target/LLVMIR/llvmir-debug.mlir
+++ b/mlir/test/Target/LLVMIR/llvmir-debug.mlir
@@ -524,25 +524,34 @@ llvm.func @fn_with_composite() {
 
 // Test that Subrange works with expression and variables.
 
-#di_basic_type = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "int">
-#di_file = #llvm.di_file<"debug-info.ll" in "/">
-#di_compile_unit = #llvm.di_compile_unit<id = distinct[1]<>, sourceLanguage = DW_LANG_Fortran95, file = #di_file, isOptimized = false, emissionKind = Full>
-#di_composite_type = #llvm.di_composite_type<tag = DW_TAG_array_type, name = "expr_elements", baseType = #di_basic_type, flags = Vector, elements = #llvm.di_subrange<count = #llvm.di_expression<[DW_OP_push_object_address, DW_OP_plus_uconst(16), DW_OP_deref]>>>
-#di_subroutine_type = #llvm.di_subroutine_type<types = #di_basic_type, #di_composite_type>
-#di_subprogram = #llvm.di_subprogram<id = distinct[2]<>, compileUnit = #di_compile_unit, scope = #di_file, name = "subranges", file = #di_file, subprogramFlags = Definition, type = #di_subroutine_type>
-#di_local_variable = #llvm.di_local_variable<scope = #di_subprogram, name = "size">
-#gv1 = #llvm.di_global_variable<scope = #di_compile_unit, name = "gv", file = #di_file, line = 3, type = #di_basic_type>
-#gve1 = #llvm.di_global_variable_expression<var = #gv1, expr = <>>
-#di_composite_type1 = #llvm.di_composite_type<tag = DW_TAG_array_type, name = "var_elements", baseType = #di_basic_type, flags = Vector, elements = #llvm.di_subrange<count = #di_local_variable, stride = #gv1>>
-#di_local_variable1 = #llvm.di_local_variable<scope = #di_subprogram, name = "size", type = #di_composite_type1>
+#bt = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "int">
+#file = #llvm.di_file<"debug-info.ll" in "/">
+#cu = #llvm.di_compile_unit<id = distinct[1]<>,
+ sourceLanguage = DW_LANG_Fortran95, file = #file, isOptimized = false,
+ emissionKind = Full>
+#comp_ty1 = #llvm.di_composite_type<tag = DW_TAG_array_type,
+ name = "expr_elements", baseType = #bt, flags = Vector,
+ elements = #llvm.di_subrange<count = #llvm.di_expression<
+ [DW_OP_push_object_address, DW_OP_plus_uconst(16), DW_OP_deref]>>>
+#srty = #llvm.di_subroutine_type<types = #bt, #comp_ty1>
+#sp = #llvm.di_subprogram<compileUnit = #cu, scope = #file, name = "subranges",
+  file = #file, subprogramFlags = Definition, type = #srty>
+#lvar = #llvm.di_local_variable<scope = #sp, name = "size">
+#gv = #llvm.di_global_variable<scope = #cu, name = "gv", file = #file,
+ line = 3, type = #bt>
+#gve = #llvm.di_global_variable_expression<var = #gv, expr = <>>
+#comp_ty2 = #llvm.di_composite_type<tag = DW_TAG_array_type,
+ name = "var_elements", baseType = #bt, flags = Vector,
+ elements = #llvm.di_subrange<count = #lvar, stride = #gv>>
+#lvar2 = #llvm.di_local_variable<scope = #sp, name = "var", type = #comp_ty2>
 #loc1 = loc("test.f90": 1:1)
-#loc2 = loc(fused<#di_subprogram>[#loc1])
+#loc2 = loc(fused<#sp>[#loc1])
 
 module attributes {} {
-  llvm.mlir.global external @gv() {dbg_expr = #gve1} : i64
+  llvm.mlir.global external @gv() {dbg_expr = #gve} : i64
 
   llvm.func @subranges(%arg: !llvm.ptr) {
-    llvm.intr.dbg.declare #di_local_variable1 = %arg : !llvm.ptr
+    llvm.intr.dbg.declare #lvar2 = %arg : !llvm.ptr
     llvm.return
   } loc(#loc2)
 }



More information about the Mlir-commits mailing list