• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; Test -sanitizer-coverage-experimental-tracing
2; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc  -S -enable-new-pm=0 | FileCheck %s --check-prefix=CHECK_PC
3; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S -enable-new-pm=0 | 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 -enable-new-pm=0 | FileCheck %s --check-prefix=CHECK_PC_GUARD_DARWIN
5
6; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc  -S | FileCheck %s --check-prefix=CHECK_PC
7; RUN: opt < %s -passes='module(sancov-module)' -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)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S -mtriple=x86_64-apple-macosx | FileCheck %s --check-prefix=CHECK_PC_GUARD_DARWIN
9
10target 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"
11target triple = "x86_64-unknown-linux-gnu"
12define void @foo(i32* %a) sanitize_address {
13entry:
14  %tobool = icmp eq i32* %a, null
15  br i1 %tobool, label %if.end, label %if.then
16
17  if.then:                                          ; preds = %entry
18  store i32 0, i32* %a, align 4
19  br label %if.end
20
21  if.end:                                           ; preds = %entry, %if.then
22  ret void
23}
24
25define available_externally void @external_bar(i32* %a) sanitize_address {
26entry:
27  ret void
28}
29
30declare void @longjmp(i8*) noreturn
31
32; We expect three coverage points here for each BB.
33define void @cond_longjmp(i1 %cond, i8* %jmp_buf) sanitize_address {
34entry:
35  br i1 %cond, label %lj, label %done
36done:
37  ret void
38lj:
39  call void @longjmp(i8* %jmp_buf)
40  unreachable
41}
42
43
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
49; CHECK_PC: ret void
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
54; CHECK_PC: ret void
55; CHECK_PC: call void @__sanitizer_cov_trace_pc
56; CHECK_PC: call void @longjmp
57; CHECK_PC: unreachable
58
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
76
77; CHECK_PC_GUARD: call void @__sanitizer_cov_trace_pc_guard_init(i32* @__start___sancov_guards, i32* @__stop___sancov_guards)
78
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* @"\01section$start$__DATA$__sancov_guards", i32* @"\01section$end$__DATA$__sancov_guards")
86