mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-12 13:38:21 +00:00
DebugInfo: Sink DwarfDebug::addNonArgumentScopeVariable into DwarfFile.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220520 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -770,7 +770,7 @@ DbgVariable *DwarfDebug::getExistingAbstractVariable(const DIVariable &DV) {
|
|||||||
void DwarfDebug::createAbstractVariable(const DIVariable &Var,
|
void DwarfDebug::createAbstractVariable(const DIVariable &Var,
|
||||||
LexicalScope *Scope) {
|
LexicalScope *Scope) {
|
||||||
auto AbsDbgVariable = make_unique<DbgVariable>(Var, DIExpression(), this);
|
auto AbsDbgVariable = make_unique<DbgVariable>(Var, DIExpression(), this);
|
||||||
addNonArgumentScopeVariable(Scope, AbsDbgVariable.get());
|
InfoHolder.addNonArgumentScopeVariable(Scope, AbsDbgVariable.get());
|
||||||
AbstractVariables[Var] = std::move(AbsDbgVariable);
|
AbstractVariables[Var] = std::move(AbsDbgVariable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1256,39 +1256,7 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) {
|
|||||||
void DwarfDebug::addScopeVariable(LexicalScope *LS, DbgVariable *Var) {
|
void DwarfDebug::addScopeVariable(LexicalScope *LS, DbgVariable *Var) {
|
||||||
if (InfoHolder.addCurrentFnArgument(Var, LS))
|
if (InfoHolder.addCurrentFnArgument(Var, LS))
|
||||||
return;
|
return;
|
||||||
addNonArgumentScopeVariable(LS, Var);
|
InfoHolder.addNonArgumentScopeVariable(LS, Var);
|
||||||
}
|
|
||||||
|
|
||||||
void DwarfDebug::addNonArgumentScopeVariable(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.
|
|
||||||
SmallVectorImpl<DbgVariable *>::iterator 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;
|
|
||||||
++I;
|
|
||||||
}
|
|
||||||
Vars.insert(I, Var);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vars.push_back(Var);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gather and emit post-function debug information.
|
// Gather and emit post-function debug information.
|
||||||
|
@ -334,7 +334,6 @@ class DwarfDebug : public AsmPrinterHandler {
|
|||||||
MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
|
MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
|
||||||
|
|
||||||
void addScopeVariable(LexicalScope *LS, DbgVariable *Var);
|
void addScopeVariable(LexicalScope *LS, DbgVariable *Var);
|
||||||
void addNonArgumentScopeVariable(LexicalScope *LS, DbgVariable *Var);
|
|
||||||
|
|
||||||
const SmallVectorImpl<std::unique_ptr<DwarfUnit>> &getUnits() {
|
const SmallVectorImpl<std::unique_ptr<DwarfUnit>> &getUnits() {
|
||||||
return InfoHolder.getUnits();
|
return InfoHolder.getUnits();
|
||||||
|
@ -176,4 +176,36 @@ bool DwarfFile::addCurrentFnArgument(DbgVariable *Var, LexicalScope *Scope) {
|
|||||||
CurrentFnArguments[ArgNo - 1] = Var;
|
CurrentFnArguments[ArgNo - 1] = Var;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DwarfFile::addNonArgumentScopeVariable(LexicalScope *LS,
|
||||||
|
DbgVariable *Var) {
|
||||||
|
SmallVectorImpl<DbgVariable *> &Vars = DD.getScopeVariables()[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;
|
||||||
|
++I;
|
||||||
|
}
|
||||||
|
Vars.insert(I, Var);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vars.push_back(Var);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,6 +85,7 @@ public:
|
|||||||
DwarfStringPool &getStringPool() { return StrPool; }
|
DwarfStringPool &getStringPool() { return StrPool; }
|
||||||
|
|
||||||
bool addCurrentFnArgument(DbgVariable *Var, LexicalScope *Scope);
|
bool addCurrentFnArgument(DbgVariable *Var, LexicalScope *Scope);
|
||||||
|
void addNonArgumentScopeVariable(LexicalScope *LS, DbgVariable *Var);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user