llvm.org GIT mirror llvm / bed0b61
[DEBUGINFO] Add -no-dwarf-debug-ranges option. Summary: Added option -no-dwarf-debug-ranges option to disable emission of .debug_ranges section. Reviewers: probinson, echristo Subscribers: aprantl, JDevlieghere, llvm-commits Differential Revision: https://reviews.llvm.org/D44384 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@328030 91177308-0d34-0410-b5e6-96231b3b80d8 Alexey Bataev 2 years ago
4 changed file(s) with 81 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
409409
410410 void DwarfCompileUnit::attachRangesOrLowHighPC(
411411 DIE &Die, SmallVector Ranges) {
412 if (Ranges.size() == 1) {
413 const auto &single = Ranges.front();
414 attachLowHighPC(Die, single.getStart(), single.getEnd());
412 if (Ranges.size() == 1 || !DD->useRangesSection()) {
413 const RangeSpan &Front = Ranges.front();
414 const RangeSpan &Back = Ranges.back();
415 attachLowHighPC(Die, Front.getStart(), Back.getEnd());
415416 } else
416417 addScopeRangeList(Die, std::move(Ranges));
417418 }
127127 cl::desc("Disable emission of DWARF pub sections."),
128128 cl::init(false));
129129
130 static cl::opt
131 NoDwarfRangesSection("no-dwarf-ranges-section", cl::Hidden,
132 cl::desc("Disable emission .debug_ranges section."),
133 cl::init(false));
134
130135 enum LinkageNameOption {
131136 DefaultLinkageNames,
132137 AllLinkageNames,
315320 DwarfVersion = DwarfVersion ? DwarfVersion : dwarf::DWARF_VERSION;
316321
317322 UsePubSections = !NoDwarfPubSections;
323 UseRangesSection = !NoDwarfRangesSection;
318324
319325 // Work around a GDB bug. GDB doesn't support the standard opcode;
320326 // SCE doesn't support GNU's; LLDB prefers the standard opcode, which
743749 // ranges for all subprogram DIEs for mach-o.
744750 DwarfCompileUnit &U = SkCU ? *SkCU : TheCU;
745751 if (unsigned NumRanges = TheCU.getRanges().size()) {
746 if (NumRanges > 1)
752 if (NumRanges > 1 && useRangesSection())
747753 // A DW_AT_low_pc attribute may also be specified in combination with
748754 // DW_AT_ranges to specify the default base address for use in
749755 // location lists (see Section 2.6.2) and range lists (see Section
19051911 if (CUMap.empty())
19061912 return;
19071913
1914 if (!useRangesSection()) {
1915 assert(llvm::all_of(
1916 CUMap,
1917 [](const decltype(CUMap)::const_iterator::value_type &Pair) {
1918 return Pair.second->getRangeLists().empty();
1919 }) &&
1920 "No debug ranges expected.");
1921 return;
1922 }
1923
19081924 // Start the dwarf ranges section.
19091925 Asm->OutStreamer->SwitchSection(
19101926 Asm->getObjFileLowering().getDwarfRangesSection());
260260 /// Whether to emit DWARF pub sections or not.
261261 bool UsePubSections = true;
262262
263 /// Allow emission of .debug_ranges section.
264 bool UseRangesSection = true;
265
263266 /// DWARF5 Experimental Options
264267 /// @{
265268 bool HasDwarfAccelTables;
505508
506509 /// Returns whether GNU oub sections should be emitted.
507510 bool usePubSections() const { return UsePubSections; }
511
512 /// Returns whether ranges section should be emitted.
513 bool useRangesSection() const { return UseRangesSection; }
508514
509515 // Experimental DWARF5 features.
510516
0 ; RUN: llc -filetype=asm -mtriple=x86_64-pc-linux-gnu < %s -o - -dwarf-version=2 -no-dwarf-ranges-section | FileCheck %s --check-prefix=DISABLED
1 ; RUN: llc -filetype=asm -mtriple=x86_64-pc-linux-gnu < %s -o - -dwarf-version=2 | FileCheck %s
2
3 ; DISABLED-NOT: {{DW_AT_ranges|.debug_ranges}}
4 ; DISABLED: .section .debug_info
5 ; DISABLED-NOT: {{DW_AT_ranges|.section}}
6 ; DISABLED: .quad .Lfunc_begin0 # DW_AT_low_pc
7 ; DISABLED-NEXT: .quad .Lfunc_end1 # DW_AT_high_pc
8 ; DISABLED-NOT: {{DW_AT_ranges|.debug_ranges}}
9
10 ; .debug_ranges section must be emitted by default
11 ; CHECK: .section .debug_info
12 ; CHECK: quad 0 # DW_AT_low_pc
13 ; CHECK-NEXT: long [[RANGE0:[.]Ldebug_ranges[0-9]+]] # DW_AT_ranges
14 ; CHECK: .debug_ranges
15 ; CHECK-NEXT: [[RANGE0]]:
16 ; CHECK-NEXT: .quad .Lfunc_begin0
17 ; CHECK-NEXT: .quad .Lfunc_end0
18 ; CHECK-NEXT: .quad .Lfunc_begin1
19 ; CHECK-NEXT: .quad .Lfunc_end1
20 ; CHECK-NEXT: .quad 0
21 ; CHECK-NEXT: .quad 0
22
23 ; Function Attrs: noinline nounwind optnone uwtable
24 define void @_Z2f1v() #0 section "a" !dbg !7 {
25 entry:
26 ret void, !dbg !10
27 }
28
29 ; Function Attrs: noinline nounwind optnone uwtable
30 define void @_Z2f2v() #0 section "b" !dbg !11 {
31 entry:
32 ret void, !dbg !12
33 }
34
35 attributes #0 = { noinline nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
36
37 !llvm.dbg.cu = !{!0}
38 !llvm.module.flags = !{!3, !4, !5}
39 !llvm.ident = !{!6}
40
41 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 6.0.0 (trunk 309523) (llvm/trunk 309526)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
42 !1 = !DIFile(filename: "funcs.cpp", directory: "/usr/local/google/home/blaikie/dev/scratch")
43 !2 = !{}
44 !3 = !{i32 2, !"Dwarf Version", i32 4}
45 !4 = !{i32 2, !"Debug Info Version", i32 3}
46 !5 = !{i32 1, !"wchar_size", i32 4}
47 !6 = !{!"clang version 6.0.0 (trunk 309523) (llvm/trunk 309526)"}
48 !7 = distinct !DISubprogram(name: "f1", linkageName: "_Z2f1v", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
49 !8 = !DISubroutineType(types: !9)
50 !9 = !{null}
51 !10 = !DILocation(line: 1, column: 42, scope: !7)
52 !11 = distinct !DISubprogram(name: "f2", linkageName: "_Z2f2v", scope: !1, file: !1, line: 2, type: !8, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
53 !12 = !DILocation(line: 2, column: 42, scope: !11)