1 ; Test -sanitizer-coverage-experimental-tracing
3 ; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc -S | FileCheck %s --check-prefix=CHECK_PC
4 ; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard -S | FileCheck %s --check-prefix=CHECK_PC_GUARD
5 ; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard -S -mtriple=x86_64-apple-macosx | FileCheck %s --check-prefix=CHECK_PC_GUARD_DARWIN
7 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"
8 target triple = "x86_64-unknown-linux-gnu"
9 define void @foo(ptr %a) sanitize_address {
11 %tobool = icmp eq ptr %a, null
12 br i1 %tobool, label %if.end, label %if.then
14 if.then: ; preds = %entry
15 store i32 0, ptr %a, align 4
18 if.end: ; preds = %entry, %if.then
22 define available_externally void @external_bar(ptr %a) sanitize_address {
27 declare void @longjmp(ptr) noreturn
29 ; We expect three coverage points here for each BB.
30 define void @cond_longjmp(i1 %cond, ptr %jmp_buf) sanitize_address {
32 br i1 %cond, label %lj, label %done
36 call void @longjmp(ptr %jmp_buf)
41 ; CHECK_PC-LABEL: define void @foo
42 ; CHECK_PC: call void @__sanitizer_cov_trace_pc
43 ; CHECK_PC: call void @__sanitizer_cov_trace_pc
44 ; CHECK_PC: call void @__sanitizer_cov_trace_pc
45 ; CHECK_PC-NOT: call void @__sanitizer_cov_trace_pc
47 ; CHECK_PC-NOT: call void @__sanitizer_cov_module_init
48 ; CHECK_PC-LABEL: @cond_longjmp
49 ; CHECK_PC: call void @__sanitizer_cov_trace_pc
50 ; CHECK_PC: call void @__sanitizer_cov_trace_pc
52 ; CHECK_PC: call void @__sanitizer_cov_trace_pc
53 ; CHECK_PC: call void @longjmp
54 ; CHECK_PC: unreachable
56 ; CHECK_PC_GUARD: section "__sancov_guards", comdat($foo), align 4
57 ; CHECK_PC_GUARD-LABEL: define void @foo
58 ; CHECK_PC_GUARD: call void @__sanitizer_cov_trace_pc_guard
59 ; CHECK_PC_GUARD: call void @__sanitizer_cov_trace_pc_guard
60 ; CHECK_PC_GUARD: call void @__sanitizer_cov_trace_pc_guard
61 ; CHECK_PC_GUARD-NOT: call void @__sanitizer_cov_trace_pc
62 ; CHECK_PC_GUARD: ret void
63 ; CHECK_PC_GUARD-LABEL: @external_bar
64 ; CHECK_PC_GUARD-NOT: call void @__sanitizer_cov_trace_pc
65 ; CHECK_PC_GUARD: ret void
66 ; CHECK_PC_GUARD-LABEL: @cond_longjmp
67 ; CHECK_PC_GUARD: call void @__sanitizer_cov_trace_pc_guard
68 ; CHECK_PC_GUARD: call void @__sanitizer_cov_trace_pc_guard
69 ; CHECK_PC_GUARD: ret void
70 ; CHECK_PC_GUARD: call void @__sanitizer_cov_trace_pc_guard
71 ; CHECK_PC_GUARD: call void @longjmp
72 ; CHECK_PC_GUARD: unreachable
74 ; CHECK_PC_GUARD: call void @__sanitizer_cov_trace_pc_guard_init(ptr @__start___sancov_guards, ptr @__stop___sancov_guards)
76 ; CHECK_PC_GUARD_DARWIN-LABEL: define void @foo
77 ; CHECK_PC_GUARD_DARWIN: call void @__sanitizer_cov_trace_pc_guard
78 ; CHECK_PC_GUARD_DARWIN: call void @__sanitizer_cov_trace_pc_guard
79 ; CHECK_PC_GUARD_DARWIN: call void @__sanitizer_cov_trace_pc_guard
80 ; CHECK_PC_GUARD_DARWIN-NOT: call void @__sanitizer_cov_trace_pc
81 ; CHECK_PC_GUARD_DARWIN: ret void
82 ; CHECK_PC_GUARD_DARWIN: call void @__sanitizer_cov_trace_pc_guard_init(ptr @"\01section$start$__DATA$__sancov_guards", ptr @"\01section$end$__DATA$__sancov_guards")