]> granicus.if.org Git - llvm/commitdiff
[sanitizer-coverage] simplify the code, NFC
authorKostya Serebryany <kcc@google.com>
Tue, 25 Jul 2017 02:07:38 +0000 (02:07 +0000)
committerKostya Serebryany <kcc@google.com>
Tue, 25 Jul 2017 02:07:38 +0000 (02:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308944 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Instrumentation/SanitizerCoverage.cpp

index 06fe07598374ba30face9125fe5a166678e4a426..0b899eb273bb312fbda512b1444d8cefa2b688ea 100644 (file)
@@ -362,6 +362,10 @@ static bool shouldInstrumentBlock(const Function &F, const BasicBlock *BB,
   if (Options.NoPrune || &F.getEntryBlock() == BB)
     return true;
 
+  if (Options.CoverageType == SanitizerCoverageOptions::SCK_Function &&
+      &F.getEntryBlock() != BB)
+    return false;
+
   // Do not instrument full dominators, or full post-dominators with multiple
   // predecessors.
   return !isFullDominator(BB, DT)
@@ -459,20 +463,10 @@ void SanitizerCoverageModule::CreateFunctionLocalArrays(size_t NumGuards,
 bool SanitizerCoverageModule::InjectCoverage(Function &F,
                                              ArrayRef<BasicBlock *> AllBlocks) {
   if (AllBlocks.empty()) return false;
-  switch (Options.CoverageType) {
-  case SanitizerCoverageOptions::SCK_None:
-    return false;
-  case SanitizerCoverageOptions::SCK_Function:
-    CreateFunctionLocalArrays(1, F);
-    InjectCoverageAtBlock(F, F.getEntryBlock(), 0);
-    return true;
-  default: {
-    CreateFunctionLocalArrays(AllBlocks.size(), F);
-    for (size_t i = 0, N = AllBlocks.size(); i < N; i++)
-      InjectCoverageAtBlock(F, *AllBlocks[i], i);
-    return true;
-  }
-  }
+  CreateFunctionLocalArrays(AllBlocks.size(), F);
+  for (size_t i = 0, N = AllBlocks.size(); i < N; i++)
+    InjectCoverageAtBlock(F, *AllBlocks[i], i);
+  return true;
 }
 
 // On every indirect call we call a run-time function