[PATCH] D113864: Don't add irrelevant items to queue in DwarfCompileUnit::createScopeChildrenDIE (NFC)

Aaron Puchert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 14 14:31:29 PST 2021


aaronpuchert created this revision.
aaronpuchert added a reviewer: aprantl.
Herald added a subscriber: hiraditya.
aaronpuchert requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Instead of popping them and then immediately throwing them away, we can
just filter out globals and items in different scopes before adding them
to WorkList. Shouldn't change anything but keep the queue smaller.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113864

Files:
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp


Index: llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -980,9 +980,7 @@
     bool visitedAllDependencies = Item.getInt();
     WorkList.pop_back();
 
-    // Dependency is in a different lexical scope or a global.
-    if (!Var)
-      continue;
+    assert(Var);
 
     // Already handled.
     if (Visited.count(Var))
@@ -1006,8 +1004,10 @@
     // visited again after all of its dependencies are handled.
     WorkList.push_back({Var, 1});
     for (auto *Dependency : dependencies(Var)) {
-      auto Dep = dyn_cast_or_null<const DILocalVariable>(Dependency);
-      WorkList.push_back({DbgVar[Dep], 0});
+      // Don't add dependency if it is in a different lexical scope or a global.
+      if (const auto *Dep = dyn_cast<const DILocalVariable>(Dependency))
+        if (DbgVariable *Var = DbgVar[Dep])
+          WorkList.push_back({Var, 0});
     }
   }
   return Result;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113864.387134.patch
Type: text/x-patch
Size: 1059 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211114/c294df1b/attachment.bin>


More information about the llvm-commits mailing list