45 lines · c
1// Test that the specified output merges the profiling data.2// Run the program twice so that the counters accumulate.3// RUN: %clang_profgen -fcoverage-mapping -o %t %s4// RUN: rm -f %t.merging.profraw %t.merging.profdata5// RUN: %run %t %t.merging.profraw6// RUN: %run %t %t.merging.profraw7// RUN: test -f %t.merging.profraw8// RUN: llvm-profdata merge -o %t.merging.profdata %t.merging.profraw9// RUN: llvm-cov show -instr-profile %t.merging.profdata %t | FileCheck %s --match-full-lines10#include <stdio.h>11 12extern void __llvm_profile_set_file_object(FILE *, int);13 14int main(int argc, const char *argv[]) {15 if (argc < 2)16 return 1;17 18 FILE *F = fopen(argv[1], "r+b");19 if (!F) {20 // File might not exist, try opening with truncation21 F = fopen(argv[1], "w+b");22 }23 __llvm_profile_set_file_object(F, 1);24 25 return 0;26}27// XFAIL: target={{.*}}-aix{{.*}}28// CHECK: 10| |#include <stdio.h>29// CHECK: 11| |30// CHECK: 12| |extern void __llvm_profile_set_file_object(FILE *, int);31// CHECK: 13| |32// CHECK: 14| 2|int main(int argc, const char *argv[]) {33// CHECK: 15| 2| if (argc < 2)34// CHECK: 16| 0| return 1;35// CHECK: 17| |36// CHECK: 18| 2| FILE *F = fopen(argv[1], "r+b");37// CHECK: 19| 2| if (!F) {38// CHECK: 20| | // File might not exist, try opening with truncation39// CHECK: 21| 1| F = fopen(argv[1], "w+b");40// CHECK: 22| 1| }41// CHECK: 23| 2| __llvm_profile_set_file_object(F, 1);42// CHECK: 24| |43// CHECK: 25| 2| return 0;44// CHECK: 26| 2|}45