[llvm] b20da51 - Don't add irrelevant items to queue in DwarfCompileUnit::createScopeChildrenDIE (NFC)

Aaron Puchert via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 16 15:01:30 PST 2021


Author: Aaron Puchert
Date: 2021-11-17T00:01:20+01:00
New Revision: b20da5117fb66e7f9bcb56cb14af86dcafe2ee9a

URL: https://github.com/llvm/llvm-project/commit/b20da5117fb66e7f9bcb56cb14af86dcafe2ee9a
DIFF: https://github.com/llvm/llvm-project/commit/b20da5117fb66e7f9bcb56cb14af86dcafe2ee9a.diff

LOG: Don't add irrelevant items to queue in DwarfCompileUnit::createScopeChildrenDIE (NFC)

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.

Reviewed By: aprantl

Differential Revision: https://reviews.llvm.org/D113864

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index 5615245b99b5..922c91840520 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -980,9 +980,7 @@ sortLocalVars(SmallVectorImpl<DbgVariable *> &Input) {
     bool visitedAllDependencies = Item.getInt();
     WorkList.pop_back();
 
-    // Dependency is in a 
diff erent lexical scope or a global.
-    if (!Var)
-      continue;
+    assert(Var);
 
     // Already handled.
     if (Visited.count(Var))
@@ -1006,8 +1004,10 @@ sortLocalVars(SmallVectorImpl<DbgVariable *> &Input) {
     // 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 
diff erent lexical scope or a global.
+      if (const auto *Dep = dyn_cast<const DILocalVariable>(Dependency))
+        if (DbgVariable *Var = DbgVar.lookup(Dep))
+          WorkList.push_back({Var, 0});
     }
   }
   return Result;


        


More information about the llvm-commits mailing list