1; RUN: llc %s -mtriple=x86_64-unknown-unknown -o - | FileCheck %s 2 3; Generated with "clang -g -c -emit-llvm -S -O3" 4 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 2 inside the wrapper inlined 10; scope within wrapper2 at line 0 inlined within f1 at line 13. 11 12; void common(); 13; inline void wrapper() { common(); } 14; extern bool b; 15; void sink(); 16; inline void wrapper2() { 17; if (b) { 18; sink(); 19; wrapper(); 20; } else 21; wrapper(); 22; } 23; void f1() { wrapper2(); } 24 25; Ensure there are two inlined_subroutine (for wrapper and wrapper2). 26 27; CHECK: .loc 1 2 25 epilogue_begin 28; CHECK-NEXT: popq %rax 29; CHECK-NEXT: .Ltmp{{.*}}: 30; CHECK-NEXT: .cfi_def_cfa_offset 8 31; CHECK-NEXT: .loc 1 2 25 is_stmt 0 32; CHECK-NEXT: jmp _Z6commonv 33; CHECK-NEXT: [[LABEL:.*]]: 34 35; CHECK: .section .debug_info 36; CHECK: DW_TAG_subprogram 37; CHECK: DW_TAG_subprogram 38; CHECK-NOT: {{DW_TAG\|End Of Children}} 39; CHECK: DW_TAG_inlined_subroutine 40; CHECK-NOT: {{DW_TAG\|End Of Children}} 41; CHECK: [[LABEL]]-{{.*}} DW_AT_high_pc 42; CHECK: .byte 13 # DW_AT_call_line 43; CHECK: DW_TAG_inlined_subroutine 44; CHECK: .byte 0 # DW_AT_call_line 45; CHECK-NOT: DW_TAG 46 47 48 49@b = external dso_local local_unnamed_addr global i8, align 1 50 51; Function Attrs: uwtable 52define dso_local void @_Z2f1v() local_unnamed_addr !dbg !7 { 53entry: 54 %0 = load i8, ptr @b, align 1, !dbg !10, !tbaa !14, !range !18 55 %tobool.i = icmp eq i8 %0, 0, !dbg !10 56 br i1 %tobool.i, label %if.else.i, label %if.then.i, !dbg !19 57 58if.then.i: ; preds = %entry 59 tail call void @_Z4sinkv(), !dbg !20 60 tail call void @_Z6commonv(), !dbg !22 61 br label %_Z8wrapper2v.exit, !dbg !25 62 63if.else.i: ; preds = %entry 64 tail call void @_Z6commonv(), !dbg !26 65 br label %_Z8wrapper2v.exit 66 67_Z8wrapper2v.exit: ; preds = %if.then.i, %if.else.i 68 ret void, !dbg !28 69} 70 71declare dso_local void @_Z4sinkv() local_unnamed_addr 72 73declare dso_local void @_Z6commonv() local_unnamed_addr 74 75!llvm.dbg.cu = !{!0} 76!llvm.module.flags = !{!3, !4, !5} 77!llvm.ident = !{!6} 78 79!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) 80!1 = !DIFile(filename: "merge_loc.cpp", directory: "/usr/local/google/home/blaikie/dev/scratch") 81!2 = !{} 82!3 = !{i32 2, !"Dwarf Version", i32 4} 83!4 = !{i32 2, !"Debug Info Version", i32 3} 84!5 = !{i32 1, !"wchar_size", i32 4} 85!6 = !{!"clang version 8.0.0 (trunk 340559) (llvm/trunk 340572)"} 86!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) 87!8 = !DISubroutineType(types: !9) 88!9 = !{null} 89!10 = !DILocation(line: 6, column: 7, scope: !11, inlinedAt: !13) 90!11 = distinct !DILexicalBlock(scope: !12, file: !1, line: 6, column: 7) 91!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) 92!13 = distinct !DILocation(line: 13, column: 3, scope: !7) 93!14 = !{!15, !15, i64 0} 94!15 = !{!"bool", !16, i64 0} 95!16 = !{!"omnipotent char", !17, i64 0} 96!17 = !{!"Simple C++ TBAA"} 97!18 = !{i8 0, i8 2} 98!19 = !DILocation(line: 6, column: 7, scope: !12, inlinedAt: !13) 99!20 = !DILocation(line: 7, column: 5, scope: !21, inlinedAt: !13) 100!21 = distinct !DILexicalBlock(scope: !11, file: !1, line: 6, column: 10) 101!22 = !DILocation(line: 2, column: 25, scope: !23, inlinedAt: !24) 102!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) 103!24 = distinct !DILocation(line: 8, column: 5, scope: !21, inlinedAt: !13) 104!25 = !DILocation(line: 9, column: 3, scope: !21, inlinedAt: !13) 105!26 = !DILocation(line: 2, column: 25, scope: !23, inlinedAt: !27) 106!27 = distinct !DILocation(line: 10, column: 5, scope: !11, inlinedAt: !13) 107!28 = !DILocation(line: 14, column: 1, scope: !7) 108