1// RUN: mlir-opt %s | mlir-opt | FileCheck %s 2 3// CHECK-DAG: #[[FILE:.*]] = #llvm.di_file<"debuginfo.mlir" in "/test/"> 4#file = #llvm.di_file<"debuginfo.mlir" in "/test/"> 5 6// CHECK-DAG: #[[CU:.*]] = #llvm.di_compile_unit<id = distinct[0]<>, sourceLanguage = DW_LANG_C, file = #[[FILE]], producer = "MLIR", isOptimized = true, emissionKind = Full> 7#cu = #llvm.di_compile_unit< 8 id = distinct[0]<>, sourceLanguage = DW_LANG_C, file = #file, 9 producer = "MLIR", isOptimized = true, emissionKind = Full 10> 11 12// CHECK-DAG: #[[NULL:.*]] = #llvm.di_null_type 13#null = #llvm.di_null_type 14 15// CHECK-DAG: #[[INT0:.*]] = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "int0"> 16#int0 = #llvm.di_basic_type< 17 // Omit the optional sizeInBits and encoding parameters. 18 tag = DW_TAG_base_type, name = "int0" 19> 20 21// CHECK-DAG: #[[INT1:.*]] = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "int1", sizeInBits = 32, encoding = DW_ATE_signed> 22#int1 = #llvm.di_basic_type< 23 tag = DW_TAG_base_type, name = "int1", 24 sizeInBits = 32, encoding = DW_ATE_signed 25> 26 27// CHECK-DAG: #[[PTR0:.*]] = #llvm.di_derived_type<tag = DW_TAG_pointer_type, baseType = #[[INT0]], sizeInBits = 64, alignInBits = 32, offsetInBits = 4, extraData = #[[INT1]]> 28#ptr0 = #llvm.di_derived_type< 29 tag = DW_TAG_pointer_type, baseType = #int0, 30 sizeInBits = 64, alignInBits = 32, offsetInBits = 4, 31 extraData = #int1 32> 33 34// CHECK-DAG: #[[PTR1:.*]] = #llvm.di_derived_type<tag = DW_TAG_pointer_type, name = "ptr1"> 35#ptr1 = #llvm.di_derived_type< 36 // Specify the name parameter. 37 tag = DW_TAG_pointer_type, name = "ptr1" 38> 39 40// CHECK-DAG: #[[PTR2:.*]] = #llvm.di_derived_type<tag = DW_TAG_pointer_type, baseType = #[[INT0]], sizeInBits = 64, alignInBits = 32, offsetInBits = 4, dwarfAddressSpace = 3, extraData = #[[INT1]]> 41#ptr2 = #llvm.di_derived_type< 42 tag = DW_TAG_pointer_type, baseType = #int0, 43 sizeInBits = 64, alignInBits = 32, offsetInBits = 4, 44 dwarfAddressSpace = 3, extraData = #int1 45> 46 47// CHECK-DAG: #[[COMP0:.*]] = #llvm.di_composite_type<tag = DW_TAG_array_type, name = "array0", line = 10, sizeInBits = 128, alignInBits = 32> 48#comp0 = #llvm.di_composite_type< 49 tag = DW_TAG_array_type, name = "array0", 50 line = 10, sizeInBits = 128, alignInBits = 32 51> 52 53// CHECK-DAG: #[[COMP1:.*]] = #llvm.di_composite_type<tag = DW_TAG_array_type, name = "array1", file = #[[FILE]], scope = #[[FILE]], baseType = #[[INT0]], elements = #llvm.di_subrange<count = 4 : i64>> 54#comp1 = #llvm.di_composite_type< 55 tag = DW_TAG_array_type, name = "array1", file = #file, 56 scope = #file, baseType = #int0, 57 // Specify the subrange count. 58 elements = #llvm.di_subrange<count = 4> 59> 60 61// CHECK-DAG: #[[TOPLEVEL:.*]] = #llvm.di_namespace<name = "toplevel", exportSymbols = true> 62#toplevel_namespace = #llvm.di_namespace< 63 name = "toplevel", exportSymbols = true 64> 65 66// CHECK-DAG: #[[NESTED:.*]] = #llvm.di_namespace<name = "nested", scope = #[[TOPLEVEL]], exportSymbols = false> 67#nested_namespace = #llvm.di_namespace< 68 name = "nested", scope = #toplevel_namespace, exportSymbols = false 69> 70 71// CHECK-DAG: #[[ANONYMOUS_NS:.*]] = #llvm.di_namespace<scope = #[[FILE]], exportSymbols = false> 72#anonymous_namespace = #llvm.di_namespace< 73 scope = #file, 74 exportSymbols = false 75> 76 77// CHECK-DAG: #[[COMP2:.*]] = #llvm.di_composite_type<tag = DW_TAG_class_type, name = "class_name", file = #[[FILE]], scope = #[[NESTED]], flags = "TypePassByReference|NonTrivial"> 78#comp2 = #llvm.di_composite_type< 79 tag = DW_TAG_class_type, name = "class_name", file = #file, scope = #nested_namespace, 80 flags = "TypePassByReference|NonTrivial" 81> 82 83// CHECK-DAG: #[[COMP3:.+]] = #llvm.di_composite_type<{{.*}}, name = "expr_elements2"{{.*}}elements = #llvm.di_generic_subrange<count = #llvm.di_expression<[DW_OP_push_object_address, DW_OP_plus_uconst(16), DW_OP_deref]>, lowerBound = #llvm.di_expression<[DW_OP_push_object_address, DW_OP_plus_uconst(24), DW_OP_deref]>, stride = #llvm.di_expression<[DW_OP_push_object_address, DW_OP_plus_uconst(32), DW_OP_deref]>>> 84#exp1 = #llvm.di_expression<[DW_OP_push_object_address, DW_OP_plus_uconst(16), DW_OP_deref]> 85#exp2 = #llvm.di_expression<[DW_OP_push_object_address, DW_OP_plus_uconst(24), DW_OP_deref]> 86#exp3 = #llvm.di_expression<[DW_OP_push_object_address, DW_OP_plus_uconst(32), DW_OP_deref]> 87#comp3 = #llvm.di_composite_type<tag = DW_TAG_array_type, 88 name = "expr_elements2", baseType = #int0, elements = 89 #llvm.di_generic_subrange<count = #exp1, lowerBound = #exp2, stride = #exp3>> 90 91// CHECK-DAG: #[[SPTYPE0:.*]] = #llvm.di_subroutine_type<callingConvention = DW_CC_normal, types = #[[NULL]], #[[INT0]], #[[PTR0]], #[[PTR1]], #[[PTR2]], #[[COMP0:.*]], #[[COMP1:.*]], #[[COMP2:.*]], #[[COMP3:.*]]> 92#spType0 = #llvm.di_subroutine_type< 93 callingConvention = DW_CC_normal, types = #null, #int0, #ptr0, #ptr1, #ptr2, #comp0, #comp1, #comp2, #comp3 94> 95 96// CHECK-DAG: #[[SPTYPE1:.*]] = #llvm.di_subroutine_type<types = #[[INT1]], #[[INT1]]> 97#spType1 = #llvm.di_subroutine_type< 98 // Omit the optional callingConvention parameter. 99 types = #int1, #int1 100> 101 102// CHECK-DAG: #[[SPTYPE2:.*]] = #llvm.di_subroutine_type<callingConvention = DW_CC_normal> 103#spType2 = #llvm.di_subroutine_type< 104 // Omit the optional types parameter array. 105 callingConvention = DW_CC_normal 106> 107 108// CHECK-DAG: #[[SP0:.*]] = #llvm.di_subprogram<compileUnit = #[[CU]], scope = #[[ANONYMOUS_NS]], name = "addr", linkageName = "addr", file = #[[FILE]], line = 3, scopeLine = 3, subprogramFlags = "Definition|Optimized", type = #[[SPTYPE0]]> 109#sp0 = #llvm.di_subprogram< 110 compileUnit = #cu, scope = #anonymous_namespace, name = "addr", linkageName = "addr", 111 file = #file, line = 3, scopeLine = 3, subprogramFlags = "Definition|Optimized", type = #spType0 112> 113 114// CHECK-DAG: #[[SP1:.*]] = #llvm.di_subprogram<scope = #[[COMP2]], file = #[[FILE]], type = #[[SPTYPE1]]> 115#sp1 = #llvm.di_subprogram< 116 // Omit the optional parameters. 117 scope = #comp2, file = #file, type = #spType1 118> 119 120// CHECK-DAG: #[[MODULE:.*]] = #llvm.di_module<file = #[[FILE]], scope = #[[FILE]], name = "module", configMacros = "bar", includePath = "/", apinotes = "/", line = 42, isDecl = true> 121#module = #llvm.di_module< 122 file = #file, scope = #file, name = "module", 123 configMacros = "bar", includePath = "/", 124 apinotes = "/", line = 42, isDecl = true 125> 126 127// CHECK-DAG: #[[SP2:.*]] = #llvm.di_subprogram<compileUnit = #[[CU]], scope = #[[MODULE]], name = "value", file = #[[FILE]], subprogramFlags = Definition, type = #[[SPTYPE2]], annotations = #llvm.di_annotation<name = "foo", value = "bar"> 128#sp2 = #llvm.di_subprogram< 129 compileUnit = #cu, scope = #module, name = "value", 130 file = #file, subprogramFlags = "Definition", type = #spType2, 131 annotations = #llvm.di_annotation<name = "foo", value = "bar"> 132> 133 134// CHECK-DAG: #[[BLOCK0:.*]] = #llvm.di_lexical_block<scope = #[[SP0]], line = 1, column = 2> 135#block0 = #llvm.di_lexical_block<scope = #sp0, line = 1, column = 2> 136 137// CHECK-DAG: #[[BLOCK1:.*]] = #llvm.di_lexical_block<scope = #[[SP1]]> 138#block1 = #llvm.di_lexical_block<scope = #sp1> 139 140// CHECK-DAG: #[[BLOCK2:.*]] = #llvm.di_lexical_block<scope = #[[SP2]]> 141#block2 = #llvm.di_lexical_block<scope = #sp2> 142 143// CHECK-DAG: #[[VAR0:.*]] = #llvm.di_local_variable<scope = #[[BLOCK0]], name = "alloc", file = #[[FILE]], line = 6, arg = 1, alignInBits = 32, type = #[[INT0]]> 144#var0 = #llvm.di_local_variable< 145 scope = #block0, name = "alloc", file = #file, 146 line = 6, arg = 1, alignInBits = 32, type = #int0 147> 148 149// CHECK-DAG: #[[VAR1:.*]] = #llvm.di_local_variable<scope = #[[BLOCK1]], name = "arg1"> 150#var1 = #llvm.di_local_variable< 151 // Omit the optional parameters. 152 scope = #block1, name = "arg1" 153> 154 155// CHECK-DAG: #[[VAR2:.*]] = #llvm.di_local_variable<scope = #[[BLOCK2]], name = "arg2"> 156#var2 = #llvm.di_local_variable< 157 // Omit the optional parameters. 158 scope = #block2, name = "arg2" 159> 160 161// CHECK-DAG: #[[LABEL1:.*]] = #llvm.di_label<scope = #[[BLOCK1]], name = "label", file = #[[FILE]], line = 42> 162#label1 = #llvm.di_label<scope = #block1, name = "label", file = #file, line = 42> 163 164// CHECK-DAG: #[[LABEL2:.*]] = #llvm.di_label<scope = #[[BLOCK2]]> 165#label2 = #llvm.di_label<scope = #block2> 166 167// CHECK-DAG: #llvm.di_common_block<scope = #[[SP1]], name = "block", file = #[[FILE]], line = 3> 168#di_common_block = #llvm.di_common_block<scope = #sp1, name = "block", file = #file, line = 3> 169#global_var = #llvm.di_global_variable<scope = #di_common_block, name = "a", 170 file = #file, line = 2, type = #int0> 171#var_expression = #llvm.di_global_variable_expression<var = #global_var, 172 expr = <>> 173#global_var1 = #llvm.di_global_variable<scope = #di_common_block, name = "b", 174 file = #file, line = 3, type = #int0> 175#var_expression1 = #llvm.di_global_variable_expression<var = #global_var1, 176 expr = <>> 177llvm.mlir.global @data() {dbg_exprs = [#var_expression, #var_expression1]} : i64 178 179// CHECK-DAG: llvm.mlir.global external @data() {{{.*}}dbg_exprs = [#[[EXP1:.*]], #[[EXP2:.*]]]} : i64 180// CHECK-DAG: #[[EXP1]] = #llvm.di_global_variable_expression<var = #[[GV1:.*]], expr = <>> 181// CHECK-DAG: #[[EXP2]] = #llvm.di_global_variable_expression<var = #[[GV2:.*]], expr = <>> 182// CHECK-DAG: #[[GV1]] = #llvm.di_global_variable<{{.*}}name = "a"{{.*}}> 183// CHECK-DAG: #[[GV2]] = #llvm.di_global_variable<{{.*}}name = "b"{{.*}}> 184 185 186// CHECK: llvm.func @addr(%[[ARG:.*]]: i64) 187llvm.func @addr(%arg: i64) { 188 // CHECK: %[[ALLOC:.*]] = llvm.alloca 189 %allocCount = llvm.mlir.constant(1 : i32) : i32 190 %alloc = llvm.alloca %allocCount x i64 : (i32) -> !llvm.ptr 191 192 // CHECK: llvm.intr.dbg.declare #[[VAR0]] = %[[ALLOC]] 193 llvm.intr.dbg.declare #var0 = %alloc : !llvm.ptr 194 llvm.return 195} 196 197// CHECK: llvm.func @value(%[[ARG1:.*]]: i32, %[[ARG2:.*]]: i32) 198llvm.func @value(%arg1: i32, %arg2: i32) { 199 // CHECK: llvm.intr.dbg.value #[[VAR1]] #llvm.di_expression<[DW_OP_LLVM_fragment(16, 8), DW_OP_plus_uconst(2), DW_OP_deref]> = %[[ARG1]] 200 llvm.intr.dbg.value #var1 #llvm.di_expression<[DW_OP_LLVM_fragment(16, 8), DW_OP_plus_uconst(2), DW_OP_deref]> = %arg1 : i32 201 // CHECK: llvm.intr.dbg.value #[[VAR2]] = %[[ARG2]] 202 llvm.intr.dbg.value #var2 = %arg2 : i32 203 // CHECK: llvm.intr.dbg.label #[[LABEL1]] 204 llvm.intr.dbg.label #label1 205 // CHECK: llvm.intr.dbg.label #[[LABEL2]] 206 llvm.intr.dbg.label #label2 207 llvm.return 208} 209