Support for reading run counts in llvm-cov.
This patch enables llvm-cov to correctly output the run count stored in
the GCDA file. GCOVProfiling currently does not generate this
information, so the GCDA run data had to be hacked on from a GCDA file
generated by gcc. This is corrected by a subsequent patch.
With the run and program data included, both llvm-cov and gcov produced
the same output.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194033 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/IR/GCOV.cpp b/lib/IR/GCOV.cpp
index 794ead9..a33da2a 100644
--- a/lib/IR/GCOV.cpp
+++ b/lib/IR/GCOV.cpp
@@ -59,8 +59,18 @@
(void)ReadGCDA;
assert(ReadGCDA && ".gcda data does not match .gcno data");
}
- while (Buffer.readProgramTag())
+ if (Buffer.readObjectTag()) {
+ uint32_t Length = Buffer.readInt();
+ Buffer.readInt(); // checksum
+ Buffer.readInt(); // num
+ RunCount = Buffer.readInt();
+ Buffer.advanceCursor(Length-3);
+ }
+ while (Buffer.readProgramTag()) {
+ uint32_t Length = Buffer.readInt();
+ Buffer.advanceCursor(Length);
++ProgramCount;
+ }
}
return true;
@@ -79,6 +89,7 @@
for (SmallVectorImpl<GCOVFunction *>::iterator I = Functions.begin(),
E = Functions.end(); I != E; ++I)
(*I)->collectLineCounts(FI);
+ FI.setRunCount(RunCount);
FI.setProgramCount(ProgramCount);
}
@@ -258,6 +269,7 @@
OS << " -: 0:Source:" << Filename << "\n";
OS << " -: 0:Graph:" << gcnoFile << "\n";
OS << " -: 0:Data:" << gcdaFile << "\n";
+ OS << " -: 0:Runs:" << RunCount << "\n";
OS << " -: 0:Programs:" << ProgramCount << "\n";
LineCounts &L = LineInfo[Filename];
OwningPtr<MemoryBuffer> Buff;