comparison clang/test/CodeGen/code-coverage.c @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 0572611fdcc8
children c4bab56944e8
comparison
equal deleted inserted replaced
173:0572611fdcc8 207:2e18cbf3894f
1 /// We support coverage versions 4.2, 4.7 and 4.8. 1 /// We support coverage versions 3.4, 4.7 and 4.8.
2 /// 3.4 redesigns the format and changed .da to .gcda
2 /// 4.7 enables cfg_checksum. 3 /// 4.7 enables cfg_checksum.
3 /// 4.8 (default, compatible with gcov 7) emits the exit block the second. 4 /// 4.8 (default, compatible with gcov 7) emits the exit block the second.
4 // RUN: %clang_cc1 -emit-llvm -disable-red-zone -femit-coverage-data -coverage-version='402*' %s -o - | \ 5 // RUN: %clang_cc1 -emit-llvm -disable-red-zone -fprofile-arcs -coverage-version='304*' %s -o - | \
5 // RUN: FileCheck --check-prefixes=CHECK,402 %s 6 // RUN: FileCheck --check-prefixes=CHECK,304 %s
6 // RUN: %clang_cc1 -emit-llvm -disable-red-zone -femit-coverage-data -coverage-version='407*' %s -o - | \ 7 // RUN: %clang_cc1 -emit-llvm -disable-red-zone -fprofile-arcs -coverage-version='407*' %s -o - | \
7 // RUN: FileCheck --check-prefixes=CHECK,407 %s 8 // RUN: FileCheck --check-prefixes=CHECK,407 %s
8 // RUN: %clang_cc1 -emit-llvm -disable-red-zone -femit-coverage-data %s -o - | \ 9 // RUN: %clang_cc1 -emit-llvm -disable-red-zone -fprofile-arcs %s -o - | \
9 // RUN: FileCheck --check-prefixes=CHECK,408 %s 10 // RUN: FileCheck --check-prefixes=CHECK,408 %s
10 11
11 // RUN: %clang_cc1 -emit-llvm -disable-red-zone -femit-coverage-data -coverage-notes-file=aaa.gcno -coverage-data-file=bbb.gcda -dwarf-column-info -debug-info-kind=limited -dwarf-version=4 %s -o - | FileCheck %s --check-prefix GCOV_FILE_INFO 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
12 13
13 // RUN: %clang_cc1 -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager -fdebug-pass-manager -femit-coverage-data %s 2>&1 | FileCheck --check-prefix=NEWPM %s 14 // RUN: %clang_cc1 -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager -fdebug-pass-manager -fprofile-arcs %s 2>&1 | FileCheck --check-prefix=NEWPM %s
14 // RUN: %clang_cc1 -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager -fdebug-pass-manager -femit-coverage-data -O3 %s 2>&1 | FileCheck --check-prefix=NEWPM-O3 %s 15 // RUN: %clang_cc1 -emit-llvm-bc -o /dev/null -fexperimental-new-pass-manager -fdebug-pass-manager -fprofile-arcs -O3 %s 2>&1 | FileCheck --check-prefix=NEWPM-O3 %s
15 16
16 // NEWPM-NOT: Running pass 17 // NEWPM-NOT: Running pass
17 // NEWPM: Running pass: GCOVProfilerPass 18 // NEWPM: Running pass: GCOVProfilerPass
18 19
19 // NEWPM-O3-NOT: Running pass 20 // NEWPM-O3-NOT: Running pass
21 // NEWPM-O3: Running pass: Annotation2MetadataPass
20 // NEWPM-O3: Running pass: ForceFunctionAttrsPass 22 // NEWPM-O3: Running pass: ForceFunctionAttrsPass
21 // NEWPM-O3: Running pass: GCOVProfilerPass 23 // NEWPM-O3: Running pass: GCOVProfilerPass
22
23 24
24 int test1(int a) { 25 int test1(int a) {
25 switch (a % 2) { 26 switch (a % 2) {
26 case 0: 27 case 0:
27 ++a; 28 ++a;
33 34
34 int test2(int b) { 35 int test2(int b) {
35 return b * 2; 36 return b * 2;
36 } 37 }
37 38
38 // 402: private unnamed_addr constant [5 x i8] c"*204\00"
39 // 407: private unnamed_addr constant [5 x i8] c"*704\00"
40 // 408: private unnamed_addr constant [5 x i8] c"*804\00"
41 39
42 // CHECK: @__llvm_internal_gcov_emit_function_args.0 = internal unnamed_addr constant [2 x %0] 40 // CHECK: @__llvm_internal_gcov_emit_function_args.0 = internal unnamed_addr constant [2 x %emit_function_args_ty]
43 // CHECK-SAME: [%0 zeroinitializer, %0 { i32 1, i32 0, i32 0 }] 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]+}} }]
42
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
44 50
45 // Check that the noredzone flag is set on the generated functions. 51 // Check that the noredzone flag is set on the generated functions.
46 52
47 // CHECK: void @__llvm_gcov_writeout() unnamed_addr [[NRZ:#[0-9]+]] 53 // CHECK: void @__llvm_gcov_writeout() unnamed_addr [[NRZ:#[0-9]+]]
48 // CHECK: void @__llvm_gcov_flush() unnamed_addr [[NRZ]]
49 // CHECK: void @__llvm_gcov_init() unnamed_addr [[NRZ]] 54 // CHECK: void @__llvm_gcov_init() unnamed_addr [[NRZ]]
50 55
51 // CHECK: attributes [[NRZ]] = { {{.*}}noredzone{{.*}} } 56 // CHECK: attributes [[NRZ]] = { {{.*}}noredzone{{.*}} }
52 57
53 // GCOV_FILE_INFO: !llvm.gcov = !{![[GCOV:[0-9]+]]} 58 // GCOV_FILE_INFO: !llvm.gcov = !{![[GCOV:[0-9]+]]}