1 ; Test enumeration representation in DWARF debug info: 2 ; * test value representation for each possible underlying integer type 3 ; * test the integer type is as expected 4 ; * test the DW_AT_enum_class attribute is present (resp. absent) as expected. 5 6 ; RUN: llc -debugger-tune=gdb -dwarf-version=4 -filetype=obj -o %t.o < %s 7 ; RUN: llvm-dwarfdump -debug-info %t.o | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-DW4 8 ; RUN: llc -debugger-tune=gdb -dwarf-version=2 -filetype=obj -o %t.o < %s 9 ; RUN: llvm-dwarfdump -debug-info %t.o | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-DW2 10 11 @x0 = global i8 0, align 1, !dbg !0 12 @x1 = global i8 0, align 1, !dbg !46 13 @x2 = global i16 0, align 2, !dbg !48 14 @x3 = global i16 0, align 2, !dbg !50 15 @x4 = global i32 0, align 4, !dbg !52 16 @x5 = global i32 0, align 4, !dbg !54 17 @x6 = global i64 0, align 8, !dbg !56 18 @x7 = global i64 0, align 8, !dbg !58 19 @x8 = global i32 0, align 4, !dbg !60 20 21 !llvm.dbg.cu = !{!2} 22 !llvm.module.flags = !{!62} 23 24 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) 25 !1 = distinct !DIGlobalVariable(name: "x0", scope: !2, file: !3, line: 5, type: !5, isLocal: false, isDefinition: true) 26 !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 7.0.0 (/data/src/llvm/tools/clang 0c08d9830124a75675348b4eeb47256f3da6693d) (/data/src/llvm cf29510f52faa77b98510cd53276f564d1f4f41f)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !45) 27 !3 = !DIFile(filename: "/data/src/llvm-dev/tools/clang/test/CodeGen/debug-info-enum.cpp", directory: "/work/build/clang-dev") 28 !4 = !{!5, !10, !14, !19, !23, !28, !32, !37, !41} 29 30 ; Test enumeration with a fixed "signed char" underlying type. 31 !5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E0", file: !3, line: 2, baseType: !6, size: 8, flags: DIFlagFixedEnum, elements: !7, identifier: "_ZTS2E0") 32 !6 = !DIBasicType(name: "signed char", size: 8, encoding: DW_ATE_signed_char) 33 !7 = !{!8, !9} 34 !8 = !DIEnumerator(name: "A0", value: -128) 35 !9 = !DIEnumerator(name: "B0", value: 127) 36 ; CHECK: DW_TAG_enumeration_type 37 ; CHECK-DW2-NOT: DW_AT_type 38 ; CHECK-DW4: DW_AT_type{{.*}}"signed char" 39 ; CHECK-DW4: DW_AT_enum_class (true) 40 ; CHECK: DW_AT_name ("E0") 41 ; CHECK: DW_TAG_enumerator 42 ; CHECK: DW_AT_name ("A0") 43 ; CHECK-NEXT: DW_AT_const_value (-128) 44 ; CHECK: DW_TAG_enumerator 45 ; CHECK: DW_AT_name ("B0") 46 ; CHECK-NEXT: DW_AT_const_value (127) 47 48 ; Test enumeration with a fixed "unsigned char" underlying type. 49 !10 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E1", file: !3, line: 12, baseType: !11, size: 8, flags: DIFlagFixedEnum, elements: !12, identifier: "_ZTS2E1") 50 !11 = !DIBasicType(name: "unsigned char", size: 8, encoding: DW_ATE_unsigned_char) 51 !12 = !{!13} 52 !13 = !DIEnumerator(name: "A1", value: 255, isUnsigned: true) 53 ; CHECK: DW_TAG_enumeration_type 54 ; CHECK-DW2-NOT: DW_AT_type 55 ; CHECK-DW4: DW_AT_type{{.*}}"unsigned char" 56 ; CHECK-DW4: DW_AT_enum_class (true) 57 ; CHECK: DW_AT_name ("E1") 58 ; CHECK: DW_TAG_enumerator 59 ; CHECK: DW_AT_name ("A1") 60 ; CHECK-NEXT: DW_AT_const_value (255) 61 62 ; Test enumeration with a fixed "short" underlying type. 63 !14 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E2", file: !3, line: 18, baseType: !15, size: 16, flags: DIFlagFixedEnum, elements: !16, identifier: "_ZTS2E2") 64 !15 = !DIBasicType(name: "short", size: 16, encoding: DW_ATE_signed) 65 !16 = !{!17, !18} 66 !17 = !DIEnumerator(name: "A2", value: -32768) 67 !18 = !DIEnumerator(name: "B2", value: 32767) 68 ; CHECK: DW_TAG_enumeration_type 69 ; CHECK-DW2-NOT: DW_AT_type 70 ; CHECK-DW4: DW_AT_type{{.*}} "short" 71 ; CHECK-DW4: DW_AT_enum_class (true) 72 ; CHECK: DW_AT_name ("E2") 73 ; CHECK: DW_TAG_enumerator 74 ; CHECK: DW_AT_name ("A2") 75 ; CHECK-NEXT: DW_AT_const_value (-32768) 76 ; CHECK: DW_TAG_enumerator 77 ; CHECK: DW_AT_name ("B2") 78 ; CHECK-NEXT: DW_AT_const_value (32767) 79 80 ; Test enumeration with a fixed "unsigned short" underlying type. 81 !19 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E3", file: !3, line: 28, baseType: !20, size: 16, flags: DIFlagFixedEnum, elements: !21, identifier: "_ZTS2E3") 82 !20 = !DIBasicType(name: "unsigned short", size: 16, encoding: DW_ATE_unsigned) 83 !21 = !{!22} 84 !22 = !DIEnumerator(name: "A3", value: 65535, isUnsigned: true) 85 ; CHECK: DW_TAG_enumeration_type 86 ; CHECK-DW2-NOT: DW_AT_type 87 ; CHECK-DW4: DW_AT_type{{.*}}"unsigned short" 88 ; CHECK-DW4: DW_AT_enum_class (true) 89 ; CHECK: DW_AT_name ("E3") 90 ; CHECK: DW_TAG_enumerator 91 ; CHECK: DW_AT_name ("A3") 92 ; CHECK-NEXT: DW_AT_const_value (65535) 93 94 ; Test enumeration with a fixed "int" underlying type. 95 !23 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E4", file: !3, line: 34, baseType: !24, size: 32, flags: DIFlagFixedEnum, elements: !25, identifier: "_ZTS2E4") 96 !24 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 97 !25 = !{!26, !27} 98 !26 = !DIEnumerator(name: "A4", value: -2147483648) 99 !27 = !DIEnumerator(name: "B4", value: 2147483647) 100 ; CHECK: DW_TAG_enumeration_type 101 ; CHECK-DW2-NOT: DW_AT_type 102 ; CHECK-DW4: DW_AT_type{{.*}}"int" 103 ; CHECK-DW4: DW_AT_enum_class (true) 104 ; CHECK: DW_AT_name ("E4") 105 ; CHECK: DW_TAG_enumerator 106 ; CHECK: DW_AT_name ("A4") 107 ; CHECK-NEXT: DW_AT_const_value (-2147483648) 108 ; CHECK: DW_TAG_enumerator 109 ; CHECK: DW_AT_name ("B4") 110 ; CHECK-NEXT: DW_AT_const_value (2147483647) 111 112 ; Test enumeration with a fixed "unsigend int" underlying type. 113 !28 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E5", file: !3, line: 41, baseType: !29, size: 32, flags: DIFlagFixedEnum, elements: !30, identifier: "_ZTS2E5") 114 !29 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned) 115 !30 = !{!31} 116 !31 = !DIEnumerator(name: "A5", value: 4294967295, isUnsigned: true) 117 ; CHECK: DW_TAG_enumeration_type 118 ; CHECK-DW2-NOT: DW_AT_type 119 ; CHECK-DW4: DW_AT_type{{.*}}"unsigned int" 120 ; CHECK-DW4: DW_AT_enum_class (true) 121 ; CHECK: DW_AT_name ("E5") 122 ; CHECK: DW_TAG_enumerator 123 ; CHECK: DW_AT_name ("A5") 124 ; CHECK-NEXT: DW_AT_const_value (4294967295) 125 126 ; Test enumeration with a fixed "long long" underlying type. 127 !32 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E6", file: !3, line: 47, baseType: !33, size: 64, flags: DIFlagFixedEnum, elements: !34, identifier: "_ZTS2E6") 128 !33 = !DIBasicType(name: "long long int", size: 64, encoding: DW_ATE_signed) 129 !34 = !{!35, !36} 130 !35 = !DIEnumerator(name: "A6", value: -9223372036854775808) 131 !36 = !DIEnumerator(name: "B6", value: 9223372036854775807) 132 ; CHECK: DW_TAG_enumeration_type 133 ; CHECK-DW2-NOT: DW_AT_type 134 ; CHECK-DW4: DW_AT_type{{.*}}"long long int" 135 ; CHECK-DW4: DW_AT_enum_class (true) 136 ; CHECK: DW_AT_name ("E6") 137 ; CHECK: DW_TAG_enumerator 138 ; CHECK: DW_AT_name ("A6") 139 ; CHECK-NEXT: DW_AT_const_value (-9223372036854775808) 140 ; CHECK: DW_TAG_enumerator 141 ; CHECK: DW_AT_name ("B6") 142 ; CHECK-NEXT: DW_AT_const_value (9223372036854775807) 143 144 ; Test enumeration with a fixed "unsigned long long" underlying type. 145 !37 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E7", file: !3, line: 57, baseType: !38, size: 64, flags: DIFlagFixedEnum, elements: !39, identifier: "_ZTS2E7") 146 !38 = !DIBasicType(name: "long long unsigned int", size: 64, encoding: DW_ATE_unsigned) 147 !39 = !{!40} 148 !40 = !DIEnumerator(name: "A7", value: 18446744073709551615, isUnsigned: true) 149 ; CHECK: DW_TAG_enumeration_type 150 ; CHECK-DW2-NOT: DW_AT_type 151 ; CHECK-DW4: DW_AT_type{{.*}}"long long unsigned int" 152 ; CHECK-DW4: DW_AT_enum_class (true) 153 ; CHECK: DW_AT_name ("E7") 154 ; CHECK: DW_TAG_enumerator 155 ; CHECK: DW_AT_name ("A7") 156 ; CHECK-NEXT: DW_AT_const_value (18446744073709551615) 157 158 ; Test enumeration without a fixed underlying type. The underlying type should 159 ; still be present (for DWARF >= 3), but the DW_AT_enum_class attribute should 160 ; be absent. 161 !41 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E8", file: !3, line: 63, baseType: !24, size: 32, elements: !42, identifier: "_ZTS2E8") 162 !42 = !{!43, !44} 163 !43 = !DIEnumerator(name: "A8", value: -128) 164 !44 = !DIEnumerator(name: "B8", value: 127) 165 ; CHECK: DW_TAG_enumeration_type 166 ; CHECK-DW2-NOT: DW_AT_type 167 ; CHECK-DW4: DW_AT_type{{.*}}"int" 168 ; CHECK-NOT: DW_AT_enum_class 169 ; CHECK: DW_AT_name ("E8") 170 171 ; Test enumeration without a fixed underlying type, but with the DIFlagFixedEnum 172 ; set. The DW_AT_enum_class attribute should be absent. This behaviour is 173 ; intented to keep compatibilty with existing DWARF consumers, which may imply 174 ; the type is present whenever DW_AT_enum_class is set. 175 !63 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E9", file: !3, line: 63, size: 32, flags: DIFlagFixedEnum, elements: !64, identifier: "_ZTS2E9") 176 !64 = !{!65, !66} 177 !65 = !DIEnumerator(name: "A9", value: -128) 178 !66 = !DIEnumerator(name: "B9", value: 127) 179 ; CHECK: DW_TAG_enumeration_type 180 ; CHECK-NOT: DW_AT_type 181 ; CHECK-NOT: DW_AT_enum_class 182 ; CHECK: DW_AT_name ("E9") 183 184 !45 = !{!0, !46, !48, !50, !52, !54, !56, !58, !60, !67} 185 !46 = !DIGlobalVariableExpression(var: !47, expr: !DIExpression()) 186 !47 = distinct !DIGlobalVariable(name: "x1", scope: !2, file: !3, line: 12, type: !10, isLocal: false, isDefinition: true) 187 !48 = !DIGlobalVariableExpression(var: !49, expr: !DIExpression()) 188 !49 = distinct !DIGlobalVariable(name: "x2", scope: !2, file: !3, line: 21, type: !14, isLocal: false, isDefinition: true) 189 !50 = !DIGlobalVariableExpression(var: !51, expr: !DIExpression()) 190 !51 = distinct !DIGlobalVariable(name: "x3", scope: !2, file: !3, line: 28, type: !19, isLocal: false, isDefinition: true) 191 !52 = !DIGlobalVariableExpression(var: !53, expr: !DIExpression()) 192 !53 = distinct !DIGlobalVariable(name: "x4", scope: !2, file: !3, line: 34, type: !23, isLocal: false, isDefinition: true) 193 !54 = !DIGlobalVariableExpression(var: !55, expr: !DIExpression()) 194 !55 = distinct !DIGlobalVariable(name: "x5", scope: !2, file: !3, line: 41, type: !28, isLocal: false, isDefinition: true) 195 !56 = !DIGlobalVariableExpression(var: !57, expr: !DIExpression()) 196 !57 = distinct !DIGlobalVariable(name: "x6", scope: !2, file: !3, line: 50, type: !32, isLocal: false, isDefinition: true) 197 !58 = !DIGlobalVariableExpression(var: !59, expr: !DIExpression()) 198 !59 = distinct !DIGlobalVariable(name: "x7", scope: !2, file: !3, line: 57, type: !37, isLocal: false, isDefinition: true) 199 !60 = !DIGlobalVariableExpression(var: !61, expr: !DIExpression()) 200 !61 = distinct !DIGlobalVariable(name: "x8", scope: !2, file: !3, line: 63, type: !41, isLocal: false, isDefinition: true) 201 !67 = !DIGlobalVariableExpression(var: !68, expr: !DIExpression()) 202 !68 = distinct !DIGlobalVariable(name: "x9", scope: !2, file: !3, line: 63, type: !63, isLocal: false, isDefinition: true) 203 !62 = !{i32 2, !"Debug Info Version", i32 3} 204