1 ; Test -sanitizer-coverage-trace-compares=1 (instrumenting a switch)
2 ; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=1 -sanitizer-coverage-trace-compares=1 -S | FileCheck %s
4 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"
5 target triple = "x86_64-unknown-linux-gnu"
6 declare void @_Z3bari(i32)
7 define void @foo(i32 %x) {
9 ; CHECK: __sancov_gen_cov_switch_values = internal global [5 x i64] [i64 3, i64 32, i64 1, i64 101, i64 1001]
10 ; CHECK: [[TMP:%[0-9]*]] = zext i32 %x to i64
11 ; CHECK-NEXT: call void @__sanitizer_cov_trace_switch(i64 [[TMP]], ptr @__sancov_gen_cov_switch_values)
12 switch i32 %x, label %sw.epilog [
14 i32 1001, label %sw.bb.1
15 i32 101, label %sw.bb.2
18 sw.bb: ; preds = %entry
19 tail call void @_Z3bari(i32 4)
22 sw.bb.1: ; preds = %entry
23 tail call void @_Z3bari(i32 5)
26 sw.bb.2: ; preds = %entry
27 tail call void @_Z3bari(i32 6)
30 sw.epilog: ; preds = %entry, %sw.bb.2, %sw.bb.1, %sw.bb
34 define void @fooi72(i72 %x) {
36 switch i72 %x, label %sw.epilog [
38 i72 101, label %sw.bb.1
39 i72 1001, label %sw.bb.2
42 sw.bb: ; preds = %entry
43 tail call void @_Z3bari(i32 4)
46 sw.bb.1: ; preds = %entry
47 tail call void @_Z3bari(i32 5)
50 sw.bb.2: ; preds = %entry
51 tail call void @_Z3bari(i32 6)
54 sw.epilog: ; preds = %entry, %sw.bb.2, %sw.bb.1, %sw.bb