94 lines · plain
1; RUN: %llc_dwarf -O0 -filetype=obj < %s | llvm-dwarfdump -debug-info - | FileCheck --implicit-check-not "{{DW_TAG|NULL}}" %s2 3; inline __attribute__((always_inline))4; int removed() { static int A; return A++; }5;6; __attribute__((always_inline))7; int not_removed() { static int B; return B++; }8;9; int foo() { return removed() + not_removed(); }10 11; Ensure that global variables belong to the correct subprograms even if those12; subprograms are inlined.13 14; CHECK: DW_TAG_compile_unit15; CHECK: DW_TAG_subprogram16; CHECK: DW_AT_abstract_origin {{.*}} "_Z11not_removedv"17; TODO: This variable should be emitted in abstract subprogram DIE.18; CHECK: DW_TAG_variable19; CHECK: DW_AT_name ("B")20; CHECK: NULL21; CHECK: DW_TAG_base_type22; CHECK: DW_TAG_subprogram23; CHECK: DW_AT_name ("removed")24; CHECK: DW_TAG_variable25; CHECK: DW_AT_name ("A")26; CHECK: NULL27; CHECK: DW_TAG_subprogram28; CHECK: DW_AT_name ("not_removed")29; CHECK: DW_TAG_subprogram30; CHECK: DW_AT_name ("foo")31; CHECK: DW_TAG_inlined_subroutine32; CHECK: DW_TAG_inlined_subroutine33; CHECK: NULL34; CHECK: NULL35 36@_ZZ11not_removedvE1A = internal global i32 0, align 4, !dbg !037@_ZZ7removedvE1A = linkonce_odr dso_local global i32 0, align 4, !dbg !1038 39define dso_local i32 @_Z11not_removedv() !dbg !2 {40 %1 = load i32, i32* @_ZZ11not_removedvE1A, align 4, !dbg !2441 %2 = add nsw i32 %1, 1, !dbg !2442 store i32 %2, i32* @_ZZ11not_removedvE1A, align 4, !dbg !2443 ret i32 %1, !dbg !2544}45 46define dso_local i32 @_Z3foov() !dbg !26 {47 %1 = load i32, i32* @_ZZ7removedvE1A, align 4, !dbg !2748 %2 = add nsw i32 %1, 1, !dbg !2749 store i32 %2, i32* @_ZZ7removedvE1A, align 4, !dbg !2750 %3 = load i32, i32* @_ZZ11not_removedvE1A, align 4, !dbg !2951 %4 = add nsw i32 %3, 1, !dbg !2952 store i32 %4, i32* @_ZZ11not_removedvE1A, align 4, !dbg !2953 %5 = add nsw i32 %1, %3, !dbg !3154 ret i32 %5, !dbg !3255}56 57!llvm.dbg.cu = !{!7}58!llvm.module.flags = !{!14, !15, !16, !17, !18, !19, !20, !21, !22}59!llvm.ident = !{!23}60 61!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())62!1 = distinct !DIGlobalVariable(name: "B", scope: !2, file: !3, line: 5, type: !6, isLocal: true, isDefinition: true)63!2 = distinct !DISubprogram(name: "not_removed", linkageName: "_Z11not_removedv", scope: !3, file: !3, line: 5, type: !4, scopeLine: 5, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !7, retainedNodes: !13)64!3 = !DIFile(filename: "example.cpp", directory: "")65!4 = !DISubroutineType(types: !5)66!5 = !{!6}67!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)68!7 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !8, producer: "clang version 14.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !9, splitDebugInlining: false, nameTableKind: None)69!8 = !DIFile(filename: "example.cpp", directory: "")70!9 = !{!0, !10}71!10 = !DIGlobalVariableExpression(var: !11, expr: !DIExpression())72!11 = distinct !DIGlobalVariable(name: "A", scope: !12, file: !3, line: 2, type: !6, isLocal: false, isDefinition: true)73!12 = distinct !DISubprogram(name: "removed", linkageName: "_Z7removedv", scope: !3, file: !3, line: 2, type: !4, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !7, retainedNodes: !13)74!13 = !{}75!14 = !{i32 7, !"Dwarf Version", i32 4}76!15 = !{i32 2, !"Debug Info Version", i32 3}77!16 = !{i32 1, !"wchar_size", i32 4}78!17 = !{i32 1, !"branch-target-enforcement", i32 0}79!18 = !{i32 1, !"sign-return-address", i32 0}80!19 = !{i32 1, !"sign-return-address-all", i32 0}81!20 = !{i32 1, !"sign-return-address-with-bkey", i32 0}82!21 = !{i32 7, !"uwtable", i32 1}83!22 = !{i32 7, !"frame-pointer", i32 1}84!23 = !{!"clang version 14.0.0"}85!24 = !DILocation(line: 5, column: 43, scope: !2)86!25 = !DILocation(line: 5, column: 35, scope: !2)87!26 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !3, file: !3, line: 7, type: !4, scopeLine: 7, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !7, retainedNodes: !13)88!27 = !DILocation(line: 2, column: 39, scope: !12, inlinedAt: !28)89!28 = distinct !DILocation(line: 7, column: 20, scope: !26)90!29 = !DILocation(line: 5, column: 43, scope: !2, inlinedAt: !30)91!30 = distinct !DILocation(line: 7, column: 32, scope: !26)92!31 = !DILocation(line: 7, column: 30, scope: !26)93!32 = !DILocation(line: 7, column: 13, scope: !26)94