diff options
author | Richard Mitton <richard@codersnotes.com> | 2013-09-23 17:56:20 +0000 |
---|---|---|
committer | Richard Mitton <richard@codersnotes.com> | 2013-09-23 17:56:20 +0000 |
commit | 089ed89e76212fe54f24d3dae83d6bad28cd88b6 (patch) | |
tree | 060a88b401f97a0807658142bd96e431972e11c9 /llvm/lib/CodeGen/AsmPrinter | |
parent | 1b5ee5d9f19bd9dcbe8fd57d9c56548e5e4527c7 (diff) | |
download | bcm5719-llvm-089ed89e76212fe54f24d3dae83d6bad28cd88b6.tar.gz bcm5719-llvm-089ed89e76212fe54f24d3dae83d6bad28cd88b6.zip |
Fixed debug_aranges handling for common symbols.
The size of common symbols is now tracked correctly, so they can be listed in the arange section without needing knowledge of other following symbols.
.comm (and .lcomm) do not indicate to the system assembler any particular section to use, so we have to treat them as having no section.
Test case update to account for this.
llvm-svn: 191210
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 3 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 15 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h | 7 |
3 files changed, 20 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index e66237706bc..de08b77012b 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -292,6 +292,9 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) { // sections and expected to be contiguous (e.g. ObjC metadata). unsigned AlignLog = getGVAlignmentLog2(GV, *TD); + if (DD) + DD->setSymbolSize(GVSym, Size); + // Handle common and BSS local symbols (.lcomm). if (GVKind.isCommon() || GVKind.isBSSLocal()) { if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 6414969774b..48a7c185ec2 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -2838,12 +2838,17 @@ void DwarfDebug::emitDebugARanges() { Asm->EmitLabelReference(Span.Start, PtrSize); // Calculate the size as being from the span start to it's end. - // If we have no valid end symbol, then we just cover the first byte. - // (this sucks, but I can't seem to figure out how to get the size) - if (Span.End) + if (Span.End) { Asm->EmitLabelDifference(Span.End, Span.Start, PtrSize); - else - Asm->OutStreamer.EmitIntValue(1, PtrSize); + } else { + // For symbols without an end marker (e.g. common), we + // write a single arange entry containing just that one symbol. + uint64_t Size = SymSize[Span.Start]; + if (Size == 0) + Size = 1; + + Asm->OutStreamer.EmitIntValue(Size, PtrSize); + } } Asm->OutStreamer.AddComment("ARange terminator"); diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h index 8fe60c77be5..e774c653945 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -341,6 +341,9 @@ class DwarfDebug { // List of all labels used in the output. std::vector<SymbolCU> Labels; + // Size of each symbol emitted (for those symbols that have a specific size). + DenseMap <const MCSymbol *, uint64_t> SymSize; + // Provides a unique id per text section. typedef DenseMap<const MCSection *, SmallVector<SymbolCU, 8> > SectionMapType; SectionMapType SectionMap; @@ -682,6 +685,10 @@ public: /// \brief Add a label so that arange data can be generated for it. void addLabel(SymbolCU SCU) { Labels.push_back(SCU); } + /// \brief For symbols that have a size designated (e.g. common symbols), + /// this tracks that size. + void setSymbolSize(const MCSymbol *Sym, uint64_t Size) { SymSize[Sym] = Size;} + /// \brief Look up the source id with the given directory and source file /// names. If none currently exists, create a new id and insert it in the /// SourceIds map. |