1 // RUN: %clang_profgen -O3 -o %t %s
2 // RUN: %run %t %t.out.1 %t.out.2 %t.out.3 %t.out.4
3 // RUN: cat %t.out.1 | FileCheck %s
4 // RUN: diff %t.out.1 %t.out.2
5 // RUN: diff %t.out.2 %t.out.3
6 // RUN: diff %t.out.3 %t.out.4
13 typedef struct ProfBufferIO ProfBufferIO
;
14 ProfBufferIO
*lprofCreateBufferIOInternal(void *File
, uint32_t BufferSz
);
15 void lprofDeleteBufferIO(ProfBufferIO
*BufferIO
);
17 int lprofBufferIOWrite(ProfBufferIO
*BufferIO
, const char *Data
, uint32_t Size
);
18 int lprofBufferIOFlush(ProfBufferIO
*BufferIO
);
20 int __llvm_profile_runtime
= 0;
22 const char *SmallData
= "ABC\n";
23 const char *MediumData
=
24 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\n";
25 char LargeData
[10 * 1024];
26 int main(int argc
, const char *argv
[]) {
27 ProfBufferIO
*BufferIO
;
29 uint32_t IOBufferSize
[4] = {8, 128, 8 * 1024, 11 * 1024};
34 for (I
= 0; I
< 10 * 1024 - 2; I
++)
37 LargeData
[I
++] = '\n';
38 LargeData
[I
++] = '\0';
40 for (J
= 0; J
< 4; J
++) {
41 File
[J
] = fopen(argv
[1 + J
], "w");
45 BufferIO
= lprofCreateBufferIOInternal(File
[J
], IOBufferSize
[J
]);
47 lprofBufferIOWrite(BufferIO
, "Short Strings:\n",
48 strlen("Short Strings:\n"));
49 for (I
= 0; I
< 1024; I
++) {
50 lprofBufferIOWrite(BufferIO
, SmallData
, strlen(SmallData
));
52 lprofBufferIOWrite(BufferIO
, "Long Strings:\n", strlen("Long Strings:\n"));
53 for (I
= 0; I
< 1024; I
++) {
54 lprofBufferIOWrite(BufferIO
, MediumData
, strlen(MediumData
));
56 lprofBufferIOWrite(BufferIO
, "Extra Long Strings:\n",
57 strlen("Extra Long Strings:\n"));
58 for (I
= 0; I
< 10; I
++) {
59 lprofBufferIOWrite(BufferIO
, LargeData
, strlen(LargeData
));
61 lprofBufferIOWrite(BufferIO
, "Mixed Strings:\n", strlen("Mixed Strings:\n"));
62 for (I
= 0; I
< 1024; I
++) {
63 lprofBufferIOWrite(BufferIO
, MediumData
, strlen(MediumData
));
64 lprofBufferIOWrite(BufferIO
, SmallData
, strlen(SmallData
));
66 lprofBufferIOWrite(BufferIO
, "Endings:\n", strlen("Endings:\n"));
67 lprofBufferIOWrite(BufferIO
, "END\n", strlen("END\n"));
68 lprofBufferIOWrite(BufferIO
, "ENDEND\n", strlen("ENDEND\n"));
69 lprofBufferIOWrite(BufferIO
, "ENDENDEND\n", strlen("ENDENDEND\n"));
70 lprofBufferIOWrite(BufferIO
, "ENDENDENDEND\n", strlen("ENDENDENDEND\n"));
71 lprofBufferIOFlush(BufferIO
);
73 lprofDeleteBufferIO(BufferIO
);
80 // CHECK-LABEL: Short Strings:
95 // CHECK-LABEL: Long Strings:
96 // CHECK-NEXT: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
97 // CHECK-NEXT: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
98 // CHECK-NEXT: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
99 // CHECK-NEXT: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
100 // CHECK-NEXT: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
101 // CHECK-NEXT: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
102 // CHECK-NEXT: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
103 // CHECK-NEXT: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
104 // CHECK-NEXT: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
105 // CHECK-NEXT: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
106 // CHECK-NEXT: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
107 // CHECK-NEXT: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
108 // CHECK-LABEL: Mixed Strings:
109 // CHECK: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
111 // CHECK-NEXT: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
113 // CHECK-NEXT: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
115 // CHECK-NEXT: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
117 // CHECK-NEXT: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
119 // CHECK-NEXT: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
121 // CHECK-NEXT: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
123 // CHECK-NEXT: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
125 // CHECK-LABEL: Endings:
127 // CHECK-NEXT: ENDEND
128 // CHECK-NEXT: ENDENDEND
129 // CHECK-NEXT: ENDENDENDEND