1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00

Revert "Use value semantics to manage DbgVariables rather than dynamic allocation/pointers."

This reverts commit r206780.

This commit was regressing gdb.opt/inline-locals.exp in the GDB 7.5 test
suite. Reverting until I can fix the issue.

llvm-svn: 206867
This commit is contained in:
David Blaikie 2014-04-22 05:41:06 +00:00
parent e2b1ac50c0
commit eb8b511a12
2 changed files with 54 additions and 57 deletions

View File

@ -564,13 +564,14 @@ DIE *DwarfDebug::createScopeChildrenDIE(DwarfCompileUnit *TheCU,
// Collect arguments for current function.
if (LScopes.isCurrentFunctionScope(Scope)) {
for (DbgVariable &ArgDV : CurrentFnArguments)
if (ArgDV.getVariable()) {
DIE *Arg = TheCU->constructVariableDIE(ArgDV, Scope->isAbstractScope());
Children.push_back(Arg);
if (ArgDV.isObjectPointer())
ObjectPointer = Arg;
}
for (DbgVariable *ArgDV : CurrentFnArguments)
if (ArgDV)
if (DIE *Arg =
TheCU->constructVariableDIE(*ArgDV, Scope->isAbstractScope())) {
Children.push_back(Arg);
if (ArgDV->isObjectPointer())
ObjectPointer = Arg;
}
// If this is a variadic function, add an unspecified parameter.
DISubprogram SP(Scope->getScopeNode());
@ -583,11 +584,11 @@ DIE *DwarfDebug::createScopeChildrenDIE(DwarfCompileUnit *TheCU,
}
// Collect lexical scope children first.
for (DbgVariable &DV : ScopeVariables.lookup(Scope))
if (DIE *Variable = TheCU->constructVariableDIE(DV,
for (DbgVariable *DV : ScopeVariables.lookup(Scope))
if (DIE *Variable = TheCU->constructVariableDIE(*DV,
Scope->isAbstractScope())) {
Children.push_back(Variable);
if (DV.isObjectPointer())
if (DV->isObjectPointer())
ObjectPointer = Variable;
}
for (LexicalScope *LS : Scope->getChildren())
@ -1120,33 +1121,32 @@ DbgVariable *DwarfDebug::findAbstractVariable(DIVariable &DV,
if (!Scope)
return NULL;
AbsDbgVariable = &addScopeVariable(Scope, DbgVariable(Var, NULL, this));
AbsDbgVariable = new DbgVariable(Var, NULL, this);
addScopeVariable(Scope, AbsDbgVariable);
AbstractVariables[Var] = AbsDbgVariable;
return AbsDbgVariable;
}
// If Var is a current function argument then add it to CurrentFnArguments list.
DbgVariable *DwarfDebug::addCurrentFnArgument(DbgVariable &Var, LexicalScope *Scope) {
bool DwarfDebug::addCurrentFnArgument(DbgVariable *Var, LexicalScope *Scope) {
if (!LScopes.isCurrentFunctionScope(Scope))
return nullptr;
DIVariable DV = Var.getVariable();
return false;
DIVariable DV = Var->getVariable();
if (DV.getTag() != dwarf::DW_TAG_arg_variable)
return nullptr;
return false;
unsigned ArgNo = DV.getArgNumber();
if (ArgNo == 0)
return nullptr;
return false;
auto I = CurrentFnArguments.begin();
for (; I != CurrentFnArguments.end(); ++I)
if (ArgNo < I->getVariable().getArgNumber())
break;
return &*CurrentFnArguments.insert(I, std::move(Var));
}
DbgVariable &DwarfDebug::addVariable(DbgVariable Var, LexicalScope *Scope) {
if (DbgVariable *Res = addCurrentFnArgument(Var, Scope))
return *Res;
return addScopeVariable(Scope, std::move(Var));
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);
CurrentFnArguments[ArgNo - 1] = Var;
return true;
}
// Collect variable information from side table maintained by MMI.
@ -1164,9 +1164,10 @@ void DwarfDebug::collectVariableInfoFromMMITable(
continue;
DbgVariable *AbsDbgVariable = findAbstractVariable(DV, VI.Loc);
DbgVariable RegVar(DV, AbsDbgVariable, this);
RegVar.setFrameIndex(VI.Slot);
addVariable(std::move(RegVar), Scope);
DbgVariable *RegVar = new DbgVariable(DV, AbsDbgVariable, this);
RegVar->setFrameIndex(VI.Slot);
if (!addCurrentFnArgument(RegVar, Scope))
addScopeVariable(Scope, RegVar);
if (AbsDbgVariable)
AbsDbgVariable->setFrameIndex(VI.Slot);
}
@ -1247,19 +1248,21 @@ DwarfDebug::collectVariableInfo(SmallPtrSet<const MDNode *, 16> &Processed) {
Processed.insert(DV);
assert(MInsn->isDebugValue() && "History must begin with debug value");
DbgVariable *AbsVar = findAbstractVariable(DV, MInsn->getDebugLoc());
DbgVariable &RegVar = addVariable(DbgVariable(DV, AbsVar, this), Scope);
DbgVariable *RegVar = new DbgVariable(DV, AbsVar, this);
if (!addCurrentFnArgument(RegVar, Scope))
addScopeVariable(Scope, RegVar);
if (AbsVar)
AbsVar->setMInsn(MInsn);
// Simplify ranges that are fully coalesced.
if (History.size() <= 1 ||
(History.size() == 2 && MInsn->isIdenticalTo(History.back()))) {
RegVar.setMInsn(MInsn);
RegVar->setMInsn(MInsn);
continue;
}
// Handle multiple DBG_VALUE instructions describing one variable.
RegVar.setDotDebugLocOffset(DotDebugLocEntries.size());
RegVar->setDotDebugLocOffset(DotDebugLocEntries.size());
DotDebugLocEntries.resize(DotDebugLocEntries.size() + 1);
DebugLocList &LocList = DotDebugLocEntries.back();
@ -1317,7 +1320,7 @@ DwarfDebug::collectVariableInfo(SmallPtrSet<const MDNode *, 16> &Processed) {
if (!DV || !DV.isVariable() || !Processed.insert(DV))
continue;
if (LexicalScope *Scope = LScopes.findLexicalScope(DV.getContext()))
addScopeVariable(Scope, DbgVariable(DV, NULL, this));
addScopeVariable(Scope, new DbgVariable(DV, NULL, this));
}
}
@ -1624,9 +1627,9 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) {
}
}
DbgVariable &DwarfDebug::addScopeVariable(LexicalScope *LS, DbgVariable Var) {
auto &Vars = ScopeVariables[LS];
DIVariable DV = Var.getVariable();
void DwarfDebug::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
@ -1636,9 +1639,9 @@ DbgVariable &DwarfDebug::addScopeVariable(LexicalScope *LS, DbgVariable Var) {
// 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();
SmallVectorImpl<DbgVariable *>::iterator I = Vars.begin();
while (I != Vars.end()) {
unsigned CurNum = I->getVariable().getArgNumber();
unsigned CurNum = (*I)->getVariable().getArgNumber();
// A local (non-parameter) variable has been found, insert immediately
// before it.
if (CurNum == 0)
@ -1648,11 +1651,11 @@ DbgVariable &DwarfDebug::addScopeVariable(LexicalScope *LS, DbgVariable Var) {
break;
++I;
}
return *Vars.insert(I, std::move(Var));
Vars.insert(I, Var);
return;
}
Vars.push_back(std::move(Var));
return Vars.back();
Vars.push_back(Var);
}
// Gather and emit post-function debug information.
@ -1708,7 +1711,7 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
if (AbstractVariables.lookup(CleanDV))
continue;
if (LexicalScope *Scope = LScopes.findAbstractScope(DV.getContext()))
addScopeVariable(Scope, DbgVariable(DV, NULL, this));
addScopeVariable(Scope, new DbgVariable(DV, NULL, this));
}
}
if (ProcessedSPNodes.count(AScope->getScopeNode()) == 0)
@ -1726,8 +1729,10 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
PrevCU = TheCU;
// Clear debug info
for (auto &I : ScopeVariables)
DeleteContainerPointers(I.second);
ScopeVariables.clear();
CurrentFnArguments.clear();
DeleteContainerPointers(CurrentFnArguments);
UserVariables.clear();
DbgValues.clear();
AbstractVariables.clear();
@ -2466,7 +2471,7 @@ void DwarfDebug::emitDebugARanges() {
// Build a set of address spans, sorted by CU.
for (const MCSection *Section : Sections) {
auto &List = SectionMap[Section];
SmallVector<SymbolCU, 8> &List = SectionMap[Section];
if (List.size() < 2)
continue;

View File

@ -30,8 +30,6 @@
#include "llvm/MC/MCDwarf.h"
#include "llvm/Support/Allocator.h"
#include <list>
namespace llvm {
class AsmPrinter;
@ -276,9 +274,7 @@ class DwarfDebug : public AsmPrinterHandler {
SectionMapType SectionMap;
// List of arguments for current function.
// Linked list use to maintain pointer validity. Singly linked list could
// suffice with some contortions to addCurrentFnArgument.
std::list<DbgVariable> CurrentFnArguments;
SmallVector<DbgVariable *, 8> CurrentFnArguments;
LexicalScopes LScopes;
@ -286,9 +282,7 @@ class DwarfDebug : public AsmPrinterHandler {
DenseMap<const MDNode *, DIE *> AbstractSPDies;
// Collection of dbg variables of a scope.
// Linked list use to maintain pointer validity. Singly linked list could
// suffice with some contortions to addScopeVariable.
typedef DenseMap<LexicalScope *, std::list<DbgVariable>>
typedef DenseMap<LexicalScope *, SmallVector<DbgVariable *, 8> >
ScopeVariablesMap;
ScopeVariablesMap ScopeVariables;
@ -419,7 +413,7 @@ class DwarfDebug : public AsmPrinterHandler {
MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
DbgVariable &addScopeVariable(LexicalScope *LS, DbgVariable Var);
void addScopeVariable(LexicalScope *LS, DbgVariable *Var);
const SmallVectorImpl<DwarfUnit *> &getUnits() {
return InfoHolder.getUnits();
@ -597,9 +591,7 @@ class DwarfDebug : public AsmPrinterHandler {
/// \brief If Var is an current function argument that add it in
/// CurrentFnArguments list.
DbgVariable *addCurrentFnArgument(DbgVariable &Var, LexicalScope *Scope);
DbgVariable &addVariable(DbgVariable Var, LexicalScope *Scope);
bool addCurrentFnArgument(DbgVariable *Var, LexicalScope *Scope);
/// \brief Populate LexicalScope entries with variables' info.
void collectVariableInfo(SmallPtrSet<const MDNode *, 16> &ProcessedVars);