- GCOVFunction Func(SP, &out, i, Options.UseCfgChecksum);
+ if (!functionHasLines(F)) continue;
+
+ // gcov expects every function to start with an entry block that has a
+ // single successor, so split the entry block to make sure of that.
+ BasicBlock &EntryBlock = F->getEntryBlock();
+ BasicBlock::iterator It = EntryBlock.begin();
+ while (isa<AllocaInst>(*It) || isa<DbgInfoIntrinsic>(*It))
+ ++It;
+ EntryBlock.splitBasicBlock(It);
+
+ Funcs.push_back(make_unique<GCOVFunction>(SP, F, &out, FunctionIdent++,
+ Options.UseCfgChecksum,
+ Options.ExitBlockBeforeBody));
+ GCOVFunction &Func = *Funcs.back();