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: rm -rf %t && mkdir %t && cd %t 6 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -disable-red-zone -coverage-data-file=/dev/null -coverage-version='B21*' %s -o - | \ 7 // RUN: FileCheck --check-prefixes=CHECK,CHECK-CTOR-INIT,1210 %s 8 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -disable-red-zone -coverage-data-file=/dev/null %s -o - | \ 9 // RUN: FileCheck --check-prefixes=CHECK,CHECK-CTOR-INIT,1110 %s 10 // RUN: %clang_cc1 -triple powerpc64-ibm-aix -emit-llvm -disable-red-zone -coverage-data-file=/dev/null -coverage-version='B21*' %s -o - | \ 11 // RUN: FileCheck --check-prefixes=CHECK,CHECK-RT-INIT,1210 %s 12 // RUN: %clang_cc1 -triple powerpc64-ibm-aix -emit-llvm -disable-red-zone -coverage-data-file=/dev/null %s -o - | \ 13 // RUN: FileCheck --check-prefixes=CHECK,CHECK-RT-INIT,1110 %s 14 15 // RUN: %clang_cc1 -emit-llvm -disable-red-zone -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 16 17 // RUN: %clang_cc1 -emit-llvm-bc -o /dev/null -fdebug-pass-manager -coverage-data-file=/dev/null %s 2>&1 | FileCheck --check-prefix=NEWPM %s 18 // RUN: %clang_cc1 -emit-llvm-bc -o /dev/null -fdebug-pass-manager -coverage-data-file=/dev/null -O3 %s 2>&1 | FileCheck --check-prefix=NEWPM-O3 %s 19 20 // NEWPM: Running pass: VerifierPass 21 // NEWPM: Running pass: GCOVProfilerPass 22 23 // NEWPM-O3: Running pass: VerifierPass 24 // NEWPM-O3: Running pass: Annotation2MetadataPass 25 // NEWPM-O3: Running pass: ForceFunctionAttrsPass 26 // NEWPM-O3: Running pass: GCOVProfilerPass 27 28 int test1(int a) { 29 switch (a % 2) { 30 case 0: 31 ++a; 32 case 1: 33 a /= 2; 34 } 35 return a; 36 } 37 38 int test2(int b) { 39 return b * 2; 40 } 41 42 43 // CHECK: @__llvm_internal_gcov_emit_function_args.0 = internal unnamed_addr constant [2 x %emit_function_args_ty] 44 // 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]+}} }] 45 46 // CHECK: @__llvm_internal_gcov_emit_file_info = internal unnamed_addr constant [1 x %file_info] 47 /// 0x4231312a 'B' '1' '1' '*' 48 // 1110-SAME: i32 1110520106 49 /// 0x4232312a 'B' '2' '1' '*' 50 // 1210-SAME: i32 1110585642 51 52 // Check for gcov initialization function pointers. 53 // CHECK-RT-INIT: @__llvm_covinit_functions = private constant { ptr, ptr } { ptr @__llvm_gcov_writeout, ptr @__llvm_gcov_reset }, section "__llvm_covinit" 54 55 // Check that the noredzone flag is set on the generated functions. 56 57 // CHECK: void @__llvm_gcov_writeout() unnamed_addr [[NRZ:#[0-9]+]] 58 // CHECK-CTOR-INIT: void @__llvm_gcov_init() unnamed_addr [[NRZ]] 59 60 // CHECK: attributes [[NRZ]] = { {{.*}}noredzone{{.*}} } 61 62 // GCOV_FILE_INFO: !llvm.gcov = !{![[GCOV:[0-9]+]]} 63 // GCOV_FILE_INFO: ![[GCOV]] = !{!"aaa.gcno", !"bbb.gcda", !{{[0-9]+}}} 64