llvm.org GIT mirror llvm / 658236d
Print section start labels when first switching to the section. This is less brittle and avoids polluting the start of the file with every debug section. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231898 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 5 years ago
12 changed file(s) with 49 addition(s) and 47 deletion(s). Raw diff Collapse all Expand all
240240 // Define out of line so we don't have to include DwarfUnit.h in DwarfDebug.h.
241241 DwarfDebug::~DwarfDebug() { }
242242
243 // Switch to the specified MCSection and emit an assembler
244 // temporary label to it if SymbolStem is specified.
245 static void emitSectionSym(AsmPrinter *Asm, const MCSection *Section) {
246 Asm->OutStreamer.SwitchSection(Section);
247 MCSymbol *TmpSym = Section->getBeginSymbol();
248 Asm->OutStreamer.EmitLabel(TmpSym);
249 }
250
251243 static bool isObjCClass(StringRef Name) {
252244 return Name.startswith("+") || Name.startswith("-");
253245 }
447439 if (!CU_Nodes)
448440 return;
449441 TypeIdentifierMap = generateDITypeIdentifierMap(CU_Nodes);
450
451 // Emit initial sections so we can reference labels later.
452 emitSectionLabels();
453442
454443 SingleCU = CU_Nodes->getNumOperands() == 1;
455444
618607
619608 // Emit all Dwarf sections that should come after the content.
620609 void DwarfDebug::endModule() {
621 const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
622610 assert(CurFn == nullptr);
623611 assert(CurMI == nullptr);
624612
625613 // If we aren't actually generating debug info (check beginModule -
626614 // conditionalized on !DisableDebugInfoPrinting and the presence of the
627615 // llvm.dbg.cu metadata node)
628 if (!TLOF.getDwarfInfoSection()->getBeginSymbol()->isInSection())
616 if (!MMI->hasDebugInfo())
629617 return;
630618
631619 // Finalize the debug info for the module.
639627 // Emit info into a debug loc section.
640628 emitDebugLoc();
641629
630 // Corresponding abbreviations into a abbrev section.
631 emitAbbreviations();
632
642633 // Emit all the DIEs into a debug info section.
643634 emitDebugInfo();
644
645 // Corresponding abbreviations into a abbrev section.
646 emitAbbreviations();
647635
648636 // Emit info into a debug aranges section.
649637 if (GenerateARangeSection)
12981286 // Emit Methods
12991287 //===----------------------------------------------------------------------===//
13001288
1301 // Emit initial Dwarf sections with a label at the start of each one.
1302 void DwarfDebug::emitSectionLabels() {
1303 const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
1304
1305 // Dwarf sections base addresses.
1306 emitSectionSym(Asm, TLOF.getDwarfInfoSection());
1307 if (useSplitDwarf()) {
1308 emitSectionSym(Asm, TLOF.getDwarfInfoDWOSection());
1309 emitSectionSym(Asm, TLOF.getDwarfTypesDWOSection());
1310 }
1311 emitSectionSym(Asm, TLOF.getDwarfAbbrevSection());
1312 if (useSplitDwarf())
1313 emitSectionSym(Asm, TLOF.getDwarfAbbrevDWOSection());
1314
1315 emitSectionSym(Asm, TLOF.getDwarfLineSection());
1316 emitSectionSym(Asm, TLOF.getDwarfStrSection());
1317 if (useSplitDwarf()) {
1318 emitSectionSym(Asm, TLOF.getDwarfStrDWOSection());
1319 emitSectionSym(Asm, TLOF.getDwarfAddrSection());
1320 emitSectionSym(Asm, TLOF.getDwarfLocDWOSection());
1321 } else
1322 emitSectionSym(Asm, TLOF.getDwarfLocSection());
1323 emitSectionSym(Asm, TLOF.getDwarfRangesSection());
1324 }
1325
13261289 // Emit the debug info section.
13271290 void DwarfDebug::emitDebugInfo() {
13281291 DwarfFile &Holder = useSplitDwarf() ? SkeletonHolder : InfoHolder;
13631326 void DwarfDebug::emitAccel(DwarfAccelTable &Accel, const MCSection *Section,
13641327 StringRef TableName) {
13651328 Accel.FinalizeTable(Asm, TableName);
1366 emitSectionSym(Asm, Section);
1329 Asm->OutStreamer.SwitchSection(Section);
13671330
13681331 // Emit the full data.
13691332 Accel.emit(Asm, Section->getBeginSymbol(), this);
338338 /// \brief Construct a DIE for this abstract scope.
339339 void constructAbstractSubprogramScopeDIE(LexicalScope *Scope);
340340
341 /// \brief Emit initial Dwarf sections with a label at the start of each one.
342 void emitSectionLabels();
343
344341 /// \brief Compute the size and offset of a DIE given an incoming Offset.
345342 unsigned computeSizeAndOffset(DIE *Die, unsigned Offset);
346343
1515 #include "llvm/MC/MCExpr.h"
1616 #include "llvm/MC/MCObjectFileInfo.h"
1717 #include "llvm/MC/MCObjectWriter.h"
18 #include "llvm/MC/MCSection.h"
1819 #include "llvm/MC/MCSymbol.h"
1920 #include "llvm/MC/MCWin64EH.h"
2021 #include "llvm/Support/ErrorHandling.h"
669670 if (MCSectionSubPair(Section, Subsection) != curSection) {
670671 SectionStack.back().first = MCSectionSubPair(Section, Subsection);
671672 ChangeSection(Section, Subsection);
673 MCSymbol *Sym = Section->getBeginSymbol();
674 if (Sym && !Sym->isInSection())
675 EmitLabel(Sym);
672676 }
673677 }
0 ; RUN: %llc_dwarf -O2 %s -o - | FileCheck %s
11 ; Check struct X for dead variable xyz from inlined function foo.
22
3 ; CHECK: .Lsection_info
34 ; CHECK: DW_TAG_structure_type
45 ; CHECK-NEXT: info_string
56
0 ; A by-value struct is a register-indirect value (breg).
11 ; RUN: llc %s -filetype=asm -o - | FileCheck %s
22
3 ; CHECK: Lsection_info:
34 ; CHECK: DW_AT_location
45 ; CHECK-NEXT: .byte 112
56 ; 112 = 0x70 = DW_OP_breg0
1313 ; CHECK-NEXT: .byte 224
1414 ; check that the expected TLS address description is the first thing in the debug_addr section
1515 ; CHECK: debug_addr
16 ; CHECK-NEXT: .Laddr_sec:
1617 ; CHECK-NEXT: .quad tls@dtprel+32768
1718
1819 @tls = thread_local global i32 0, align 4
0 ; RUN: llc -mtriple=x86_64-linux < %s | FileCheck %s
11
2 ; CHECK: .section .debug_info
23 ; CHECK: DW_AT_const_value
34 ; CHECK-NEXT: 42
45
0 ; RUN: llc -mtriple x86_64-pc-linux < %s | FileCheck %s
1
2 ; Test that we don't pollute the start of the file with debug sections
3
4 ; CHECK: .text
5 ; CHECK-NEXT: .file ""
6 ; CHECK-NEXT: .globl f
7 ; CHECK-NEXT: .align 16, 0x90
8 ; CHECK-NEXT: .type f,@function
9 ; CHECK-NEXT: f: # @f
10
11 ; CHECK: .section .debug_str
12
13 define void @f() {
14 ret void, !dbg !9
15 }
16 !llvm.dbg.cu = !{!0}
17 !llvm.module.flags = !{!7, !8}
18
19 !0 = !MDCompileUnit(language: DW_LANG_C99, file: !1, producer: "foo", isOptimized: true, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2)
20 !1 = !MDFile(filename: "/foo/test.c", directory: "/foo")
21 !2 = !{}
22 !3 = !{!4}
23 !4 = !MDSubprogram(name: "f", scope: !1, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, function: void ()* @f, variables: !2)
24 !5 = !MDSubroutineType(types: !6)
25 !6 = !{null}
26 !7 = !{i32 2, !"Dwarf Version", i32 4}
27 !8 = !{i32 2, !"Debug Info Version", i32 3}
28 !9 = !MDLocation(line: 1, column: 15, scope: !4)
0 ; RUN: llc -mtriple x86_64-pc-linux-gnu < %s | FileCheck %s
1
2 ; CHECK: .long .Lline_table_start0 # DW_AT_stmt_list
13
24 ; CHECK: .section .debug_line,"",@progbits
35 ; CHECK-NEXT: .Lsection_line:
4
5 ; CHECK: .long .Lline_table_start0 # DW_AT_stmt_list
6 ; CHECK-NEXT: .Lline_table_start0:
67
78 define void @f() {
89 entry:
6767
6868 ; check that the expected TLS address description is the first thing in the debug_addr section
6969 ; FISSION: .section .debug_addr
70 ; FISSION: addr_sec:
7071 ; FISSION-NEXT: .quad tls@DTPOFF
7172 ; FISSION-NEXT: .quad glbl
7273 ; FISSION-NOT: .quad glbl
2424 !7 = distinct !MDLexicalBlock(line: 3, column: 12, file: !14, scope: !0)
2525 !8 = !MDCompositeType(tag: DW_TAG_array_type, align: 32, file: !14, scope: !2, baseType: !5, elements: !9)
2626 !9 = !{!10}
27 ;CHECK: section_info:
2728 ;CHECK: DW_TAG_subrange_type
2829 ;CHECK-NEXT: DW_AT_type
2930 ;CHECK-NOT: DW_AT_lower_bound
3333 // ASM: .section .debug_info
3434
3535 // ASM: .section .debug_abbrev
36 // ASM-NEXT: .Lsection_abbrev:
3637 // ASM-NEXT: [[ABBREV_LABEL:.Ltmp[0-9]+]]
3738
3839 // Second instance of the section has the CU
4748 // ASM-NEXT: .long [[LINE_LABEL:.L[a-z0-9]+]]
4849
4950 // ASM: .section .debug_line
51 // ASM-NEXT:.Lsection_line:
5052 // ASM-NEXT: [[LINE_LABEL]]
5153
5254 // DWARF1: Dwarf version 1 is not supported.