From 87e9d8c05128a2dc2b33c70424bacca135160e9c Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Thu, 23 Oct 2014 00:16:05 +0000 Subject: [PATCH] [DebugInfo] Sink DwarfDebug::addCurrentFnArgument down into DwarfFile. Variable handling will be sunk into DwarfFile so that abstract variables and the like can be shared across multiple CUs (to handle cross-CU inlining, for example). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220453 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 25 +------------------------ lib/CodeGen/AsmPrinter/DwarfFile.cpp | 23 +++++++++++++++++++++++ lib/CodeGen/AsmPrinter/DwarfFile.h | 4 ++++ 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index eb2d25ec2d4..151790ccfe8 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -794,29 +794,6 @@ DwarfDebug::ensureAbstractVariableIsCreatedIfScoped(const DIVariable &DV, createAbstractVariable(Cleansed, Scope); } -// If Var is a current function argument then add it to CurrentFnArguments list. -bool DwarfDebug::addCurrentFnArgument(DbgVariable *Var, LexicalScope *Scope) { - if (Scope->getParent()) - return false; - DIVariable DV = Var->getVariable(); - if (DV.getTag() != dwarf::DW_TAG_arg_variable) - return false; - unsigned ArgNo = DV.getArgNumber(); - if (ArgNo == 0) - return false; - - size_t Size = CurrentFnArguments.size(); - if (Size == 0) - CurrentFnArguments.resize(CurFn->getFunction()->arg_size()); - // llvm::Function argument size is not good indicator of how many - // arguments does the function have at source level. - if (ArgNo > Size) - CurrentFnArguments.resize(ArgNo * 2); - assert(!CurrentFnArguments[ArgNo - 1]); - CurrentFnArguments[ArgNo - 1] = Var; - return true; -} - // Collect variable information from side table maintained by MMI. void DwarfDebug::collectVariableInfoFromMMITable( SmallPtrSetImpl &Processed) { @@ -1277,7 +1254,7 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) { } void DwarfDebug::addScopeVariable(LexicalScope *LS, DbgVariable *Var) { - if (addCurrentFnArgument(Var, LS)) + if (InfoHolder.addCurrentFnArgument(Var, LS)) return; addNonArgumentScopeVariable(LS, Var); } diff --git a/lib/CodeGen/AsmPrinter/DwarfFile.cpp b/lib/CodeGen/AsmPrinter/DwarfFile.cpp index d453e8967f9..355bfd64393 100644 --- a/lib/CodeGen/AsmPrinter/DwarfFile.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfFile.cpp @@ -70,6 +70,7 @@ void DwarfFile::emitUnits(const MCSymbol *ASectionSym) { Asm->OutStreamer.EmitLabel(TheU->getLabelEnd()); } } + // Compute the size and offset for each DIE. void DwarfFile::computeSizeAndOffsets() { // Offset from the first CU in the debug info section is 0 initially. @@ -155,4 +156,26 @@ void DwarfFile::emitStrings(const MCSection *StrSection, const MCSection *OffsetSection) { StrPool.emit(*Asm, StrSection, OffsetSection); } + +// If Var is a current function argument then add it to CurrentFnArguments list. +bool DwarfFile::addCurrentFnArgument(DbgVariable *Var, LexicalScope *Scope) { + if (Scope->getParent()) + return false; + DIVariable DV = Var->getVariable(); + if (DV.getTag() != dwarf::DW_TAG_arg_variable) + return false; + unsigned ArgNo = DV.getArgNumber(); + if (ArgNo == 0) + return false; + + auto &CurrentFnArguments = DD.getCurrentFnArguments(); + + // llvm::Function argument size is not good indicator of how many + // arguments does the function have at source level. + if (ArgNo > CurrentFnArguments.size()) + CurrentFnArguments.resize(ArgNo * 2); + assert(!CurrentFnArguments[ArgNo - 1]); + CurrentFnArguments[ArgNo - 1] = Var; + return true; +} } diff --git a/lib/CodeGen/AsmPrinter/DwarfFile.h b/lib/CodeGen/AsmPrinter/DwarfFile.h index 02d296ebd23..ce12f1246cd 100644 --- a/lib/CodeGen/AsmPrinter/DwarfFile.h +++ b/lib/CodeGen/AsmPrinter/DwarfFile.h @@ -24,10 +24,12 @@ namespace llvm { class AsmPrinter; +class DbgVariable; class DwarfUnit; class DIEAbbrev; class MCSymbol; class DIE; +class LexicalScope; class StringRef; class DwarfDebug; class MCSection; @@ -81,6 +83,8 @@ public: /// \brief Returns the string pool. DwarfStringPool &getStringPool() { return StrPool; } + + bool addCurrentFnArgument(DbgVariable *Var, LexicalScope *Scope); }; } #endif