diff options
author | dim <dim@FreeBSD.org> | 2015-01-18 16:17:27 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2015-01-18 16:17:27 +0000 |
commit | 081af4da16b9046c019ca40f64b1fb7ee8c6dca1 (patch) | |
tree | 4abb9cbeecc7901726dd0b4a37369596c852e9ef /lib/CodeGen/AsmPrinter/DwarfFile.cpp | |
parent | 3c7e7a1538a873b0d3b012ef8811969ac4552c2a (diff) | |
download | FreeBSD-src-081af4da16b9046c019ca40f64b1fb7ee8c6dca1.zip FreeBSD-src-081af4da16b9046c019ca40f64b1fb7ee8c6dca1.tar.gz |
Vendor import of llvm RELEASE_360/rc1 tag r226102 (effectively, 3.6.0 RC1):
https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_360/rc1@226102
Diffstat (limited to 'lib/CodeGen/AsmPrinter/DwarfFile.cpp')
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfFile.cpp | 65 |
1 files changed, 47 insertions, 18 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfFile.cpp b/lib/CodeGen/AsmPrinter/DwarfFile.cpp index 737ee54..549abf8 100644 --- a/lib/CodeGen/AsmPrinter/DwarfFile.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfFile.cpp @@ -8,18 +8,18 @@ //===----------------------------------------------------------------------===// #include "DwarfFile.h" - #include "DwarfDebug.h" #include "DwarfUnit.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/IR/DataLayout.h" #include "llvm/MC/MCStreamer.h" #include "llvm/Support/LEB128.h" -#include "llvm/IR/DataLayout.h" -#include "llvm/ADT/STLExtras.h" #include "llvm/Target/TargetLoweringObjectFile.h" namespace llvm { -DwarfFile::DwarfFile(AsmPrinter *AP, StringRef Pref, BumpPtrAllocator &DA) - : Asm(AP), StrPool(DA, *Asm, Pref) {} +DwarfFile::DwarfFile(AsmPrinter *AP, DwarfDebug &DD, StringRef Pref, + BumpPtrAllocator &DA) + : Asm(AP), DD(DD), StrPool(DA, *Asm, Pref) {} DwarfFile::~DwarfFile() {} @@ -48,25 +48,18 @@ void DwarfFile::addUnit(std::unique_ptr<DwarfUnit> U) { // Emit the various dwarf units to the unit section USection with // the abbreviations going into ASection. -void DwarfFile::emitUnits(DwarfDebug *DD, const MCSymbol *ASectionSym) { +void DwarfFile::emitUnits(const MCSymbol *ASectionSym) { for (const auto &TheU : CUs) { DIE &Die = TheU->getUnitDie(); const MCSection *USection = TheU->getSection(); Asm->OutStreamer.SwitchSection(USection); - // Emit the compile units header. - Asm->OutStreamer.EmitLabel(TheU->getLabelBegin()); - - // Emit size of content not including length itself - Asm->OutStreamer.AddComment("Length of Unit"); - Asm->EmitInt32(TheU->getHeaderSize() + Die.getSize()); - TheU->emitHeader(ASectionSym); - DD->emitDIE(Die); - Asm->OutStreamer.EmitLabel(TheU->getLabelEnd()); + DD.emitDIE(Die); } } + // Compute the size and offset for each DIE. void DwarfFile::computeSizeAndOffsets() { // Offset from the first CU in the debug info section is 0 initially. @@ -149,8 +142,44 @@ void DwarfFile::emitAbbrevs(const MCSection *Section) { // Emit strings into a string section. void DwarfFile::emitStrings(const MCSection *StrSection, - const MCSection *OffsetSection, - const MCSymbol *StrSecSym) { - StrPool.emit(*Asm, StrSection, OffsetSection, StrSecSym); + const MCSection *OffsetSection) { + StrPool.emit(*Asm, StrSection, OffsetSection); +} + +void DwarfFile::addScopeVariable(LexicalScope *LS, DbgVariable *Var) { + SmallVectorImpl<DbgVariable *> &Vars = ScopeVariables[LS]; + DIVariable DV = Var->getVariable(); + // Variables with positive arg numbers are parameters. + if (unsigned ArgNum = DV.getArgNumber()) { + // Keep all parameters in order at the start of the variable list to ensure + // function types are correct (no out-of-order parameters) + // + // This could be improved by only doing it for optimized builds (unoptimized + // builds have the right order to begin with), searching from the back (this + // would catch the unoptimized case quickly), or doing a binary search + // rather than linear search. + auto I = Vars.begin(); + while (I != Vars.end()) { + unsigned CurNum = (*I)->getVariable().getArgNumber(); + // A local (non-parameter) variable has been found, insert immediately + // before it. + if (CurNum == 0) + break; + // A later indexed parameter has been found, insert immediately before it. + if (CurNum > ArgNum) + break; + // FIXME: There are still some cases where two inlined functions are + // conflated together (two calls to the same function at the same + // location (eg: via a macro, or without column info, etc)) and then + // their arguments are conflated as well. + assert((LS->getParent() || CurNum != ArgNum) && + "Duplicate argument for top level (non-inlined) function"); + ++I; + } + Vars.insert(I, Var); + return; + } + + Vars.push_back(Var); } } |