[compiler-rt] Fixed __llvm_profile_write_buffer in presence of ValueProfileData. (PR #97350)
Sunil Srivastava via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 1 21:50:07 PDT 2024
sks75220 wrote:
> I'm still reading the implementation. To clarify about the high-level goal, does this patch intend to add value profiling support for `__llvm_profile_write_buffer` (which is absent before)?
Yes.
> And would you mind elaborating on how is `__llvm_profile_write_buffer` is invoked in your use case?
Basically, the test program calls __llvm_profile_write_buffer(buf) to generate profdata in a buffer, and then writes that buffer to the file via plain fwrite. That should generate a valid profraw file, but it does not in this case. That is the bug being fixed here.
buf = malloc(bufsize = __llvm_profile_get_size_for_buffer());
__llvm_profile_write_buffer(buf); // generates invalid data
fwrite(buf, ....); // hence, generates invalid profraw file.
The generated file is not accepted by 'llvm-profdata show' or merge. They fail with :
$ bin/llvm-profdata show /home/ssrivastava/UPS2/BUILDRT/projects/compiler-rt/t
est/profile/Profile-x86_64/Output/instrprof-write-buffer.c.tmp.buf.profraw
error: /home/ssrivastava/UPS2/BUILDRT/projects/compiler-rt/test/profile/Profile-x86_64/Output/instrprof-write-buffer.c.tmp.buf.profraw: truncated profile data
https://github.com/llvm/llvm-project/pull/97350
More information about the llvm-commits
mailing list