InstrProf: Use a stable sort when reading coverage regions
authorJustin Bogner <mail@justinbogner.com>
Wed, 4 Feb 2015 00:12:18 +0000 (00:12 +0000)
committerJustin Bogner <mail@justinbogner.com>
Wed, 4 Feb 2015 00:12:18 +0000 (00:12 +0000)
Keeping regions that start at the same location in insertion order
makes this logic easier to test / more deterministic.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228083 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ProfileData/CoverageMappingWriter.cpp

index aef5511fc0e4ba7064deef0908d6201fb4b16397..d90d2f5651551f0a651209247a6123b00e4c4794 100644 (file)
@@ -109,7 +109,7 @@ 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::sort(MappingRegions.begin(), MappingRegions.end());
+  std::stable_sort(MappingRegions.begin(), MappingRegions.end());
 
   // Write out the fileid -> filename mapping.
   encodeULEB128(VirtualFileMapping.size(), OS);