@@ -362,6 +362,10 @@ static bool shouldInstrumentBlock(const Function &F, const BasicBlock *BB,
362
362
if (Options.NoPrune || &F.getEntryBlock () == BB)
363
363
return true ;
364
364
365
+ if (Options.CoverageType == SanitizerCoverageOptions::SCK_Function &&
366
+ &F.getEntryBlock () != BB)
367
+ return false ;
368
+
365
369
// Do not instrument full dominators, or full post-dominators with multiple
366
370
// predecessors.
367
371
return !isFullDominator (BB, DT)
@@ -459,20 +463,10 @@ void SanitizerCoverageModule::CreateFunctionLocalArrays(size_t NumGuards,
459
463
bool SanitizerCoverageModule::InjectCoverage (Function &F,
460
464
ArrayRef<BasicBlock *> AllBlocks) {
461
465
if (AllBlocks.empty ()) return false ;
462
- switch (Options.CoverageType ) {
463
- case SanitizerCoverageOptions::SCK_None:
464
- return false ;
465
- case SanitizerCoverageOptions::SCK_Function:
466
- CreateFunctionLocalArrays (1 , F);
467
- InjectCoverageAtBlock (F, F.getEntryBlock (), 0 );
468
- return true ;
469
- default : {
470
- CreateFunctionLocalArrays (AllBlocks.size (), F);
471
- for (size_t i = 0 , N = AllBlocks.size (); i < N; i++)
472
- InjectCoverageAtBlock (F, *AllBlocks[i], i);
473
- return true ;
474
- }
475
- }
466
+ CreateFunctionLocalArrays (AllBlocks.size (), F);
467
+ for (size_t i = 0 , N = AllBlocks.size (); i < N; i++)
468
+ InjectCoverageAtBlock (F, *AllBlocks[i], i);
469
+ return true ;
476
470
}
477
471
478
472
// On every indirect call we call a run-time function
0 commit comments