<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/95644>95644</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[compiler-rt] [profile] __llvm_profile_get_size_for_buffer not contain the size of the value profile
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
dongjianqiang2
</td>
</tr>
</table>
<pre>
test.c :
```
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
int max(int a, int b) {
return a>b?a:b;
}
int __llvm_profile_runtime = 0;
uint64_t __llvm_profile_get_size_for_buffer(void);
int __llvm_profile_write_buffer(char *);
int __llvm_profile_merge_from_buffer(const char *, uint64_t Size);
int write_buffer(uint64_t, const char *);
int main(int argc, const char *argv[]) {
if (argc < 2)
return 1;
const uint64_t MaxSize = 10000;
static char Buffer[MaxSize];
int (*func)(int,int);
func = max;
int result=(*func)(1,2);
uint64_t Size = __llvm_profile_get_size_for_buffer();
if (Size > MaxSize)
return 1;
int Write = __llvm_profile_write_buffer(Buffer);
if (Write)
return Write;
// Actually write it out so we can FileCheck the output.
FILE *File = fopen(argv[1], "w");
if (!File)
return 1;
if (fwrite(Buffer, 1, Size, File) != Size)
return 1;
return fclose(File);
}
```
clang test.c -fprofile-generate
./a.out 111.profdata
llvm-profdata merge 111.profdata -o merge.profdata
warning: 111.profdata: truncated profile data
error: no profile can be merged
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVU2PozgQ_TXFpRSEDaThwCEfHWml3dMe9hgZKIhnHTtrTDIzv35lIEmHZKZbanWAqvfqVb3CiK6TrSYqIF1Dug1E7w7GFrXR7Tcp9H9S6JYHpal_FI46F1YI8QqiLUQrWEbT33jLY6kr1deEEG86V0vtwgPE778IK1l-DP-CwzzlSO3wKL4Dz_yVAL5Bf1ECzxHe1mMSIlpyvdUoIH4vId4JiFclxFMc3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