From 01c0f8d8a37e01f941522c8ebe66d17f28104172 Mon Sep 17 00:00:00 2001 From: Mike Aizatsky Date: Fri, 1 Apr 2016 18:13:19 +0000 Subject: [PATCH] [sancov] save entry block from pruning (it is always full dominator) llvm-svn: 265168 --- llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp | 6 +++--- llvm/test/Instrumentation/SanitizerCoverage/coverage.ll | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp index 12fdfbd..1fac003 100644 --- a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp +++ b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp @@ -342,9 +342,9 @@ static bool isFullPostDominator(const BasicBlock *BB, return true; } -static bool shouldInstrumentBlock(const BasicBlock *BB, const DominatorTree *DT, +static bool shouldInstrumentBlock(const Function& F, const BasicBlock *BB, const DominatorTree *DT, const PostDominatorTree *PDT) { - if (!ClPruneBlocks) + if (!ClPruneBlocks || &F.getEntryBlock() == BB) return true; return !(isFullDominator(BB, DT) || isFullPostDominator(BB, PDT)); @@ -374,7 +374,7 @@ bool SanitizerCoverageModule::runOnFunction(Function &F) { &getAnalysis(F).getPostDomTree(); for (auto &BB : F) { - if (shouldInstrumentBlock(&BB, DT, PDT)) + if (shouldInstrumentBlock(F, &BB, DT, PDT)) BlocksToInstrument.push_back(&BB); for (auto &Inst : BB) { if (Options.IndirectCalls) { diff --git a/llvm/test/Instrumentation/SanitizerCoverage/coverage.ll b/llvm/test/Instrumentation/SanitizerCoverage/coverage.ll index 71177eb..98f9a2e 100644 --- a/llvm/test/Instrumentation/SanitizerCoverage/coverage.ll +++ b/llvm/test/Instrumentation/SanitizerCoverage/coverage.ll @@ -13,7 +13,7 @@ ; RUN: -S | FileCheck %s --check-prefix=CHECK2 ; RUN: opt < %s -sancov -sanitizer-coverage-level=2 -sanitizer-coverage-block-threshold=1 \ ; RUN: -S | FileCheck %s --check-prefix=CHECK_WITH_CHECK -; RUN: opt < %s -sancov -sanitizer-coverage-level=2 -sanitizer-coverage-prune-blocks=1 -S | FileCheck %s --check-prefix=CHECKPRUNE +; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-prune-blocks=1 -S | FileCheck %s --check-prefix=CHECKPRUNE target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target triple = "x86_64-unknown-linux-gnu" @@ -138,8 +138,7 @@ entry: ; CHECKPRUNE-LABEL: define void @foo ; CHECKPRUNE: call void @__sanitizer_cov -; CHECKPRUNE: call void asm sideeffect "", ""() ; CHECKPRUNE: call void @__sanitizer_cov -; CHECKPRUNE: call void asm sideeffect "", ""() +; CHECKPRUNE: call void @__sanitizer_cov ; CHECKPRUNE-NOT: call void @__sanitizer_cov ; CHECKPRUNE: ret void -- 2.7.4