DwarfDebug: Avoid an extra map lookup while constructing abstract scope DIEs and reduce nesting/conditionals.

One test case had to be updated as it still had the extra indirection
for the variable list - removing the extra indirection got it back to
passing.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208608 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie 2014-05-12 18:23:35 +00:00
parent d6cd0381f6
commit 9f84cecfdc
2 changed files with 21 additions and 21 deletions

View File

@ -576,7 +576,8 @@ void DwarfDebug::constructAbstractSubprogramScopeDIE(DwarfCompileUnit &TheCU,
DISubprogram Sub(Scope->getScopeNode()); DISubprogram Sub(Scope->getScopeNode());
ProcessedSPNodes.insert(Sub); if (!ProcessedSPNodes.insert(Sub))
return;
if (DIE *ScopeDIE = TheCU.getDIE(Sub)) { if (DIE *ScopeDIE = TheCU.getDIE(Sub)) {
AbstractSPDies.insert(std::make_pair(Sub, ScopeDIE)); AbstractSPDies.insert(std::make_pair(Sub, ScopeDIE));
@ -1575,25 +1576,25 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
// Construct abstract scopes. // Construct abstract scopes.
for (LexicalScope *AScope : LScopes.getAbstractScopesList()) { for (LexicalScope *AScope : LScopes.getAbstractScopesList()) {
DISubprogram SP(AScope->getScopeNode()); DISubprogram SP(AScope->getScopeNode());
if (SP.isSubprogram()) { if (!SP.isSubprogram())
// Collect info for variables that were optimized out. continue;
DIArray Variables = SP.getVariables(); // Collect info for variables that were optimized out.
for (unsigned i = 0, e = Variables.getNumElements(); i != e; ++i) { DIArray Variables = SP.getVariables();
DIVariable DV(Variables.getElement(i)); for (unsigned i = 0, e = Variables.getNumElements(); i != e; ++i) {
if (!DV || !DV.isVariable() || !ProcessedVars.insert(DV)) DIVariable DV(Variables.getElement(i));
continue; assert(DV && DV.isVariable());
// Check that DbgVariable for DV wasn't created earlier, when if (!ProcessedVars.insert(DV))
// findAbstractVariable() was called for inlined instance of DV. continue;
LLVMContext &Ctx = DV->getContext(); // Check that DbgVariable for DV wasn't created earlier, when
DIVariable CleanDV = cleanseInlinedVariable(DV, Ctx); // findAbstractVariable() was called for inlined instance of DV.
if (AbstractVariables.lookup(CleanDV)) LLVMContext &Ctx = DV->getContext();
continue; DIVariable CleanDV = cleanseInlinedVariable(DV, Ctx);
if (LexicalScope *Scope = LScopes.findAbstractScope(DV.getContext())) if (AbstractVariables.lookup(CleanDV))
addScopeVariable(Scope, new DbgVariable(DV, nullptr, this)); continue;
} if (LexicalScope *Scope = LScopes.findAbstractScope(DV.getContext()))
addScopeVariable(Scope, new DbgVariable(DV, nullptr, this));
} }
if (ProcessedSPNodes.count(AScope->getScopeNode()) == 0) constructAbstractSubprogramScopeDIE(TheCU, AScope);
constructAbstractSubprogramScopeDIE(TheCU, AScope);
} }
DIE &CurFnDIE = constructSubprogramScopeDIE(TheCU, FnScope); DIE &CurFnDIE = constructSubprogramScopeDIE(TheCU, FnScope);

View File

@ -30,8 +30,7 @@ declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
!10 = metadata !{i32 786478, metadata !26, metadata !6, metadata !"f", metadata !"f", metadata !"_ZL1fi", i32 3, metadata !11, i1 true, i1 true, i32 0, i32 0, null, i32 256, i1 true, null, null, null, metadata !13, i32 3} ; [ DW_TAG_subprogram ] !10 = metadata !{i32 786478, metadata !26, metadata !6, metadata !"f", metadata !"f", metadata !"_ZL1fi", i32 3, metadata !11, i1 true, i1 true, i32 0, i32 0, null, i32 256, i1 true, null, null, null, metadata !13, i32 3} ; [ DW_TAG_subprogram ]
!11 = metadata !{i32 786453, null, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !12, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] !11 = metadata !{i32 786453, null, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !12, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
!12 = metadata !{metadata !9, metadata !9} !12 = metadata !{metadata !9, metadata !9}
!13 = metadata !{metadata !14} !13 = metadata !{metadata !15, metadata !16}
!14 = metadata !{metadata !15, metadata !16}
!15 = metadata !{i32 786689, metadata !10, metadata !"argument", metadata !6, i32 16777219, metadata !9, i32 0, i32 0} ; [ DW_TAG_arg_variable ] !15 = metadata !{i32 786689, metadata !10, metadata !"argument", metadata !6, i32 16777219, metadata !9, i32 0, i32 0} ; [ DW_TAG_arg_variable ]
; Two DW_TAG_formal_parameter: one abstract and one inlined. ; Two DW_TAG_formal_parameter: one abstract and one inlined.