From b0b7b18e8cb64fcb9f16bfee9b4cad0025d01ae4 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Mon, 21 Apr 2014 20:13:09 +0000 Subject: Use value semantics to manage DbgVariables rather than dynamic allocation/pointers. Requires switching some vectors to lists to maintain pointer validity. These could be changed to forward_lists (singly linked) with a bit more work - I've left comments to that effect. llvm-svn: 206780 --- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h') diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h index 8c4514e615e..0c1922ed3aa 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -30,6 +30,8 @@ #include "llvm/MC/MCDwarf.h" #include "llvm/Support/Allocator.h" +#include + namespace llvm { class AsmPrinter; @@ -274,7 +276,9 @@ class DwarfDebug : public AsmPrinterHandler { SectionMapType SectionMap; // List of arguments for current function. - SmallVector CurrentFnArguments; + // Linked list use to maintain pointer validity. Singly linked list could + // suffice with some contortions to addCurrentFnArgument. + std::list CurrentFnArguments; LexicalScopes LScopes; @@ -282,7 +286,9 @@ class DwarfDebug : public AsmPrinterHandler { DenseMap AbstractSPDies; // Collection of dbg variables of a scope. - typedef DenseMap > + // Linked list use to maintain pointer validity. Singly linked list could + // suffice with some contortions to addScopeVariable. + typedef DenseMap> ScopeVariablesMap; ScopeVariablesMap ScopeVariables; @@ -413,7 +419,7 @@ class DwarfDebug : public AsmPrinterHandler { MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &); - void addScopeVariable(LexicalScope *LS, DbgVariable *Var); + DbgVariable &addScopeVariable(LexicalScope *LS, DbgVariable Var); const SmallVectorImpl &getUnits() { return InfoHolder.getUnits(); @@ -591,7 +597,9 @@ class DwarfDebug : public AsmPrinterHandler { /// \brief If Var is an current function argument that add it in /// CurrentFnArguments list. - bool addCurrentFnArgument(DbgVariable *Var, LexicalScope *Scope); + DbgVariable *addCurrentFnArgument(DbgVariable &Var, LexicalScope *Scope); + + DbgVariable &addVariable(DbgVariable Var, LexicalScope *Scope); /// \brief Populate LexicalScope entries with variables' info. void collectVariableInfo(SmallPtrSet &ProcessedVars); -- cgit v1.2.3