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 ; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=1 -sanitizer-coverage-trace-compares=1 -S | FileCheck %s
5 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"
6 target triple = "x86_64-unknown-linux-gnu"
7 define i32 @foo(i32 %a, i32 %b) #0 {
10 ; compare (non-const, non-const)
11 %cmp = icmp slt i32 %a, %b
12 ; CHECK: call void @__sanitizer_cov_trace_cmp4
13 ; CHECK-NEXT: icmp slt i32 %a, %b
15 ; compare (const, non-const)
17 ; CHECK: call void @__sanitizer_cov_trace_const_cmp4(i32 1, i32 %a)
18 ; CHECK-NEXT: icmp slt i32 %a, 1
20 ; compare (non-const, const)
22 ; CHECK: call void @__sanitizer_cov_trace_const_cmp4(i32 1, i32 %a)
23 ; CHECK-NEXT: icmp slt i32 1, %a
25 ; compare (const, const) - should not be instrumented
27 ; CHECK-NOT: call void @__sanitizer_cov_trace
28 ; CHECK icmp slt i32 1, 0
30 ; compare variables of byte size
31 %x = trunc i32 %a to i8
34 ; CHECK: call void @__sanitizer_cov_trace_const_cmp1(i8 1, i8 %x)
35 ; CHECK-NEXT: icmp slt i8 %x, 1
38 ; CHECK: call void @__sanitizer_cov_trace_const_cmp1(i8 1, i8 %x)
39 ; CHECK-NEXT: icmp slt i8 1, %x
41 ; compare variables of word size
42 %y = trunc i32 %a to i16
45 ; CHECK: call void @__sanitizer_cov_trace_const_cmp2(i16 1, i16 %y)
46 ; CHECK-NEXT: icmp slt i16 %y, 1
49 ; CHECK: call void @__sanitizer_cov_trace_const_cmp2(i16 1, i16 %y)
50 ; CHECK-NEXT: icmp slt i16 1, %y
52 ; compare variables of qword size
53 %z = zext i32 %a to i64
56 ; CHECK: call void @__sanitizer_cov_trace_const_cmp8(i64 1, i64 %z)
57 ; CHECK-NEXT: icmp slt i64 %z, 1
60 ; CHECK: call void @__sanitizer_cov_trace_const_cmp8(i64 1, i64 %z)
61 ; CHECK-NEXT: icmp slt i64 1, %z
63 %conv = zext i1 %cmp to i32