xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGen/code-coverage.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -emit-llvm -disable-red-zone -femit-coverage-data %s -o - | FileCheck %s
2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -emit-llvm -disable-red-zone -femit-coverage-data -coverage-no-function-names-in-data %s -o - | FileCheck %s --check-prefix WITHOUTNAMES
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc // <rdar://problem/12843084>
5*f4a2713aSLionel Sambuc 
test1(int a)6*f4a2713aSLionel Sambuc int test1(int a) {
7*f4a2713aSLionel Sambuc   switch (a % 2) {
8*f4a2713aSLionel Sambuc   case 0:
9*f4a2713aSLionel Sambuc     ++a;
10*f4a2713aSLionel Sambuc   case 1:
11*f4a2713aSLionel Sambuc     a /= 2;
12*f4a2713aSLionel Sambuc   }
13*f4a2713aSLionel Sambuc   return a;
14*f4a2713aSLionel Sambuc }
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc // Check that the noredzone flag is set on the generated functions.
17*f4a2713aSLionel Sambuc 
18*f4a2713aSLionel Sambuc // CHECK: void @__llvm_gcov_indirect_counter_increment(i32* %{{.*}}, i64** %{{.*}}) unnamed_addr [[NRZ:#[0-9]+]]
19*f4a2713aSLionel Sambuc 
20*f4a2713aSLionel Sambuc // Inside llvm_gcov_writeout, check that -coverage-no-function-names-in-data
21*f4a2713aSLionel Sambuc // passes null as the function name.
22*f4a2713aSLionel Sambuc // CHECK: void @__llvm_gcov_writeout() unnamed_addr [[NRZ]]
23*f4a2713aSLionel Sambuc // CHECK: call void @llvm_gcda_emit_function({{.*}}, i8* getelementptr {{.*}}, {{.*}})
24*f4a2713aSLionel Sambuc // WITHOUTNAMES: void @__llvm_gcov_writeout() unnamed_addr
25*f4a2713aSLionel Sambuc // WITHOUTNAMES: call void @llvm_gcda_emit_function({{.*}}, i8* null, {{.*}})
26*f4a2713aSLionel Sambuc 
27*f4a2713aSLionel Sambuc // CHECK: void @__llvm_gcov_flush() unnamed_addr [[NRZ]]
28*f4a2713aSLionel Sambuc // CHECK: void @__llvm_gcov_init() unnamed_addr [[NRZ]]
29*f4a2713aSLionel Sambuc 
30*f4a2713aSLionel Sambuc // CHECK: attributes [[NRZ]] = { {{.*}}noredzone{{.*}} }
31