forked from OSchip/llvm-project
[gcov] Simplify/speed up CFG hash calculation
This commit is contained in:
parent
e97aa5609f
commit
fae221e7ad
|
@ -32,6 +32,7 @@
|
|||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/InitializePasses.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/Support/CRC.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/FileSystem.h"
|
||||
|
@ -300,15 +301,16 @@ namespace {
|
|||
assert(OutEdges.empty());
|
||||
}
|
||||
|
||||
uint32_t Number;
|
||||
SmallVector<GCOVBlock *, 4> OutEdges;
|
||||
|
||||
private:
|
||||
friend class GCOVFunction;
|
||||
|
||||
GCOVBlock(GCOVProfiler *P, uint32_t Number)
|
||||
: GCOVRecord(P), Number(Number) {}
|
||||
|
||||
uint32_t Number;
|
||||
StringMap<GCOVLines> LinesByFile;
|
||||
SmallVector<GCOVBlock *, 4> OutEdges;
|
||||
};
|
||||
|
||||
// A function has a unique identifier, a checksum (we leave as zero) and a
|
||||
|
@ -347,18 +349,6 @@ namespace {
|
|||
return ReturnBlock;
|
||||
}
|
||||
|
||||
std::string getEdgeDestinations() {
|
||||
std::string EdgeDestinations;
|
||||
raw_string_ostream EDOS(EdgeDestinations);
|
||||
Function *F = Blocks.begin()->first->getParent();
|
||||
for (BasicBlock &I : *F) {
|
||||
GCOVBlock &Block = getBlock(&I);
|
||||
for (int i = 0, e = Block.OutEdges.size(); i != e; ++i)
|
||||
EDOS << Block.OutEdges[i]->Number;
|
||||
}
|
||||
return EdgeDestinations;
|
||||
}
|
||||
|
||||
uint32_t getFuncChecksum() const {
|
||||
return FuncChecksum;
|
||||
}
|
||||
|
@ -729,7 +719,7 @@ void GCOVProfiler::emitProfileNotes() {
|
|||
continue;
|
||||
}
|
||||
|
||||
std::string EdgeDestinations;
|
||||
std::vector<uint8_t> EdgeDestinations;
|
||||
|
||||
Endian = M->getDataLayout().isLittleEndian() ? support::endianness::little
|
||||
: support::endianness::big;
|
||||
|
@ -774,6 +764,11 @@ void GCOVProfiler::emitProfileNotes() {
|
|||
} else if (isa<ReturnInst>(TI)) {
|
||||
Block.addEdge(Func.getReturnBlock());
|
||||
}
|
||||
for (GCOVBlock *Succ : Block.OutEdges) {
|
||||
uint32_t Idx = Succ->Number;
|
||||
do EdgeDestinations.push_back(Idx & 255);
|
||||
while ((Idx >>= 8) > 0);
|
||||
}
|
||||
|
||||
for (auto &I : BB) {
|
||||
// Debug intrinsic locations correspond to the location of the
|
||||
|
@ -798,12 +793,13 @@ void GCOVProfiler::emitProfileNotes() {
|
|||
}
|
||||
Line = 0;
|
||||
}
|
||||
EdgeDestinations += Func.getEdgeDestinations();
|
||||
}
|
||||
|
||||
char Tmp[4];
|
||||
JamCRC JC;
|
||||
JC.update(EdgeDestinations);
|
||||
os = &out;
|
||||
auto Stamp = static_cast<uint32_t>(hash_value(EdgeDestinations));
|
||||
uint32_t Stamp = JC.getCRC();
|
||||
FileChecksums.push_back(Stamp);
|
||||
if (Endian == support::endianness::big) {
|
||||
out.write("gcno", 4);
|
||||
|
|
Loading…
Reference in New Issue