210 lines · plain
1; Test enumeration representation in DWARF debug info:2; * test value representation for each possible underlying integer type3; * test the integer type is as expected4; * test the DW_AT_enum_class attribute is present (resp. absent) as expected.5; * test that DW_AT_type is present for v3 and greater, and v2 when strict DWARF6; is not enabled.7 8; RUN: llc -debugger-tune=gdb -dwarf-version=4 -filetype=obj -o %t.o < %s9; RUN: llvm-dwarfdump -debug-info %t.o | FileCheck %s --check-prefixes=CHECK,CHECK-DW4,CHECK-TYPE10; RUN: llc -debugger-tune=gdb -dwarf-version=3 -filetype=obj -o %t.o < %s11; RUN: llvm-dwarfdump -debug-info %t.o | FileCheck %s --check-prefixes=CHECK,CHECK-TYPE12; RUN: llc -debugger-tune=gdb -dwarf-version=2 -filetype=obj -o %t.o < %s13; RUN: llvm-dwarfdump -debug-info %t.o | FileCheck %s --check-prefixes=CHECK,CHECK-TYPE14; RUN: llc -debugger-tune=gdb -dwarf-version=2 -strict-dwarf=true -filetype=obj -o %t.o < %s15; RUN: llvm-dwarfdump -debug-info %t.o | FileCheck %s --check-prefixes=CHECK,CHECK-DW2-STRICT16 17@x0 = global i8 0, align 1, !dbg !018@x1 = global i8 0, align 1, !dbg !4619@x2 = global i16 0, align 2, !dbg !4820@x3 = global i16 0, align 2, !dbg !5021@x4 = global i32 0, align 4, !dbg !5222@x5 = global i32 0, align 4, !dbg !5423@x6 = global i64 0, align 8, !dbg !5624@x7 = global i64 0, align 8, !dbg !5825@x8 = global i32 0, align 4, !dbg !6026 27!llvm.dbg.cu = !{!2}28!llvm.module.flags = !{!62}29 30!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())31!1 = distinct !DIGlobalVariable(name: "x0", scope: !2, file: !3, line: 5, type: !5, isLocal: false, isDefinition: true)32!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)33!3 = !DIFile(filename: "/data/src/llvm-dev/tools/clang/test/CodeGen/debug-info-enum.cpp", directory: "/work/build/clang-dev")34!4 = !{!5, !10, !14, !19, !23, !28, !32, !37, !41}35 36; Test enumeration with a fixed "signed char" underlying type.37!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E0", file: !3, line: 2, baseType: !6, size: 8, flags: DIFlagEnumClass, elements: !7, identifier: "_ZTS2E0")38!6 = !DIBasicType(name: "signed char", size: 8, encoding: DW_ATE_signed_char)39!7 = !{!8, !9}40!8 = !DIEnumerator(name: "A0", value: -128)41!9 = !DIEnumerator(name: "B0", value: 127)42; CHECK: DW_TAG_enumeration_type43; CHECK-DW2-STRICT-NOT: DW_AT_type44; CHECK-TYPE: DW_AT_type{{.*}}"signed char"45; CHECK-DW4: DW_AT_enum_class (true)46; CHECK: DW_AT_name ("E0")47; CHECK: DW_TAG_enumerator48; CHECK: DW_AT_name ("A0")49; CHECK-NEXT: DW_AT_const_value (-128)50; CHECK: DW_TAG_enumerator51; CHECK: DW_AT_name ("B0")52; CHECK-NEXT: DW_AT_const_value (127)53 54; Test enumeration with a fixed "unsigned char" underlying type.55!10 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E1", file: !3, line: 12, baseType: !11, size: 8, flags: DIFlagEnumClass, elements: !12, identifier: "_ZTS2E1")56!11 = !DIBasicType(name: "unsigned char", size: 8, encoding: DW_ATE_unsigned_char)57!12 = !{!13}58!13 = !DIEnumerator(name: "A1", value: 255, isUnsigned: true)59; CHECK: DW_TAG_enumeration_type60; CHECK-DW2-STRICT-NOT: DW_AT_type61; CHECK-TYPE: DW_AT_type{{.*}}"unsigned char"62; CHECK-DW4: DW_AT_enum_class (true)63; CHECK: DW_AT_name ("E1")64; CHECK: DW_TAG_enumerator65; CHECK: DW_AT_name ("A1")66; CHECK-NEXT: DW_AT_const_value (255)67 68; Test enumeration with a fixed "short" underlying type.69!14 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E2", file: !3, line: 18, baseType: !15, size: 16, flags: DIFlagEnumClass, elements: !16, identifier: "_ZTS2E2")70!15 = !DIBasicType(name: "short", size: 16, encoding: DW_ATE_signed)71!16 = !{!17, !18}72!17 = !DIEnumerator(name: "A2", value: -32768)73!18 = !DIEnumerator(name: "B2", value: 32767)74; CHECK: DW_TAG_enumeration_type75; CHECK-DW2-STRICT-NOT: DW_AT_type76; CHECK-TYPE: DW_AT_type{{.*}} "short"77; CHECK-DW4: DW_AT_enum_class (true)78; CHECK: DW_AT_name ("E2")79; CHECK: DW_TAG_enumerator80; CHECK: DW_AT_name ("A2")81; CHECK-NEXT: DW_AT_const_value (-32768)82; CHECK: DW_TAG_enumerator83; CHECK: DW_AT_name ("B2")84; CHECK-NEXT: DW_AT_const_value (32767)85 86; Test enumeration with a fixed "unsigned short" underlying type.87!19 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E3", file: !3, line: 28, baseType: !20, size: 16, flags: DIFlagEnumClass, elements: !21, identifier: "_ZTS2E3")88!20 = !DIBasicType(name: "unsigned short", size: 16, encoding: DW_ATE_unsigned)89!21 = !{!22}90!22 = !DIEnumerator(name: "A3", value: 65535, isUnsigned: true)91; CHECK: DW_TAG_enumeration_type92; CHECK-DW2-STRICT-NOT: DW_AT_type93; CHECK-TYPE DW_AT_type{{.*}}"unsigned short"94; CHECK-DW4: DW_AT_enum_class (true)95; CHECK: DW_AT_name ("E3")96; CHECK: DW_TAG_enumerator97; CHECK: DW_AT_name ("A3")98; CHECK-NEXT: DW_AT_const_value (65535)99 100; Test enumeration with a fixed "int" underlying type.101!23 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E4", file: !3, line: 34, baseType: !24, size: 32, flags: DIFlagEnumClass, elements: !25, identifier: "_ZTS2E4")102!24 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)103!25 = !{!26, !27}104!26 = !DIEnumerator(name: "A4", value: -2147483648)105!27 = !DIEnumerator(name: "B4", value: 2147483647)106; CHECK: DW_TAG_enumeration_type107; CHECK-DW2-STRICT-NOT: DW_AT_type108; CHECK-TYPE: DW_AT_type{{.*}}"int"109; CHECK-DW4: DW_AT_enum_class (true)110; CHECK: DW_AT_name ("E4")111; CHECK: DW_TAG_enumerator112; CHECK: DW_AT_name ("A4")113; CHECK-NEXT: DW_AT_const_value (-2147483648)114; CHECK: DW_TAG_enumerator115; CHECK: DW_AT_name ("B4")116; CHECK-NEXT: DW_AT_const_value (2147483647)117 118; Test enumeration with a fixed "unsigend int" underlying type.119!28 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E5", file: !3, line: 41, baseType: !29, size: 32, flags: DIFlagEnumClass, elements: !30, identifier: "_ZTS2E5")120!29 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)121!30 = !{!31}122!31 = !DIEnumerator(name: "A5", value: 4294967295, isUnsigned: true)123; CHECK: DW_TAG_enumeration_type124; CHECK-DW2-STRICT-NOT: DW_AT_type125; CHECK-TYPE: DW_AT_type{{.*}}"unsigned int"126; CHECK-DW4: DW_AT_enum_class (true)127; CHECK: DW_AT_name ("E5")128; CHECK: DW_TAG_enumerator129; CHECK: DW_AT_name ("A5")130; CHECK-NEXT: DW_AT_const_value (4294967295)131 132; Test enumeration with a fixed "long long" underlying type.133!32 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E6", file: !3, line: 47, baseType: !33, size: 64, flags: DIFlagEnumClass, elements: !34, identifier: "_ZTS2E6")134!33 = !DIBasicType(name: "long long int", size: 64, encoding: DW_ATE_signed)135!34 = !{!35, !36}136!35 = !DIEnumerator(name: "A6", value: -9223372036854775808)137!36 = !DIEnumerator(name: "B6", value: 9223372036854775807)138; CHECK: DW_TAG_enumeration_type139; CHECK-DW2-STRICT-NOT: DW_AT_type140; CHECK-TYPE: DW_AT_type{{.*}}"long long int"141; CHECK-DW4: DW_AT_enum_class (true)142; CHECK: DW_AT_name ("E6")143; CHECK: DW_TAG_enumerator144; CHECK: DW_AT_name ("A6")145; CHECK-NEXT: DW_AT_const_value (-9223372036854775808)146; CHECK: DW_TAG_enumerator147; CHECK: DW_AT_name ("B6")148; CHECK-NEXT: DW_AT_const_value (9223372036854775807)149 150; Test enumeration with a fixed "unsigned long long" underlying type.151!37 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E7", file: !3, line: 57, baseType: !38, size: 64, flags: DIFlagEnumClass, elements: !39, identifier: "_ZTS2E7")152!38 = !DIBasicType(name: "long long unsigned int", size: 64, encoding: DW_ATE_unsigned)153!39 = !{!40}154!40 = !DIEnumerator(name: "A7", value: 18446744073709551615, isUnsigned: true)155; CHECK: DW_TAG_enumeration_type156; CHECK-DW2-STRICT-NOT: DW_AT_type157; CHECK-TYPE: DW_AT_type{{.*}}"long long unsigned int"158; CHECK-DW4: DW_AT_enum_class (true)159; CHECK: DW_AT_name ("E7")160; CHECK: DW_TAG_enumerator161; CHECK: DW_AT_name ("A7")162; CHECK-NEXT: DW_AT_const_value (18446744073709551615)163 164; Test enumeration without a fixed underlying type. The underlying type should165; still be present (for DWARF >= 3), but the DW_AT_enum_class attribute should166; be absent.167!41 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E8", file: !3, line: 63, baseType: !24, size: 32, elements: !42, identifier: "_ZTS2E8")168!42 = !{!43, !44}169!43 = !DIEnumerator(name: "A8", value: -128)170!44 = !DIEnumerator(name: "B8", value: 127)171; CHECK: DW_TAG_enumeration_type172; CHECK-DW2-STRICT-NOT: DW_AT_type173; CHECK-TYPE: DW_AT_type{{.*}}"int"174; CHECK-NOT: DW_AT_enum_class175; CHECK: DW_AT_name ("E8")176 177; Test enumeration without a fixed underlying type, but with the DIFlagEnumClass178; set. The DW_AT_enum_class attribute should be absent. This behaviour is179; intented to keep compatibilty with existing DWARF consumers, which may imply180; the type is present whenever DW_AT_enum_class is set.181!63 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E9", file: !3, line: 63, size: 32, flags: DIFlagEnumClass, elements: !64, identifier: "_ZTS2E9")182!64 = !{!65, !66}183!65 = !DIEnumerator(name: "A9", value: -128)184!66 = !DIEnumerator(name: "B9", value: 127)185; CHECK: DW_TAG_enumeration_type186; CHECK-NOT: DW_AT_type187; CHECK-NOT: DW_AT_enum_class188; CHECK: DW_AT_name ("E9")189 190!45 = !{!0, !46, !48, !50, !52, !54, !56, !58, !60, !67}191!46 = !DIGlobalVariableExpression(var: !47, expr: !DIExpression())192!47 = distinct !DIGlobalVariable(name: "x1", scope: !2, file: !3, line: 12, type: !10, isLocal: false, isDefinition: true)193!48 = !DIGlobalVariableExpression(var: !49, expr: !DIExpression())194!49 = distinct !DIGlobalVariable(name: "x2", scope: !2, file: !3, line: 21, type: !14, isLocal: false, isDefinition: true)195!50 = !DIGlobalVariableExpression(var: !51, expr: !DIExpression())196!51 = distinct !DIGlobalVariable(name: "x3", scope: !2, file: !3, line: 28, type: !19, isLocal: false, isDefinition: true)197!52 = !DIGlobalVariableExpression(var: !53, expr: !DIExpression())198!53 = distinct !DIGlobalVariable(name: "x4", scope: !2, file: !3, line: 34, type: !23, isLocal: false, isDefinition: true)199!54 = !DIGlobalVariableExpression(var: !55, expr: !DIExpression())200!55 = distinct !DIGlobalVariable(name: "x5", scope: !2, file: !3, line: 41, type: !28, isLocal: false, isDefinition: true)201!56 = !DIGlobalVariableExpression(var: !57, expr: !DIExpression())202!57 = distinct !DIGlobalVariable(name: "x6", scope: !2, file: !3, line: 50, type: !32, isLocal: false, isDefinition: true)203!58 = !DIGlobalVariableExpression(var: !59, expr: !DIExpression())204!59 = distinct !DIGlobalVariable(name: "x7", scope: !2, file: !3, line: 57, type: !37, isLocal: false, isDefinition: true)205!60 = !DIGlobalVariableExpression(var: !61, expr: !DIExpression())206!61 = distinct !DIGlobalVariable(name: "x8", scope: !2, file: !3, line: 63, type: !41, isLocal: false, isDefinition: true)207!67 = !DIGlobalVariableExpression(var: !68, expr: !DIExpression())208!68 = distinct !DIGlobalVariable(name: "x9", scope: !2, file: !3, line: 63, type: !63, isLocal: false, isDefinition: true)209!62 = !{i32 2, !"Debug Info Version", i32 3}210