1 ; Test -sanitizer-coverage-experimental-tracing
2 ; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc -S | FileCheck %s --check-prefix=CHECK_PC
3 ; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard -S | FileCheck %s --check-prefix=CHECK_PC_GUARD
4 ; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard -S -mtriple=x86_64-apple-macosx | FileCheck %s --check-prefix=CHECK_PC_GUARD_DARWIN
6 ; RUN: opt < %s -passes='module(sancov-module),function(sancov-func)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc -S | FileCheck %s --check-prefix=CHECK_PC
7 ; RUN: opt < %s -passes='module(sancov-module),function(sancov-func)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard -S | FileCheck %s --check-prefix=CHECK_PC_GUARD
8 ; RUN: opt < %s -passes='module(sancov-module),function(sancov-func)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard -S -mtriple=x86_64-apple-macosx | FileCheck %s --check-prefix=CHECK_PC_GUARD_DARWIN
10 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"
11 target triple = "x86_64-unknown-linux-gnu"
12 define void @foo(i32* %a) sanitize_address {
14 %tobool = icmp eq i32* %a, null
15 br i1 %tobool, label %if.end, label %if.then
17 if.then: ; preds = %entry
18 store i32 0, i32* %a, align 4
21 if.end: ; preds = %entry, %if.then
25 define available_externally void @external_bar(i32* %a) sanitize_address {
30 declare void @longjmp(i8*) noreturn
32 ; We expect three coverage points here for each BB.
33 define void @cond_longjmp(i1 %cond, i8* %jmp_buf) sanitize_address {
35 br i1 %cond, label %lj, label %done
39 call void @longjmp(i8* %jmp_buf)
44 ; CHECK_PC-LABEL: define void @foo
45 ; CHECK_PC: call void @__sanitizer_cov_trace_pc
46 ; CHECK_PC: call void @__sanitizer_cov_trace_pc
47 ; CHECK_PC: call void @__sanitizer_cov_trace_pc
48 ; CHECK_PC-NOT: call void @__sanitizer_cov_trace_pc
50 ; CHECK_PC-NOT: call void @__sanitizer_cov_module_init
51 ; CHECK_PC-LABEL: @cond_longjmp
52 ; CHECK_PC: call void @__sanitizer_cov_trace_pc
53 ; CHECK_PC: call void @__sanitizer_cov_trace_pc
55 ; CHECK_PC: call void @__sanitizer_cov_trace_pc
56 ; CHECK_PC: call void @longjmp
57 ; CHECK_PC: unreachable
59 ; CHECK_PC_GUARD: section "__sancov_guards", comdat($foo), align 4
60 ; CHECK_PC_GUARD-LABEL: define void @foo
61 ; CHECK_PC_GUARD: call void @__sanitizer_cov_trace_pc_guard
62 ; CHECK_PC_GUARD: call void @__sanitizer_cov_trace_pc_guard
63 ; CHECK_PC_GUARD: call void @__sanitizer_cov_trace_pc_guard
64 ; CHECK_PC_GUARD-NOT: call void @__sanitizer_cov_trace_pc
65 ; CHECK_PC_GUARD: ret void
66 ; CHECK_PC_GUARD-LABEL: @external_bar
67 ; CHECK_PC_GUARD-NOT: call void @__sanitizer_cov_trace_pc
68 ; CHECK_PC_GUARD: ret void
69 ; CHECK_PC_GUARD-LABEL: @cond_longjmp
70 ; CHECK_PC_GUARD: call void @__sanitizer_cov_trace_pc_guard
71 ; CHECK_PC_GUARD: call void @__sanitizer_cov_trace_pc_guard
72 ; CHECK_PC_GUARD: ret void
73 ; CHECK_PC_GUARD: call void @__sanitizer_cov_trace_pc_guard
74 ; CHECK_PC_GUARD: call void @longjmp
75 ; CHECK_PC_GUARD: unreachable
77 ; CHECK_PC_GUARD: call void @__sanitizer_cov_trace_pc_guard_init(i32* bitcast (i32** @__start___sancov_guards to i32*), i32* bitcast (i32** @__stop___sancov_guards to i32*))
79 ; CHECK_PC_GUARD_DARWIN-LABEL: define void @foo
80 ; CHECK_PC_GUARD_DARWIN: call void @__sanitizer_cov_trace_pc_guard
81 ; CHECK_PC_GUARD_DARWIN: call void @__sanitizer_cov_trace_pc_guard
82 ; CHECK_PC_GUARD_DARWIN: call void @__sanitizer_cov_trace_pc_guard
83 ; CHECK_PC_GUARD_DARWIN-NOT: call void @__sanitizer_cov_trace_pc
84 ; CHECK_PC_GUARD_DARWIN: ret void
85 ; CHECK_PC_GUARD_DARWIN: call void @__sanitizer_cov_trace_pc_guard_init(i32* bitcast (i32** @"\01section$start$__DATA$__sancov_guards" to i32*), i32* bitcast (i32** @"\01section$end$__DATA$__sancov_guards" to i32*))