summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ProfileData
diff options
context:
space:
mode:
authorIgor Kudrin <ikudrin.dev@gmail.com>2016-08-31 07:01:17 +0000
committerIgor Kudrin <ikudrin.dev@gmail.com>2016-08-31 07:01:17 +0000
commitf3c8a9cfbba46ba2a4024794da38343af4dcb7ea (patch)
tree655a815760043009424e2eb7aaf37d0fa277bbf1 /llvm/lib/ProfileData
parenta815f488d5f6e878cc90736b2b5f4df59f0ec4aa (diff)
downloadbcm5719-llvm-f3c8a9cfbba46ba2a4024794da38343af4dcb7ea.tar.gz
bcm5719-llvm-f3c8a9cfbba46ba2a4024794da38343af4dcb7ea.zip
[Coverage] Make sorting criteria for CounterMappingRegions local.
Move the comparison function into the only place there it is used, i.e. the call to std::stable_sort in CoverageMappingWriter::write(). Add sorting by region kinds as it is required to ensure stable order in our tests and to simplify D23987. Differential Revision: https://reviews.llvm.org/D24034 llvm-svn: 280198
Diffstat (limited to 'llvm/lib/ProfileData')
-rw-r--r--llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp b/llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
index 8ff90d62cfd..82356333b93 100644
--- a/llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
+++ b/llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
@@ -108,8 +108,16 @@ static void writeCounter(ArrayRef<CounterExpression> Expressions, Counter C,
void CoverageMappingWriter::write(raw_ostream &OS) {
// Sort the regions in an ascending order by the file id and the starting
- // location.
- std::stable_sort(MappingRegions.begin(), MappingRegions.end());
+ // location. Sort by region kinds to ensure stable order for tests.
+ std::stable_sort(
+ MappingRegions.begin(), MappingRegions.end(),
+ [](const CounterMappingRegion &LHS, const CounterMappingRegion &RHS) {
+ if (LHS.FileID != RHS.FileID)
+ return LHS.FileID < RHS.FileID;
+ if (LHS.startLoc() != RHS.startLoc())
+ return LHS.startLoc() < RHS.startLoc();
+ return LHS.Kind < RHS.Kind;
+ });
// Write out the fileid -> filename mapping.
encodeULEB128(VirtualFileMapping.size(), OS);
OpenPOWER on IntegriCloud