From 30672d90861ba7b94fdab3ba171b836552d4ed43 Mon Sep 17 00:00:00 2001 From: Yuchen Wu Date: Tue, 5 Nov 2013 01:11:58 +0000 Subject: 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. llvm-svn: 194033 --- llvm/lib/IR/GCOV.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'llvm/lib/IR/GCOV.cpp') diff --git a/llvm/lib/IR/GCOV.cpp b/llvm/lib/IR/GCOV.cpp index 794ead9e71f..a33da2a5525 100644 --- a/llvm/lib/IR/GCOV.cpp +++ b/llvm/lib/IR/GCOV.cpp @@ -59,8 +59,18 @@ bool GCOVFile::read(GCOVBuffer &Buffer) { (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 @@ void GCOVFile::collectLineCounts(FileInfo &FI) { for (SmallVectorImpl::iterator I = Functions.begin(), E = Functions.end(); I != E; ++I) (*I)->collectLineCounts(FI); + FI.setRunCount(RunCount); FI.setProgramCount(ProgramCount); } @@ -258,6 +269,7 @@ void FileInfo::print(raw_fd_ostream &OS, StringRef gcnoFile, 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 Buff; -- cgit v1.2.3