1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

Update the gcov version used slightly, to make it stop causing modern gcov's to

crash.

llvm-svn: 130911
This commit is contained in:
Nick Lewycky 2011-05-05 02:46:38 +00:00
parent 83b0b39eff
commit c537bf5a97
2 changed files with 35 additions and 15 deletions

View File

@ -87,7 +87,7 @@ namespace {
// list.
void insertCounterWriteout(DebugInfoFinder &,
SmallVector<std::pair<GlobalVariable *,
uint32_t>, 8> &);
MDNode *>, 8> &);
std::string mangleName(DICompileUnit CU, std::string NewStem);
@ -261,12 +261,13 @@ namespace {
ReturnBlock = new GCOVBlock(i++, os);
writeBytes(FunctionTag, 4);
uint32_t BlockLen = 1 + 1 + 1 + lengthOfGCOVString(SP.getName()) +
uint32_t BlockLen = 1 + 1 + 1 + 1 + lengthOfGCOVString(SP.getName()) +
1 + lengthOfGCOVString(SP.getFilename()) + 1;
write(BlockLen);
uint32_t Ident = reinterpret_cast<intptr_t>((MDNode*)SP);
write(Ident);
write(0); // checksum
write(0); // checksum #1
write(0); // checksum #2
writeGCOVString(SP.getName());
writeGCOVString(SP.getFilename());
write(SP.getLineNumber());
@ -418,7 +419,7 @@ bool GCOVProfiler::emitProfileArcs(DebugInfoFinder &DIF) {
if (DIF.subprogram_begin() == DIF.subprogram_end())
return false;
SmallVector<std::pair<GlobalVariable *, uint32_t>, 8> CountersByIdent;
SmallVector<std::pair<GlobalVariable *, MDNode *>, 8> CountersBySP;
for (DebugInfoFinder::iterator SPI = DIF.subprogram_begin(),
SPE = DIF.subprogram_end(); SPI != SPE; ++SPI) {
DISubprogram SP(*SPI);
@ -441,8 +442,7 @@ bool GCOVProfiler::emitProfileArcs(DebugInfoFinder &DIF) {
GlobalValue::InternalLinkage,
Constant::getNullValue(CounterTy),
"__llvm_gcov_ctr", 0, false, 0);
CountersByIdent.push_back(
std::make_pair(Counters, reinterpret_cast<intptr_t>((MDNode*)SP)));
CountersBySP.push_back(std::make_pair(Counters, (MDNode*)SP));
UniqueVector<BasicBlock *> ComplexEdgePreds;
UniqueVector<BasicBlock *> ComplexEdgeSuccs;
@ -509,7 +509,7 @@ bool GCOVProfiler::emitProfileArcs(DebugInfoFinder &DIF) {
}
}
insertCounterWriteout(DIF, CountersByIdent);
insertCounterWriteout(DIF, CountersBySP);
return true;
}
@ -580,7 +580,10 @@ Constant *GCOVProfiler::getIncrementIndirectCounterFunc() {
}
Constant *GCOVProfiler::getEmitFunctionFunc() {
const Type *Args[] = { Type::getInt32Ty(*Ctx) };
const Type *Args[2] = {
Type::getInt32Ty(*Ctx), // uint32_t ident
Type::getInt8PtrTy(*Ctx), // const char *function_name
};
const FunctionType *FTy = FunctionType::get(Type::getVoidTy(*Ctx),
Args, false);
return M->getOrInsertFunction("llvm_gcda_emit_function", FTy);
@ -616,7 +619,7 @@ GlobalVariable *GCOVProfiler::getEdgeStateValue() {
void GCOVProfiler::insertCounterWriteout(
DebugInfoFinder &DIF,
SmallVector<std::pair<GlobalVariable *, uint32_t>, 8> &CountersByIdent) {
SmallVector<std::pair<GlobalVariable *, MDNode *>, 8> &CountersBySP) {
const FunctionType *WriteoutFTy =
FunctionType::get(Type::getVoidTy(*Ctx), false);
Function *WriteoutF = Function::Create(WriteoutFTy,
@ -637,11 +640,15 @@ void GCOVProfiler::insertCounterWriteout(
std::string FilenameGcda = mangleName(compile_unit, "gcda");
Builder.CreateCall(StartFile,
Builder.CreateGlobalStringPtr(FilenameGcda));
for (SmallVector<std::pair<GlobalVariable *, uint32_t>, 8>::iterator
I = CountersByIdent.begin(), E = CountersByIdent.end();
for (SmallVector<std::pair<GlobalVariable *, MDNode *>, 8>::iterator
I = CountersBySP.begin(), E = CountersBySP.end();
I != E; ++I) {
Builder.CreateCall(EmitFunction, ConstantInt::get(Type::getInt32Ty(*Ctx),
I->second));
DISubprogram SP(I->second);
intptr_t ident = reinterpret_cast<intptr_t>(I->second);
Builder.CreateCall2(EmitFunction,
ConstantInt::get(Type::getInt32Ty(*Ctx), ident),
Builder.CreateGlobalStringPtr(SP.getName()));
GlobalVariable *GV = I->first;
unsigned Arcs =
cast<ArrayType>(GV->getType()->getElementType())->getNumElements();

View File

@ -48,6 +48,17 @@ static void write_int64(uint64_t i) {
write_int32(hi);
}
static uint32_t length_of_string(const char *s) {
return (strlen(s) + 5) / 4;
}
static void write_string(const char *s) {
uint32_t len = length_of_string(s);
write_int32(len);
fwrite(s, strlen(s), 1, output_file);
fwrite("\0\0\0\0", 4 - (strlen(s) % 4), 1, output_file);
}
static char *mangle_filename(const char *orig_filename) {
/* TODO: handle GCOV_PREFIX_STRIP */
const char *prefix;
@ -129,16 +140,18 @@ void llvm_gcda_increment_indirect_counter(uint32_t *predecessor,
#endif
}
void llvm_gcda_emit_function(uint32_t ident) {
void llvm_gcda_emit_function(uint32_t ident, const char *function_name) {
#ifdef DEBUG_GCDAPROFILING
printf("llvmgcda: function id=%x\n", ident);
#endif
/* function tag */
fwrite("\0\0\0\1", 4, 1, output_file);
write_int32(2);
write_int32(3 + 1 + length_of_string(function_name));
write_int32(ident);
write_int32(0);
write_int32(0);
write_string(function_name);
}
void llvm_gcda_emit_arcs(uint32_t num_counters, uint64_t *counters) {