David Blaikie | bb27911 | 2018-11-13 20:08:10 +0000 | [diff] [blame] | 1 | ; RUN: llc -filetype=asm -mtriple=x86_64-pc-linux-gnu %s -o - | FileCheck %s |
David Blaikie | 71812e3 | 2018-07-18 20:37:01 +0000 | [diff] [blame] | 2 | ; RUN: llc -filetype=asm -mtriple=x86_64-pc-linux-gnu %s -o - -dwarf-version 5 | FileCheck --check-prefix=DWARF5 %s |
David Blaikie | 89c81a0 | 2017-07-30 22:10:00 +0000 | [diff] [blame] | 3 | |
| 4 | ; Group ranges in a range list that apply to the same section and use a base |
| 5 | ; address selection entry to reduce the number of relocations to one reloc per |
David Blaikie | d661405 | 2018-07-18 18:04:42 +0000 | [diff] [blame] | 6 | ; section per range list. DWARF5 debug_rnglist (with *x variants) are more |
| 7 | ; efficient than this in terms of relocations, but it's still better than one |
| 8 | ; reloc per entry in a range list. |
David Blaikie | 89c81a0 | 2017-07-30 22:10:00 +0000 | [diff] [blame] | 9 | |
| 10 | ; This is an object/executable size tradeoff - shrinking objects, but growing |
| 11 | ; the linked executable. In one large binary tested, total object size (not just |
| 12 | ; debug info) shrank by 16%, entirely relocation entries. Linked executable |
| 13 | ; grew by 4%. This was with compressed debug info in the objects, uncompressed |
| 14 | ; in the linked executable. Without compression in the objects, the win would be |
| 15 | ; smaller (the growth of debug_ranges itself would be more significant). |
| 16 | |
David Blaikie | bb27911 | 2018-11-13 20:08:10 +0000 | [diff] [blame] | 17 | ; This is a merged module containing two CUs, one that uses range base address |
| 18 | ; specifiers and exercises different cases there, and another that does not |
David Blaikie | 14cfa0d | 2018-10-20 09:16:49 +0000 | [diff] [blame] | 19 | |
David Blaikie | bb27911 | 2018-11-13 20:08:10 +0000 | [diff] [blame] | 20 | ; ranges.cpp |
| 21 | ; Single range entry |
| 22 | ; __attribute__((section("a"))) void f1() {} |
| 23 | ; Single address with two ranges due to the whole caused by f3 |
| 24 | ; __attribute__((section("b"))) void f2() {} |
| 25 | ; __attribute__((section("b"))) __attribute__((nodebug)) void f3() {} |
| 26 | ; __attribute__((section("b"))) void f4() {} |
| 27 | ; Reset the base address & emit a couple more single range entries |
| 28 | ; __attribute__((section("c"))) void f5() {} |
| 29 | ; __attribute__((section("d"))) void f6() {} |
| 30 | ; ranges_no_base.cpp: |
| 31 | ; Include enough complexity to cause ranges to be emitted, so it can be checked |
| 32 | ; that those ranges don't use base address specifiers |
| 33 | ; __attribute__((section("e"))) void f7() {} |
| 34 | ; __attribute__((section("f"))) void f8() {} |
| 35 | |
| 36 | ; CHECK: {{^.Ldebug_ranges0}} |
| 37 | ; CHECK-NEXT: .quad -1 |
| 38 | ; CHECK-NEXT: .quad .Lfunc_begin0 |
| 39 | ; CHECK-NEXT: .quad .Lfunc_begin0-.Lfunc_begin0 |
| 40 | ; CHECK-NEXT: .quad .Lfunc_end0-.Lfunc_begin0 |
| 41 | ; CHECK-NEXT: .quad -1 |
| 42 | ; CHECK-NEXT: .quad .Lfunc_begin1 |
| 43 | ; CHECK-NEXT: .quad .Lfunc_begin1-.Lfunc_begin1 |
| 44 | ; CHECK-NEXT: .quad .Lfunc_end1-.Lfunc_begin1 |
| 45 | ; CHECK-NEXT: .quad .Lfunc_begin3-.Lfunc_begin1 |
| 46 | ; CHECK-NEXT: .quad .Lfunc_end3-.Lfunc_begin1 |
| 47 | ; CHECK-NEXT: .quad -1 |
| 48 | ; CHECK-NEXT: .quad .Lfunc_begin4 |
| 49 | ; CHECK-NEXT: .quad .Lfunc_begin4-.Lfunc_begin4 |
| 50 | ; CHECK-NEXT: .quad .Lfunc_end4-.Lfunc_begin4 |
| 51 | ; CHECK-NEXT: .quad -1 |
| 52 | ; CHECK-NEXT: .quad .Lfunc_begin5 |
| 53 | ; CHECK-NEXT: .quad .Lfunc_begin5-.Lfunc_begin5 |
| 54 | ; CHECK-NEXT: .quad .Lfunc_end5-.Lfunc_begin5 |
| 55 | ; CHECK-NEXT: .quad 0 |
| 56 | ; CHECK-NEXT: .quad 0 |
| 57 | ; CHECK-NEXT: {{^.Ldebug_ranges1}} |
| 58 | ; CHECK-NEXT: .quad .Lfunc_begin6 |
| 59 | ; CHECK-NEXT: .quad .Lfunc_end6 |
| 60 | ; CHECK-NEXT: .quad .Lfunc_begin7 |
| 61 | ; CHECK-NEXT: .quad .Lfunc_end7 |
David Blaikie | 89c81a0 | 2017-07-30 22:10:00 +0000 | [diff] [blame] | 62 | |
David Blaikie | d661405 | 2018-07-18 18:04:42 +0000 | [diff] [blame] | 63 | ; DWARF5: {{^.Ldebug_ranges0}} |
David Blaikie | c4af8bf | 2018-10-20 07:36:39 +0000 | [diff] [blame] | 64 | ; DWARF5-NEXT: # DW_RLE_startx_length |
| 65 | ; DWARF5-NEXT: .byte 0 # start index |
David Blaikie | d661405 | 2018-07-18 18:04:42 +0000 | [diff] [blame] | 66 | ; DWARF5-NEXT: .uleb128 .Lfunc_end0-.Lfunc_begin0 # length |
David Blaikie | c4af8bf | 2018-10-20 07:36:39 +0000 | [diff] [blame] | 67 | ; DWARF5-NEXT: # DW_RLE_base_addressx |
| 68 | ; DWARF5-NEXT: .byte 1 # base address index |
David Blaikie | d661405 | 2018-07-18 18:04:42 +0000 | [diff] [blame] | 69 | ; DWARF5-NEXT: # DW_RLE_offset_pair |
| 70 | ; DWARF5-NEXT: .uleb128 .Lfunc_begin1-.Lfunc_begin1 # starting offset |
| 71 | ; DWARF5-NEXT: .uleb128 .Lfunc_end1-.Lfunc_begin1 # ending offset |
| 72 | ; DWARF5-NEXT: # DW_RLE_offset_pair |
| 73 | ; DWARF5-NEXT: .uleb128 .Lfunc_begin3-.Lfunc_begin1 # starting offset |
| 74 | ; DWARF5-NEXT: .uleb128 .Lfunc_end3-.Lfunc_begin1 # ending offset |
David Blaikie | c4af8bf | 2018-10-20 07:36:39 +0000 | [diff] [blame] | 75 | ; DWARF5-NEXT: # DW_RLE_startx_length |
| 76 | ; DWARF5-NEXT: .byte 3 # start index |
David Blaikie | d661405 | 2018-07-18 18:04:42 +0000 | [diff] [blame] | 77 | ; DWARF5-NEXT: .uleb128 .Lfunc_end4-.Lfunc_begin4 # length |
David Blaikie | c4af8bf | 2018-10-20 07:36:39 +0000 | [diff] [blame] | 78 | ; DWARF5-NEXT: # DW_RLE_startx_length |
| 79 | ; DWARF5-NEXT: .byte 4 # start index |
David Blaikie | d661405 | 2018-07-18 18:04:42 +0000 | [diff] [blame] | 80 | ; DWARF5-NEXT: .uleb128 .Lfunc_end5-.Lfunc_begin5 # length |
| 81 | ; DWARF5-NEXT: # DW_RLE_end_of_list |
David Blaikie | bb27911 | 2018-11-13 20:08:10 +0000 | [diff] [blame] | 82 | ; DWARF5-NEXT: {{^.Ldebug_ranges1}} |
| 83 | ; DWARF5-NEXT: # DW_RLE_startx_length |
| 84 | ; DWARF5-NEXT: .byte 5 # start index |
| 85 | ; DWARF5-NEXT: .uleb128 .Lfunc_end6-.Lfunc_begin6 # length |
| 86 | ; DWARF5-NEXT: # DW_RLE_startx_length |
| 87 | ; DWARF5-NEXT: .byte 6 # start index |
| 88 | ; DWARF5-NEXT: .uleb128 .Lfunc_end7-.Lfunc_begin7 # length |
| 89 | ; DWARF5-NEXT: # DW_RLE_end_of_list |
David Blaikie | d661405 | 2018-07-18 18:04:42 +0000 | [diff] [blame] | 90 | |
David Blaikie | 89c81a0 | 2017-07-30 22:10:00 +0000 | [diff] [blame] | 91 | ; Function Attrs: noinline nounwind optnone uwtable |
David Blaikie | bb27911 | 2018-11-13 20:08:10 +0000 | [diff] [blame] | 92 | define dso_local void @_Z2f1v() section "a" !dbg !9 { |
David Blaikie | 89c81a0 | 2017-07-30 22:10:00 +0000 | [diff] [blame] | 93 | entry: |
| 94 | ret void, !dbg !12 |
| 95 | } |
| 96 | |
| 97 | ; Function Attrs: noinline nounwind optnone uwtable |
David Blaikie | bb27911 | 2018-11-13 20:08:10 +0000 | [diff] [blame] | 98 | define dso_local void @_Z2f2v() section "b" !dbg !13 { |
David Blaikie | 89c81a0 | 2017-07-30 22:10:00 +0000 | [diff] [blame] | 99 | entry: |
| 100 | ret void, !dbg !14 |
| 101 | } |
| 102 | |
David Blaikie | 4dd6637 | 2017-07-31 00:18:24 +0000 | [diff] [blame] | 103 | ; Function Attrs: noinline nounwind optnone uwtable |
David Blaikie | bb27911 | 2018-11-13 20:08:10 +0000 | [diff] [blame] | 104 | define dso_local void @_Z2f3v() section "b" { |
| 105 | entry: |
| 106 | ret void |
| 107 | } |
| 108 | |
| 109 | ; Function Attrs: noinline nounwind optnone uwtable |
| 110 | define dso_local void @_Z2f4v() section "b" !dbg !15 { |
David Blaikie | 4dd6637 | 2017-07-31 00:18:24 +0000 | [diff] [blame] | 111 | entry: |
| 112 | ret void, !dbg !16 |
| 113 | } |
| 114 | |
| 115 | ; Function Attrs: noinline nounwind optnone uwtable |
David Blaikie | bb27911 | 2018-11-13 20:08:10 +0000 | [diff] [blame] | 116 | define dso_local void @_Z2f5v() section "c" !dbg !17 { |
David Blaikie | 4dd6637 | 2017-07-31 00:18:24 +0000 | [diff] [blame] | 117 | entry: |
| 118 | ret void, !dbg !18 |
| 119 | } |
| 120 | |
David Blaikie | bb27911 | 2018-11-13 20:08:10 +0000 | [diff] [blame] | 121 | ; Function Attrs: noinline nounwind optnone uwtable |
| 122 | define dso_local void @_Z2f6v() section "d" !dbg !19 { |
| 123 | entry: |
| 124 | ret void, !dbg !20 |
| 125 | } |
David Blaikie | 89c81a0 | 2017-07-30 22:10:00 +0000 | [diff] [blame] | 126 | |
David Blaikie | bb27911 | 2018-11-13 20:08:10 +0000 | [diff] [blame] | 127 | ; Function Attrs: noinline nounwind optnone uwtable |
| 128 | define dso_local void @_Z2f7v() section "e" !dbg !21 { |
| 129 | entry: |
| 130 | ret void, !dbg !22 |
| 131 | } |
David Blaikie | 89c81a0 | 2017-07-30 22:10:00 +0000 | [diff] [blame] | 132 | |
David Blaikie | bb27911 | 2018-11-13 20:08:10 +0000 | [diff] [blame] | 133 | ; Function Attrs: noinline nounwind optnone uwtable |
| 134 | define dso_local void @_Z2f8v() section "f" !dbg !23 { |
| 135 | entry: |
| 136 | ret void, !dbg !24 |
| 137 | } |
| 138 | |
| 139 | !llvm.dbg.cu = !{!0, !3} |
| 140 | !llvm.ident = !{!5, !5} |
| 141 | !llvm.module.flags = !{!6, !7, !8} |
| 142 | |
David Blaikie | b350c66 | 2019-12-30 22:32:08 -0800 | [diff] [blame] | 143 | !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 8.0.0 (trunk 346343) (llvm/trunk 346350)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None, debugBaseAddress: true) |
David Blaikie | bb27911 | 2018-11-13 20:08:10 +0000 | [diff] [blame] | 144 | !1 = !DIFile(filename: "ranges.cpp", directory: "/usr/local/google/home/blaikie/dev/scratch") |
David Blaikie | 89c81a0 | 2017-07-30 22:10:00 +0000 | [diff] [blame] | 145 | !2 = !{} |
David Blaikie | bb27911 | 2018-11-13 20:08:10 +0000 | [diff] [blame] | 146 | !3 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !4, producer: "clang version 8.0.0 (trunk 346343) (llvm/trunk 346350)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None) |
| 147 | !4 = !DIFile(filename: "ranges_no_base.cpp", directory: "/usr/local/google/home/blaikie/dev/scratch") |
| 148 | !5 = !{!"clang version 8.0.0 (trunk 346343) (llvm/trunk 346350)"} |
| 149 | !6 = !{i32 2, !"Dwarf Version", i32 4} |
| 150 | !7 = !{i32 2, !"Debug Info Version", i32 3} |
| 151 | !8 = !{i32 1, !"wchar_size", i32 4} |
| 152 | !9 = distinct !DISubprogram(name: "f1", linkageName: "_Z2f1v", scope: !1, file: !1, line: 1, type: !10, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2) |
| 153 | !10 = !DISubroutineType(types: !11) |
| 154 | !11 = !{null} |
| 155 | !12 = !DILocation(line: 1, column: 42, scope: !9) |
| 156 | !13 = distinct !DISubprogram(name: "f2", linkageName: "_Z2f2v", scope: !1, file: !1, line: 2, type: !10, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2) |
| 157 | !14 = !DILocation(line: 2, column: 42, scope: !13) |
| 158 | !15 = distinct !DISubprogram(name: "f4", linkageName: "_Z2f4v", scope: !1, file: !1, line: 4, type: !10, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2) |
| 159 | !16 = !DILocation(line: 4, column: 42, scope: !15) |
| 160 | !17 = distinct !DISubprogram(name: "f5", linkageName: "_Z2f5v", scope: !1, file: !1, line: 5, type: !10, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2) |
| 161 | !18 = !DILocation(line: 5, column: 42, scope: !17) |
| 162 | !19 = distinct !DISubprogram(name: "f6", linkageName: "_Z2f6v", scope: !1, file: !1, line: 6, type: !10, isLocal: false, isDefinition: true, scopeLine: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2) |
| 163 | !20 = !DILocation(line: 6, column: 42, scope: !19) |
| 164 | !21 = distinct !DISubprogram(name: "f7", linkageName: "_Z2f7v", scope: !4, file: !4, line: 1, type: !10, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !3, retainedNodes: !2) |
| 165 | !22 = !DILocation(line: 1, column: 42, scope: !21) |
| 166 | !23 = distinct !DISubprogram(name: "f8", linkageName: "_Z2f8v", scope: !4, file: !4, line: 2, type: !10, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !3, retainedNodes: !2) |
| 167 | !24 = !DILocation(line: 2, column: 42, scope: !23) |