[PATCH] D48899: [dsymutil] Convert recursion in lookForDIEsToKeep into worklist.
David Blaikie via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 9 14:45:03 PDT 2018
dblaikie added inline comments.
================
Comment at: llvm/tools/dsymutil/DwarfLinker.cpp:878-880
+ std::vector<DWARFDie> Children(Current.Die.begin(), Current.Die.end());
+ std::reverse(Children.begin(), Children.end());
+ for (auto Child : Children)
----------------
JDevlieghere wrote:
> friss wrote:
> > Can you use something like make_reverse_iterator to avoid copying the list?
> The iterator is a forward iterator (it uses getSibling to advance) so unfortunately not.
I think, maybe, getPreviousSibling could be implemented without great cost & this could be made into a bidirectional iterator? (looks like getSibling works by scanning forward in the list of DIEs until it finds another DIE with the same depth (or bailing out if it finds a DIE with a shallower depth) - the reverse search coudl be done the same way, I think?)
================
Comment at: llvm/tools/dsymutil/DwarfLinker.cpp:883-884
+ SmallVector<DWARFDie, 4> Children(Current.Die.begin(), Current.Die.end());
+ for (auto Child = Children.rbegin(), End = Children.rend(); Child != End;
+ ++Child)
+ Worklist.emplace_back(*Child, Current.Flags);
----------------
for (... : reverse(Children))
perhaps?
https://reviews.llvm.org/D48899
More information about the llvm-commits
mailing list