[llvm] r228083 - InstrProf: Use a stable sort when reading coverage regions

Justin Bogner mail at justinbogner.com
Tue Feb 3 16:12:18 PST 2015

Author: bogner
Date: Tue Feb  3 18:12:18 2015
New Revision: 228083

URL: http://llvm.org/viewvc/llvm-project?rev=228083&view=rev
InstrProf: Use a stable sort when reading coverage regions

Keeping regions that start at the same location in insertion order
makes this logic easier to test / more deterministic.


Modified: llvm/trunk/lib/ProfileData/CoverageMappingWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/CoverageMappingWriter.cpp?rev=228083&r1=228082&r2=228083&view=diff
--- llvm/trunk/lib/ProfileData/CoverageMappingWriter.cpp (original)
+++ llvm/trunk/lib/ProfileData/CoverageMappingWriter.cpp Tue Feb  3 18:12:18 2015
@@ -109,7 +109,7 @@ static void writeCounter(ArrayRef<Counte
 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);

More information about the llvm-commits mailing list