Skip to content

Commit c485ca0

Browse files
committed
[sanitizer-coverage] simplify the code, NFC
llvm-svn: 308944
1 parent 2fdfab2 commit c485ca0

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,10 @@ static bool shouldInstrumentBlock(const Function &F, const BasicBlock *BB,
362362
if (Options.NoPrune || &F.getEntryBlock() == BB)
363363
return true;
364364

365+
if (Options.CoverageType == SanitizerCoverageOptions::SCK_Function &&
366+
&F.getEntryBlock() != BB)
367+
return false;
368+
365369
// Do not instrument full dominators, or full post-dominators with multiple
366370
// predecessors.
367371
return !isFullDominator(BB, DT)
@@ -459,20 +463,10 @@ void SanitizerCoverageModule::CreateFunctionLocalArrays(size_t NumGuards,
459463
bool SanitizerCoverageModule::InjectCoverage(Function &F,
460464
ArrayRef<BasicBlock *> AllBlocks) {
461465
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;
476470
}
477471

478472
// On every indirect call we call a run-time function

0 commit comments

Comments
 (0)