1 // RUN: mlir-translate -mlir-to-llvmir --write-experimental-debuginfo=false --split-input-file %s | FileCheck %s --check-prefixes=CHECK,INTRINSICS
2 // RUN: mlir-translate -mlir-to-llvmir --write-experimental-debuginfo=true --split-input-file %s | FileCheck %s --check-prefixes=CHECK,RECORDS
4 // CHECK-LABEL: define void @func_with_empty_named_info()
5 // Check that translation doens't crash in the presence of an inlineble call
6 // with a named loc that has no backing source info.
9 } loc("calleesource.cc":1:1)
10 llvm.func @func_with_empty_named_info() {
11 llvm.call @callee() : () -> () loc("named with no line info")
15 // CHECK-LABEL: define void @func_no_debug()
17 llvm.func @func_no_debug() {
18 llvm.return loc(unknown)
21 #file = #llvm.di_file<"foo.mlir" in "/test/">
22 #si64 = #llvm.di_basic_type<
23 // Omit the optional sizeInBits and encoding parameters.
24 tag = DW_TAG_base_type, name = "si64"
26 #si32 = #llvm.di_basic_type<
27 tag = DW_TAG_base_type, name = "si32",
28 sizeInBits = 32, encoding = DW_ATE_signed
30 #ptr = #llvm.di_derived_type<
31 tag = DW_TAG_pointer_type, baseType = #si32,
32 sizeInBits = 64, alignInBits = 32, offsetInBits = 8,
35 #named = #llvm.di_derived_type<
36 // Specify the name parameter.
37 tag = DW_TAG_pointer_type, name = "named", baseType = #si32
39 #ptrWithAddressSpace = #llvm.di_derived_type<
40 tag = DW_TAG_pointer_type, baseType = #si32,
41 sizeInBits = 64, alignInBits = 32, offsetInBits = 8,
44 #cu = #llvm.di_compile_unit<
45 id = distinct[0]<>, sourceLanguage = DW_LANG_C, file = #file,
46 producer = "MLIR", isOptimized = true, emissionKind = Full,
49 #composite = #llvm.di_composite_type<
50 tag = DW_TAG_structure_type, name = "composite", file = #file,
51 line = 42, sizeInBits = 64, alignInBits = 32,
52 elements = #llvm.di_subrange<count = 4>
54 #vector = #llvm.di_composite_type<
55 tag = DW_TAG_array_type, name = "array", file = #file,
56 baseType = #si64, flags = Vector,
57 elements = #llvm.di_subrange<lowerBound = 0, upperBound = 4, stride = 1>
59 #null = #llvm.di_null_type
60 #spType0 = #llvm.di_subroutine_type<callingConvention = DW_CC_normal, types = #null, #si64, #ptr, #named, #ptrWithAddressSpace, #composite, #vector>
61 #toplevel_namespace = #llvm.di_namespace<
62 name = "toplevel", exportSymbols = true
64 #nested_namespace = #llvm.di_namespace<
65 name = "nested", scope = #toplevel_namespace, exportSymbols = false
67 #sp0 = #llvm.di_subprogram<
68 compileUnit = #cu, scope = #nested_namespace, name = "func_with_debug", linkageName = "func_with_debug",
69 file = #file, line = 3, scopeLine = 3, subprogramFlags = "Definition|Optimized", type = #spType0
71 #calleeType = #llvm.di_subroutine_type<
72 // Omit the optional callingConvention parameter.
74 #callee = #llvm.di_subprogram<
75 // Omit the optional linkageName, line, and scopeLine parameters.
76 compileUnit = #cu, scope = #composite, name = "callee",
77 file = #file, subprogramFlags = "Definition", type = #calleeType
79 #fileScope = #llvm.di_lexical_block_file<scope = #sp0, file = #file, discriminator = 0>
80 #blockScope = #llvm.di_lexical_block<scope = #sp0>
81 #variable = #llvm.di_local_variable<scope = #fileScope, name = "arg", file = #file, line = 6, arg = 1, alignInBits = 32, type = #si64>
82 #variableAddr = #llvm.di_local_variable<scope = #blockScope, name = "alloc">
83 #noNameVariable = #llvm.di_local_variable<scope = #blockScope>
84 #module = #llvm.di_module<
85 file = #file, scope = #file, name = "module",
86 configMacros = "bar", includePath = "/",
87 apinotes = "/", line = 42, isDecl = true
89 #spType1 = #llvm.di_subroutine_type<callingConvention = DW_CC_normal>
90 #sp1 = #llvm.di_subprogram<
91 compileUnit = #cu, scope = #module, name = "empty_types",
92 file = #file, subprogramFlags = "Definition", type = #spType1,
93 annotations = #llvm.di_annotation<name = "foo", value = "bar">
96 // CHECK-LABEL: define void @func_with_debug(
97 // CHECK-SAME: i64 %[[ARG:.*]]) !dbg ![[FUNC_LOC:[0-9]+]]
98 llvm.func @func_with_debug(%arg: i64) {
99 // CHECK: %[[ALLOC:.*]] = alloca
100 %allocCount = llvm.mlir.constant(1 : i32) : i32
101 %alloc = llvm.alloca %allocCount x i64 : (i32) -> !llvm.ptr
103 // INTRINSICS: call void @llvm.dbg.value(metadata i64 %[[ARG]], metadata ![[VAR_LOC:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 1))
104 // RECORDS: #dbg_value(i64 %[[ARG]], ![[VAR_LOC:[0-9]+]], !DIExpression(DW_OP_LLVM_fragment, 0, 1), !{{.*}})
105 llvm.intr.dbg.value #variable #llvm.di_expression<[DW_OP_LLVM_fragment(0, 1)]> = %arg : i64
107 // INTRINSICS: call void @llvm.dbg.declare(metadata ptr %[[ALLOC]], metadata ![[ADDR_LOC:[0-9]+]], metadata !DIExpression(DW_OP_deref, DW_OP_LLVM_convert, 4, DW_ATE_signed))
108 // RECORDS: #dbg_declare(ptr %[[ALLOC]], ![[ADDR_LOC:[0-9]+]], !DIExpression(DW_OP_deref, DW_OP_LLVM_convert, 4, DW_ATE_signed), !{{.*}})
109 llvm.intr.dbg.declare #variableAddr #llvm.di_expression<[DW_OP_deref, DW_OP_LLVM_convert(4, DW_ATE_signed)]> = %alloc : !llvm.ptr
111 // INTRINSICS: call void @llvm.dbg.value(metadata i64 %[[ARG]], metadata ![[NO_NAME_VAR:[0-9]+]], metadata !DIExpression())
112 // RECORDS: #dbg_value(i64 %[[ARG]], ![[NO_NAME_VAR:[0-9]+]], !DIExpression(), !{{.*}})
113 llvm.intr.dbg.value #noNameVariable = %arg : i64
115 // CHECK: call void @func_no_debug(), !dbg ![[FILE_LOC:[0-9]+]]
116 llvm.call @func_no_debug() : () -> () loc("foo.mlir":1:2)
118 // CHECK: call void @func_no_debug(), !dbg ![[NAMED_LOC:[0-9]+]]
119 llvm.call @func_no_debug() : () -> () loc("named"("foo.mlir":10:10))
121 // CHECK: call void @func_no_debug(), !dbg ![[MY_SOURCE_LOC:[0-9]+]]
122 llvm.call @func_no_debug() : () -> () loc(callsite("nodebug.cc":3:4 at "mysource.cc":5:6))
124 // CHECK: call void @func_no_debug(), !dbg ![[MY_SOURCE_LOC]]
125 llvm.call @func_no_debug() : () -> () loc(callsite("nodebug.cc":3:4 at fused<#sp0>["mysource.cc":5:6]))
127 // CHECK: call void @func_no_debug(), !dbg ![[FUSED_LOC:[0-9]+]]
128 llvm.call @func_no_debug() : () -> () loc(fused[callsite(fused<#callee>["mysource.cc":5:6] at "mysource.cc":1:1), "mysource.cc":1:1])
130 // CHECK: call void @func_no_debug(), !dbg ![[FUSEDWITH_LOC:[0-9]+]]
131 llvm.call @func_no_debug() : () -> () loc(callsite(callsite(fused<#callee>["foo.mlir":2:4] at "foo.mlir":1:1) at fused<#sp0>["foo.mlir":28:5]))
133 // CHECK: add i64 %[[ARG]], %[[ARG]], !dbg ![[FUSEDWITH_LOC]]
134 %sum = llvm.add %arg, %arg : i64 loc(callsite(fused<#callee>["foo.mlir":2:4] at fused<#sp0>["foo.mlir":28:5]))
137 } loc(fused<#sp0>["foo.mlir":1:1])
139 // CHECK: define void @empty_types() !dbg ![[EMPTY_TYPES_LOC:[0-9]+]]
140 llvm.func @empty_types() {
142 } loc(fused<#sp1>["foo.mlir":2:1])
144 // CHECK: ![[CU_LOC:.*]] = distinct !DICompileUnit(language: DW_LANG_C, file: ![[CU_FILE_LOC:.*]], producer: "MLIR", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, nameTableKind: None)
145 // CHECK: ![[CU_FILE_LOC]] = !DIFile(filename: "foo.mlir", directory: "/test/")
147 // CHECK: ![[FUNC_LOC]] = distinct !DISubprogram(name: "func_with_debug", linkageName: "func_with_debug", scope: ![[NESTED_NAMESPACE:.*]], file: ![[CU_FILE_LOC]], line: 3, type: ![[FUNC_TYPE:.*]], scopeLine: 3, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: ![[CU_LOC]])
148 // CHECK: ![[NESTED_NAMESPACE]] = !DINamespace(name: "nested", scope: ![[TOPLEVEL_NAMESPACE:.*]])
149 // CHECK: ![[TOPLEVEL_NAMESPACE]] = !DINamespace(name: "toplevel", scope: null, exportSymbols: true)
150 // CHECK: ![[FUNC_TYPE]] = !DISubroutineType(cc: DW_CC_normal, types: ![[FUNC_ARGS:.*]])
151 // CHECK: ![[FUNC_ARGS]] = !{null, ![[ARG_TYPE:.*]], ![[PTR_TYPE:.*]], ![[NAMED_TYPE:.*]], ![[PTR_WITH_ADDR_SPACE:.*]], ![[COMPOSITE_TYPE:.*]], ![[VECTOR_TYPE:.*]]}
152 // CHECK: ![[ARG_TYPE]] = !DIBasicType(name: "si64")
153 // CHECK: ![[PTR_TYPE]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[BASE_TYPE:.*]], size: 64, align: 32, offset: 8, extraData: ![[BASE_TYPE]])
154 // CHECK: ![[BASE_TYPE]] = !DIBasicType(name: "si32", size: 32, encoding: DW_ATE_signed)
155 // CHECK: ![[NAMED_TYPE]] = !DIDerivedType(tag: DW_TAG_pointer_type, name: "named", baseType: ![[BASE_TYPE:.*]])
156 // CHECK: ![[PTR_WITH_ADDR_SPACE]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[BASE_TYPE:.*]], size: 64, align: 32, offset: 8, dwarfAddressSpace: 3)
157 // CHECK: ![[COMPOSITE_TYPE]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "composite", file: ![[CU_FILE_LOC]], line: 42, size: 64, align: 32, elements: ![[COMPOSITE_ELEMENTS:.*]])
158 // CHECK: ![[COMPOSITE_ELEMENTS]] = !{![[COMPOSITE_ELEMENT:.*]]}
159 // CHECK: ![[COMPOSITE_ELEMENT]] = !DISubrange(count: 4)
160 // CHECK: ![[VECTOR_TYPE]] = !DICompositeType(tag: DW_TAG_array_type, name: "array", file: ![[CU_FILE_LOC]], baseType: ![[ARG_TYPE]], flags: DIFlagVector, elements: ![[VECTOR_ELEMENTS:.*]])
161 // CHECK: ![[VECTOR_ELEMENTS]] = !{![[VECTOR_ELEMENT:.*]]}
162 // CHECK: ![[VECTOR_ELEMENT]] = !DISubrange(lowerBound: 0, upperBound: 4, stride: 1)
164 // CHECK: ![[VAR_LOC]] = !DILocalVariable(name: "arg", arg: 1, scope: ![[VAR_SCOPE:.*]], file: ![[CU_FILE_LOC]], line: 6, type: ![[ARG_TYPE]], align: 32)
165 // CHECK: ![[VAR_SCOPE]] = distinct !DILexicalBlockFile(scope: ![[FUNC_LOC]], file: ![[CU_FILE_LOC]], discriminator: 0)
166 // CHECK: ![[ADDR_LOC]] = !DILocalVariable(name: "alloc", scope: ![[BLOCK_LOC:.*]])
167 // CHECK: ![[BLOCK_LOC]] = distinct !DILexicalBlock(scope: ![[FUNC_LOC]])
168 // CHECK: ![[NO_NAME_VAR]] = !DILocalVariable(scope: ![[BLOCK_LOC]])
170 // CHECK-DAG: ![[MY_SOURCE_LOC]] = !DILocation(line: 5, column: 6
171 // CHECK-DAG: ![[FILE_LOC]] = !DILocation(line: 1, column: 2,
172 // CHECK-DAG: ![[NAMED_LOC]] = !DILocation(line: 10, column: 10
173 // CHECK-DAG: ![[FUSED_LOC]] = !DILocation(line: 1, column: 1
175 // CHECK: ![[FUSEDWITH_LOC]] = !DILocation(line: 2, column: 4, scope: ![[CALLEE_LOC:.*]], inlinedAt: ![[INLINE_LOC:.*]])
176 // CHECK: ![[CALLEE_LOC]] = distinct !DISubprogram(name: "callee", scope: ![[COMPOSITE_TYPE]], file: ![[CU_FILE_LOC]], type: ![[CALLEE_TYPE:.*]], spFlags: DISPFlagDefinition, unit: ![[CU_LOC]])
177 // CHECK: ![[CALLEE_TYPE]] = !DISubroutineType(types: ![[CALLEE_ARGS:.*]])
178 // CHECK: ![[CALLEE_ARGS]] = !{![[ARG_TYPE:.*]], ![[ARG_TYPE:.*]]}
179 // CHECK: ![[INLINE_LOC]] = !DILocation(line: 28, column: 5,
181 // CHECK: ![[EMPTY_TYPES_LOC]] = distinct !DISubprogram(name: "empty_types", scope: ![[MODULE:.*]], file: ![[CU_FILE_LOC]], type: ![[EMPTY_TYPES_TYPE:.*]], spFlags: DISPFlagDefinition, unit: ![[CU_LOC]], annotations: ![[ANNOTATIONS:.*]])
182 // CHECK: ![[MODULE]] = !DIModule(scope: ![[CU_FILE_LOC]], name: "module", configMacros: "bar", includePath: "/", apinotes: "/", file: ![[CU_FILE_LOC]], line: 42, isDecl: true)
183 // CHECK: ![[EMPTY_TYPES_TYPE]] = !DISubroutineType(cc: DW_CC_normal, types: ![[EMPTY_TYPES_ARGS:.*]])
184 // CHECK: ![[EMPTY_TYPES_ARGS]] = !{}
186 // CHECK: ![[ANNOTATIONS]] = !{![[ANNOTATION:.*]]}
187 // CHECK: ![[ANNOTATION]] = !{!"foo", !"bar"}
191 #di_file = #llvm.di_file<"foo.mlir" in "/test/">
192 #di_subprogram = #llvm.di_subprogram<
193 scope = #di_file, name = "func_decl_with_subprogram", file = #di_file
196 // CHECK-LABEL: declare !dbg
197 // CHECK-SAME: ![[SUBPROGRAM:.*]] i32 @func_decl_with_subprogram(
198 llvm.func @func_decl_with_subprogram() -> (i32) loc(fused<#di_subprogram>["foo.mlir":2:1])
200 // CHECK: ![[SUBPROGRAM]] = !DISubprogram(name: "func_decl_with_subprogram", scope: ![[FILE:.*]], file: ![[FILE]], spFlags: 0)
201 // CHECK: ![[FILE]] = !DIFile(filename: "foo.mlir", directory: "/test/")
205 #di_basic_type = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "int", sizeInBits = 32, encoding = DW_ATE_signed>
206 #di_file = #llvm.di_file<"foo.mlir" in "/test/">
207 #di_compile_unit = #llvm.di_compile_unit<
208 id = distinct[0]<>, sourceLanguage = DW_LANG_C, file = #di_file,
209 producer = "MLIR", isOptimized = true, emissionKind = Full
211 #di_subprogram = #llvm.di_subprogram<
212 compileUnit = #di_compile_unit, scope = #di_file, name = "outer_func",
213 file = #di_file, subprogramFlags = "Definition|Optimized"
215 #di_subprogram1 = #llvm.di_subprogram<
216 compileUnit = #di_compile_unit, scope = #di_file, name = "inner_func",
217 file = #di_file, subprogramFlags = "LocalToUnit|Definition|Optimized"
219 #di_local_variable0 = #llvm.di_local_variable<scope = #di_subprogram, name = "a", file = #di_file, type = #di_basic_type>
220 #di_lexical_block_file = #llvm.di_lexical_block_file<scope = #di_subprogram1, file = #di_file, discriminator = 0>
221 #di_local_variable1 = #llvm.di_local_variable<scope = #di_lexical_block_file, name = "b", file = #di_file, type = #di_basic_type>
222 #di_label = #llvm.di_label<scope = #di_lexical_block_file, name = "label", file = #di_file, line = 42>
224 #loc0 = loc("foo.mlir":0:0)
225 #loc1 = loc(callsite(fused<#di_lexical_block_file>[#loc0] at fused<#di_subprogram>["foo.mlir":4:2]))
227 // CHECK-LABEL: define i32 @func_with_inlined_dbg_value(
228 // CHECK-SAME: i32 %[[ARG:.*]]) !dbg ![[OUTER_FUNC:[0-9]+]]
229 llvm.func @func_with_inlined_dbg_value(%arg0: i32) -> (i32) {
230 // INTRINSICS: call void @llvm.dbg.value(metadata i32 %[[ARG]], metadata ![[VAR_LOC0:[0-9]+]], metadata !DIExpression()), !dbg ![[DBG_LOC0:.*]]
231 // RECORDS: #dbg_value(i32 %[[ARG]], ![[VAR_LOC0:[0-9]+]], !DIExpression(), ![[DBG_LOC0:.*]])
232 llvm.intr.dbg.value #di_local_variable0 = %arg0 : i32 loc(fused<#di_subprogram>[#loc0])
233 // INTRINSICS: call void @llvm.dbg.value(metadata i32 %[[ARG]], metadata ![[VAR_LOC1:[0-9]+]], metadata !DIExpression()), !dbg ![[DBG_LOC1:.*]]
234 // RECORDS: #dbg_value(i32 %[[ARG]], ![[VAR_LOC1:[0-9]+]], !DIExpression(), ![[DBG_LOC1:.*]])
235 llvm.intr.dbg.value #di_local_variable1 = %arg0 : i32 loc(#loc1)
236 // INTRINSICS: call void @llvm.dbg.label(metadata ![[LABEL:[0-9]+]]), !dbg ![[DBG_LOC1:.*]]
237 // RECORDS: #dbg_label(![[LABEL:[0-9]+]], ![[DBG_LOC1:.*]])
238 llvm.intr.dbg.label #di_label loc(#loc1)
239 llvm.return %arg0 : i32
240 } loc(fused<#di_subprogram>["caller"])
242 // CHECK: ![[FILE:.*]] = !DIFile(filename: "foo.mlir", directory: "/test/")
243 // CHECK-DAG: ![[OUTER_FUNC]] = distinct !DISubprogram(name: "outer_func", scope: ![[FILE]]
244 // CHECK-DAG: ![[INNER_FUNC:.*]] = distinct !DISubprogram(name: "inner_func", scope: ![[FILE]]
245 // CHECK-DAG: ![[LEXICAL_BLOCK_FILE:.*]] = distinct !DILexicalBlockFile(scope: ![[INNER_FUNC]], file: ![[FILE]], discriminator: 0)
246 // CHECK-DAG: ![[VAR_LOC0]] = !DILocalVariable(name: "a", scope: ![[OUTER_FUNC]], file: ![[FILE]]
247 // CHECK-DAG: ![[VAR_LOC1]] = !DILocalVariable(name: "b", scope: ![[LEXICAL_BLOCK_FILE]], file: ![[FILE]]
248 // CHECK-DAG: ![[LABEL]] = !DILabel(scope: ![[LEXICAL_BLOCK_FILE]], name: "label", file: ![[FILE]], line: 42)
252 #di_basic_type = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "int", sizeInBits = 32, encoding = DW_ATE_signed>
253 #di_file = #llvm.di_file<"foo.mlir" in "/test/">
254 #di_compile_unit = #llvm.di_compile_unit<
255 id = distinct[0]<>, sourceLanguage = DW_LANG_C, file = #di_file,
256 producer = "MLIR", isOptimized = true, emissionKind = Full
258 #di_subprogram = #llvm.di_subprogram<
259 compileUnit = #di_compile_unit, scope = #di_file, name = "func",
260 file = #di_file, subprogramFlags = Definition>
261 #di_local_variable = #llvm.di_local_variable<scope = #di_subprogram, name = "a", file = #di_file, type = #di_basic_type>
263 #loc = loc("foo.mlir":0:0)
265 // CHECK-LABEL: define void @func_without_subprogram(
266 // CHECK-SAME: i32 %[[ARG:.*]])
267 llvm.func @func_without_subprogram(%0 : i32) {
268 // INTRINSICS: call void @llvm.dbg.value(metadata i32 %[[ARG]], metadata ![[VAR_LOC:[0-9]+]], metadata !DIExpression()), !dbg ![[DBG_LOC0:.*]]
269 // RECORDS: #dbg_value(i32 %[[ARG]], ![[VAR_LOC:[0-9]+]], !DIExpression(), ![[DBG_LOC0:.*]])
270 llvm.intr.dbg.value #di_local_variable = %0 : i32 loc(fused<#di_subprogram>[#loc])
274 // CHECK: ![[FILE:.*]] = !DIFile(filename: "foo.mlir", directory: "/test/")
275 // CHECK-DAG: ![[FUNC:.*]] = distinct !DISubprogram(name: "func", scope: ![[FILE]]
276 // CHECK-DAG: ![[VAR_LOC]] = !DILocalVariable(name: "a", scope: ![[FUNC]], file: ![[FILE]]
280 // Ensures that debug intrinsics without a valid location are not exported to
281 // avoid broken LLVM IR.
283 #di_file = #llvm.di_file<"foo.mlir" in "/test/">
284 #di_compile_unit = #llvm.di_compile_unit<
285 id = distinct[0]<>, sourceLanguage = DW_LANG_C, file = #di_file,
286 producer = "MLIR", isOptimized = true, emissionKind = Full
288 #di_subprogram = #llvm.di_subprogram<
289 compileUnit = #di_compile_unit, scope = #di_file, name = "outer_func",
290 file = #di_file, subprogramFlags = "Definition|Optimized"
292 #di_local_variable = #llvm.di_local_variable<scope = #di_subprogram, name = "a">
293 #declared_var = #llvm.di_local_variable<scope = #di_subprogram, name = "alloc">
294 #di_label = #llvm.di_label<scope = #di_subprogram, name = "label", file = #di_file, line = 42>
296 // CHECK-LABEL: define i32 @dbg_intrinsics_with_no_location(
297 llvm.func @dbg_intrinsics_with_no_location(%arg0: i32) -> (i32) {
298 %allocCount = llvm.mlir.constant(1 : i32) : i32
299 %alloc = llvm.alloca %allocCount x i64 : (i32) -> !llvm.ptr
300 // INTRINSICS-NOT: @llvm.dbg.value
301 // RECORDS-NOT: #dbg_value
302 llvm.intr.dbg.value #di_local_variable = %arg0 : i32
303 // INTRINSICS-NOT: @llvm.dbg.declare
304 // RECORDS-NOT: #dbg_declare
305 llvm.intr.dbg.declare #declared_var = %alloc : !llvm.ptr
306 // INTRINSICS-NOT: @llvm.dbg.label
307 // RECORDS-NOT: #dbg_label
308 llvm.intr.dbg.label #di_label
309 llvm.return %arg0 : i32
314 // CHECK: @global_with_expr_1 = external global i64, !dbg {{.*}}
315 // CHECK: @global_with_expr_2 = external global i64, !dbg {{.*}}
316 // CHECK: !llvm.module.flags = !{{{.*}}}
317 // CHECK: !llvm.dbg.cu = !{{{.*}}}
318 // CHECK-DAG: ![[FILE:.*]] = !DIFile(filename: "not", directory: "existence")
319 // CHECK-DAG: ![[TYPE:.*]] = !DIBasicType(name: "uint64_t", size: 64, encoding: DW_ATE_unsigned)
320 // CHECK-DAG: ![[SCOPE:.*]] = distinct !DICompileUnit(language: DW_LANG_C, file: ![[FILE]], producer: "MLIR", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: ![[GVALS:.*]])
321 // CHECK-DAG: ![[GVAR0:.*]] = distinct !DIGlobalVariable(name: "global_with_expr_1", linkageName: "global_with_expr_1", scope: ![[SCOPE]], file: ![[FILE]], line: 370, type: ![[TYPE]], isLocal: false, isDefinition: false)
322 // CHECK-DAG: ![[GVAR1:.*]] = distinct !DIGlobalVariable(name: "global_with_expr_2", linkageName: "global_with_expr_2", scope: ![[SCOPE]], file: ![[FILE]], line: 371, type: ![[TYPE]], isLocal: true, isDefinition: true, align: 8)
323 // CHECK-DAG: ![[GEXPR0:.*]] = !DIGlobalVariableExpression(var: ![[GVAR0]], expr: !DIExpression())
324 // CHECK-DAG: ![[GEXPR1:.*]] = !DIGlobalVariableExpression(var: ![[GVAR1]], expr: !DIExpression())
325 // CHECK-DAG: ![[GVALS]] = !{![[GEXPR0]], ![[GEXPR1]]}
327 #di_file_2 = #llvm.di_file<"not" in "existence">
328 #di_compile_unit_2 = #llvm.di_compile_unit<id = distinct[0]<>, sourceLanguage = DW_LANG_C, file = #di_file_2, producer = "MLIR", isOptimized = true, emissionKind = Full>
329 #di_basic_type_2 = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "uint64_t", sizeInBits = 64, encoding = DW_ATE_unsigned>
330 llvm.mlir.global external @global_with_expr_1() {addr_space = 0 : i32, dbg_exprs = [#llvm.di_global_variable_expression<var = <scope = #di_compile_unit_2, name = "global_with_expr_1", linkageName = "global_with_expr_1", file = #di_file_2, line = 370, type = #di_basic_type_2>, expr = <>>]} : i64
331 llvm.mlir.global external @global_with_expr_2() {addr_space = 0 : i32, dbg_exprs = [#llvm.di_global_variable_expression<var = <scope = #di_compile_unit_2, name = "global_with_expr_2", linkageName = "global_with_expr_2", file = #di_file_2, line = 371, type = #di_basic_type_2, isLocalToUnit = true, isDefined = true, alignInBits = 8>, expr = <>>]} : i64
335 // CHECK: @module_global = external global i64, !dbg {{.*}}
336 // CHECK: !llvm.module.flags = !{{{.*}}}
337 // CHECK: !llvm.dbg.cu = !{{{.*}}}
338 // CHECK-DAG: ![[FILE:.*]] = !DIFile(filename: "test.f90", directory: "existence")
339 // CHECK-DAG: ![[TYPE:.*]] = !DIBasicType(name: "integer", size: 64, encoding: DW_ATE_signed)
340 // CHECK-DAG: ![[SCOPE:.*]] = distinct !DICompileUnit(language: DW_LANG_Fortran95, file: ![[FILE]], producer: "MLIR", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: ![[GVALS:.*]])
341 // CHECK-DAG: ![[SCOPE1:.*]] = !DIModule(scope: ![[SCOPE]], name: "module2", file: ![[FILE]], line: 120)
342 // CHECK-DAG: ![[GVAR:.*]] = distinct !DIGlobalVariable(name: "module_global", linkageName: "module_global", scope: ![[SCOPE1]], file: ![[FILE]], line: 121, type: ![[TYPE]], isLocal: false, isDefinition: true)
343 // CHECK-DAG: ![[GEXPR:.*]] = !DIGlobalVariableExpression(var: ![[GVAR]], expr: !DIExpression())
344 // CHECK-DAG: ![[GVALS]] = !{![[GEXPR]]}
346 #di_file = #llvm.di_file<"test.f90" in "existence">
347 #di_compile_unit = #llvm.di_compile_unit<id = distinct[0]<>, sourceLanguage = DW_LANG_Fortran95, file = #di_file, producer = "MLIR", isOptimized = true, emissionKind = Full>
348 #di_basic_type = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "integer", sizeInBits = 64, encoding = DW_ATE_signed>
349 #di_module = #llvm.di_module<file = #di_file, scope = #di_compile_unit, name = "module2", configMacros = "", includePath = "", apinotes = "", line = 120, isDecl = false >
350 llvm.mlir.global external @module_global() {dbg_exprs = [#llvm.di_global_variable_expression<var = <scope = #di_module, name = "module_global", linkageName = "module_global", file = #di_file, line = 121, type = #di_basic_type, isLocalToUnit = false, isDefined = true>, expr = <>>]} : i64
354 // CHECK: @func_global = external global i64, !dbg {{.*}}
355 // CHECK-DAG: ![[CU:.*]] = distinct !DICompileUnit({{.*}}globals: ![[GVALS:.*]])
356 // CHECK-DAG: ![[SP:.*]] = distinct !DISubprogram(name: "fn_with_gl"{{.*}}unit: ![[CU]])
357 // CHECK-DAG: ![[GVAR:.*]] = distinct !DIGlobalVariable(name: "func_global"{{.*}}, scope: ![[SP]]{{.*}})
358 // CHECK-DAG: ![[GEXPR:.*]] = !DIGlobalVariableExpression(var: ![[GVAR]], expr: !DIExpression())
359 // CHECK-DAG: ![[GVALS]] = !{![[GEXPR]]}
361 #file = #llvm.di_file<"test.f90" in "existence">
362 #cu = #llvm.di_compile_unit<id = distinct[0]<>, sourceLanguage = DW_LANG_Fortran95, file = #file, producer = "MLIR", isOptimized = true, emissionKind = Full>
363 #ty1 = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "integer", sizeInBits = 64, encoding = DW_ATE_signed>
364 #sp = #llvm.di_subprogram<compileUnit = #cu, scope = #file, name = "fn_with_gl", file = #file, subprogramFlags = "Definition|Optimized">
365 llvm.mlir.global @func_global() {dbg_exprs = [#llvm.di_global_variable_expression<var = <scope = #sp, name = "func_global", linkageName = "func_global", file = #file, line = 121, type = #ty1, isLocalToUnit = true, isDefined = true>, expr = <>>]} : i64
367 llvm.func @fn_with_gl() {
369 } loc(fused<#sp>["foo1.mlir":0:0])
373 // Test that imported entries correctly generates 'retainedNodes' in the
376 llvm.func @imp_fn() {
380 #di_file = #llvm.di_file<"test.f90" in "">
381 #di_subroutine_type = #llvm.di_subroutine_type<callingConvention = DW_CC_program>
382 #di_compile_unit = #llvm.di_compile_unit<id = distinct[0]<>,
383 sourceLanguage = DW_LANG_Fortran95, file = #di_file, isOptimized = false,
385 #di_module_1 = #llvm.di_module<file = #di_file, scope = #di_compile_unit, name = "mod1">
386 #di_module_2 = #llvm.di_module<file = #di_file, scope = #di_compile_unit, name = "mod2">
387 #di_subprogram_self_rec = #llvm.di_subprogram<recId = distinct[1]<>>
388 #di_imported_entity_1 = #llvm.di_imported_entity<tag = DW_TAG_imported_module,
389 scope = #di_subprogram_self_rec, entity = #di_module_1, file = #di_file, line = 1>
390 #di_imported_entity_2 = #llvm.di_imported_entity<tag = DW_TAG_imported_module,
391 scope = #di_subprogram_self_rec, entity = #di_module_2, file = #di_file, line = 1>
392 #di_subprogram = #llvm.di_subprogram<id = distinct[2]<>, recId = distinct[1]<>,
393 compileUnit = #di_compile_unit, scope = #di_file, name = "imp_fn",
394 file = #di_file, subprogramFlags = Definition, type = #di_subroutine_type,
395 retainedNodes = #di_imported_entity_1, #di_imported_entity_2>
396 #loc1 = loc("test.f90":12:14)
397 #loc2 = loc(fused<#di_subprogram>[#loc1])
399 // CHECK-DAG: ![[SP:[0-9]+]] = {{.*}}!DISubprogram(name: "imp_fn"{{.*}}retainedNodes: ![[NODES:[0-9]+]])
400 // CHECK-DAG: ![[NODES]] = !{![[NODE1:[0-9]+]], ![[NODE2:[0-9]+]]}
401 // CHECK-DAG: ![[NODE1]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: ![[SP]], entity: ![[MOD1:[0-9]+]]{{.*}})
402 // CHECK-DAG: ![[NODE2]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: ![[SP]], entity: ![[MOD2:[0-9]+]]{{.*}})
403 // CHECK-DAG: ![[MOD1]] = !DIModule({{.*}}name: "mod1"{{.*}})
404 // CHECK-DAG: ![[MOD2]] = !DIModule({{.*}}name: "mod2"{{.*}})
408 // Nameless and scopeless global constant.
410 // CHECK-LABEL: @.str.1 = external constant [10 x i8]
411 // CHECK-SAME: !dbg ![[GLOBAL_VAR_EXPR:.*]]
412 // CHECK-DAG: ![[GLOBAL_VAR_EXPR]] = !DIGlobalVariableExpression(var: ![[GLOBAL_VAR:.*]], expr: !DIExpression())
413 // CHECK-DAG: ![[GLOBAL_VAR]] = distinct !DIGlobalVariable(scope: null, file: !{{[0-9]+}}, line: 268, type: !{{[0-9]+}}, isLocal: true, isDefinition: true)
415 #di_basic_type = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "char", sizeInBits = 8, encoding = DW_ATE_signed_char>
416 #di_file = #llvm.di_file<"file.c" in "/path/to/file">
417 #di_derived_type = #llvm.di_derived_type<tag = DW_TAG_const_type, baseType = #di_basic_type>
418 #di_composite_type = #llvm.di_composite_type<tag = DW_TAG_array_type, baseType = #di_derived_type, sizeInBits = 80>
419 #di_global_variable = #llvm.di_global_variable<file = #di_file, line = 268, type = #di_composite_type, isLocalToUnit = true, isDefined = true>
420 #di_global_variable_expression = #llvm.di_global_variable_expression<var = #di_global_variable, expr = <>>
422 llvm.mlir.global external constant @".str.1"() {addr_space = 0 : i32, dbg_exprs = [#di_global_variable_expression]} : !llvm.array<10 x i8>
426 // CHECK-DAG: ![[FILE1:.*]] = !DIFile(filename: "foo1.mlir", directory: "/test/")
427 #di_file_1 = #llvm.di_file<"foo1.mlir" in "/test/">
428 // CHECK-DAG: ![[FILE2:.*]] = !DIFile(filename: "foo2.mlir", directory: "/test/")
429 #di_file_2 = #llvm.di_file<"foo2.mlir" in "/test/">
430 // CHECK-DAG: ![[SCOPE2:.*]] = distinct !DICompileUnit(language: DW_LANG_C, file: ![[FILE2]], producer: "MLIR", isOptimized: true, runtimeVersion: 0, emissionKind: DebugDirectivesOnly)
431 #di_compile_unit_1 = #llvm.di_compile_unit<id = distinct[0]<>, sourceLanguage = DW_LANG_C, file = #di_file_1, producer = "MLIR", isOptimized = true, emissionKind = LineTablesOnly>
432 // CHECK-DAG: ![[SCOPE1:.*]] = distinct !DICompileUnit(language: DW_LANG_C, file: ![[FILE1]], producer: "MLIR", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly)
433 #di_compile_unit_2 = #llvm.di_compile_unit<id = distinct[1]<>, sourceLanguage = DW_LANG_C, file = #di_file_2, producer = "MLIR", isOptimized = true, emissionKind = DebugDirectivesOnly>
434 #di_subprogram_1 = #llvm.di_subprogram<compileUnit = #di_compile_unit_1, scope = #di_file_1, name = "func1", file = #di_file_1, subprogramFlags = "Definition|Optimized">
435 #di_subprogram_2 = #llvm.di_subprogram<compileUnit = #di_compile_unit_2, scope = #di_file_2, name = "func2", file = #di_file_2, subprogramFlags = "Definition|Optimized">
437 llvm.func @func_line_tables() {
439 } loc(fused<#di_subprogram_1>["foo1.mlir":0:0])
441 llvm.func @func_debug_directives() {
443 } loc(fused<#di_subprogram_2>["foo2.mlir":0:0])
447 // Ensure recursive types with multiple external references work.
449 // Common base nodes.
450 #di_file = #llvm.di_file<"test.mlir" in "/">
451 #di_null_type = #llvm.di_null_type
452 #di_compile_unit = #llvm.di_compile_unit<id = distinct[1]<>, sourceLanguage = DW_LANG_C, file = #di_file, isOptimized = false, emissionKind = None>
454 // Recursive type itself.
455 #di_struct_self = #llvm.di_composite_type<recId = distinct[0]<>, isRecSelf = true>
456 #di_ptr_inner = #llvm.di_derived_type<tag = DW_TAG_pointer_type, baseType = #di_struct_self, sizeInBits = 64>
457 #di_subroutine_inner = #llvm.di_subroutine_type<types = #di_null_type, #di_ptr_inner>
458 #di_subprogram_inner = #llvm.di_subprogram<
460 compileUnit = #di_compile_unit,
461 scope = #di_struct_self,
462 name = "class_method",
464 subprogramFlags = Definition,
465 type = #di_subroutine_inner>
466 #di_struct = #llvm.di_composite_type<
467 tag = DW_TAG_class_type,
468 recId = distinct[0]<>,
472 flags = "TypePassByReference|NonTrivial",
473 elements = #di_subprogram_inner>
475 // Outer types referencing the entire recursive type.
476 #di_ptr_outer = #llvm.di_derived_type<tag = DW_TAG_pointer_type, baseType = #di_struct, sizeInBits = 64>
477 #di_subroutine_outer = #llvm.di_subroutine_type<types = #di_null_type, #di_ptr_outer>
478 #di_subprogram_outer = #llvm.di_subprogram<
480 compileUnit = #di_compile_unit,
482 name = "class_method",
484 subprogramFlags = Definition,
485 type = #di_subroutine_outer>
487 #loc3 = loc(fused<#di_subprogram_outer>["test.mlir":1:1])
489 // CHECK: @class_method
490 // CHECK: ret void, !dbg ![[LOC:.*]]
492 // CHECK: ![[CU:.*]] = distinct !DICompileUnit(
493 // CHECK: ![[SP:.*]] = distinct !DISubprogram(name: "class_method", scope: ![[STRUCT:.*]], file: !{{.*}}, type: ![[SUBROUTINE:.*]], spFlags: DISPFlagDefinition, unit: ![[CU]])
494 // CHECK: ![[STRUCT]] = distinct !DICompositeType(tag: DW_TAG_class_type, name: "class_name", {{.*}}, elements: ![[ELEMS:.*]])
495 // CHECK: ![[ELEMS]] = !{![[SP]]}
496 // CHECK: ![[SUBROUTINE]] = !DISubroutineType(types: ![[SUBROUTINE_ELEMS:.*]])
497 // CHECK: ![[SUBROUTINE_ELEMS]] = !{null, ![[PTR:.*]]}
498 // CHECK: ![[PTR]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[STRUCT]], size: 64)
499 // CHECK: ![[LOC]] = !DILocation(line: 1, column: 1, scope: ![[SP]])
501 llvm.func @class_method() {
502 llvm.return loc(#loc3)
507 // Ensures composite types with a recursive scope work.
509 #di_composite_type_self = #llvm.di_composite_type<recId = distinct[0]<>, isRecSelf = true>
510 #di_file = #llvm.di_file<"test.mlir" in "/">
511 #di_subroutine_type = #llvm.di_subroutine_type<types = #di_composite_type_self>
512 #di_subprogram = #llvm.di_subprogram<scope = #di_file, file = #di_file, subprogramFlags = Optimized, type = #di_subroutine_type>
513 #di_composite_type = #llvm.di_composite_type<tag = DW_TAG_class_type, recId = distinct[0]<>, scope = #di_subprogram>
514 #di_global_variable = #llvm.di_global_variable<file = #di_file, line = 1, type = #di_composite_type>
515 #di_global_variable_expression = #llvm.di_global_variable_expression<var = #di_global_variable>
517 llvm.mlir.global @global_variable() {dbg_exprs = [#di_global_variable_expression]} : !llvm.struct<()>
519 // CHECK: distinct !DIGlobalVariable({{.*}}type: ![[COMP:[0-9]+]],
520 // CHECK: ![[COMP]] = distinct !DICompositeType({{.*}}scope: ![[SCOPE:[0-9]+]]
521 // CHECK: ![[SCOPE]] = !DISubprogram({{.*}}type: ![[SUBROUTINE:[0-9]+]],
522 // CHECK: ![[SUBROUTINE]] = !DISubroutineType(types: ![[SR_TYPES:[0-9]+]])
523 // CHECK: ![[SR_TYPES]] = !{![[COMP]]}
527 // Ensures nested recursive decls work.
528 // The output should be identical to if the inner composite type decl was
529 // replaced with the recursive self reference.
531 #di_file = #llvm.di_file<"test.mlir" in "/">
532 #di_composite_type_self = #llvm.di_composite_type<recId = distinct[0]<>, isRecSelf = true>
534 #di_subroutine_type_inner = #llvm.di_subroutine_type<types = #di_composite_type_self>
535 #di_subprogram_inner = #llvm.di_subprogram<scope = #di_file, file = #di_file, subprogramFlags = Optimized, type = #di_subroutine_type_inner>
536 #di_composite_type_inner = #llvm.di_composite_type<tag = DW_TAG_class_type, recId = distinct[0]<>, scope = #di_subprogram_inner>
538 #di_subroutine_type = #llvm.di_subroutine_type<types = #di_composite_type_inner>
539 #di_subprogram = #llvm.di_subprogram<scope = #di_file, file = #di_file, subprogramFlags = Optimized, type = #di_subroutine_type>
540 #di_composite_type = #llvm.di_composite_type<tag = DW_TAG_class_type, recId = distinct[0]<>, scope = #di_subprogram>
542 // Use the inner type standalone outside too. Ensures it's not cached wrong.
543 #di_var_type = #llvm.di_subroutine_type<types = #di_composite_type, #di_composite_type_inner>
544 #di_global_variable = #llvm.di_global_variable<file = #di_file, line = 1, type = #di_var_type>
545 #di_global_variable_expression = #llvm.di_global_variable_expression<var = #di_global_variable>
547 llvm.mlir.global @global_variable() {dbg_exprs = [#di_global_variable_expression]} : !llvm.struct<()>
549 // CHECK: distinct !DIGlobalVariable({{.*}}type: ![[VAR:[0-9]+]],
550 // CHECK: ![[VAR]] = !DISubroutineType(types: ![[COMPS:[0-9]+]])
551 // CHECK: ![[COMPS]] = !{![[COMP:[0-9]+]],
552 // CHECK: ![[COMP]] = distinct !DICompositeType({{.*}}scope: ![[SCOPE:[0-9]+]]
553 // CHECK: ![[SCOPE]] = !DISubprogram({{.*}}type: ![[SUBROUTINE:[0-9]+]],
554 // CHECK: ![[SUBROUTINE]] = !DISubroutineType(types: ![[SR_TYPES:[0-9]+]])
555 // CHECK: ![[SR_TYPES]] = !{![[COMP]]}
559 #file = #llvm.di_file<"test.f90" in "">
560 #cu = #llvm.di_compile_unit<id = distinct[0]<>, sourceLanguage = DW_LANG_Fortran95,
561 file = #file, producer = "", isOptimized = false, emissionKind = Full>
562 #i32 = #llvm.di_basic_type<
563 tag = DW_TAG_base_type, name = "integer",
564 sizeInBits = 32, encoding = DW_ATE_signed
566 #null = #llvm.di_null_type
567 #alloc = #llvm.di_expression<[DW_OP_lit0, DW_OP_ne]>
568 #assoc = #llvm.di_expression<[DW_OP_lit0, DW_OP_eq]>
569 #rank = #llvm.di_expression<[DW_OP_push_object_address, DW_OP_plus_uconst(16), DW_OP_deref]>
570 #datal = #llvm.di_expression<[DW_OP_push_object_address, DW_OP_deref]>
571 #array = #llvm.di_composite_type<tag = DW_TAG_array_type,
573 dataLocation = #datal, rank = #rank,
574 allocated = #alloc, associated = #assoc,
575 elements = #llvm.di_subrange<lowerBound = 1, count = 5>
577 #spType0 = #llvm.di_subroutine_type<callingConvention = DW_CC_normal, types = #null, #array>
578 #sp0 = #llvm.di_subprogram<
579 compileUnit = #cu, scope = #cu, name = "fn_with_composite", file = #file,
580 subprogramFlags = "Definition|Optimized", type = #spType0
582 llvm.func @fn_with_composite() {
584 }loc(fused<#sp0>["foo.mlir":1:1])
585 // CHECK-LABEL: define void @fn_with_composite()
586 // CHECK: !DICompositeType(
587 // CHECK-SAME: dataLocation: !DIExpression(DW_OP_push_object_address, DW_OP_deref)
588 // CHECK-SAME: associated: !DIExpression(DW_OP_lit0, DW_OP_eq)
589 // CHECK-SAME: allocated: !DIExpression(DW_OP_lit0, DW_OP_ne)
590 // CHECK-SAME: rank: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 16, DW_OP_deref)
594 // Test that Subrange/generic_subrange works with expression and variables.
596 #bt = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "int">
597 #file = #llvm.di_file<"debug-info.ll" in "/">
598 #cu = #llvm.di_compile_unit<id = distinct[1]<>,
599 sourceLanguage = DW_LANG_Fortran95, file = #file, isOptimized = false,
601 #exp1 = #llvm.di_expression<[DW_OP_push_object_address, DW_OP_plus_uconst(16),
603 #comp_ty1 = #llvm.di_composite_type<tag = DW_TAG_array_type,
604 name = "expr_elements", baseType = #bt, flags = Vector,
605 elements = #llvm.di_subrange<count = #exp1>>
606 #exp2 = #llvm.di_expression<[DW_OP_push_object_address, DW_OP_plus_uconst(24),
608 #exp3 = #llvm.di_expression<[DW_OP_push_object_address, DW_OP_plus_uconst(32),
610 #comp_ty2 = #llvm.di_composite_type<tag = DW_TAG_array_type,
611 name = "expr_elements2", baseType = #bt, elements =
612 #llvm.di_generic_subrange<count = #exp1, lowerBound = #exp2, stride = #exp3>>
613 #srty = #llvm.di_subroutine_type<types = #bt, #comp_ty1, #comp_ty2>
614 #sp = #llvm.di_subprogram<compileUnit = #cu, scope = #file, name = "subranges",
615 file = #file, subprogramFlags = Definition, type = #srty>
616 #lvar = #llvm.di_local_variable<scope = #sp, name = "size">
617 #gv = #llvm.di_global_variable<scope = #cu, name = "gv", file = #file,
618 line = 3, type = #bt>
619 #gve = #llvm.di_global_variable_expression<var = #gv, expr = <>>
620 #comp_ty3 = #llvm.di_composite_type<tag = DW_TAG_array_type,
621 name = "var_elements", baseType = #bt, flags = Vector,
622 elements = #llvm.di_subrange<count = #lvar, stride = #gv>>
623 #comp_ty4 = #llvm.di_composite_type<tag = DW_TAG_array_type,
624 name = "var_elements2", baseType = #bt, elements =
625 #llvm.di_generic_subrange<count = #lvar, lowerBound = #gv, stride = #gv>>
626 #lvar2 = #llvm.di_local_variable<scope = #sp, name = "var", type = #comp_ty3>
627 #lvar3 = #llvm.di_local_variable<scope = #sp, name = "var1", type = #comp_ty4>
628 #loc1 = loc("test.f90": 1:1)
629 #loc2 = loc(fused<#sp>[#loc1])
631 llvm.mlir.global external @gv() {dbg_exprs = [#gve]} : i64
633 llvm.func @subranges(%arg: !llvm.ptr) {
634 llvm.intr.dbg.declare #lvar2 = %arg : !llvm.ptr
635 llvm.intr.dbg.declare #lvar3 = %arg : !llvm.ptr
639 // CHECK-LABEL: define void @subranges
640 // CHECK: ![[GV:[0-9]+]] = {{.*}}!DIGlobalVariable(name: "gv"{{.*}})
641 // CHECK: !DICompositeType(tag: DW_TAG_array_type, name: "expr_elements"{{.*}}elements: ![[ELEMENTS1:[0-9]+]])
642 // CHECK: ![[ELEMENTS1]] = !{![[ELEMENT1:[0-9]+]]}
643 // CHECK: ![[ELEMENT1]] = !DISubrange(count: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 16, DW_OP_deref))
644 // CHECK: !DICompositeType(tag: DW_TAG_array_type, name: "expr_elements2"{{.*}}elements: ![[GSR_ELEMS:[0-9]+]])
645 // CHECK: ![[GSR_ELEMS]] = !{![[GSR_ELEM:[0-9]+]]}
646 // CHECK: ![[GSR_ELEM]] = !DIGenericSubrange(count: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 16, DW_OP_deref)
647 // CHECK-SAME: lowerBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 24, DW_OP_deref)
648 // CHECK-SAME: stride: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 32, DW_OP_deref)
650 // CHECK: !DICompositeType(tag: DW_TAG_array_type, name: "var_elements"{{.*}}elements: ![[ELEMENTS2:[0-9]+]])
651 // CHECK: ![[ELEMENTS2]] = !{![[ELEMENT2:[0-9]+]]}
652 // CHECK: ![[ELEMENT2]] = !DISubrange(count: ![[LV:[0-9]+]], stride: ![[GV]])
653 // CHECK: ![[LV]] = !DILocalVariable(name: "size"{{.*}})
654 // CHECK: !DICompositeType(tag: DW_TAG_array_type, name: "var_elements2", baseType: !{{.*}}, elements: ![[GSR_ELEMS2:[0-9]+]])
655 // CHECK: ![[GSR_ELEMS2]] = !{![[GSR_ELEM2:[0-9]+]]}
656 // CHECK: ![[GSR_ELEM2]] = !DIGenericSubrange(count: ![[LV]], lowerBound: ![[GV]], stride: ![[GV]])
660 #bt = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "int", sizeInBits = 32>
661 #file = #llvm.di_file<"debug-info.ll" in "/">
662 #cu = #llvm.di_compile_unit<id = distinct[0]<>, sourceLanguage = DW_LANG_C,
663 file = #file, isOptimized = false, emissionKind = Full>
664 #sp = #llvm.di_subprogram<compileUnit = #cu, scope = #file, name = "test",
665 file = #file, subprogramFlags = Definition>
666 #var = #llvm.di_local_variable<scope = #sp, name = "string_size", type = #bt, flags = Artificial>
667 #ty = #llvm.di_string_type<tag = DW_TAG_string_type, name = "character(*)",
668 sizeInBits = 32, alignInBits = 8, stringLength = #var,
669 stringLengthExp = <[DW_OP_push_object_address, DW_OP_plus_uconst(8)]>,
670 stringLocationExp = <[DW_OP_push_object_address, DW_OP_deref]>>
671 #var1 = #llvm.di_local_variable<scope = #sp, name = "str", type = #ty>
673 llvm.func @string_ty(%arg0: !llvm.ptr) {
674 llvm.intr.dbg.value #var1 = %arg0 : !llvm.ptr
675 llvm.intr.dbg.value #var = %arg0 : !llvm.ptr
679 #loc1 = loc("test.f90":1:1)
680 #loc2 = loc(fused<#sp>[#loc1])
682 // CHECK-DAG: !DIStringType(name: "character(*)", stringLength: ![[VAR:[0-9]+]], stringLengthExpression: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 8), stringLocationExpression: !DIExpression(DW_OP_push_object_address, DW_OP_deref), size: 32, align: 8)
683 // CHECK-DAG: ![[VAR]] = !DILocalVariable(name: "string_size"{{.*}} flags: DIFlagArtificial)
687 // Test translation of DICommonBlockAttr.
688 #bt = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "int", sizeInBits = 32>
689 #file = #llvm.di_file<"test.f90" in "">
690 #cu = #llvm.di_compile_unit<id = distinct[0]<>, sourceLanguage = DW_LANG_C,
691 file = #file, isOptimized = false, emissionKind = Full>
692 #sp = #llvm.di_subprogram<compileUnit = #cu, scope = #file, name = "test",
693 file = #file, subprogramFlags = Definition>
694 #di_common_block = #llvm.di_common_block<scope = #sp, name = "block",
695 file = #file, line = 3>
696 #global_var = #llvm.di_global_variable<scope = #di_common_block, name = "a",
697 file = #file, line = 2, type = #bt>
698 #var_expression = #llvm.di_global_variable_expression<var = #global_var,
701 llvm.mlir.global common @block_(dense<0> : tensor<8xi8>)
702 {dbg_exprs = [#var_expression]} : !llvm.array<8 x i8>
708 #loc1 = loc("test.f90":1:0)
709 #loc2 = loc(fused<#sp>[#loc1])
711 // CHECK: !DICommonBlock(scope: ![[SCOPE:[0-9]+]], declaration: null, name: "block", file: ![[FILE:[0-9]+]], line: 3)
712 // CHECK: ![[SCOPE]] = {{.*}}!DISubprogram(name: "test"{{.*}})
713 // CHECK: ![[FILE]] = !DIFile(filename: "test.f90"{{.*}})
717 // Test multiple DIGlobalVariableExpression on a global.
718 #bt = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "int", sizeInBits = 32>
719 #file = #llvm.di_file<"test.f90" in "">
720 #cu = #llvm.di_compile_unit<id = distinct[0]<>, sourceLanguage = DW_LANG_C,
721 file = #file, isOptimized = false, emissionKind = Full>
722 #global_var = #llvm.di_global_variable<scope = #cu, name = "a",
723 file = #file, line = 2, type = #bt>
724 #var_expression = #llvm.di_global_variable_expression<var = #global_var,
726 #global_var1 = #llvm.di_global_variable<scope = #cu, name = "b",
727 file = #file, line = 3, type = #bt>
728 #var_expression1 = #llvm.di_global_variable_expression<var = #global_var1,
731 llvm.mlir.global @data() {dbg_exprs = [#var_expression, #var_expression1]} : i64
733 // CHECK: @data = external global i64, !dbg ![[EXP1:[0-9]+]], !dbg ![[EXP2:[0-9]+]]
734 // CHECK: ![[EXP1]] = !DIGlobalVariableExpression(var: ![[VAR1:[0-9]+]], expr: !DIExpression())
735 // CHECK: ![[VAR1]] = {{.*}}!DIGlobalVariable(name: "a"{{.*}})
736 // CHECK: ![[EXP2]] = !DIGlobalVariableExpression(var: ![[VAR2:[0-9]+]], expr: !DIExpression())
737 // CHECK: ![[VAR2]] = {{.*}}!DIGlobalVariable(name: "b"{{.*}})