diff options
author | OCHyams <orlando.hyams@sony.com> | 2023-04-26 10:53:57 +0100 |
---|---|---|
committer | OCHyams <orlando.hyams@sony.com> | 2023-04-26 11:14:51 +0100 |
commit | b59d672ed489ddb3373db62be168bb0926c4f5f3 (patch) | |
tree | 1f8a2967a99235975cbdb8d7aa8ce2622b8e4e79 /llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp | |
parent | baafc74ab0bf95b650a8cd9b987ce50087b72121 (diff) | |
download | llvm-b59d672ed489ddb3373db62be168bb0926c4f5f3.zip llvm-b59d672ed489ddb3373db62be168bb0926c4f5f3.tar.gz llvm-b59d672ed489ddb3373db62be168bb0926c4f5f3.tar.bz2 |
[Assignment Tracking] Fix faulty assertion inside std::sort predicate
The vectors being sorted here shouldn't contain duplicate entries. Prior to
this patch this was checked with an assert within the `std::sort`
predicate. However, `std::sort` may compare an element against itself which
causes the assert to fire (false positive). Move the assert outside of the sort
predicate to avoid such issues.
Reviewed By: StephenTozer
Differential Revision: https://reviews.llvm.org/D149045
Diffstat (limited to 'llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp b/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp index cd094d6..d5e133d 100644 --- a/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp +++ b/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp @@ -2011,16 +2011,17 @@ static AssignmentTrackingLowering::OverlapMap buildOverlapMapAndRecordDeclares( } } - // Sort the fragment map for each DebugAggregate in non-descending - // order of fragment size. Assert no entries are duplicates. + // Sort the fragment map for each DebugAggregate in ascending + // order of fragment size - there should be no duplicates. for (auto &Pair : FragmentMap) { SmallVector<DebugVariable, 8> &Frags = Pair.second; - std::sort( - Frags.begin(), Frags.end(), [](DebugVariable Next, DebugVariable Elmt) { - assert(!(Elmt.getFragmentOrDefault() == Next.getFragmentOrDefault())); - return Elmt.getFragmentOrDefault().SizeInBits > - Next.getFragmentOrDefault().SizeInBits; - }); + std::sort(Frags.begin(), Frags.end(), + [](const DebugVariable &Next, const DebugVariable &Elmt) { + return Elmt.getFragmentOrDefault().SizeInBits > + Next.getFragmentOrDefault().SizeInBits; + }); + // Check for duplicates. + assert(std::adjacent_find(Frags.begin(), Frags.end()) == Frags.end()); } // Build the map. |