[compiler-rt] [compiler-rt] Add baremetal version of profile library. (PR #167998)

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 18 02:59:33 PST 2025


smithp35 wrote:

Thanks for adding the comments. I agree with you on splitting the file, was tempted to mention that yesterday but it may have been a change too far for others to accept.

> This subset of the profile library includes __llvm_profile_write_buffer, which outputs counters in the format llvm-profdata expects. Obviously the user still needs to copy that data off the device somehow.

Thanks for pointing that out, it is quite easy to miss what the intended usage is. I eWhat I was thinking for a comment for toolchain vendors for how to use the API to save some time figuring it out. May not need to be in the source code, could put it in the description. 

Could it be as simple as:
```
extern uint64_t __llvm_profile_get_size_for_buffer(void);
extern int __llvm_profile_write_buffer(char *Buffer);

uint64_t size = __llvm_profile_get_size_for_buffer(void);
char* buffer = allocate_memory(size);
if (__llvm_profile_write_buffer(buffer) == -1) {
  // error
}
// Program specifc way to write out buffer
```

I'm with Lenary in that I'm supportive of the direction, but I don't have any prior commit experience. If we end up with no-one willing to approve/reject I can put my name to it though.

https://github.com/llvm/llvm-project/pull/167998


More information about the llvm-commits mailing list