[sanitizer-coverage] make trace-pc-guard and indirect-call work together

llvm-svn: 281665
This commit is contained in:
Kostya Serebryany 2016-09-15 22:11:08 +00:00
parent be82d3ec0c
commit 66a9c175bf
3 changed files with 7 additions and 3 deletions

View File

@ -323,8 +323,8 @@ and can be used with `AFL <http://lcamtuf.coredump.cx/afl>`__.
Tracing PCs with guards
=======================
Another *experimental* feature that tries to combine `trace-pc`,
`8bit-counters` and boolean coverage
Another *experimental* feature that tries to combine the functionality of `trace-pc`,
`8bit-counters` and boolean coverage.
With ``-fsanitize-coverage=trace-pc-guard`` the compiler will insert the following code
on every edge:
@ -338,6 +338,9 @@ Every edge will have its own 1-byte `guard_variable`.
All such guard variables will reside in a dedicated section
(i.e. they essentially form an array).
Similarly to `trace-pc,indirect-calls`, with `trace-pc-guards,indirect-calls`
``__sanitizer_cov_trace_pc_indirect(void *callee)`` will be inserted on every indirect call.
The compler will also insert a module constructor that will call
.. code-block:: c++

View File

@ -521,7 +521,7 @@ void SanitizerCoverageModule::InjectCoverageForIndirectCalls(
*F.getParent(), Ty, false, GlobalValue::PrivateLinkage,
Constant::getNullValue(Ty), "__sancov_gen_callee_cache");
CalleeCache->setAlignment(CacheAlignment);
if (Options.TracePC)
if (Options.TracePC || Options.TracePCGuard)
IRB.CreateCall(SanCovTracePCIndir,
IRB.CreatePointerCast(Callee, IntptrTy));
else

View File

@ -7,6 +7,7 @@
; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-block-threshold=10 -S | FileCheck %s --check-prefix=CHECK3
; RUN: opt < %s -sancov -sanitizer-coverage-level=4 -S | FileCheck %s --check-prefix=CHECK4
; RUN: opt < %s -sancov -sanitizer-coverage-level=4 -sanitizer-coverage-trace-pc -S | FileCheck %s --check-prefix=CHECK_TRACE_PC
; RUN: opt < %s -sancov -sanitizer-coverage-level=4 -sanitizer-coverage-trace-pc-guard -S | FileCheck %s --check-prefix=CHECK_TRACE_PC
; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-8bit-counters=1 -S | FileCheck %s --check-prefix=CHECK-8BIT
; RUN: opt < %s -sancov -sanitizer-coverage-level=2 -sanitizer-coverage-block-threshold=10 \