diff options
author | Yuchen Wu <yuchenericwu@hotmail.com> | 2013-11-14 00:32:00 +0000 |
---|---|---|
committer | Yuchen Wu <yuchenericwu@hotmail.com> | 2013-11-14 00:32:00 +0000 |
commit | 131a764e0e7abc90b322fd568e042d3c5a0633af (patch) | |
tree | d5844b31868fa1b75acd086e89644bec44313af3 /lib/IR | |
parent | dbb51ff01fd08df39e5040c1cd9edacdc3e4308a (diff) | |
download | external_llvm-131a764e0e7abc90b322fd568e042d3c5a0633af.zip external_llvm-131a764e0e7abc90b322fd568e042d3c5a0633af.tar.gz external_llvm-131a764e0e7abc90b322fd568e042d3c5a0633af.tar.bz2 |
llvm-cov: Removed StringMap holding GCOVLines.
According to the hazy gcov documentation, it appeared to be technically
possible for lines within a block to belong to different source files.
However, upon further investigation, gcov does not actually support
multiple source files for a single block.
This change removes a level of separation between blocks and lines by
replacing the StringMap of GCOVLines with a SmallVector of ints
representing line numbers. This also means that the GCOVLines class is
no longer needed.
This paves the way for supporting the "-a" option, which will output
block information.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194637 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR')
-rw-r--r-- | lib/IR/GCOV.cpp | 54 |
1 files changed, 15 insertions, 39 deletions
diff --git a/lib/IR/GCOV.cpp b/lib/IR/GCOV.cpp index ba45d91..65ed3a5 100644 --- a/lib/IR/GCOV.cpp +++ b/lib/IR/GCOV.cpp @@ -161,7 +161,7 @@ bool GCOVFunction::read(GCOVBuffer &Buff, GCOV::GCOVFormat Format) { if (!Buff.readInt(BlockCount)) return false; for (uint32_t i = 0, e = BlockCount; i != e; ++i) { if (!Buff.readInt(Dummy)) return false; // Block flags; - Blocks.push_back(new GCOVBlock(i)); + Blocks.push_back(new GCOVBlock(*this, i)); } // read edges. @@ -197,14 +197,18 @@ bool GCOVFunction::read(GCOVBuffer &Buff, GCOV::GCOVFormat Format) { GCOVBlock *Block = Blocks[BlockNo]; if (!Buff.readInt(Dummy)) return false; // flag while (Buff.getCursor() != (EndPos - 4)) { - StringRef Filename; - if (!Buff.readString(Filename)) return false; + StringRef F; + if (!Buff.readString(F)) return false; + if (F != Filename) { + errs() << "Multiple sources for a single basic block.\n"; + return false; + } if (Buff.getCursor() == (EndPos - 4)) break; while (true) { uint32_t Line; if (!Buff.readInt(Line)) return false; if (!Line) break; - Block->addLine(Filename, Line); + Block->addLine(Line); } } if (!Buff.readInt(Dummy)) return false; // flag @@ -234,22 +238,15 @@ void GCOVFunction::collectLineCounts(FileInfo &FI) { /// ~GCOVBlock - Delete GCOVBlock and its content. GCOVBlock::~GCOVBlock() { Edges.clear(); - DeleteContainerSeconds(Lines); -} - -void GCOVBlock::addLine(StringRef Filename, uint32_t LineNo) { - GCOVLines *&LinesForFile = Lines[Filename]; - if (!LinesForFile) - LinesForFile = new GCOVLines(); - LinesForFile->add(LineNo); + Lines.clear(); } /// collectLineCounts - Collect line counts. This must be used after /// reading .gcno and .gcda files. void GCOVBlock::collectLineCounts(FileInfo &FI) { - for (StringMap<GCOVLines *>::iterator I = Lines.begin(), + for (SmallVectorImpl<uint32_t>::iterator I = Lines.begin(), E = Lines.end(); I != E; ++I) - I->second->collectLineCounts(FI, I->first(), Counter); + FI.addLineCount(Parent.getFilename(), *I, Counter); } /// dump - Dump GCOVBlock content to dbgs() for debugging purposes. @@ -264,35 +261,14 @@ void GCOVBlock::dump() { } if (!Lines.empty()) { dbgs() << "\tLines : "; - for (StringMap<GCOVLines *>::iterator LI = Lines.begin(), - LE = Lines.end(); LI != LE; ++LI) { - dbgs() << LI->first() << " -> "; - LI->second->dump(); - dbgs() << "\n"; - } + for (SmallVectorImpl<uint32_t>::iterator I = Lines.begin(), + E = Lines.end(); I != E; ++I) + dbgs() << (*I) << ","; + dbgs() << "\n"; } } //===----------------------------------------------------------------------===// -// GCOVLines implementation. - -/// collectLineCounts - Collect line counts. This must be used after -/// reading .gcno and .gcda files. -void GCOVLines::collectLineCounts(FileInfo &FI, StringRef Filename, - uint64_t Count) { - for (SmallVectorImpl<uint32_t>::iterator I = Lines.begin(), - E = Lines.end(); I != E; ++I) - FI.addLineCount(Filename, *I, Count); -} - -/// dump - Dump GCOVLines content to dbgs() for debugging purposes. -void GCOVLines::dump() { - for (SmallVectorImpl<uint32_t>::iterator I = Lines.begin(), - E = Lines.end(); I != E; ++I) - dbgs() << (*I) << ","; -} - -//===----------------------------------------------------------------------===// // FileInfo implementation. /// print - Print source files with collected line count information. |