730 lines · plain
1// RUN: mlir-translate -mlir-to-llvmir --split-input-file %s | FileCheck %s --check-prefixes=CHECK,RECORDS2 3// CHECK-LABEL: define void @func_with_empty_named_info()4// Check that translation doens't crash in the presence of an inlineble call5// with a named loc that has no backing source info.6llvm.func @callee() {7 llvm.return8} loc("calleesource.cc":1:1)9llvm.func @func_with_empty_named_info() {10 llvm.call @callee() : () -> () loc("named with no line info")11 llvm.return12}13 14// CHECK-LABEL: define void @func_no_debug()15// CHECK-NOT: !dbg16llvm.func @func_no_debug() {17 llvm.return loc(unknown)18} loc(unknown)19 20#file = #llvm.di_file<"foo.mlir" in "/test/">21#si64 = #llvm.di_basic_type<22 // Omit the optional sizeInBits and encoding parameters.23 tag = DW_TAG_base_type, name = "si64"24>25#si32 = #llvm.di_basic_type<26 tag = DW_TAG_base_type, name = "si32",27 sizeInBits = 32, encoding = DW_ATE_signed28>29#ptr = #llvm.di_derived_type<30 tag = DW_TAG_pointer_type, baseType = #si32,31 sizeInBits = 64, alignInBits = 32, offsetInBits = 8,32 extraData = #si3233>34#named = #llvm.di_derived_type<35 // Specify the name parameter.36 tag = DW_TAG_pointer_type, name = "named", baseType = #si3237>38#ptrWithAddressSpace = #llvm.di_derived_type<39 tag = DW_TAG_pointer_type, baseType = #si32,40 sizeInBits = 64, alignInBits = 32, offsetInBits = 8,41 dwarfAddressSpace = 342>43#cu = #llvm.di_compile_unit<44 id = distinct[0]<>, sourceLanguage = DW_LANG_C, file = #file,45 producer = "MLIR", isOptimized = true, emissionKind = Full,46 nameTableKind = None, splitDebugFilename = "test.dwo"47>48#composite = #llvm.di_composite_type<49 tag = DW_TAG_structure_type, name = "composite", file = #file,50 line = 42, sizeInBits = 64, alignInBits = 32,51 elements = #llvm.di_subrange<count = 4>52>53#vector = #llvm.di_composite_type<54 tag = DW_TAG_array_type, name = "array", file = #file,55 baseType = #si64, flags = Vector,56 elements = #llvm.di_subrange<lowerBound = 0, upperBound = 4, stride = 1>57>58#null = #llvm.di_null_type59#spType0 = #llvm.di_subroutine_type<callingConvention = DW_CC_normal, types = #null, #si64, #ptr, #named, #ptrWithAddressSpace, #composite, #vector>60#toplevel_namespace = #llvm.di_namespace<61 name = "toplevel", exportSymbols = true62>63#nested_namespace = #llvm.di_namespace<64 name = "nested", scope = #toplevel_namespace, exportSymbols = false65>66#sp0 = #llvm.di_subprogram<67 compileUnit = #cu, scope = #nested_namespace, name = "func_with_debug", linkageName = "func_with_debug",68 file = #file, line = 3, scopeLine = 3, subprogramFlags = "Definition|Optimized", type = #spType069>70#calleeType = #llvm.di_subroutine_type<71 // Omit the optional callingConvention parameter.72 types = #si64, #si64>73#callee = #llvm.di_subprogram<74 // Omit the optional linkageName, line, and scopeLine parameters.75 compileUnit = #cu, scope = #composite, name = "callee",76 file = #file, subprogramFlags = "Definition", type = #calleeType77>78#fileScope = #llvm.di_lexical_block_file<scope = #sp0, file = #file, discriminator = 0>79#blockScope = #llvm.di_lexical_block<scope = #sp0>80#variable = #llvm.di_local_variable<scope = #fileScope, name = "arg", file = #file, line = 6, arg = 1, alignInBits = 32, type = #si64>81#variableAddr = #llvm.di_local_variable<scope = #blockScope, name = "alloc">82#noNameVariable = #llvm.di_local_variable<scope = #blockScope>83#module = #llvm.di_module<84 file = #file, scope = #file, name = "module",85 configMacros = "bar", includePath = "/",86 apinotes = "/", line = 42, isDecl = true87>88#spType1 = #llvm.di_subroutine_type<callingConvention = DW_CC_normal>89#sp1 = #llvm.di_subprogram<90 compileUnit = #cu, scope = #module, name = "empty_types",91 file = #file, subprogramFlags = "Definition", type = #spType1,92 annotations = #llvm.di_annotation<name = "foo", value = "bar">93>94 95// CHECK-LABEL: define void @func_with_debug(96// CHECK-SAME: i64 %[[ARG:.*]]) !dbg ![[FUNC_LOC:[0-9]+]]97llvm.func @func_with_debug(%arg: i64) {98 // CHECK: %[[ALLOC:.*]] = alloca99 %allocCount = llvm.mlir.constant(1 : i32) : i32100 %alloc = llvm.alloca %allocCount x i64 : (i32) -> !llvm.ptr101 102 // RECORDS: #dbg_value(i64 %[[ARG]], ![[VAR_LOC:[0-9]+]], !DIExpression(DW_OP_LLVM_fragment, 0, 1), !{{.*}})103 llvm.intr.dbg.value #variable #llvm.di_expression<[DW_OP_LLVM_fragment(0, 1)]> = %arg : i64104 105 // RECORDS: #dbg_declare(ptr %[[ALLOC]], ![[ADDR_LOC:[0-9]+]], !DIExpression(DW_OP_deref, DW_OP_LLVM_convert, 4, DW_ATE_signed), !{{.*}})106 llvm.intr.dbg.declare #variableAddr #llvm.di_expression<[DW_OP_deref, DW_OP_LLVM_convert(4, DW_ATE_signed)]> = %alloc : !llvm.ptr107 108 // RECORDS: #dbg_value(i64 %[[ARG]], ![[NO_NAME_VAR:[0-9]+]], !DIExpression(), !{{.*}})109 llvm.intr.dbg.value #noNameVariable = %arg : i64110 111 // CHECK: call void @func_no_debug(), !dbg ![[FILE_LOC:[0-9]+]]112 llvm.call @func_no_debug() : () -> () loc("foo.mlir":1:2)113 114 // CHECK: call void @func_no_debug(), !dbg ![[FILE_LOC:[0-9]+]]115 llvm.call @func_no_debug() : () -> () loc("foo.mlir":1:2 to 5:6)116 117 // CHECK: call void @func_no_debug(), !dbg ![[NAMED_LOC:[0-9]+]]118 llvm.call @func_no_debug() : () -> () loc("named"("foo.mlir":10:10))119 120 // CHECK: call void @func_no_debug(), !dbg ![[MY_SOURCE_LOC:[0-9]+]]121 llvm.call @func_no_debug() : () -> () loc(callsite("nodebug.cc":3:4 at "mysource.cc":5:6))122 123 // CHECK: call void @func_no_debug(), !dbg ![[MY_SOURCE_LOC]]124 llvm.call @func_no_debug() : () -> () loc(callsite("nodebug.cc":3:4 at fused<#sp0>["mysource.cc":5:6]))125 126 // CHECK: call void @func_no_debug(), !dbg ![[FUSED_LOC:[0-9]+]]127 llvm.call @func_no_debug() : () -> () loc(fused[callsite(fused<#callee>["mysource.cc":5:6] at "mysource.cc":1:1), "mysource.cc":1:1])128 129 // CHECK: call void @func_no_debug(), !dbg ![[FUSEDWITH_LOC:[0-9]+]]130 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]))131 132 // CHECK: add i64 %[[ARG]], %[[ARG]], !dbg ![[FUSEDWITH_LOC]]133 %sum = llvm.add %arg, %arg : i64 loc(callsite(fused<#callee>["foo.mlir":2:4] at fused<#sp0>["foo.mlir":28:5]))134 135 llvm.return136} loc(fused<#sp0>["foo.mlir":1:1])137 138// CHECK: define void @empty_types() !dbg ![[EMPTY_TYPES_LOC:[0-9]+]]139llvm.func @empty_types() {140 llvm.return141} loc(fused<#sp1>["foo.mlir":2:1])142 143// CHECK: ![[CU_LOC:.*]] = distinct !DICompileUnit(language: DW_LANG_C, file: ![[CU_FILE_LOC:.*]], producer: "MLIR", isOptimized: true, runtimeVersion: 0, splitDebugFilename: "test.dwo", emissionKind: FullDebug, nameTableKind: None)144// CHECK: ![[CU_FILE_LOC]] = !DIFile(filename: "foo.mlir", directory: "/test/")145 146// 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]])147// CHECK: ![[NESTED_NAMESPACE]] = !DINamespace(name: "nested", scope: ![[TOPLEVEL_NAMESPACE:.*]])148// CHECK: ![[TOPLEVEL_NAMESPACE]] = !DINamespace(name: "toplevel", scope: null, exportSymbols: true)149// CHECK: ![[FUNC_TYPE]] = !DISubroutineType(cc: DW_CC_normal, types: ![[FUNC_ARGS:.*]])150// CHECK: ![[FUNC_ARGS]] = !{null, ![[ARG_TYPE:.*]], ![[PTR_TYPE:.*]], ![[NAMED_TYPE:.*]], ![[PTR_WITH_ADDR_SPACE:.*]], ![[COMPOSITE_TYPE:.*]], ![[VECTOR_TYPE:.*]]}151// CHECK: ![[ARG_TYPE]] = !DIBasicType(name: "si64")152// CHECK: ![[PTR_TYPE]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[BASE_TYPE:.*]], size: 64, align: 32, offset: 8, extraData: ![[BASE_TYPE]])153// CHECK: ![[BASE_TYPE]] = !DIBasicType(name: "si32", size: 32, encoding: DW_ATE_signed)154// CHECK: ![[NAMED_TYPE]] = !DIDerivedType(tag: DW_TAG_pointer_type, name: "named", baseType: ![[BASE_TYPE:.*]])155// CHECK: ![[PTR_WITH_ADDR_SPACE]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[BASE_TYPE:.*]], size: 64, align: 32, offset: 8, dwarfAddressSpace: 3)156// 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:.*]])157// CHECK: ![[COMPOSITE_ELEMENTS]] = !{![[COMPOSITE_ELEMENT:.*]]}158// CHECK: ![[COMPOSITE_ELEMENT]] = !DISubrange(count: 4)159// CHECK: ![[VECTOR_TYPE]] = !DICompositeType(tag: DW_TAG_array_type, name: "array", file: ![[CU_FILE_LOC]], baseType: ![[ARG_TYPE]], flags: DIFlagVector, elements: ![[VECTOR_ELEMENTS:.*]])160// CHECK: ![[VECTOR_ELEMENTS]] = !{![[VECTOR_ELEMENT:.*]]}161// CHECK: ![[VECTOR_ELEMENT]] = !DISubrange(lowerBound: 0, upperBound: 4, stride: 1)162 163// CHECK: ![[VAR_LOC]] = !DILocalVariable(name: "arg", arg: 1, scope: ![[VAR_SCOPE:.*]], file: ![[CU_FILE_LOC]], line: 6, type: ![[ARG_TYPE]], align: 32)164// CHECK: ![[VAR_SCOPE]] = distinct !DILexicalBlockFile(scope: ![[FUNC_LOC]], file: ![[CU_FILE_LOC]], discriminator: 0)165// CHECK: ![[ADDR_LOC]] = !DILocalVariable(name: "alloc", scope: ![[BLOCK_LOC:.*]])166// CHECK: ![[BLOCK_LOC]] = distinct !DILexicalBlock(scope: ![[FUNC_LOC]])167// CHECK: ![[NO_NAME_VAR]] = !DILocalVariable(scope: ![[BLOCK_LOC]])168 169// CHECK-DAG: ![[MY_SOURCE_LOC]] = !DILocation(line: 5, column: 6170// CHECK-DAG: ![[FILE_LOC]] = !DILocation(line: 1, column: 2,171// CHECK-DAG: ![[NAMED_LOC]] = !DILocation(line: 10, column: 10172// CHECK-DAG: ![[FUSED_LOC]] = !DILocation(line: 1, column: 1173 174// CHECK: ![[FUSEDWITH_LOC]] = !DILocation(line: 2, column: 4, scope: ![[CALLEE_LOC:.*]], inlinedAt: ![[INLINE_LOC:.*]])175// CHECK: ![[CALLEE_LOC]] = distinct !DISubprogram(name: "callee", scope: ![[COMPOSITE_TYPE]], file: ![[CU_FILE_LOC]], type: ![[CALLEE_TYPE:.*]], spFlags: DISPFlagDefinition, unit: ![[CU_LOC]])176// CHECK: ![[CALLEE_TYPE]] = !DISubroutineType(types: ![[CALLEE_ARGS:.*]])177// CHECK: ![[CALLEE_ARGS]] = !{![[ARG_TYPE:.*]], ![[ARG_TYPE:.*]]}178// CHECK: ![[INLINE_LOC]] = !DILocation(line: 28, column: 5,179 180// 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:.*]])181// CHECK: ![[MODULE]] = !DIModule(scope: ![[CU_FILE_LOC]], name: "module", configMacros: "bar", includePath: "/", apinotes: "/", file: ![[CU_FILE_LOC]], line: 42, isDecl: true)182// CHECK: ![[EMPTY_TYPES_TYPE]] = !DISubroutineType(cc: DW_CC_normal, types: ![[EMPTY_TYPES_ARGS:.*]])183// CHECK: ![[EMPTY_TYPES_ARGS]] = !{}184 185// CHECK: ![[ANNOTATIONS]] = !{![[ANNOTATION:.*]]}186// CHECK: ![[ANNOTATION]] = !{!"foo", !"bar"}187 188// -----189 190#di_file = #llvm.di_file<"foo.mlir" in "/test/">191#di_subprogram = #llvm.di_subprogram<192 scope = #di_file, name = "func_decl_with_subprogram", file = #di_file193>194 195// CHECK-LABEL: declare !dbg196// CHECK-SAME: ![[SUBPROGRAM:.*]] i32 @func_decl_with_subprogram(197llvm.func @func_decl_with_subprogram() -> (i32) loc(fused<#di_subprogram>["foo.mlir":2:1])198 199// CHECK: ![[SUBPROGRAM]] = !DISubprogram(name: "func_decl_with_subprogram", scope: ![[FILE:.*]], file: ![[FILE]], spFlags: 0)200// CHECK: ![[FILE]] = !DIFile(filename: "foo.mlir", directory: "/test/")201 202// -----203 204#di_basic_type = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "int", sizeInBits = 32, encoding = DW_ATE_signed>205#di_file = #llvm.di_file<"foo.mlir" in "/test/">206#di_compile_unit = #llvm.di_compile_unit<207 id = distinct[0]<>, sourceLanguage = DW_LANG_C, file = #di_file,208 producer = "MLIR", isOptimized = true, emissionKind = Full209>210#di_subprogram = #llvm.di_subprogram<211 compileUnit = #di_compile_unit, scope = #di_file, name = "outer_func",212 file = #di_file, subprogramFlags = "Definition|Optimized"213>214#di_subprogram1 = #llvm.di_subprogram<215 compileUnit = #di_compile_unit, scope = #di_file, name = "inner_func",216 file = #di_file, subprogramFlags = "LocalToUnit|Definition|Optimized"217>218#di_local_variable0 = #llvm.di_local_variable<scope = #di_subprogram, name = "a", file = #di_file, type = #di_basic_type>219#di_lexical_block_file = #llvm.di_lexical_block_file<scope = #di_subprogram1, file = #di_file, discriminator = 0>220#di_local_variable1 = #llvm.di_local_variable<scope = #di_lexical_block_file, name = "b", file = #di_file, type = #di_basic_type>221#di_label = #llvm.di_label<scope = #di_lexical_block_file, name = "label", file = #di_file, line = 42>222 223#loc0 = loc("foo.mlir":0:0)224#loc1 = loc(callsite(fused<#di_lexical_block_file>[#loc0] at fused<#di_subprogram>["foo.mlir":4:2]))225 226// CHECK-LABEL: define i32 @func_with_inlined_dbg_value(227// CHECK-SAME: i32 %[[ARG:.*]]) !dbg ![[OUTER_FUNC:[0-9]+]]228llvm.func @func_with_inlined_dbg_value(%arg0: i32) -> (i32) {229 // RECORDS: #dbg_value(i32 %[[ARG]], ![[VAR_LOC0:[0-9]+]], !DIExpression(), ![[DBG_LOC0:.*]])230 llvm.intr.dbg.value #di_local_variable0 = %arg0 : i32 loc(fused<#di_subprogram>[#loc0])231 // RECORDS: #dbg_value(i32 %[[ARG]], ![[VAR_LOC1:[0-9]+]], !DIExpression(), ![[DBG_LOC1:.*]])232 llvm.intr.dbg.value #di_local_variable1 = %arg0 : i32 loc(#loc1)233 // RECORDS: #dbg_label(![[LABEL:[0-9]+]], ![[DBG_LOC1:.*]])234 llvm.intr.dbg.label #di_label loc(#loc1)235 llvm.return %arg0 : i32236} loc(fused<#di_subprogram>["caller"])237 238// CHECK: ![[FILE:.*]] = !DIFile(filename: "foo.mlir", directory: "/test/")239// CHECK-DAG: ![[OUTER_FUNC]] = distinct !DISubprogram(name: "outer_func", scope: ![[FILE]]240// CHECK-DAG: ![[INNER_FUNC:.*]] = distinct !DISubprogram(name: "inner_func", scope: ![[FILE]]241// CHECK-DAG: ![[LEXICAL_BLOCK_FILE:.*]] = distinct !DILexicalBlockFile(scope: ![[INNER_FUNC]], file: ![[FILE]], discriminator: 0)242// CHECK-DAG: ![[VAR_LOC0]] = !DILocalVariable(name: "a", scope: ![[OUTER_FUNC]], file: ![[FILE]]243// CHECK-DAG: ![[VAR_LOC1]] = !DILocalVariable(name: "b", scope: ![[LEXICAL_BLOCK_FILE]], file: ![[FILE]]244// CHECK-DAG: ![[LABEL]] = !DILabel(scope: ![[LEXICAL_BLOCK_FILE]], name: "label", file: ![[FILE]], line: 42)245 246// -----247 248#di_basic_type = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "int", sizeInBits = 32, encoding = DW_ATE_signed>249#di_file = #llvm.di_file<"foo.mlir" in "/test/">250#di_compile_unit = #llvm.di_compile_unit<251 id = distinct[0]<>, sourceLanguage = DW_LANG_C, file = #di_file,252 producer = "MLIR", isOptimized = true, emissionKind = Full253>254#di_subprogram = #llvm.di_subprogram<255 compileUnit = #di_compile_unit, scope = #di_file, name = "func",256 file = #di_file, subprogramFlags = Definition>257#di_local_variable = #llvm.di_local_variable<scope = #di_subprogram, name = "a", file = #di_file, type = #di_basic_type>258 259#loc = loc("foo.mlir":0:0)260 261// CHECK-LABEL: define void @func_without_subprogram(262// CHECK-SAME: i32 %[[ARG:.*]])263llvm.func @func_without_subprogram(%0 : i32) {264 // RECORDS: #dbg_value(i32 %[[ARG]], ![[VAR_LOC:[0-9]+]], !DIExpression(), ![[DBG_LOC0:.*]])265 llvm.intr.dbg.value #di_local_variable = %0 : i32 loc(fused<#di_subprogram>[#loc])266 llvm.return267}268 269// CHECK: ![[FILE:.*]] = !DIFile(filename: "foo.mlir", directory: "/test/")270// CHECK-DAG: ![[FUNC:.*]] = distinct !DISubprogram(name: "func", scope: ![[FILE]]271// CHECK-DAG: ![[VAR_LOC]] = !DILocalVariable(name: "a", scope: ![[FUNC]], file: ![[FILE]]272 273// -----274 275// Ensures that debug intrinsics without a valid location are not exported to276// avoid broken LLVM IR.277 278#di_file = #llvm.di_file<"foo.mlir" in "/test/">279#di_compile_unit = #llvm.di_compile_unit<280 id = distinct[0]<>, sourceLanguage = DW_LANG_C, file = #di_file,281 producer = "MLIR", isOptimized = true, emissionKind = Full282>283#di_subprogram = #llvm.di_subprogram<284 compileUnit = #di_compile_unit, scope = #di_file, name = "outer_func",285 file = #di_file, subprogramFlags = "Definition|Optimized"286>287#di_local_variable = #llvm.di_local_variable<scope = #di_subprogram, name = "a">288#declared_var = #llvm.di_local_variable<scope = #di_subprogram, name = "alloc">289#di_label = #llvm.di_label<scope = #di_subprogram, name = "label", file = #di_file, line = 42>290 291// CHECK-LABEL: define i32 @dbg_intrinsics_with_no_location(292llvm.func @dbg_intrinsics_with_no_location(%arg0: i32) -> (i32) {293 %allocCount = llvm.mlir.constant(1 : i32) : i32294 %alloc = llvm.alloca %allocCount x i64 : (i32) -> !llvm.ptr295 // RECORDS-NOT: #dbg_value296 llvm.intr.dbg.value #di_local_variable = %arg0 : i32297 // RECORDS-NOT: #dbg_declare298 llvm.intr.dbg.declare #declared_var = %alloc : !llvm.ptr299 // RECORDS-NOT: #dbg_label300 llvm.intr.dbg.label #di_label301 llvm.return %arg0 : i32302}303 304// -----305 306// CHECK: @global_with_expr_1 = external global i64, !dbg {{.*}}307// CHECK: @global_with_expr_2 = external global i64, !dbg {{.*}}308// CHECK-DAG: !llvm.module.flags = !{{{.*}}}309// CHECK-DAG: !llvm.dbg.cu = !{{{.*}}}310// CHECK-DAG: ![[FILE:.*]] = !DIFile(filename: "not", directory: "existence")311// CHECK-DAG: ![[TYPE:.*]] = !DIBasicType(name: "uint64_t", size: 64, encoding: DW_ATE_unsigned)312// CHECK-DAG: ![[SCOPE:.*]] = distinct !DICompileUnit(language: DW_LANG_C, file: ![[FILE]], producer: "MLIR", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: ![[GVALS:.*]])313// 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)314// 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)315// CHECK-DAG: ![[GEXPR0:.*]] = !DIGlobalVariableExpression(var: ![[GVAR0]], expr: !DIExpression())316// CHECK-DAG: ![[GEXPR1:.*]] = !DIGlobalVariableExpression(var: ![[GVAR1]], expr: !DIExpression())317// CHECK-DAG: ![[GVALS]] = !{![[GEXPR0]], ![[GEXPR1]]}318 319#di_file_2 = #llvm.di_file<"not" in "existence">320#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>321#di_basic_type_2 = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "uint64_t", sizeInBits = 64, encoding = DW_ATE_unsigned>322llvm.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 = <>>]} : i64323llvm.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 = <>>]} : i64324 325// -----326 327// CHECK: @module_global = external global i64, !dbg {{.*}}328// CHECK-DAG: !llvm.module.flags = !{{{.*}}}329// CHECK-DAG: !llvm.dbg.cu = !{{{.*}}}330// CHECK-DAG: ![[FILE:.*]] = !DIFile(filename: "test.f90", directory: "existence")331// CHECK-DAG: ![[TYPE:.*]] = !DIBasicType(name: "integer", size: 64, encoding: DW_ATE_signed)332// CHECK-DAG: ![[SCOPE:.*]] = distinct !DICompileUnit(language: DW_LANG_Fortran95, file: ![[FILE]], producer: "MLIR", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: ![[GVALS:.*]])333// CHECK-DAG: ![[SCOPE1:.*]] = !DIModule(scope: ![[SCOPE]], name: "module2", file: ![[FILE]], line: 120)334// CHECK-DAG: ![[GVAR:.*]] = distinct !DIGlobalVariable(name: "module_global", linkageName: "module_global", scope: ![[SCOPE1]], file: ![[FILE]], line: 121, type: ![[TYPE]], isLocal: false, isDefinition: true)335// CHECK-DAG: ![[GEXPR:.*]] = !DIGlobalVariableExpression(var: ![[GVAR]], expr: !DIExpression())336// CHECK-DAG: ![[GVALS]] = !{![[GEXPR]]}337 338#di_file = #llvm.di_file<"test.f90" in "existence">339#di_compile_unit = #llvm.di_compile_unit<id = distinct[0]<>, sourceLanguage = DW_LANG_Fortran95, file = #di_file, producer = "MLIR", isOptimized = true, emissionKind = Full>340#di_basic_type = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "integer", sizeInBits = 64, encoding = DW_ATE_signed>341#di_module = #llvm.di_module<file = #di_file, scope = #di_compile_unit, name = "module2", configMacros = "", includePath = "", apinotes = "", line = 120, isDecl = false >342llvm.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 = <>>]} : i64343 344// -----345 346// CHECK: @func_global = external global i64, !dbg {{.*}}347// CHECK-DAG: ![[CU:.*]] = distinct !DICompileUnit({{.*}}globals: ![[GVALS:.*]])348// CHECK-DAG: ![[SP:.*]] = distinct !DISubprogram(name: "fn_with_gl"{{.*}}unit: ![[CU]])349// CHECK-DAG: ![[GVAR:.*]] = distinct !DIGlobalVariable(name: "func_global"{{.*}}, scope: ![[SP]]{{.*}})350// CHECK-DAG: ![[GEXPR:.*]] = !DIGlobalVariableExpression(var: ![[GVAR]], expr: !DIExpression())351// CHECK-DAG: ![[GVALS]] = !{![[GEXPR]]}352 353#file = #llvm.di_file<"test.f90" in "existence">354#cu = #llvm.di_compile_unit<id = distinct[0]<>, sourceLanguage = DW_LANG_Fortran95, file = #file, producer = "MLIR", isOptimized = true, emissionKind = Full>355#ty1 = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "integer", sizeInBits = 64, encoding = DW_ATE_signed>356#sp = #llvm.di_subprogram<compileUnit = #cu, scope = #file, name = "fn_with_gl", file = #file, subprogramFlags = "Definition|Optimized">357llvm.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 = <>>]} : i64358 359llvm.func @fn_with_gl() {360 llvm.return361} loc(fused<#sp>["foo1.mlir":0:0])362 363// -----364 365// Test that imported entries correctly generates 'retainedNodes' in the366// subprogram.367 368llvm.func @imp_fn() {369 llvm.return370} loc(#loc2)371 372#di_file = #llvm.di_file<"test.f90" in "">373#di_subroutine_type = #llvm.di_subroutine_type<callingConvention = DW_CC_program>374#di_compile_unit = #llvm.di_compile_unit<id = distinct[0]<>,375 sourceLanguage = DW_LANG_Fortran95, file = #di_file, isOptimized = false,376 emissionKind = Full>377#di_module_1 = #llvm.di_module<file = #di_file, scope = #di_compile_unit, name = "mod1">378#di_module_2 = #llvm.di_module<file = #di_file, scope = #di_compile_unit, name = "mod2">379#di_subprogram_self_rec = #llvm.di_subprogram<recId = distinct[1]<>>380#di_imported_entity_1 = #llvm.di_imported_entity<tag = DW_TAG_imported_module,381 scope = #di_subprogram_self_rec, entity = #di_module_1, file = #di_file, line = 1>382#di_imported_entity_2 = #llvm.di_imported_entity<tag = DW_TAG_imported_module,383 scope = #di_subprogram_self_rec, entity = #di_module_2, file = #di_file, line = 1>384#di_subprogram = #llvm.di_subprogram<id = distinct[2]<>, recId = distinct[1]<>,385 compileUnit = #di_compile_unit, scope = #di_file, name = "imp_fn",386 file = #di_file, subprogramFlags = Definition, type = #di_subroutine_type,387 retainedNodes = #di_imported_entity_1, #di_imported_entity_2>388#loc1 = loc("test.f90":12:14)389#loc2 = loc(fused<#di_subprogram>[#loc1])390 391// CHECK-DAG: ![[SP:[0-9]+]] = {{.*}}!DISubprogram(name: "imp_fn"{{.*}}retainedNodes: ![[NODES:[0-9]+]])392// CHECK-DAG: ![[NODES]] = !{![[NODE1:[0-9]+]], ![[NODE2:[0-9]+]]}393// CHECK-DAG: ![[NODE1]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: ![[SP]], entity: ![[MOD1:[0-9]+]]{{.*}})394// CHECK-DAG: ![[NODE2]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: ![[SP]], entity: ![[MOD2:[0-9]+]]{{.*}})395// CHECK-DAG: ![[MOD1]] = !DIModule({{.*}}name: "mod1"{{.*}})396// CHECK-DAG: ![[MOD2]] = !DIModule({{.*}}name: "mod2"{{.*}})397 398// -----399 400// Nameless and scopeless global constant.401 402// CHECK-LABEL: @.str.1 = external constant [10 x i8]403// CHECK-SAME: !dbg ![[GLOBAL_VAR_EXPR:.*]]404// CHECK-DAG: ![[GLOBAL_VAR_EXPR]] = !DIGlobalVariableExpression(var: ![[GLOBAL_VAR:.*]], expr: !DIExpression())405// CHECK-DAG: ![[GLOBAL_VAR]] = distinct !DIGlobalVariable(scope: null, file: !{{[0-9]+}}, line: 268, type: !{{[0-9]+}}, isLocal: true, isDefinition: true)406 407#di_basic_type = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "char", sizeInBits = 8, encoding = DW_ATE_signed_char>408#di_file = #llvm.di_file<"file.c" in "/path/to/file">409#di_derived_type = #llvm.di_derived_type<tag = DW_TAG_const_type, baseType = #di_basic_type>410#di_composite_type = #llvm.di_composite_type<tag = DW_TAG_array_type, baseType = #di_derived_type, sizeInBits = 80>411#di_global_variable = #llvm.di_global_variable<file = #di_file, line = 268, type = #di_composite_type, isLocalToUnit = true, isDefined = true>412#di_global_variable_expression = #llvm.di_global_variable_expression<var = #di_global_variable, expr = <>>413 414llvm.mlir.global external constant @".str.1"() {addr_space = 0 : i32, dbg_exprs = [#di_global_variable_expression]} : !llvm.array<10 x i8>415 416// -----417 418// CHECK-DAG: ![[FILE1:.*]] = !DIFile(filename: "foo1.mlir", directory: "/test/")419#di_file_1 = #llvm.di_file<"foo1.mlir" in "/test/">420// CHECK-DAG: ![[FILE2:.*]] = !DIFile(filename: "foo2.mlir", directory: "/test/")421#di_file_2 = #llvm.di_file<"foo2.mlir" in "/test/">422// CHECK-DAG: ![[SCOPE2:.*]] = distinct !DICompileUnit(language: DW_LANG_C, file: ![[FILE2]], producer: "MLIR", isOptimized: true, runtimeVersion: 0, emissionKind: DebugDirectivesOnly)423#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>424// CHECK-DAG: ![[SCOPE1:.*]] = distinct !DICompileUnit(language: DW_LANG_C, file: ![[FILE1]], producer: "MLIR", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly)425#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>426#di_subprogram_1 = #llvm.di_subprogram<compileUnit = #di_compile_unit_1, scope = #di_file_1, name = "func1", file = #di_file_1, subprogramFlags = "Definition|Optimized">427#di_subprogram_2 = #llvm.di_subprogram<compileUnit = #di_compile_unit_2, scope = #di_file_2, name = "func2", file = #di_file_2, subprogramFlags = "Definition|Optimized">428 429llvm.func @func_line_tables() {430 llvm.return431} loc(fused<#di_subprogram_1>["foo1.mlir":0:0])432 433llvm.func @func_debug_directives() {434 llvm.return435} loc(fused<#di_subprogram_2>["foo2.mlir":0:0])436 437// -----438 439// Ensure recursive types with multiple external references work.440 441// Common base nodes.442#di_file = #llvm.di_file<"test.mlir" in "/">443#di_null_type = #llvm.di_null_type444#di_compile_unit = #llvm.di_compile_unit<id = distinct[1]<>, sourceLanguage = DW_LANG_C, file = #di_file, isOptimized = false, emissionKind = None>445 446// Recursive type itself.447#di_struct_self = #llvm.di_composite_type<recId = distinct[0]<>, isRecSelf = true>448#di_ptr_inner = #llvm.di_derived_type<tag = DW_TAG_pointer_type, baseType = #di_struct_self, sizeInBits = 64>449#di_subroutine_inner = #llvm.di_subroutine_type<types = #di_null_type, #di_ptr_inner>450#di_subprogram_inner = #llvm.di_subprogram<451 id = distinct[2]<>,452 compileUnit = #di_compile_unit,453 scope = #di_struct_self,454 name = "class_method",455 file = #di_file,456 subprogramFlags = Definition,457 type = #di_subroutine_inner>458#di_struct = #llvm.di_composite_type<459 tag = DW_TAG_class_type,460 recId = distinct[0]<>,461 name = "class_name",462 file = #di_file,463 line = 42,464 flags = "TypePassByReference|NonTrivial",465 elements = #di_subprogram_inner>466 467// Outer types referencing the entire recursive type.468#di_ptr_outer = #llvm.di_derived_type<tag = DW_TAG_pointer_type, baseType = #di_struct, sizeInBits = 64>469#di_subroutine_outer = #llvm.di_subroutine_type<types = #di_null_type, #di_ptr_outer>470#di_subprogram_outer = #llvm.di_subprogram<471 id = distinct[2]<>,472 compileUnit = #di_compile_unit,473 scope = #di_struct,474 name = "class_method",475 file = #di_file,476 subprogramFlags = Definition,477 type = #di_subroutine_outer>478 479#loc3 = loc(fused<#di_subprogram_outer>["test.mlir":1:1])480 481// CHECK: @class_method482// CHECK: ret void, !dbg ![[LOC:.*]]483 484// CHECK: ![[CU:.*]] = distinct !DICompileUnit(485// CHECK: ![[SP:.*]] = distinct !DISubprogram(name: "class_method", scope: ![[STRUCT:.*]], file: !{{.*}}, type: ![[SUBROUTINE:.*]], spFlags: DISPFlagDefinition, unit: ![[CU]])486// CHECK: ![[STRUCT]] = distinct !DICompositeType(tag: DW_TAG_class_type, name: "class_name", {{.*}}, elements: ![[ELEMS:.*]])487// CHECK: ![[ELEMS]] = !{![[SP]]}488// CHECK: ![[SUBROUTINE]] = !DISubroutineType(types: ![[SUBROUTINE_ELEMS:.*]])489// CHECK: ![[SUBROUTINE_ELEMS]] = !{null, ![[PTR:.*]]}490// CHECK: ![[PTR]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[STRUCT]], size: 64)491// CHECK: ![[LOC]] = !DILocation(line: 1, column: 1, scope: ![[SP]])492 493llvm.func @class_method() {494 llvm.return loc(#loc3)495} loc(#loc3)496 497// -----498 499// Ensures composite types with a recursive scope work.500 501#di_composite_type_self = #llvm.di_composite_type<recId = distinct[0]<>, isRecSelf = true>502#di_file = #llvm.di_file<"test.mlir" in "/">503#di_subroutine_type = #llvm.di_subroutine_type<types = #di_composite_type_self>504#di_subprogram = #llvm.di_subprogram<scope = #di_file, file = #di_file, subprogramFlags = Optimized, type = #di_subroutine_type>505#di_composite_type = #llvm.di_composite_type<tag = DW_TAG_class_type, recId = distinct[0]<>, scope = #di_subprogram>506#di_global_variable = #llvm.di_global_variable<file = #di_file, line = 1, type = #di_composite_type>507#di_global_variable_expression = #llvm.di_global_variable_expression<var = #di_global_variable>508 509llvm.mlir.global @global_variable() {dbg_exprs = [#di_global_variable_expression]} : !llvm.struct<()>510 511// CHECK: distinct !DIGlobalVariable({{.*}}type: ![[COMP:[0-9]+]],512// CHECK: ![[COMP]] = distinct !DICompositeType({{.*}}scope: ![[SCOPE:[0-9]+]]513// CHECK: ![[SCOPE]] = !DISubprogram({{.*}}type: ![[SUBROUTINE:[0-9]+]],514// CHECK: ![[SUBROUTINE]] = !DISubroutineType(types: ![[SR_TYPES:[0-9]+]])515// CHECK: ![[SR_TYPES]] = !{![[COMP]]}516 517// -----518 519// Ensures nested recursive decls work.520// The output should be identical to if the inner composite type decl was521// replaced with the recursive self reference.522 523#di_file = #llvm.di_file<"test.mlir" in "/">524#di_composite_type_self = #llvm.di_composite_type<recId = distinct[0]<>, isRecSelf = true>525 526#di_subroutine_type_inner = #llvm.di_subroutine_type<types = #di_composite_type_self>527#di_subprogram_inner = #llvm.di_subprogram<scope = #di_file, file = #di_file, subprogramFlags = Optimized, type = #di_subroutine_type_inner>528#di_composite_type_inner = #llvm.di_composite_type<tag = DW_TAG_class_type, recId = distinct[0]<>, scope = #di_subprogram_inner>529 530#di_subroutine_type = #llvm.di_subroutine_type<types = #di_composite_type_inner>531#di_subprogram = #llvm.di_subprogram<scope = #di_file, file = #di_file, subprogramFlags = Optimized, type = #di_subroutine_type>532#di_composite_type = #llvm.di_composite_type<tag = DW_TAG_class_type, recId = distinct[0]<>, scope = #di_subprogram>533 534// Use the inner type standalone outside too. Ensures it's not cached wrong.535#di_var_type = #llvm.di_subroutine_type<types = #di_composite_type, #di_composite_type_inner>536#di_global_variable = #llvm.di_global_variable<file = #di_file, line = 1, type = #di_var_type>537#di_global_variable_expression = #llvm.di_global_variable_expression<var = #di_global_variable>538 539llvm.mlir.global @global_variable() {dbg_exprs = [#di_global_variable_expression]} : !llvm.struct<()>540 541// CHECK: distinct !DIGlobalVariable({{.*}}type: ![[VAR:[0-9]+]],542// CHECK: ![[VAR]] = !DISubroutineType(types: ![[COMPS:[0-9]+]])543// CHECK: ![[COMPS]] = !{![[COMP:[0-9]+]],544// CHECK: ![[COMP]] = distinct !DICompositeType({{.*}}scope: ![[SCOPE:[0-9]+]]545// CHECK: ![[SCOPE]] = !DISubprogram({{.*}}type: ![[SUBROUTINE:[0-9]+]],546// CHECK: ![[SUBROUTINE]] = !DISubroutineType(types: ![[SR_TYPES:[0-9]+]])547// CHECK: ![[SR_TYPES]] = !{![[COMP]]}548 549// -----550 551#file = #llvm.di_file<"test.f90" in "">552#cu = #llvm.di_compile_unit<id = distinct[0]<>, sourceLanguage = DW_LANG_Fortran95,553 file = #file, producer = "", isOptimized = false, emissionKind = Full>554#i32 = #llvm.di_basic_type<555 tag = DW_TAG_base_type, name = "integer",556 sizeInBits = 32, encoding = DW_ATE_signed557>558#null = #llvm.di_null_type559#alloc = #llvm.di_expression<[DW_OP_lit0, DW_OP_ne]>560#assoc = #llvm.di_expression<[DW_OP_lit0, DW_OP_eq]>561#rank = #llvm.di_expression<[DW_OP_push_object_address, DW_OP_plus_uconst(16), DW_OP_deref]>562#datal = #llvm.di_expression<[DW_OP_push_object_address, DW_OP_deref]>563#array = #llvm.di_composite_type<tag = DW_TAG_array_type,564 baseType = #i32,565 dataLocation = #datal, rank = #rank,566 allocated = #alloc, associated = #assoc,567 elements = #llvm.di_subrange<lowerBound = 1, count = 5>568>569#spType0 = #llvm.di_subroutine_type<callingConvention = DW_CC_normal, types = #null, #array>570#sp0 = #llvm.di_subprogram<571 compileUnit = #cu, scope = #cu, name = "fn_with_composite", file = #file,572 subprogramFlags = "Definition|Optimized", type = #spType0573>574llvm.func @fn_with_composite() {575 llvm.return576}loc(fused<#sp0>["foo.mlir":1:1])577// CHECK-LABEL: define void @fn_with_composite()578// CHECK: !DICompositeType(579// CHECK-SAME: dataLocation: !DIExpression(DW_OP_push_object_address, DW_OP_deref)580// CHECK-SAME: associated: !DIExpression(DW_OP_lit0, DW_OP_eq)581// CHECK-SAME: allocated: !DIExpression(DW_OP_lit0, DW_OP_ne)582// CHECK-SAME: rank: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 16, DW_OP_deref)583 584// -----585 586// Test that Subrange/generic_subrange works with expression and variables.587 588#bt = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "int">589#file = #llvm.di_file<"debug-info.ll" in "/">590#cu = #llvm.di_compile_unit<id = distinct[1]<>,591 sourceLanguage = DW_LANG_Fortran95, file = #file, isOptimized = false,592 emissionKind = Full>593#exp1 = #llvm.di_expression<[DW_OP_push_object_address, DW_OP_plus_uconst(16),594 DW_OP_deref]>595#comp_ty1 = #llvm.di_composite_type<tag = DW_TAG_array_type,596 name = "expr_elements", baseType = #bt, flags = Vector,597 elements = #llvm.di_subrange<count = #exp1>>598#exp2 = #llvm.di_expression<[DW_OP_push_object_address, DW_OP_plus_uconst(24),599 DW_OP_deref]>600#exp3 = #llvm.di_expression<[DW_OP_push_object_address, DW_OP_plus_uconst(32),601 DW_OP_deref]>602#comp_ty2 = #llvm.di_composite_type<tag = DW_TAG_array_type,603 name = "expr_elements2", baseType = #bt, elements =604 #llvm.di_generic_subrange<count = #exp1, lowerBound = #exp2, stride = #exp3>>605#srty = #llvm.di_subroutine_type<types = #bt, #comp_ty1, #comp_ty2>606#sp = #llvm.di_subprogram<compileUnit = #cu, scope = #file, name = "subranges",607 file = #file, subprogramFlags = Definition, type = #srty>608#lvar = #llvm.di_local_variable<scope = #sp, name = "size">609#gv = #llvm.di_global_variable<scope = #cu, name = "gv", file = #file,610 line = 3, type = #bt>611#gve = #llvm.di_global_variable_expression<var = #gv, expr = <>>612#comp_ty3 = #llvm.di_composite_type<tag = DW_TAG_array_type,613 name = "var_elements", baseType = #bt, flags = Vector,614 elements = #llvm.di_subrange<count = #lvar, stride = #gv>>615#comp_ty4 = #llvm.di_composite_type<tag = DW_TAG_array_type,616 name = "var_elements2", baseType = #bt, elements =617 #llvm.di_generic_subrange<count = #lvar, lowerBound = #gv, stride = #gv>>618#lvar2 = #llvm.di_local_variable<scope = #sp, name = "var", type = #comp_ty3>619#lvar3 = #llvm.di_local_variable<scope = #sp, name = "var1", type = #comp_ty4>620#loc1 = loc("test.f90": 1:1)621#loc2 = loc(fused<#sp>[#loc1])622 623llvm.mlir.global external @gv() {dbg_exprs = [#gve]} : i64624 625llvm.func @subranges(%arg: !llvm.ptr) {626 llvm.intr.dbg.declare #lvar2 = %arg : !llvm.ptr627 llvm.intr.dbg.declare #lvar3 = %arg : !llvm.ptr628 llvm.return629} loc(#loc2)630 631// CHECK-LABEL: define void @subranges632// CHECK: ![[GV:[0-9]+]] = {{.*}}!DIGlobalVariable(name: "gv"{{.*}})633// CHECK: !DICompositeType(tag: DW_TAG_array_type, name: "expr_elements"{{.*}}elements: ![[ELEMENTS1:[0-9]+]])634// CHECK: ![[ELEMENTS1]] = !{![[ELEMENT1:[0-9]+]]}635// CHECK: ![[ELEMENT1]] = !DISubrange(count: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 16, DW_OP_deref))636// CHECK: !DICompositeType(tag: DW_TAG_array_type, name: "expr_elements2"{{.*}}elements: ![[GSR_ELEMS:[0-9]+]])637// CHECK: ![[GSR_ELEMS]] = !{![[GSR_ELEM:[0-9]+]]}638// CHECK: ![[GSR_ELEM]] = !DIGenericSubrange(count: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 16, DW_OP_deref)639// CHECK-SAME: lowerBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 24, DW_OP_deref)640// CHECK-SAME: stride: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 32, DW_OP_deref)641 642// CHECK: !DICompositeType(tag: DW_TAG_array_type, name: "var_elements"{{.*}}elements: ![[ELEMENTS2:[0-9]+]])643// CHECK: ![[ELEMENTS2]] = !{![[ELEMENT2:[0-9]+]]}644// CHECK: ![[ELEMENT2]] = !DISubrange(count: ![[LV:[0-9]+]], stride: ![[GV]])645// CHECK: ![[LV]] = !DILocalVariable(name: "size"{{.*}})646// CHECK: !DICompositeType(tag: DW_TAG_array_type, name: "var_elements2", baseType: !{{.*}}, elements: ![[GSR_ELEMS2:[0-9]+]])647// CHECK: ![[GSR_ELEMS2]] = !{![[GSR_ELEM2:[0-9]+]]}648// CHECK: ![[GSR_ELEM2]] = !DIGenericSubrange(count: ![[LV]], lowerBound: ![[GV]], stride: ![[GV]])649 650// -----651 652#bt = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "int", sizeInBits = 32>653#file = #llvm.di_file<"debug-info.ll" in "/">654#cu = #llvm.di_compile_unit<id = distinct[0]<>, sourceLanguage = DW_LANG_C,655 file = #file, isOptimized = false, emissionKind = Full>656#sp = #llvm.di_subprogram<compileUnit = #cu, scope = #file, name = "test",657 file = #file, subprogramFlags = Definition>658#var = #llvm.di_local_variable<scope = #sp, name = "string_size", type = #bt, flags = Artificial>659#ty = #llvm.di_string_type<tag = DW_TAG_string_type, name = "character(*)",660 sizeInBits = 32, alignInBits = 8, stringLength = #var,661 stringLengthExp = <[DW_OP_push_object_address, DW_OP_plus_uconst(8)]>,662 stringLocationExp = <[DW_OP_push_object_address, DW_OP_deref]>>663#var1 = #llvm.di_local_variable<scope = #sp, name = "str", type = #ty>664 665llvm.func @string_ty(%arg0: !llvm.ptr) {666 llvm.intr.dbg.value #var1 = %arg0 : !llvm.ptr667 llvm.intr.dbg.value #var = %arg0 : !llvm.ptr668 llvm.return669} loc(#loc2)670 671#loc1 = loc("test.f90":1:1)672#loc2 = loc(fused<#sp>[#loc1])673 674// 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)675// CHECK-DAG: ![[VAR]] = !DILocalVariable(name: "string_size"{{.*}} flags: DIFlagArtificial)676 677// -----678 679// Test translation of DICommonBlockAttr.680#bt = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "int", sizeInBits = 32>681#file = #llvm.di_file<"test.f90" in "">682#cu = #llvm.di_compile_unit<id = distinct[0]<>, sourceLanguage = DW_LANG_C,683 file = #file, isOptimized = false, emissionKind = Full>684#sp = #llvm.di_subprogram<compileUnit = #cu, scope = #file, name = "test",685 file = #file, subprogramFlags = Definition>686#di_common_block = #llvm.di_common_block<scope = #sp, name = "block",687 file = #file, line = 3>688#global_var = #llvm.di_global_variable<scope = #di_common_block, name = "a",689 file = #file, line = 2, type = #bt>690#var_expression = #llvm.di_global_variable_expression<var = #global_var,691 expr = <>>692 693llvm.mlir.global common @block_(dense<0> : tensor<8xi8>)694 {dbg_exprs = [#var_expression]} : !llvm.array<8 x i8>695 696llvm.func @test() {697 llvm.return698} loc(#loc2)699 700#loc1 = loc("test.f90":1:0)701#loc2 = loc(fused<#sp>[#loc1])702 703// CHECK: !DICommonBlock(scope: ![[SCOPE:[0-9]+]], declaration: null, name: "block", file: ![[FILE:[0-9]+]], line: 3)704// CHECK: ![[SCOPE]] = {{.*}}!DISubprogram(name: "test"{{.*}})705// CHECK: ![[FILE]] = !DIFile(filename: "test.f90"{{.*}})706 707// -----708 709// Test multiple DIGlobalVariableExpression on a global.710#bt = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "int", sizeInBits = 32>711#file = #llvm.di_file<"test.f90" in "">712#cu = #llvm.di_compile_unit<id = distinct[0]<>, sourceLanguage = DW_LANG_C,713 file = #file, isOptimized = false, emissionKind = Full>714#global_var = #llvm.di_global_variable<scope = #cu, name = "a",715 file = #file, line = 2, type = #bt>716#var_expression = #llvm.di_global_variable_expression<var = #global_var,717 expr = <>>718#global_var1 = #llvm.di_global_variable<scope = #cu, name = "b",719 file = #file, line = 3, type = #bt>720#var_expression1 = #llvm.di_global_variable_expression<var = #global_var1,721 expr = <>>722 723llvm.mlir.global @data() {dbg_exprs = [#var_expression, #var_expression1]} : i64724 725// CHECK: @data = external global i64, !dbg ![[EXP1:[0-9]+]], !dbg ![[EXP2:[0-9]+]]726// CHECK: ![[EXP1]] = !DIGlobalVariableExpression(var: ![[VAR1:[0-9]+]], expr: !DIExpression())727// CHECK: ![[VAR1]] = {{.*}}!DIGlobalVariable(name: "a"{{.*}})728// CHECK: ![[EXP2]] = !DIGlobalVariableExpression(var: ![[VAR2:[0-9]+]], expr: !DIExpression())729// CHECK: ![[VAR2]] = {{.*}}!DIGlobalVariable(name: "b"{{.*}})730