[PGO] Fix a bug in InstProfWriter addRecord
[oota-llvm.git] / 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);