Recommit "rL366894: [yaml2obj] - Allow custom fields for the SHT_UNDEF sections."
[llvm-complete.git] / test / Instrumentation / SanitizerCoverage / tracing.ll
blob7bf8cf7e18e6e241cd2cf7cef3e9faddbbe8b5cf
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 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"
7 target triple = "x86_64-unknown-linux-gnu"
8 define void @foo(i32* %a) sanitize_address {
9 entry:
10   %tobool = icmp eq i32* %a, null
11   br i1 %tobool, label %if.end, label %if.then
13   if.then:                                          ; preds = %entry
14   store i32 0, i32* %a, align 4
15   br label %if.end
17   if.end:                                           ; preds = %entry, %if.then
18   ret void
21 define available_externally void @external_bar(i32* %a) sanitize_address {
22 entry:
23   ret void
26 declare void @longjmp(i8*) noreturn
28 ; We expect three coverage points here for each BB.
29 define void @cond_longjmp(i1 %cond, i8* %jmp_buf) sanitize_address {
30 entry:
31   br i1 %cond, label %lj, label %done
32 done:
33   ret void
34 lj:
35   call void @longjmp(i8* %jmp_buf)
36   unreachable
40 ; CHECK_PC-LABEL: define void @foo
41 ; CHECK_PC: call void @__sanitizer_cov_trace_pc
42 ; CHECK_PC: call void @__sanitizer_cov_trace_pc
43 ; CHECK_PC: call void @__sanitizer_cov_trace_pc
44 ; CHECK_PC-NOT: call void @__sanitizer_cov_trace_pc
45 ; CHECK_PC: ret void
46 ; CHECK_PC-NOT: call void @__sanitizer_cov_module_init
47 ; CHECK_PC-LABEL: @cond_longjmp
48 ; CHECK_PC: call void @__sanitizer_cov_trace_pc
49 ; CHECK_PC: call void @__sanitizer_cov_trace_pc
50 ; CHECK_PC: ret void
51 ; CHECK_PC: call void @__sanitizer_cov_trace_pc
52 ; CHECK_PC: call void @longjmp
53 ; CHECK_PC: unreachable
55 ; CHECK_PC_GUARD: section "__sancov_guards", comdat($foo), align 4
56 ; CHECK_PC_GUARD-LABEL: define void @foo
57 ; CHECK_PC_GUARD: call void @__sanitizer_cov_trace_pc_guard
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-NOT: call void @__sanitizer_cov_trace_pc
61 ; CHECK_PC_GUARD: ret void
62 ; CHECK_PC_GUARD-LABEL: @external_bar
63 ; CHECK_PC_GUARD-NOT: call void @__sanitizer_cov_trace_pc
64 ; CHECK_PC_GUARD: ret void
65 ; CHECK_PC_GUARD-LABEL: @cond_longjmp
66 ; CHECK_PC_GUARD: call void @__sanitizer_cov_trace_pc_guard
67 ; CHECK_PC_GUARD: call void @__sanitizer_cov_trace_pc_guard
68 ; CHECK_PC_GUARD: ret void
69 ; CHECK_PC_GUARD: call void @__sanitizer_cov_trace_pc_guard
70 ; CHECK_PC_GUARD: call void @longjmp
71 ; CHECK_PC_GUARD: unreachable
73 ; 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*))
75 ; CHECK_PC_GUARD_DARWIN-LABEL: define void @foo
76 ; CHECK_PC_GUARD_DARWIN: call void @__sanitizer_cov_trace_pc_guard
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-NOT: call void @__sanitizer_cov_trace_pc
80 ; CHECK_PC_GUARD_DARWIN: ret void
81 ; 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*))