mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Do not emit empty DW_TAG_lexical_block DIEs. In one test case, size of debug info reduced by almost 7%.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126009 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
fe19e3f74c
commit
5bc9fec7ec
@ -1800,6 +1800,16 @@ DIE *DwarfDebug::constructScopeDIE(DbgScope *Scope) {
|
|||||||
if (!Scope || !Scope->getScopeNode())
|
if (!Scope || !Scope->getScopeNode())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
SmallVector <DIE *, 8> Children;
|
||||||
|
// Collect lexical scope childrens first.
|
||||||
|
const SmallVector<DbgVariable *, 8> &Variables = Scope->getDbgVariables();
|
||||||
|
for (unsigned i = 0, N = Variables.size(); i < N; ++i)
|
||||||
|
if (DIE *Variable = constructVariableDIE(Variables[i], Scope))
|
||||||
|
Children.push_back(Variable);
|
||||||
|
const SmallVector<DbgScope *, 4> &Scopes = Scope->getScopes();
|
||||||
|
for (unsigned j = 0, M = Scopes.size(); j < M; ++j)
|
||||||
|
if (DIE *Nested = constructScopeDIE(Scopes[j]))
|
||||||
|
Children.push_back(Nested);
|
||||||
DIScope DS(Scope->getScopeNode());
|
DIScope DS(Scope->getScopeNode());
|
||||||
DIE *ScopeDIE = NULL;
|
DIE *ScopeDIE = NULL;
|
||||||
if (Scope->getInlinedAt())
|
if (Scope->getInlinedAt())
|
||||||
@ -1815,26 +1825,19 @@ DIE *DwarfDebug::constructScopeDIE(DbgScope *Scope) {
|
|||||||
else
|
else
|
||||||
ScopeDIE = updateSubprogramScopeDIE(DS);
|
ScopeDIE = updateSubprogramScopeDIE(DS);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
|
// There is no need to emit empty lexical block DIE.
|
||||||
|
if (Children.empty())
|
||||||
|
return NULL;
|
||||||
ScopeDIE = constructLexicalScopeDIE(Scope);
|
ScopeDIE = constructLexicalScopeDIE(Scope);
|
||||||
|
}
|
||||||
|
|
||||||
if (!ScopeDIE) return NULL;
|
if (!ScopeDIE) return NULL;
|
||||||
|
|
||||||
// Add variables to scope.
|
// Add children
|
||||||
const SmallVector<DbgVariable *, 8> &Variables = Scope->getDbgVariables();
|
for (SmallVector<DIE *, 8>::iterator I = Children.begin(),
|
||||||
for (unsigned i = 0, N = Variables.size(); i < N; ++i) {
|
E = Children.end(); I != E; ++I)
|
||||||
DIE *VariableDIE = constructVariableDIE(Variables[i], Scope);
|
ScopeDIE->addChild(*I);
|
||||||
if (VariableDIE)
|
|
||||||
ScopeDIE->addChild(VariableDIE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add nested scopes.
|
|
||||||
const SmallVector<DbgScope *, 4> &Scopes = Scope->getScopes();
|
|
||||||
for (unsigned j = 0, M = Scopes.size(); j < M; ++j) {
|
|
||||||
// Define the Scope debug information entry.
|
|
||||||
DIE *NestedDIE = constructScopeDIE(Scopes[j]);
|
|
||||||
if (NestedDIE)
|
|
||||||
ScopeDIE->addChild(NestedDIE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DS.isSubprogram())
|
if (DS.isSubprogram())
|
||||||
addPubTypes(DISubprogram(DS));
|
addPubTypes(DISubprogram(DS));
|
||||||
|
Loading…
Reference in New Issue
Block a user