llvm-cov: Fixed some bugs related to file checksum.

Added call to update CfgChecksum. Made FileChecksum a vector, separate
for each source file.

llvm-svn: 195309
This commit is contained in:
Yuchen Wu 2013-11-21 04:01:05 +00:00
parent dbfa25a6b6
commit d218a85f8c

View File

@ -136,7 +136,7 @@ namespace {
// Reversed, NUL-terminated copy of Options.Version.
char ReversedVersion[5];
// Checksum, produced by hash of EdgeDestinations
uint32_t FileChecksum;
SmallVector<uint32_t, 4> FileChecksums;
Module *M;
LLVMContext *Ctx;
@ -498,14 +498,17 @@ void GCOVProfiler::emitProfileNotes() {
EdgeDestinations += Func->getEdgeDestinations();
}
FileChecksum = hash_value(EdgeDestinations);
FileChecksums.push_back(hash_value(EdgeDestinations));
out.write("oncg", 4);
out.write(ReversedVersion, 4);
out.write(reinterpret_cast<char*>(&FileChecksum), 4);
out.write(reinterpret_cast<char*>(&FileChecksums.back()), 4);
for (SmallVectorImpl<GCOVFunction *>::iterator I = Funcs.begin(),
E = Funcs.end(); I != E; ++I)
(*I)->writeOut();
E = Funcs.end(); I != E; ++I) {
GCOVFunction *Func = *I;
Func->setCfgChecksum(FileChecksums.back());
Func->writeOut();
}
out.write("\0\0\0\0\0\0\0\0", 8); // EOF
out.close();
@ -803,7 +806,7 @@ Function *GCOVProfiler::insertCounterWriteout(
Builder.CreateCall3(StartFile,
Builder.CreateGlobalStringPtr(FilenameGcda),
Builder.CreateGlobalStringPtr(ReversedVersion),
Builder.getInt32(FileChecksum));
Builder.getInt32(FileChecksums[i]));
for (unsigned j = 0, e = CountersBySP.size(); j != e; ++j) {
DISubprogram SP(CountersBySP[j].second);
Builder.CreateCall4(
@ -812,7 +815,7 @@ Function *GCOVProfiler::insertCounterWriteout(
Builder.CreateGlobalStringPtr(getFunctionName(SP)) :
Constant::getNullValue(Builder.getInt8PtrTy()),
Builder.getInt8(Options.UseCfgChecksum),
Builder.getInt32(FileChecksum));
Builder.getInt32(FileChecksums[i]));
GlobalVariable *GV = CountersBySP[j].first;
unsigned Arcs =