[PATCH] D38830: [DWARF] Fix bad comparator in sortGlobalExprs.
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 12 13:54:26 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315619: [DWARF] Fix bad comparator in sortGlobalExprs. (authored by efriedma).
Changed prior to commit:
https://reviews.llvm.org/D38830?vs=118725&id=118841#toc
Repository:
rL LLVM
https://reviews.llvm.org/D38830
Files:
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
Index: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -543,13 +543,18 @@
sortGlobalExprs(SmallVectorImpl<DwarfCompileUnit::GlobalExpr> &GVEs) {
std::sort(GVEs.begin(), GVEs.end(),
[](DwarfCompileUnit::GlobalExpr A, DwarfCompileUnit::GlobalExpr B) {
- if (A.Expr != B.Expr && A.Expr && B.Expr) {
- auto FragmentA = A.Expr->getFragmentInfo();
- auto FragmentB = B.Expr->getFragmentInfo();
- if (FragmentA && FragmentB)
- return FragmentA->OffsetInBits < FragmentB->OffsetInBits;
- }
- return false;
+ // Sort order: first null exprs, then exprs without fragment
+ // info, then sort by fragment offset in bits.
+ // FIXME: Come up with a more comprehensive comparator so
+ // the sorting isn't non-deterministic, and so the following
+ // std::unique call works correctly.
+ if (!A.Expr || !B.Expr)
+ return !!B.Expr;
+ auto FragmentA = A.Expr->getFragmentInfo();
+ auto FragmentB = B.Expr->getFragmentInfo();
+ if (!FragmentA || !FragmentB)
+ return !!FragmentB;
+ return FragmentA->OffsetInBits < FragmentB->OffsetInBits;
});
GVEs.erase(std::unique(GVEs.begin(), GVEs.end(),
[](DwarfCompileUnit::GlobalExpr A,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38830.118841.patch
Type: text/x-patch
Size: 1609 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171012/09954d0b/attachment.bin>
More information about the llvm-commits
mailing list