[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGen / code-coverage.c
blob3748f23cbf674a59503aade3d339733d72bec25b
1 /// We support coverage versions 3.4, 4.7 and 4.8.
2 /// 3.4 redesigns the format and changed .da to .gcda
3 /// 4.7 enables cfg_checksum.
4 /// 4.8 (default, compatible with gcov 7) emits the exit block the second.
5 // RUN: %clang_cc1 -emit-llvm -disable-red-zone -fprofile-arcs -coverage-version='304*' %s -o - | \
6 // RUN: FileCheck --check-prefixes=CHECK,304 %s
7 // RUN: %clang_cc1 -emit-llvm -disable-red-zone -fprofile-arcs -coverage-version='407*' %s -o - | \
8 // RUN: FileCheck --check-prefixes=CHECK,407 %s
9 // RUN: %clang_cc1 -emit-llvm -disable-red-zone -fprofile-arcs %s -o - | \
10 // RUN: FileCheck --check-prefixes=CHECK,408 %s
12 // RUN: %clang_cc1 -emit-llvm -disable-red-zone -fprofile-arcs -coverage-notes-file=aaa.gcno -coverage-data-file=bbb.gcda -debug-info-kind=limited -dwarf-version=4 %s -o - | FileCheck %s --check-prefix GCOV_FILE_INFO
14 // RUN: %clang_cc1 -emit-llvm-bc -o /dev/null -fdebug-pass-manager -fprofile-arcs %s 2>&1 | FileCheck --check-prefix=NEWPM %s
15 // RUN: %clang_cc1 -emit-llvm-bc -o /dev/null -fdebug-pass-manager -fprofile-arcs -O3 %s 2>&1 | FileCheck --check-prefix=NEWPM-O3 %s
17 // NEWPM-NOT: Running pass
18 // NEWPM: Running pass: GCOVProfilerPass
20 // NEWPM-O3-NOT: Running pass
21 // NEWPM-O3: Running pass: Annotation2MetadataPass
22 // NEWPM-O3: Running pass: ForceFunctionAttrsPass
23 // NEWPM-O3: Running pass: GCOVProfilerPass
25 int test1(int a) {
26 switch (a % 2) {
27 case 0:
28 ++a;
29 case 1:
30 a /= 2;
32 return a;
35 int test2(int b) {
36 return b * 2;
40 // CHECK: @__llvm_internal_gcov_emit_function_args.0 = internal unnamed_addr constant [2 x %emit_function_args_ty]
41 // CHECK-SAME: [%emit_function_args_ty { i32 0, i32 {{[-0-9]+}}, i32 {{[-0-9]+}} }, %emit_function_args_ty { i32 1, i32 {{[-0-9]+}}, i32 {{[-0-9]+}} }]
43 // CHECK: @__llvm_internal_gcov_emit_file_info = internal unnamed_addr constant [1 x %file_info]
44 /// 0x3330342a '3' '0' '4' '*'
45 // 304-SAME: i32 858797098
46 /// 0x3430372a '4' '0' '7' '*'
47 // 407-SAME: i32 875575082
48 /// 0x3430382a '4' '0' '8' '*'
49 // 408-SAME: i32 875575338
51 // Check that the noredzone flag is set on the generated functions.
53 // CHECK: void @__llvm_gcov_writeout() unnamed_addr [[NRZ:#[0-9]+]]
54 // CHECK: void @__llvm_gcov_init() unnamed_addr [[NRZ]]
56 // CHECK: attributes [[NRZ]] = { {{.*}}noredzone{{.*}} }
58 // GCOV_FILE_INFO: !llvm.gcov = !{![[GCOV:[0-9]+]]}
59 // GCOV_FILE_INFO: ![[GCOV]] = !{!"aaa.gcno", !"bbb.gcda", !{{[0-9]+}}}