1 // RUN: %clang_cc1 -triple %itanium_abi_triple %s -o - -emit-llvm -fprofile-instrument=clang -fcoverage-mapping -fcoverage-mcdc | FileCheck %s -check-prefix=MCDCCTOR
2 // RUN: %clang_cc1 -triple %itanium_abi_triple %s -o - -emit-llvm -fprofile-instrument=clang -fcoverage-mapping -fcoverage-mcdc | FileCheck %s -check-prefix=MCDCDTOR
8 void setValue(int len
);
10 Value(); // This is the constructor declaration
11 ~Value(); // This is the destructor declaration
17 // Member functions definitions including constructor
19 if (value
!= 2 || value
!= 6)
23 if (value
!= 2 || value
!= 3)
28 // MCDCCTOR: @__profbm__ZN5ValueC2Ev = private global [1 x i8] zeroinitializer
29 // MCDCCTOR: @__profc__ZN5ValueC2Ev = private global [4 x i64] zeroinitializer
31 // ALLOCATE MCDC TEMP AND ZERO IT.
32 // MCDCCTOR-LABEL: @_ZN5ValueC2Ev(
33 // MCDCCTOR: %mcdc.addr = alloca i32, align 4
34 // MCDCCTOR: store i32 0, ptr %mcdc.addr, align 4
36 // SHIFT FIRST CONDITION WITH ID = 0.
37 // MCDCCTOR: %[[LAB1:[0-9]+]] = load i32, ptr %value, align 4
38 // MCDCCTOR-DAG: %[[BOOL:cmp[0-9]*]] = icmp ne i32 %[[LAB1]], 2
39 // MCDCCTOR-DAG: %[[TEMP:mcdc.*]] = load i32, ptr %mcdc.addr, align 4
40 // MCDCCTOR-DAG: %[[LAB2:[0-9]+]] = add i32 %[[TEMP]], 0
41 // MCDCCTOR-DAG: %[[LAB3:[0-9]+]] = add i32 %[[TEMP]], 0
42 // MCDCCTOR-DAG: %[[LAB4:[0-9]+]] = select i1 %[[BOOL]], i32 %[[LAB2]], i32 %[[LAB3]]
43 // MCDCCTOR-DAG: store i32 %[[LAB4]], ptr %mcdc.addr, align 4
45 // SHIFT SECOND CONDITION WITH ID = 1.
46 // MCDCCTOR: %[[LAB1:[0-9]+]] = load i32, ptr %value2, align 4
47 // MCDCCTOR-DAG: %[[BOOL:cmp[0-9]*]] = icmp ne i32 %[[LAB1]], 6
48 // MCDCCTOR-DAG: %[[TEMP:mcdc.*]] = load i32, ptr %mcdc.addr, align 4
49 // MCDCCTOR-DAG: %[[LAB2:[0-9]+]] = add i32 %[[TEMP]], 2
50 // MCDCCTOR-DAG: %[[LAB3:[0-9]+]] = add i32 %[[TEMP]], 1
51 // MCDCCTOR-DAG: %[[LAB4:[0-9]+]] = select i1 %[[BOOL]], i32 %[[LAB2]], i32 %[[LAB3]]
52 // MCDCCTOR-DAG: store i32 %[[LAB4]], ptr %mcdc.addr, align 4
54 // UPDATE FINAL BITMASK WITH RESULT.
55 // MCDCCTOR-DAG: %[[TEMP0:mcdc.temp[0-9]*]] = load i32, ptr %mcdc.addr, align 4
56 // MCDCCTOR: %[[TEMP:[0-9]+]] = add i32 %[[TEMP0]], 0
57 // MCDCCTOR: %[[LAB1:[0-9]+]] = lshr i32 %[[TEMP]], 3
58 // MCDCCTOR: %[[LAB4:[0-9]+]] = getelementptr inbounds i8, ptr @__profbm__ZN5ValueC2Ev, i32 %[[LAB1]]
59 // MCDCCTOR: %[[LAB5:[0-9]+]] = and i32 %[[TEMP]], 7
60 // MCDCCTOR: %[[LAB6:[0-9]+]] = trunc i32 %[[LAB5]] to i8
61 // MCDCCTOR: %[[LAB7:[0-9]+]] = shl i8 1, %[[LAB6]]
62 // MCDCCTOR: %[[BITS:.+]] = load i8, ptr %[[LAB4]], align 1
63 // MCDCCTOR: %[[LAB8:[0-9]+]] = or i8 %[[BITS]], %[[LAB7]]
64 // MCDCCTOR: store i8 %[[LAB8]], ptr %[[LAB4]], align 1
66 // MCDCDTOR: @__profbm__ZN5ValueD2Ev = private global [1 x i8] zeroinitializer
67 // MCDCDTOR: @__profc__ZN5ValueD2Ev = private global [4 x i64] zeroinitializer
69 // ALLOCATE MCDC TEMP AND ZERO IT.
70 // MCDCDTOR-LABEL: @_ZN5ValueD2Ev(
71 // MCDCDTOR: %mcdc.addr = alloca i32, align 4
72 // MCDCDTOR: store i32 0, ptr %mcdc.addr, align 4
74 // SHIFT FIRST CONDITION WITH ID = 0.
75 // MCDCDTOR: %[[LAB1:[0-9]+]] = load i32, ptr %value, align 4
76 // MCDCDTOR-DAG: %[[BOOL:cmp[0-9]*]] = icmp ne i32 %[[LAB1]], 2
77 // MCDCDTOR-DAG: %[[TEMP:mcdc.*]] = load i32, ptr %mcdc.addr, align 4
78 // MCDCDTOR-DAG: %[[LAB2:[0-9]+]] = add i32 %[[TEMP]], 0
79 // MCDCDTOR-DAG: %[[LAB3:[0-9]+]] = add i32 %[[TEMP]], 0
80 // MCDCDTOR-DAG: %[[LAB4:[0-9]+]] = select i1 %[[BOOL]], i32 %[[LAB2]], i32 %[[LAB3]]
81 // MCDCDTOR-DAG: store i32 %[[LAB4]], ptr %mcdc.addr, align 4
83 // SHIFT SECOND CONDITION WITH ID = 1.
84 // MCDCDTOR: %[[LAB1:[0-9]+]] = load i32, ptr %value2, align 4
85 // MCDCDTOR-DAG: %[[BOOL:cmp[0-9]*]] = icmp ne i32 %[[LAB1]], 3
86 // MCDCDTOR-DAG: %[[TEMP:mcdc.*]] = load i32, ptr %mcdc.addr, align 4
87 // MCDCDTOR-DAG: %[[LAB2:[0-9]+]] = add i32 %[[TEMP]], 2
88 // MCDCDTOR-DAG: %[[LAB3:[0-9]+]] = add i32 %[[TEMP]], 1
89 // MCDCDTOR-DAG: %[[LAB4:[0-9]+]] = select i1 %[[BOOL]], i32 %[[LAB2]], i32 %[[LAB3]]
90 // MCDCDTOR-DAG: store i32 %[[LAB4]], ptr %mcdc.addr, align 4
92 // UPDATE FINAL BITMASK WITH RESULT.
93 // MCDCDTOR-DAG: %[[TEMP0:mcdc.temp[0-9]*]] = load i32, ptr %mcdc.addr, align 4
94 // MCDCDTOR: %[[TEMP:[0-9]+]] = add i32 %[[TEMP0]], 0
95 // MCDCDTOR: %[[LAB1:[0-9]+]] = lshr i32 %[[TEMP]], 3
96 // MCDCDTOR: %[[LAB4:[0-9]+]] = getelementptr inbounds i8, ptr @__profbm__ZN5ValueD2Ev, i32 %[[LAB1]]
97 // MCDCDTOR: %[[LAB5:[0-9]+]] = and i32 %[[TEMP]], 7
98 // MCDCDTOR: %[[LAB6:[0-9]+]] = trunc i32 %[[LAB5]] to i8
99 // MCDCDTOR: %[[LAB7:[0-9]+]] = shl i8 1, %[[LAB6]]
100 // MCDCDTOR: %[[BITS:.+]] = load i8, ptr %[[LAB4]], align 1
101 // MCDCDTOR: %[[LAB8:[0-9]+]] = or i8 %[[BITS]], %[[LAB7]]
102 // MCDCDTOR: store i8 %[[LAB8]], ptr %[[LAB4]], align 1