aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2011-09-20 18:35:00 +0000
committerDevang Patel <dpatel@apple.com>2011-09-20 18:35:00 +0000
commit16c19a155c65fd41865562fe4e678ef32728510b (patch)
tree655a150639c3123f3b59ca7dfebb9231767fdc8c
parentf34fa6f34e52ff86ec3caf601c1cb18e3f60da50 (diff)
downloadexternal_llvm-16c19a155c65fd41865562fe4e678ef32728510b.zip
external_llvm-16c19a155c65fd41865562fe4e678ef32728510b.tar.gz
external_llvm-16c19a155c65fd41865562fe4e678ef32728510b.tar.bz2
Update GCOVLines to provide interfaces to write line table and calculate complete length.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140167 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Instrumentation/GCOVProfiling.cpp30
1 files changed, 17 insertions, 13 deletions
diff --git a/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/lib/Transforms/Instrumentation/GCOVProfiling.cpp
index 250489b..acc36f0 100644
--- a/lib/Transforms/Instrumentation/GCOVProfiling.cpp
+++ b/lib/Transforms/Instrumentation/GCOVProfiling.cpp
@@ -158,7 +158,8 @@ namespace {
class GCOVBlock;
// Constructed only by requesting it from a GCOVBlock, this object stores a
- // list of line numbers representing lines that belong to the block.
+ // list of line numbers and a single filename, representing lines that belong
+ // to the block.
class GCOVLines : public GCOVRecord {
public:
void addLine(uint32_t Line) {
@@ -166,17 +167,25 @@ namespace {
}
uint32_t length() {
- // FIXME: ??? What is the significance of 2 here ?
- return 2 + Lines.size();
+ // Here 2 = 1 for string lenght + 1 for '0' id#.
+ return lengthOfGCOVString(Filename) + 2 + Lines.size();
}
+ void writeOut() {
+ write(0);
+ writeGCOVString(Filename);
+ for (int i = 0, e = Lines.size(); i != e; ++i)
+ write(Lines[i]);
+ }
private:
friend class GCOVBlock;
- GCOVLines(raw_ostream *os) {
+ GCOVLines(StringRef F, raw_ostream *os)
+ : Filename(F) {
this->os = os;
}
+ StringRef Filename;
SmallVector<uint32_t, 32> Lines;
};
@@ -188,7 +197,7 @@ namespace {
GCOVLines &getFile(StringRef Filename) {
GCOVLines *&Lines = LinesByFile[Filename];
if (!Lines) {
- Lines = new GCOVLines(os);
+ Lines = new GCOVLines(Filename, os);
}
return *Lines;
}
@@ -201,20 +210,15 @@ namespace {
uint32_t Len = 3;
for (StringMap<GCOVLines *>::iterator I = LinesByFile.begin(),
E = LinesByFile.end(); I != E; ++I) {
- Len = Len + lengthOfGCOVString(I->first()) + I->second->length();
+ Len += I->second->length();
}
writeBytes(LinesTag, 4);
write(Len);
write(Number);
for (StringMap<GCOVLines *>::iterator I = LinesByFile.begin(),
- E = LinesByFile.end(); I != E; ++I) {
- write(0);
- writeGCOVString(I->first());
- for (int i = 0, e = I->second->Lines.size(); i != e; ++i) {
- write(I->second->Lines[i]);
- }
- }
+ E = LinesByFile.end(); I != E; ++I)
+ I->second->writeOut();
write(0);
write(0);
}