1 // RUN: %clang_cc1 -triple %itanium_abi_triple %s -o - -emit-llvm -fprofile-instrument=clang -fcoverage-mapping -fcoverage-mcdc | FileCheck %s -check-prefix=MCDC
2 // RUN: %clang_cc1 -triple %itanium_abi_triple %s -o - -emit-llvm -fprofile-instrument=clang -fcoverage-mapping | FileCheck %s -check-prefix=NOMCDC
4 int test(int a
, int b
, int c
, int d
, int e
, int f
) {
5 return ((!a
&& b
) || ((!c
&& d
) || (e
&& !f
)));
8 // NOMCDC-NOT: %mcdc.addr
9 // NOMCDC-NOT: __profbm_test
12 // MCDC: @__profbm_test = private global [2 x i8] zeroinitializer
13 // MCDC: @__profc_test = private global [9 x i64] zeroinitializer
15 // ALLOCATE MCDC TEMP AND ZERO IT.
17 // MCDC: %mcdc.addr = alloca i32, align 4
18 // MCDC: store i32 0, ptr %mcdc.addr, align 4
20 // SHIFT FIRST CONDITION WITH ID = 0.
21 // MCDC: %[[LAB1:[0-9]+]] = load i32, ptr %a.addr, align 4
22 // MCDC-DAG: %[[BOOL:tobool[0-9]*]] = icmp ne i32 %[[LAB1]], 0
23 // MCDC-DAG: %[[LNOT:lnot[0-9]*]] = xor i1 %[[BOOL]]
24 // MCDC-DAG: %[[TEMP:mcdc.*]] = load i32, ptr %mcdc.addr, align 4
25 // MCDC-DAG: %[[LAB2:[0-9]+]] = add i32 %[[TEMP]], 0
26 // MCDC-DAG: %[[LAB3:[0-9]+]] = add i32 %[[TEMP]], 0
27 // MCDC-DAG: %[[LAB4:[0-9]+]] = select i1 %[[LNOT]], i32 %[[LAB2]], i32 %[[LAB3]]
28 // MCDC-DAG: store i32 %[[LAB4]], ptr %mcdc.addr, align 4
30 // SHIFT SECOND CONDITION WITH ID = 2.
31 // MCDC: %[[LAB1:[0-9]+]] = load i32, ptr %b.addr, align 4
32 // MCDC-DAG: %[[BOOL:tobool[0-9]*]] = icmp ne i32 %[[LAB1]], 0
33 // MCDC-DAG: %[[TEMP:mcdc.*]] = load i32, ptr %mcdc.addr, align 4
34 // MCDC-DAG: %[[LAB2:[0-9]+]] = add i32 %[[TEMP]], 14
35 // MCDC-DAG: %[[LAB3:[0-9]+]] = add i32 %[[TEMP]], 1
36 // MCDC-DAG: %[[LAB4:[0-9]+]] = select i1 %[[BOOL]], i32 %[[LAB2]], i32 %[[LAB3]]
37 // MCDC-DAG: store i32 %[[LAB4]], ptr %mcdc.addr, align 4
39 // SHIFT THIRD CONDITION WITH ID = 1.
40 // MCDC: %[[LAB1:[0-9]+]] = load i32, ptr %c.addr, align 4
41 // MCDC-DAG: %[[BOOL:tobool[0-9]*]] = icmp ne i32 %[[LAB1]], 0
42 // MCDC-DAG: %[[LNOT:lnot[0-9]*]] = xor i1 %[[BOOL]]
43 // MCDC-DAG: %[[TEMP:mcdc.*]] = load i32, ptr %mcdc.addr, align 4
44 // MCDC-DAG: %[[LAB2:[0-9]+]] = add i32 %[[TEMP]], 0
45 // MCDC-DAG: %[[LAB3:[0-9]+]] = add i32 %[[TEMP]], 0
46 // MCDC-DAG: %[[LAB4:[0-9]+]] = select i1 %[[LNOT]], i32 %[[LAB2]], i32 %[[LAB3]]
47 // MCDC-DAG: store i32 %[[LAB4]], ptr %mcdc.addr, align 4
49 // SHIFT FOURTH CONDITION WITH ID = 4.
50 // MCDC: %[[LAB1:[0-9]+]] = load i32, ptr %d.addr, align 4
51 // MCDC-DAG: %[[BOOL:tobool[0-9]*]] = icmp ne i32 %[[LAB1]], 0
52 // MCDC-DAG: %[[TEMP:mcdc.*]] = load i32, ptr %mcdc.addr, align 4
53 // MCDC-DAG: %[[LAB2:[0-9]+]] = add i32 %[[TEMP]], 12
54 // MCDC-DAG: %[[LAB3:[0-9]+]] = add i32 %[[TEMP]], 2
55 // MCDC-DAG: %[[LAB4:[0-9]+]] = select i1 %[[BOOL]], i32 %[[LAB2]], i32 %[[LAB3]]
56 // MCDC-DAG: store i32 %[[LAB4]], ptr %mcdc.addr, align 4
58 // SHIFT FIFTH CONDITION WITH ID = 3.
59 // MCDC: %[[LAB1:[0-9]+]] = load i32, ptr %e.addr, align 4
60 // MCDC-DAG: %[[BOOL:tobool[0-9]*]] = icmp ne i32 %[[LAB1]], 0
61 // MCDC-DAG: %[[TEMP:mcdc.*]] = load i32, ptr %mcdc.addr, align 4
62 // MCDC-DAG: %[[LAB2:[0-9]+]] = add i32 %[[TEMP]], 0
63 // MCDC-DAG: %[[LAB3:[0-9]+]] = add i32 %[[TEMP]], 0
64 // MCDC-DAG: %[[LAB4:[0-9]+]] = select i1 %[[BOOL]], i32 %[[LAB2]], i32 %[[LAB3]]
65 // MCDC-DAG: store i32 %[[LAB4]], ptr %mcdc.addr, align 4
67 // SHIFT SIXTH CONDITION WITH ID = 5.
68 // MCDC: %[[LAB1:[0-9]+]] = load i32, ptr %f.addr, align 4
69 // MCDC-DAG: %[[BOOL:tobool[0-9]*]] = icmp ne i32 %[[LAB1]], 0
70 // MCDC-DAG: %[[LNOT:lnot[0-9]*]] = xor i1 %[[BOOL]]
71 // MCDC-DAG: %[[TEMP:mcdc.*]] = load i32, ptr %mcdc.addr, align 4
72 // MCDC-DAG: %[[LAB2:[0-9]+]] = add i32 %[[TEMP]], 8
73 // MCDC-DAG: %[[LAB3:[0-9]+]] = add i32 %[[TEMP]], 4
74 // MCDC-DAG: %[[LAB4:[0-9]+]] = select i1 %[[LNOT]], i32 %[[LAB2]], i32 %[[LAB3]]
75 // MCDC-DAG: store i32 %[[LAB4]], ptr %mcdc.addr, align 4
77 // UPDATE FINAL BITMASK WITH RESULT.
78 // MCDC-DAG: %[[TEMP0:mcdc.temp[0-9]*]] = load i32, ptr %mcdc.addr, align 4
79 // MCDC: %[[TEMP:[0-9]+]] = add i32 %[[TEMP0]], 0
80 // MCDC: %[[LAB1:[0-9]+]] = lshr i32 %[[TEMP]], 3
81 // MCDC: %[[LAB4:[0-9]+]] = getelementptr inbounds i8, ptr @__profbm_test, i32 %[[LAB1]]
82 // MCDC: %[[LAB5:[0-9]+]] = and i32 %[[TEMP]], 7
83 // MCDC: %[[LAB6:[0-9]+]] = trunc i32 %[[LAB5]] to i8
84 // MCDC: %[[LAB7:[0-9]+]] = shl i8 1, %[[LAB6]]
85 // MCDC: %[[BITS:.+]] = load i8, ptr %[[LAB4]], align 1
86 // MCDC: %[[LAB8:[0-9]+]] = or i8 %[[BITS]], %[[LAB7]]
87 // MCDC: store i8 %[[LAB8]], ptr %[[LAB4]], align 1