diff options
| author | Eric Christopher <echristo@gmail.com> | 2013-11-23 00:05:29 +0000 |
|---|---|---|
| committer | Eric Christopher <echristo@gmail.com> | 2013-11-23 00:05:29 +0000 |
| commit | 4751d701b743270db71f81e2f1bc31758eadc8d2 (patch) | |
| tree | f469c2e3c933be78cf3c73fa24e8f005cd73c41d /llvm/lib/CodeGen/AsmPrinter | |
| parent | f8da6aa7c71d6a49c551fe2c7bcc7cba7d7f7ad5 (diff) | |
| download | bcm5719-llvm-4751d701b743270db71f81e2f1bc31758eadc8d2.tar.gz bcm5719-llvm-4751d701b743270db71f81e2f1bc31758eadc8d2.zip | |
Refactor DW_AT_ranges handling to use labels for ranges rather than
a non-relocatable number offset.
One fixme to make the ranges as discrete data structures and
have range lists explicitly represented rather than as a list of symbols.
llvm-svn: 195523
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter')
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 6613aac87d5..b267a2096d3 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -475,11 +475,11 @@ DIE *DwarfDebug::constructLexicalScopeDIE(CompileUnit *TheCU, // If we have multiple ranges, emit them into the range section. if (Ranges.size() > 1) { // .debug_range section has not been laid out yet. Emit offset in - // .debug_range as a uint, size 4, for now. emitDIE will handle - // DW_AT_ranges appropriately. - TheCU->addSectionOffset(ScopeDIE, dwarf::DW_AT_ranges, - DebugRangeSymbols.size() * - Asm->getDataLayout().getPointerSize()); + // .debug_range as a relocatable label. emitDIE will handle + // emitting it appropriately. + unsigned Offset = DebugRangeSymbols.size(); + TheCU->addSectionLabel(ScopeDIE, dwarf::DW_AT_ranges, + Asm->GetTempSymbol("debug_ranges", Offset)); for (SmallVectorImpl<InsnRange>::const_iterator RI = Ranges.begin(), RE = Ranges.end(); RI != RE; ++RI) { @@ -531,11 +531,11 @@ DIE *DwarfDebug::constructInlinedScopeDIE(CompileUnit *TheCU, if (Ranges.size() > 1) { // .debug_range section has not been laid out yet. Emit offset in - // .debug_range as a uint, size 4, for now. emitDIE will handle - // DW_AT_ranges appropriately. - TheCU->addSectionOffset(ScopeDIE, dwarf::DW_AT_ranges, - DebugRangeSymbols.size() * - Asm->getDataLayout().getPointerSize()); + // .debug_range as a relocatable label. emitDIE will handle + // emitting it appropriately. + unsigned Offset = DebugRangeSymbols.size(); + TheCU->addSectionLabel(ScopeDIE, dwarf::DW_AT_ranges, + Asm->GetTempSymbol("debug_ranges", Offset)); for (SmallVectorImpl<InsnRange>::const_iterator RI = Ranges.begin(), RE = Ranges.end(); RI != RE; ++RI) { @@ -2083,14 +2083,12 @@ void DwarfDebug::emitDIE(DIE *Die, ArrayRef<DIEAbbrev *> Abbrevs) { } case dwarf::DW_AT_ranges: { // DW_AT_range Value encodes offset in debug_range section. - DIEInteger *V = cast<DIEInteger>(Values[i]); + DIELabel *V = cast<DIELabel>(Values[i]); - if (Asm->MAI->doesDwarfUseRelocationsAcrossSections()) { - Asm->EmitLabelPlusOffset(DwarfDebugRangeSectionSym, V->getValue(), 4); - } else { - Asm->EmitLabelOffsetDifference(DwarfDebugRangeSectionSym, V->getValue(), - DwarfDebugRangeSectionSym, 4); - } + if (Asm->MAI->doesDwarfUseRelocationsAcrossSections()) + Asm->EmitSectionOffset(V->getValue(), DwarfDebugRangeSectionSym); + else + Asm->EmitLabelDifference(V->getValue(), DwarfDebugRangeSectionSym, 4); break; } case dwarf::DW_AT_location: { @@ -2928,12 +2926,15 @@ void DwarfDebug::emitDebugRanges() { Asm->OutStreamer.SwitchSection( Asm->getObjFileLowering().getDwarfRangesSection()); unsigned char Size = Asm->getDataLayout().getPointerSize(); - for (SmallVectorImpl<const MCSymbol *>::iterator - I = DebugRangeSymbols.begin(), - E = DebugRangeSymbols.end(); - I != E; ++I) { - if (*I) - Asm->OutStreamer.EmitSymbolValue(const_cast<MCSymbol *>(*I), Size); + for (uint32_t i = 0, e = DebugRangeSymbols.size(); i < e; ++i) { + // Only emit a symbol for every range pair for now. + // FIXME: Make this per range list. + if ((i % 2) == 0) + Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("debug_ranges", i)); + + const MCSymbol *I = DebugRangeSymbols[i]; + if (I) + Asm->OutStreamer.EmitSymbolValue(I, Size); else Asm->OutStreamer.EmitIntValue(0, Size); } |

