[llvm] r208608 - DwarfDebug: Avoid an extra map lookup while constructing abstract scope DIEs and reduce nesting/conditionals.

David Blaikie dblaikie at gmail.com
Mon May 12 11:23:35 PDT 2014


Author: dblaikie
Date: Mon May 12 13:23:35 2014
New Revision: 208608

URL: http://llvm.org/viewvc/llvm-project?rev=208608&view=rev
Log:
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.

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    llvm/trunk/test/DebugInfo/inlined-vars.ll

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=208608&r1=208607&r2=208608&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon May 12 13:23:35 2014
@@ -576,7 +576,8 @@ void DwarfDebug::constructAbstractSubpro
 
   DISubprogram Sub(Scope->getScopeNode());
 
-  ProcessedSPNodes.insert(Sub);
+  if (!ProcessedSPNodes.insert(Sub))
+    return;
 
   if (DIE *ScopeDIE = TheCU.getDIE(Sub)) {
     AbstractSPDies.insert(std::make_pair(Sub, ScopeDIE));
@@ -1575,25 +1576,25 @@ void DwarfDebug::endFunction(const Machi
   // Construct abstract scopes.
   for (LexicalScope *AScope : LScopes.getAbstractScopesList()) {
     DISubprogram SP(AScope->getScopeNode());
-    if (SP.isSubprogram()) {
-      // Collect info for variables that were optimized out.
-      DIArray Variables = SP.getVariables();
-      for (unsigned i = 0, e = Variables.getNumElements(); i != e; ++i) {
-        DIVariable DV(Variables.getElement(i));
-        if (!DV || !DV.isVariable() || !ProcessedVars.insert(DV))
-          continue;
-        // Check that DbgVariable for DV wasn't created earlier, when
-        // findAbstractVariable() was called for inlined instance of DV.
-        LLVMContext &Ctx = DV->getContext();
-        DIVariable CleanDV = cleanseInlinedVariable(DV, Ctx);
-        if (AbstractVariables.lookup(CleanDV))
-          continue;
-        if (LexicalScope *Scope = LScopes.findAbstractScope(DV.getContext()))
-          addScopeVariable(Scope, new DbgVariable(DV, nullptr, this));
-      }
+    if (!SP.isSubprogram())
+      continue;
+    // Collect info for variables that were optimized out.
+    DIArray Variables = SP.getVariables();
+    for (unsigned i = 0, e = Variables.getNumElements(); i != e; ++i) {
+      DIVariable DV(Variables.getElement(i));
+      assert(DV && DV.isVariable());
+      if (!ProcessedVars.insert(DV))
+        continue;
+      // Check that DbgVariable for DV wasn't created earlier, when
+      // findAbstractVariable() was called for inlined instance of DV.
+      LLVMContext &Ctx = DV->getContext();
+      DIVariable CleanDV = cleanseInlinedVariable(DV, Ctx);
+      if (AbstractVariables.lookup(CleanDV))
+        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);

Modified: llvm/trunk/test/DebugInfo/inlined-vars.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/inlined-vars.ll?rev=208608&r1=208607&r2=208608&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/inlined-vars.ll (original)
+++ llvm/trunk/test/DebugInfo/inlined-vars.ll Mon May 12 13:23:35 2014
@@ -30,8 +30,7 @@ declare void @llvm.dbg.value(metadata, i
 !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 ]
 !12 = metadata !{metadata !9, metadata !9}
-!13 = metadata !{metadata !14}
-!14 = metadata !{metadata !15, metadata !16}
+!13 = 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 ]
 
 ; Two DW_TAG_formal_parameter: one abstract and one inlined.





More information about the llvm-commits mailing list