llvm.org GIT mirror llvm / 5409a18
Update the gcov version used slightly, to make it stop causing modern gcov's to crash. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130911 91177308-0d34-0410-b5e6-96231b3b80d8 Nick Lewycky 8 years ago
2 changed file(s) with 35 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
8686 // list.
8787 void insertCounterWriteout(DebugInfoFinder &,
8888 SmallVector
89 uint32_t>, 8> &);
89 MDNode *>, 8> &);
9090
9191 std::string mangleName(DICompileUnit CU, std::string NewStem);
9292
260260 ReturnBlock = new GCOVBlock(i++, os);
261261
262262 writeBytes(FunctionTag, 4);
263 uint32_t BlockLen = 1 + 1 + 1 + lengthOfGCOVString(SP.getName()) +
263 uint32_t BlockLen = 1 + 1 + 1 + 1 + lengthOfGCOVString(SP.getName()) +
264264 1 + lengthOfGCOVString(SP.getFilename()) + 1;
265265 write(BlockLen);
266266 uint32_t Ident = reinterpret_cast((MDNode*)SP);
267267 write(Ident);
268 write(0); // checksum
268 write(0); // checksum #1
269 write(0); // checksum #2
269270 writeGCOVString(SP.getName());
270271 writeGCOVString(SP.getFilename());
271272 write(SP.getLineNumber());
417418 if (DIF.subprogram_begin() == DIF.subprogram_end())
418419 return false;
419420
420 SmallVectoruint32_t>, 8> CountersByIdent;
421 SmallVectorMDNode *>, 8> CountersBySP;
421422 for (DebugInfoFinder::iterator SPI = DIF.subprogram_begin(),
422423 SPE = DIF.subprogram_end(); SPI != SPE; ++SPI) {
423424 DISubprogram SP(*SPI);
440441 GlobalValue::InternalLinkage,
441442 Constant::getNullValue(CounterTy),
442443 "__llvm_gcov_ctr", 0, false, 0);
443 CountersByIdent.push_back(
444 std::make_pair(Counters, reinterpret_cast((MDNode*)SP)));
444 CountersBySP.push_back(std::make_pair(Counters, (MDNode*)SP));
445445
446446 UniqueVector ComplexEdgePreds;
447447 UniqueVector ComplexEdgeSuccs;
508508 }
509509 }
510510
511 insertCounterWriteout(DIF, CountersByIdent);
511 insertCounterWriteout(DIF, CountersBySP);
512512
513513 return true;
514514 }
579579 }
580580
581581 Constant *GCOVProfiler::getEmitFunctionFunc() {
582 const Type *Args[] = { Type::getInt32Ty(*Ctx) };
582 const Type *Args[2] = {
583 Type::getInt32Ty(*Ctx), // uint32_t ident
584 Type::getInt8PtrTy(*Ctx), // const char *function_name
585 };
583586 const FunctionType *FTy = FunctionType::get(Type::getVoidTy(*Ctx),
584587 Args, false);
585588 return M->getOrInsertFunction("llvm_gcda_emit_function", FTy);
615618
616619 void GCOVProfiler::insertCounterWriteout(
617620 DebugInfoFinder &DIF,
618 SmallVectoruint32_t>, 8> &CountersByIdent) {
621 SmallVectorMDNode *>, 8> &CountersBySP) {
619622 const FunctionType *WriteoutFTy =
620623 FunctionType::get(Type::getVoidTy(*Ctx), false);
621624 Function *WriteoutF = Function::Create(WriteoutFTy,
636639 std::string FilenameGcda = mangleName(compile_unit, "gcda");
637640 Builder.CreateCall(StartFile,
638641 Builder.CreateGlobalStringPtr(FilenameGcda));
639 for (SmallVector, 8>::iterator
640 I = CountersByIdent.begin(), E = CountersByIdent.end();
642 for (SmallVector, 8>::iterator
643 I = CountersBySP.begin(), E = CountersBySP.end();
641644 I != E; ++I) {
642 Builder.CreateCall(EmitFunction, ConstantInt::get(Type::getInt32Ty(*Ctx),
643 I->second));
645 DISubprogram SP(I->second);
646 intptr_t ident = reinterpret_cast(I->second);
647 Builder.CreateCall2(EmitFunction,
648 ConstantInt::get(Type::getInt32Ty(*Ctx), ident),
649 Builder.CreateGlobalStringPtr(SP.getName()));
650
644651 GlobalVariable *GV = I->first;
645652 unsigned Arcs =
646653 cast(GV->getType()->getElementType())->getNumElements();
4545
4646 write_int32(lo);
4747 write_int32(hi);
48 }
49
50 static uint32_t length_of_string(const char *s) {
51 return (strlen(s) + 5) / 4;
52 }
53
54 static void write_string(const char *s) {
55 uint32_t len = length_of_string(s);
56 write_int32(len);
57 fwrite(s, strlen(s), 1, output_file);
58 fwrite("\0\0\0\0", 4 - (strlen(s) % 4), 1, output_file);
4859 }
4960
5061 static char *mangle_filename(const char *orig_filename) {
128139 #endif
129140 }
130141
131 void llvm_gcda_emit_function(uint32_t ident) {
142 void llvm_gcda_emit_function(uint32_t ident, const char *function_name) {
132143 #ifdef DEBUG_GCDAPROFILING
133144 printf("llvmgcda: function id=%x\n", ident);
134145 #endif
135146
136147 /* function tag */
137148 fwrite("\0\0\0\1", 4, 1, output_file);
138 write_int32(2);
149 write_int32(3 + 1 + length_of_string(function_name));
139150 write_int32(ident);
140151 write_int32(0);
152 write_int32(0);
153 write_string(function_name);
141154 }
142155
143156 void llvm_gcda_emit_arcs(uint32_t num_counters, uint64_t *counters) {