[llvm] r209721 - [asancov] Don't emit extra runtime calls when compiling without coverage.
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Wed May 28 02:26:46 PDT 2014
Author: eugenis
Date: Wed May 28 04:26:46 2014
New Revision: 209721
URL: http://llvm.org/viewvc/llvm-project?rev=209721&view=rev
Log:
[asancov] Don't emit extra runtime calls when compiling without coverage.
Modified:
llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/trunk/test/Instrumentation/AddressSanitizer/coverage.ll
Modified: llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp?rev=209721&r1=209720&r2=209721&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp Wed May 28 04:26:46 2014
@@ -1030,9 +1030,11 @@ bool AddressSanitizerModule::runOnModule
assert(CtorFunc);
IRBuilder<> IRB(CtorFunc->getEntryBlock().getTerminator());
- Function *CovFunc = M.getFunction(kAsanCovName);
- int nCov = CovFunc ? CovFunc->getNumUses() : 0;
- IRB.CreateCall(AsanCovModuleInit, ConstantInt::get(IntptrTy, nCov));
+ if (ClCoverage > 0) {
+ Function *CovFunc = M.getFunction(kAsanCovName);
+ int nCov = CovFunc ? CovFunc->getNumUses() : 0;
+ IRB.CreateCall(AsanCovModuleInit, ConstantInt::get(IntptrTy, nCov));
+ }
size_t n = GlobalsToChange.size();
if (n == 0) return false;
Modified: llvm/trunk/test/Instrumentation/AddressSanitizer/coverage.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/AddressSanitizer/coverage.ll?rev=209721&r1=209720&r2=209721&view=diff
==============================================================================
--- llvm/trunk/test/Instrumentation/AddressSanitizer/coverage.ll (original)
+++ llvm/trunk/test/Instrumentation/AddressSanitizer/coverage.ll Wed May 28 04:26:46 2014
@@ -1,3 +1,4 @@
+; RUN: opt < %s -asan -asan-module -asan-coverage=0 -S | FileCheck %s --check-prefix=CHECK0
; RUN: opt < %s -asan -asan-module -asan-coverage=1 -S | FileCheck %s --check-prefix=CHECK1
; RUN: opt < %s -asan -asan-module -asan-coverage=2 -S | FileCheck %s --check-prefix=CHECK2
; RUN: opt < %s -asan -asan-module -asan-coverage=2 -asan-coverage-block-threshold=10 -S | FileCheck %s --check-prefix=CHECK2
@@ -17,6 +18,9 @@ entry:
ret void
}
+; CHECK0-NOT: call void @__sanitizer_cov(
+; CHECK0-NOT: call void @__sanitizer_cov_module_init(
+
; CHECK1-LABEL: define void @foo
; CHECK1: %0 = load atomic i8* @__asan_gen_cov_foo monotonic, align 1
; CHECK1: %1 = icmp eq i8 0, %0
More information about the llvm-commits
mailing list