llvm.org GIT mirror llvm / 6b2b204
Check whether functions have any lines associated before emitting coverage info for them. This isn't just a size/time saving, gcov may crash on these. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206671 91177308-0d34-0410-b5e6-96231b3b80d8 Nick Lewycky 6 years ago
1 changed file(s) with 17 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
448448 return false;
449449 }
450450
451 static bool functionHasLines(Function *F) {
452 // Check whether this function actually has any source lines. Not only
453 // do these waste space, they also can crash gcov.
454 for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {
455 for (BasicBlock::iterator I = BB->begin(), IE = BB->end();
456 I != IE; ++I) {
457 const DebugLoc &Loc = I->getDebugLoc();
458 if (Loc.isUnknown()) continue;
459 if (Loc.getLine() != 0)
460 return true;
461 }
462 }
463 return false;
464 }
465
451466 void GCOVProfiler::emitProfileNotes() {
452467 NamedMDNode *CU_Nodes = M->getNamedMetadata("llvm.dbg.cu");
453468 if (!CU_Nodes) return;
473488
474489 Function *F = SP.getFunction();
475490 if (!F) continue;
491 if (!functionHasLines(F)) continue;
476492
477493 // gcov expects every function to start with an entry block that has a
478494 // single successor, so split the entry block to make sure of that.
548564 continue;
549565 Function *F = SP.getFunction();
550566 if (!F) continue;
567 if (!functionHasLines(F)) continue;
551568 if (!Result) Result = true;
552569 unsigned Edges = 0;
553570 for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {