• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; Test -sanitizer-coverage-trace-compares=1
2; RUN: opt < %s -sancov -sanitizer-coverage-level=1 -sanitizer-coverage-trace-compares=1  -S | FileCheck %s
3
4target 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"
5target triple = "x86_64-unknown-linux-gnu"
6define i32 @foo(i32 %a, i32 %b) #0 {
7entry:
8
9; compare (non-const, non-const)
10  %cmp = icmp slt i32 %a, %b
11; CHECK: call void @__sanitizer_cov_trace_cmp4
12; CHECK-NEXT: icmp slt i32 %a, %b
13
14; compare (const, non-const)
15  icmp slt i32 %a, 1
16; CHECK: call void @__sanitizer_cov_trace_const_cmp4(i32 1, i32 %a)
17; CHECK-NEXT: icmp slt i32 %a, 1
18
19; compare (non-const, const)
20  icmp slt i32 1, %a
21; CHECK: call void @__sanitizer_cov_trace_const_cmp4(i32 1, i32 %a)
22; CHECK-NEXT: icmp slt i32 1, %a
23
24; compare (const, const) - should not be instrumented
25  icmp slt i32 1, 0
26; CHECK-NOT: call void @__sanitizer_cov_trace
27; CHECK icmp slt i32 1, 0
28
29; compare variables of byte size
30  %x = trunc i32 %a to i8
31
32  icmp slt i8 %x, 1
33; CHECK: call void @__sanitizer_cov_trace_const_cmp1(i8 1, i8 %x)
34; CHECK-NEXT: icmp slt i8 %x, 1
35
36  icmp slt i8 1, %x
37; CHECK: call void @__sanitizer_cov_trace_const_cmp1(i8 1, i8 %x)
38; CHECK-NEXT: icmp slt i8 1, %x
39
40; compare variables of word size
41  %y = trunc i32 %a to i16
42
43  icmp slt i16 %y, 1
44; CHECK: call void @__sanitizer_cov_trace_const_cmp2(i16 1, i16 %y)
45; CHECK-NEXT: icmp slt i16 %y, 1
46
47  icmp slt i16 1, %y
48; CHECK: call void @__sanitizer_cov_trace_const_cmp2(i16 1, i16 %y)
49; CHECK-NEXT: icmp slt i16 1, %y
50
51; compare variables of qword size
52  %z = zext i32 %a to i64
53
54  icmp slt i64 %z, 1
55; CHECK: call void @__sanitizer_cov_trace_const_cmp8(i64 1, i64 %z)
56; CHECK-NEXT: icmp slt i64 %z, 1
57
58  icmp slt i64 1, %z
59; CHECK: call void @__sanitizer_cov_trace_const_cmp8(i64 1, i64 %z)
60; CHECK-NEXT: icmp slt i64 1, %z
61
62  %conv = zext i1 %cmp to i32
63  ret i32 %conv
64}
65