mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
Debug Info: simplify parameter ordering preservation
Seems we emit the parameter ordering number (spuriously named 'arg number') in the debug info, so there's no need to search through the variable list to figure out the parameter ordering. This implementation does 'always' do the work, even in non-optimized debug info (the previous implementation checked the existence of the 'variables' list on the subprogram which is only present in optimized builds). No intended functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183446 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5bf5b96c2b
commit
b20fdff6fe
@ -1628,32 +1628,28 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) {
|
|||||||
void DwarfDebug::addScopeVariable(LexicalScope *LS, DbgVariable *Var) {
|
void DwarfDebug::addScopeVariable(LexicalScope *LS, DbgVariable *Var) {
|
||||||
SmallVectorImpl<DbgVariable *> &Vars = ScopeVariables[LS];
|
SmallVectorImpl<DbgVariable *> &Vars = ScopeVariables[LS];
|
||||||
DIVariable DV = Var->getVariable();
|
DIVariable DV = Var->getVariable();
|
||||||
if (DV.getTag() == dwarf::DW_TAG_arg_variable) {
|
// Variables with positive arg numbers are parameters.
|
||||||
DISubprogram Ctxt(DV.getContext());
|
if (unsigned ArgNum = DV.getArgNumber()) {
|
||||||
DIArray Variables = Ctxt.getVariables();
|
// Keep all parameters in order at the start of the variable list to ensure
|
||||||
// If the variable is a parameter (arg_variable) and this is an optimized
|
// function types are correct (no out-of-order parameters)
|
||||||
// build (the subprogram has a 'variables' list) make sure we keep the
|
//
|
||||||
// parameters in order. Otherwise we would produce an incorrect function
|
// This could be improved by only doing it for optimized builds (unoptimized
|
||||||
// type with parameters out of order if function parameters were used out of
|
// builds have the right order to begin with), searching from the back (this
|
||||||
// order or unused (see the call to addScopeVariable in endFunction where
|
// would catch the unoptimized case quickly), or doing a binary search
|
||||||
// the remaining unused variables (including parameters) are added).
|
// rather than linear search.
|
||||||
if (unsigned NumVariables = Variables.getNumElements()) {
|
SmallVectorImpl<DbgVariable *>::iterator I = Vars.begin();
|
||||||
// Keep the parameters at the start of the variables list. Search through
|
while (I != Vars.end()) {
|
||||||
// current variable list (Vars) and the full function variable list in
|
unsigned CurNum = (*I)->getVariable().getArgNumber();
|
||||||
// lock-step looking for this parameter in the full list to find the
|
// A local (non-parameter) variable has been found, insert immediately
|
||||||
// insertion point.
|
// before it.
|
||||||
SmallVectorImpl<DbgVariable *>::iterator I = Vars.begin();
|
if (CurNum == 0)
|
||||||
unsigned j = 0;
|
break;
|
||||||
while (I != Vars.end() && j != NumVariables &&
|
// A later indexed parameter has been found, insert immediately before it.
|
||||||
Variables.getElement(j) != DV &&
|
if (CurNum < ArgNum)
|
||||||
(*I)->getVariable().getTag() == dwarf::DW_TAG_arg_variable) {
|
break;
|
||||||
if (Variables.getElement(j) == (*I)->getVariable())
|
|
||||||
++I;
|
|
||||||
++j;
|
|
||||||
}
|
|
||||||
Vars.insert(I, Var);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
Vars.insert(I, Var);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vars.push_back(Var);
|
Vars.push_back(Var);
|
||||||
|
Loading…
Reference in New Issue
Block a user