@@ -87,7 +87,7 @@ namespace {
87
87
// list.
88
88
void insertCounterWriteout (DebugInfoFinder &,
89
89
SmallVector<std::pair<GlobalVariable *,
90
- uint32_t >, 8 > &);
90
+ MDNode * >, 8 > &);
91
91
92
92
std::string mangleName (DICompileUnit CU, std::string NewStem);
93
93
@@ -261,12 +261,13 @@ namespace {
261
261
ReturnBlock = new GCOVBlock (i++, os);
262
262
263
263
writeBytes (FunctionTag, 4 );
264
- uint32_t BlockLen = 1 + 1 + 1 + lengthOfGCOVString (SP.getName ()) +
264
+ uint32_t BlockLen = 1 + 1 + 1 + 1 + lengthOfGCOVString (SP.getName ()) +
265
265
1 + lengthOfGCOVString (SP.getFilename ()) + 1 ;
266
266
write (BlockLen);
267
267
uint32_t Ident = reinterpret_cast <intptr_t >((MDNode*)SP);
268
268
write (Ident);
269
- write (0 ); // checksum
269
+ write (0 ); // checksum #1
270
+ write (0 ); // checksum #2
270
271
writeGCOVString (SP.getName ());
271
272
writeGCOVString (SP.getFilename ());
272
273
write (SP.getLineNumber ());
@@ -418,7 +419,7 @@ bool GCOVProfiler::emitProfileArcs(DebugInfoFinder &DIF) {
418
419
if (DIF.subprogram_begin () == DIF.subprogram_end ())
419
420
return false ;
420
421
421
- SmallVector<std::pair<GlobalVariable *, uint32_t >, 8 > CountersByIdent ;
422
+ SmallVector<std::pair<GlobalVariable *, MDNode * >, 8 > CountersBySP ;
422
423
for (DebugInfoFinder::iterator SPI = DIF.subprogram_begin (),
423
424
SPE = DIF.subprogram_end (); SPI != SPE; ++SPI) {
424
425
DISubprogram SP (*SPI);
@@ -441,8 +442,7 @@ bool GCOVProfiler::emitProfileArcs(DebugInfoFinder &DIF) {
441
442
GlobalValue::InternalLinkage,
442
443
Constant::getNullValue (CounterTy),
443
444
" __llvm_gcov_ctr" , 0 , false , 0 );
444
- CountersByIdent.push_back (
445
- std::make_pair (Counters, reinterpret_cast <intptr_t >((MDNode*)SP)));
445
+ CountersBySP.push_back (std::make_pair (Counters, (MDNode*)SP));
446
446
447
447
UniqueVector<BasicBlock *> ComplexEdgePreds;
448
448
UniqueVector<BasicBlock *> ComplexEdgeSuccs;
@@ -509,7 +509,7 @@ bool GCOVProfiler::emitProfileArcs(DebugInfoFinder &DIF) {
509
509
}
510
510
}
511
511
512
- insertCounterWriteout (DIF, CountersByIdent );
512
+ insertCounterWriteout (DIF, CountersBySP );
513
513
514
514
return true ;
515
515
}
@@ -580,7 +580,10 @@ Constant *GCOVProfiler::getIncrementIndirectCounterFunc() {
580
580
}
581
581
582
582
Constant *GCOVProfiler::getEmitFunctionFunc () {
583
- const Type *Args[] = { Type::getInt32Ty (*Ctx) };
583
+ const Type *Args[2 ] = {
584
+ Type::getInt32Ty (*Ctx), // uint32_t ident
585
+ Type::getInt8PtrTy (*Ctx), // const char *function_name
586
+ };
584
587
const FunctionType *FTy = FunctionType::get (Type::getVoidTy (*Ctx),
585
588
Args, false );
586
589
return M->getOrInsertFunction (" llvm_gcda_emit_function" , FTy);
@@ -616,7 +619,7 @@ GlobalVariable *GCOVProfiler::getEdgeStateValue() {
616
619
617
620
void GCOVProfiler::insertCounterWriteout (
618
621
DebugInfoFinder &DIF,
619
- SmallVector<std::pair<GlobalVariable *, uint32_t >, 8 > &CountersByIdent ) {
622
+ SmallVector<std::pair<GlobalVariable *, MDNode * >, 8 > &CountersBySP ) {
620
623
const FunctionType *WriteoutFTy =
621
624
FunctionType::get (Type::getVoidTy (*Ctx), false );
622
625
Function *WriteoutF = Function::Create (WriteoutFTy,
@@ -637,11 +640,15 @@ void GCOVProfiler::insertCounterWriteout(
637
640
std::string FilenameGcda = mangleName (compile_unit, " gcda" );
638
641
Builder.CreateCall (StartFile,
639
642
Builder.CreateGlobalStringPtr (FilenameGcda));
640
- for (SmallVector<std::pair<GlobalVariable *, uint32_t >, 8 >::iterator
641
- I = CountersByIdent .begin (), E = CountersByIdent .end ();
643
+ for (SmallVector<std::pair<GlobalVariable *, MDNode * >, 8 >::iterator
644
+ I = CountersBySP .begin (), E = CountersBySP .end ();
642
645
I != E; ++I) {
643
- Builder.CreateCall (EmitFunction, ConstantInt::get (Type::getInt32Ty (*Ctx),
644
- I->second ));
646
+ DISubprogram SP (I->second );
647
+ intptr_t ident = reinterpret_cast <intptr_t >(I->second );
648
+ Builder.CreateCall2 (EmitFunction,
649
+ ConstantInt::get (Type::getInt32Ty (*Ctx), ident),
650
+ Builder.CreateGlobalStringPtr (SP.getName ()));
651
+
645
652
GlobalVariable *GV = I->first ;
646
653
unsigned Arcs =
647
654
cast<ArrayType>(GV->getType ()->getElementType ())->getNumElements ();
0 commit comments