From b20da5117fb66e7f9bcb56cb14af86dcafe2ee9a Mon Sep 17 00:00:00 2001 From: Aaron Puchert Date: Tue, 16 Nov 2021 23:57:41 +0100 Subject: [PATCH] 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 --- llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 &Input) { 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 @@ sortLocalVars(SmallVectorImpl &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(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(Dependency)) + if (DbgVariable *Var = DbgVar.lookup(Dep)) + WorkList.push_back({Var, 0}); } } return Result;