|
| 1 | +; RUN: %llc_dwarf -filetype=obj -o %t.o < %s |
| 2 | +; RUN: llvm-dwarfdump -v -debug-info %t.o | FileCheck %s -check-prefix=CHECK |
| 3 | + |
| 4 | +; LLVM IR generated using: clang -emit-llvm -S -g -gdwarf-5 |
| 5 | +; |
| 6 | +; struct C |
| 7 | +; { |
| 8 | +; static int a; |
| 9 | +; const static bool b = true; |
| 10 | +; static constexpr int c = 15; |
| 11 | +; }; |
| 12 | +; |
| 13 | +; int C::a = 10; |
| 14 | +; |
| 15 | +; int main() |
| 16 | +; { |
| 17 | +; C instance_C; |
| 18 | +; return C::a + (int)C::b + C::c; |
| 19 | +; } |
| 20 | + |
| 21 | +source_filename = "llvm/test/DebugInfo/X86/dwarf5-debug-info-static-member.ll" |
| 22 | + |
| 23 | +%struct.C = type { i8 } |
| 24 | + |
| 25 | +@_ZN1C1aE = global i32 10, align 4, !dbg !0 |
| 26 | + |
| 27 | +; Function Attrs: mustprogress noinline norecurse nounwind optnone ssp uwtable(sync) |
| 28 | +define noundef i32 @main() #0 !dbg !26 { |
| 29 | +entry: |
| 30 | + %retval = alloca i32, align 4 |
| 31 | + %instance_C = alloca %struct.C, align 1 |
| 32 | + store i32 0, ptr %retval, align 4 |
| 33 | + call void @llvm.dbg.declare(metadata ptr %instance_C, metadata !30, metadata !DIExpression()), !dbg !31 |
| 34 | + %0 = load i32, ptr @_ZN1C1aE, align 4, !dbg !32 |
| 35 | + %add = add nsw i32 %0, 1, !dbg !33 |
| 36 | + %add1 = add nsw i32 %add, 15, !dbg !34 |
| 37 | + ret i32 %add1, !dbg !35 |
| 38 | +} |
| 39 | + |
| 40 | +; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) |
| 41 | +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 |
| 42 | + |
| 43 | +attributes #0 = { nounwind uwtable } |
| 44 | +attributes #1 = { nounwind readnone } |
| 45 | + |
| 46 | +!llvm.dbg.cu = !{!2} |
| 47 | +!llvm.module.flags = !{!19, !20, !21, !22, !23, !24} |
| 48 | +!llvm.ident = !{!25} |
| 49 | + |
| 50 | +!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) |
| 51 | +!1 = distinct !DIGlobalVariable(name: "a", linkageName: "_ZN1C1aE", scope: !2, file: !3, line: 8, type: !5, isLocal: false, isDefinition: true, declaration: !8) |
| 52 | +!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 18.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, retainedTypes: !4, globals: !14, splitDebugInlining: false, nameTableKind: Apple, sysroot: "/") |
| 53 | +!3 = !DIFile(filename: "main.cpp", directory: "/tmp", checksumkind: CSK_MD5, checksum: "b2547f7df8f54777c012dbfbd626f155") |
| 54 | +!4 = !{!5, !6} |
| 55 | +!5 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) |
| 56 | +!6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "C", file: !3, line: 1, size: 8, flags: DIFlagTypePassByValue, elements: !7, identifier: "_ZTS1C") |
| 57 | +!7 = !{!8, !9, !12} |
| 58 | +!8 = !DIDerivedType(tag: DW_TAG_variable, name: "a", scope: !6, file: !3, line: 3, baseType: !5, flags: DIFlagStaticMember) |
| 59 | +!9 = !DIDerivedType(tag: DW_TAG_variable, name: "b", scope: !6, file: !3, line: 4, baseType: !10, flags: DIFlagStaticMember) |
| 60 | +!10 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !11) |
| 61 | +!11 = !DIBasicType(name: "bool", size: 8, encoding: DW_ATE_boolean) |
| 62 | +!12 = !DIDerivedType(tag: DW_TAG_variable, name: "c", scope: !6, file: !3, line: 5, baseType: !13, flags: DIFlagStaticMember) |
| 63 | +!13 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !5) |
| 64 | +!14 = !{!0, !15, !17} |
| 65 | +!15 = !DIGlobalVariableExpression(var: !16, expr: !DIExpression(DW_OP_constu, 1, DW_OP_stack_value)) |
| 66 | +!16 = distinct !DIGlobalVariable(name: "b", scope: !2, file: !3, line: 4, type: !10, isLocal: true, isDefinition: true, declaration: !9) |
| 67 | +!17 = !DIGlobalVariableExpression(var: !18, expr: !DIExpression(DW_OP_constu, 15, DW_OP_stack_value)) |
| 68 | +!18 = distinct !DIGlobalVariable(name: "c", scope: !2, file: !3, line: 5, type: !13, isLocal: true, isDefinition: true, declaration: !12) |
| 69 | +!19 = !{i32 7, !"Dwarf Version", i32 5} |
| 70 | +!20 = !{i32 2, !"Debug Info Version", i32 3} |
| 71 | +!21 = !{i32 1, !"wchar_size", i32 4} |
| 72 | +!22 = !{i32 8, !"PIC Level", i32 2} |
| 73 | +!23 = !{i32 7, !"uwtable", i32 1} |
| 74 | +!24 = !{i32 7, !"frame-pointer", i32 1} |
| 75 | +!25 = !{!"clang version 18.0.0"} |
| 76 | +!26 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 10, type: !27, scopeLine: 11, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !29) |
| 77 | +!27 = !DISubroutineType(types: !28) |
| 78 | +!28 = !{!5} |
| 79 | +!29 = !{} |
| 80 | +!30 = !DILocalVariable(name: "instance_C", scope: !26, file: !3, line: 12, type: !6) |
| 81 | +!31 = !DILocation(line: 12, column: 5, scope: !26) |
| 82 | +!32 = !DILocation(line: 13, column: 10, scope: !26) |
| 83 | +!33 = !DILocation(line: 13, column: 15, scope: !26) |
| 84 | +!34 = !DILocation(line: 13, column: 27, scope: !26) |
| 85 | +!35 = !DILocation(line: 13, column: 3, scope: !26) |
| 86 | + |
| 87 | +; CHECK: .debug_info contents: |
| 88 | +; CHECK: DW_TAG_variable |
| 89 | +; CHECK-NEXT: DW_AT_specification {{.*}} "a" |
| 90 | +; CHECK: DW_TAG_structure_type |
| 91 | +; CHECK: DW_AT_name {{.*}} "C" |
| 92 | +; CHECK: DW_TAG_variable |
| 93 | +; CHECK-NEXT: DW_AT_name {{.*}} "a" |
| 94 | +; CHECK: DW_AT_external |
| 95 | +; CHECK: DW_AT_declaration |
| 96 | +; CHECK: DW_TAG_variable |
| 97 | +; CHECK-NEXT: DW_AT_name {{.*}} "b" |
| 98 | +; CHECK: DW_AT_external |
| 99 | +; CHECK: DW_AT_declaration |
| 100 | +; CHECK: DW_TAG_variable |
| 101 | +; CHECK-NEXT: DW_AT_name {{.*}} "c" |
| 102 | +; CHECK: DW_AT_external |
| 103 | +; CHECK: DW_AT_declaration |
| 104 | +; CHECK: NULL |
| 105 | +; CHECK: DW_TAG_variable |
| 106 | +; CHECK-NEXT: DW_AT_specification {{.*}} "b" |
| 107 | +; CHECK-NEXT: DW_AT_const_value |
| 108 | +; CHECK: DW_TAG_variable |
| 109 | +; CHECK-NEXT: DW_AT_specification {{.*}} "c" |
0 commit comments