1 ; RUN: llc %s -mtriple=x86_64-unknown-unknown -o - | FileCheck %s
3 ; Generated with "clang -g -c -emit-llvm -S -O3"
5 ; This will test several features of merging debug locations. Importantly,
6 ; locations with the same source line but different scopes should be merged to
7 ; a line zero location at the nearest common scope and inlining. The location
8 ; of the single call to "common" (the two calls are collapsed together by
9 ; BranchFolding) should be attributed to line zero inside the wrapper2 inlined
13 ; inline void wrapper() { common(); }
16 ; inline void wrapper2() {
23 ; void f1() { wrapper2(); }
25 ; Ensure there is only one inlined_subroutine (for wrapper2, none for wrapper)
26 ; & that its address range includes the call to 'common'.
28 ; CHECK: jmp _Z6commonv
29 ; CHECK-NEXT: [[LABEL:.*]]:
31 ; CHECK: .section .debug_info
32 ; CHECK: DW_TAG_subprogram
33 ; CHECK: DW_TAG_subprogram
34 ; CHECK-NOT: {{DW_TAG\|End Of Children}}
35 ; CHECK: DW_TAG_inlined_subroutine
36 ; CHECK-NOT: {{DW_TAG\|End Of Children}}
37 ; CHECK: [[LABEL]]-{{.*}} DW_AT_high_pc
42 @b = external dso_local local_unnamed_addr global i8, align 1
44 ; Function Attrs: uwtable
45 define dso_local void @_Z2f1v() local_unnamed_addr !dbg !7 {
47 %0 = load i8, i8* @b, align 1, !dbg !10, !tbaa !14, !range !18
48 %tobool.i = icmp eq i8 %0, 0, !dbg !10
49 br i1 %tobool.i, label %if.else.i, label %if.then.i, !dbg !19
51 if.then.i: ; preds = %entry
52 tail call void @_Z4sinkv(), !dbg !20
53 tail call void @_Z6commonv(), !dbg !22
54 br label %_Z8wrapper2v.exit, !dbg !25
56 if.else.i: ; preds = %entry
57 tail call void @_Z6commonv(), !dbg !26
58 br label %_Z8wrapper2v.exit
60 _Z8wrapper2v.exit: ; preds = %if.then.i, %if.else.i
64 declare dso_local void @_Z4sinkv() local_unnamed_addr
66 declare dso_local void @_Z6commonv() local_unnamed_addr
69 !llvm.module.flags = !{!3, !4, !5}
72 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 8.0.0 (trunk 340559) (llvm/trunk 340572)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
73 !1 = !DIFile(filename: "merge_loc.cpp", directory: "/usr/local/google/home/blaikie/dev/scratch")
75 !3 = !{i32 2, !"Dwarf Version", i32 4}
76 !4 = !{i32 2, !"Debug Info Version", i32 3}
77 !5 = !{i32 1, !"wchar_size", i32 4}
78 !6 = !{!"clang version 8.0.0 (trunk 340559) (llvm/trunk 340572)"}
79 !7 = distinct !DISubprogram(name: "f1", linkageName: "_Z2f1v", scope: !1, file: !1, line: 12, type: !8, isLocal: false, isDefinition: true, scopeLine: 12, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !2)
80 !8 = !DISubroutineType(types: !9)
82 !10 = !DILocation(line: 6, column: 7, scope: !11, inlinedAt: !13)
83 !11 = distinct !DILexicalBlock(scope: !12, file: !1, line: 6, column: 7)
84 !12 = distinct !DISubprogram(name: "wrapper2", linkageName: "_Z8wrapper2v", scope: !1, file: !1, line: 5, type: !8, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !2)
85 !13 = distinct !DILocation(line: 13, column: 3, scope: !7)
86 !14 = !{!15, !15, i64 0}
87 !15 = !{!"bool", !16, i64 0}
88 !16 = !{!"omnipotent char", !17, i64 0}
89 !17 = !{!"Simple C++ TBAA"}
91 !19 = !DILocation(line: 6, column: 7, scope: !12, inlinedAt: !13)
92 !20 = !DILocation(line: 7, column: 5, scope: !21, inlinedAt: !13)
93 !21 = distinct !DILexicalBlock(scope: !11, file: !1, line: 6, column: 10)
94 !22 = !DILocation(line: 2, column: 25, scope: !23, inlinedAt: !24)
95 !23 = distinct !DISubprogram(name: "wrapper", linkageName: "_Z7wrapperv", scope: !1, file: !1, line: 2, type: !8, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !2)
96 !24 = distinct !DILocation(line: 8, column: 5, scope: !21, inlinedAt: !13)
97 !25 = !DILocation(line: 9, column: 3, scope: !21, inlinedAt: !13)
98 !26 = !DILocation(line: 2, column: 25, scope: !23, inlinedAt: !27)
99 !27 = distinct !DILocation(line: 10, column: 5, scope: !11, inlinedAt: !13)
100 !28 = !DILocation(line: 14, column: 1, scope: !7)