summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/GCOV.cpp
diff options
context:
space:
mode:
authorYuchen Wu <yuchenericwu@hotmail.com>2013-10-25 02:22:21 +0000
committerYuchen Wu <yuchenericwu@hotmail.com>2013-10-25 02:22:21 +0000
commit14ae8e6195ac01b02e663d3436fa82cb9b1e9cd0 (patch)
tree05dc9358f6a2078f8e4e581140f0b22402fc5640 /llvm/lib/IR/GCOV.cpp
parentb09388569655f44edd4a4282f3af316db2838a92 (diff)
downloadbcm5719-llvm-14ae8e6195ac01b02e663d3436fa82cb9b1e9cd0.tar.gz
bcm5719-llvm-14ae8e6195ac01b02e663d3436fa82cb9b1e9cd0.zip
Support for reading program counts in llvm-cov.
llvm-cov will now be able to read program counts from the GCDA file and output it in the same format as gcov. The program summary tag was identified from gcov-io.h as "\0\0\0\a3". There is currently a bug in GCOVProfiling.cpp which does not generate the run- or program-counting IR, so this change was tested manually by modifying the GCDA file and comparing the gcov and llvm-cov outputs. llvm-svn: 193389
Diffstat (limited to 'llvm/lib/IR/GCOV.cpp')
-rw-r--r--llvm/lib/IR/GCOV.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/llvm/lib/IR/GCOV.cpp b/llvm/lib/IR/GCOV.cpp
index 908523a3a66..fe8ebb2e9a2 100644
--- a/llvm/lib/IR/GCOV.cpp
+++ b/llvm/lib/IR/GCOV.cpp
@@ -44,21 +44,24 @@ bool GCOVFile::read(GCOVBuffer &Buffer) {
if (Format == GCOV::InvalidGCOV)
return false;
- unsigned i = 0;
- while (1) {
- GCOVFunction *GFun = NULL;
- if (isGCDAFile(Format)) {
- // Use existing function while reading .gcda file.
- assert(i < Functions.size() && ".gcda data does not match .gcno data");
- GFun = Functions[i];
- } else if (isGCNOFile(Format)) {
- GFun = new GCOVFunction();
+ if (isGCNOFile(Format)) {
+ while (true) {
+ GCOVFunction *GFun = new GCOVFunction();
+ if (!GFun->read(Buffer, Format))
+ break;
Functions.push_back(GFun);
}
- if (!GFun || !GFun->read(Buffer, Format))
- break;
- ++i;
}
+ else if (isGCDAFile(Format)) {
+ for (size_t i = 0, e = Functions.size(); i < e; ++i) {
+ bool ReadGCDA = Functions[i]->read(Buffer, Format);
+ (void)ReadGCDA;
+ assert(ReadGCDA && ".gcda data does not match .gcno data");
+ }
+ while (Buffer.readProgramTag())
+ ++ProgramCount;
+ }
+
return true;
}
@@ -75,6 +78,7 @@ void GCOVFile::collectLineCounts(FileInfo &FI) {
for (SmallVectorImpl<GCOVFunction *>::iterator I = Functions.begin(),
E = Functions.end(); I != E; ++I)
(*I)->collectLineCounts(FI);
+ FI.setProgramCount(ProgramCount);
}
//===----------------------------------------------------------------------===//
@@ -252,6 +256,7 @@ void FileInfo::print(StringRef gcnoFile, StringRef gcdaFile) {
outs() << " -: 0:Source:" << Filename << "\n";
outs() << " -: 0:Graph:" << gcnoFile << "\n";
outs() << " -: 0:Data:" << gcdaFile << "\n";
+ outs() << " -: 0:Programs:" << ProgramCount << "\n";
LineCounts &L = LineInfo[Filename];
OwningPtr<MemoryBuffer> Buff;
if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, Buff)) {
OpenPOWER on IntegriCloud