[llvm] r357054 - [DWARF] Add D to Seen early to avoid duplicate elements in Worklist
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 27 02:38:06 PDT 2019
Author: maskray
Date: Wed Mar 27 02:38:05 2019
New Revision: 357054
URL: http://llvm.org/viewvc/llvm-project?rev=357054&view=rev
Log:
[DWARF] Add D to Seen early to avoid duplicate elements in Worklist
Modified:
llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp?rev=357054&r1=357053&r2=357054&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp Wed Mar 27 02:38:05 2019
@@ -396,6 +396,7 @@ DWARFDie::findRecursively(ArrayRef<dwarf
// DWARF. This corresponds to following the DW_AT_abstract_origin and
// DW_AT_specification just once.
SmallSet<DWARFDie, 3> Seen;
+ Seen.insert(*this);
while (!Worklist.empty()) {
DWARFDie Die = Worklist.back();
@@ -404,19 +405,16 @@ DWARFDie::findRecursively(ArrayRef<dwarf
if (!Die.isValid())
continue;
- if (Seen.count(Die))
- continue;
-
- Seen.insert(Die);
-
if (auto Value = Die.find(Attrs))
return Value;
if (auto D = Die.getAttributeValueAsReferencedDie(DW_AT_abstract_origin))
- Worklist.push_back(D);
+ if (Seen.insert(D).second)
+ Worklist.push_back(D);
if (auto D = Die.getAttributeValueAsReferencedDie(DW_AT_specification))
- Worklist.push_back(D);
+ if (Seen.insert(D).second)
+ Worklist.push_back(D);
}
return None;
More information about the llvm-commits
mailing list