1 // RUN: rm -f %t.profraw
2 // RUN: touch %t.profraw
3 // RUN: %clang_profgen -o %t %s
5 // RUN: %t %t.profraw modifyfile
6 // RUN: cp %t.profraw %t.profraw.old
7 // RUN: %t %t.profraw 2>&1 | FileCheck %s
8 // RUN: diff %t.profraw %t.profraw.old
9 // CHECK: Invalid profile data to merge
23 #define VALUE_PROF_KIND(Enumerator, Value, Descr) Enumerator = Value,
24 #include "profile/InstrProfData.inc"
27 typedef struct __llvm_profile_header
{
28 #define INSTR_PROF_RAW_HEADER(Type, Name, Initializer) Type Name;
29 #include "profile/InstrProfData.inc"
30 } __llvm_profile_header
;
32 typedef void *IntPtrT
;
33 typedef struct __llvm_profile_data
{
34 #define INSTR_PROF_DATA(Type, LLVMType, Name, Initializer) Type Name;
35 #include "profile/InstrProfData.inc"
36 } __llvm_profile_data
;
38 void __llvm_profile_set_file_object(FILE* File
, int EnableMerge
);
40 void bail(const char* str
) {
41 fprintf(stderr
, "%s %s\n", str
, strerror(errno
));
45 int main(int argc
, char** argv
) {
47 int fd
= open(argv
[1], O_RDWR
);
52 if (stat(argv
[1], &st
))
54 uint64_t FileSize
= st
.st_size
;
56 char* Buf
= (char *) mmap(NULL
, FileSize
, PROT_READ
| PROT_WRITE
, MAP_SHARED
, fd
, 0);
57 if (Buf
== MAP_FAILED
)
60 __llvm_profile_header
*Header
= (__llvm_profile_header
*)Buf
;
61 __llvm_profile_data
*SrcDataStart
=
62 (__llvm_profile_data
*)(Buf
+ sizeof(__llvm_profile_header
) +
63 Header
->BinaryIdsSize
);
64 memset(&SrcDataStart
->CounterPtr
, 0xAB, sizeof(SrcDataStart
->CounterPtr
));
66 if (munmap(Buf
, FileSize
))
72 FILE* f
= fopen(argv
[1], "r+b");
75 __llvm_profile_set_file_object(f
, 1);