[Lldb-commits] [PATCH] D72909: Make SymbolFileDWARF::ParseLineTable use std::sort instead of insertion sort

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Jan 21 05:17:42 PST 2020


labath added inline comments.


================
Comment at: lldb/source/Symbol/LineTable.cpp:27
+  LineTable::Entry::LessThanBinaryPredicate less_than_bp(this);
+  std::sort(sequences.begin(), sequences.end(), less_than_bp);
+  for (auto *sequence : sequences) {
----------------
teemperor wrote:
> grimar wrote:
> > I wonder if this have to be `std::stable_sort`?
> > For `std::sort` the order of equal elements is not guaranteed to be preserved.
> > 
> > nit: you could also probably use the `llvm::sort` (it would be a bit shorter):
> > `llvm::sort(sequences, less_than_bp);`
> I think we should change this to llvm::sort just because of the additional checks we get there (I think the shuffle/sort<->stable_sort checks are only in llvm::sort).
I've changed this to llvm::stable_sort in 9a52ea5cf9c. I went for a stable sort because it's possible (though probably not very useful) for the debug info to contain two line sequences for the same address (and I've just today found a flaky test due to nondeterminism in lldb).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72909/new/

https://reviews.llvm.org/D72909





More information about the lldb-commits mailing list