[all-commits] [llvm/llvm-project] dfdc3d: [ctx_profile] Profile reader and writer (#91859)

Mircea Trofin via All-commits all-commits at lists.llvm.org
Tue May 14 18:01:45 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: dfdc3dcbe7f38bde64bc83a74b9c3451c50e1ad4
      https://github.com/llvm/llvm-project/commit/dfdc3dcbe7f38bde64bc83a74b9c3451c50e1ad4
  Author: Mircea Trofin <mtrofin at google.com>
  Date:   2024-05-14 (Tue, 14 May 2024)

  Changed paths:
    A llvm/include/llvm/ProfileData/PGOCtxProfReader.h
    A llvm/include/llvm/ProfileData/PGOCtxProfWriter.h
    M llvm/lib/ProfileData/CMakeLists.txt
    A llvm/lib/ProfileData/PGOCtxProfReader.cpp
    A llvm/lib/ProfileData/PGOCtxProfWriter.cpp
    M llvm/unittests/ProfileData/CMakeLists.txt
    A llvm/unittests/ProfileData/PGOCtxProfReaderWriterTest.cpp

  Log Message:
  -----------
  [ctx_profile] Profile reader and writer (#91859)

Utility converting a profile coming from `compiler_rt` to bitstream, and
a reader.

`PGOCtxProfileWriter::write` would be used as the `Writer` parameter for
`__llvm_ctx_profile_fetch` API. This is expected to happen in user code,
for example in the RPC hanler tasked with collecting a profile, and
would look like this:

```
// set up an output stream "Out", which could contain other stuff
{
  // constructing the Writer will start the section, in Out, containing
  // the collected contextual profiles.
  PGOCtxProfWriter Writer(Out);
  __llvm_ctx_profile_fetch(&Writer, +[](void* W, const ContextNode &N) {
    reinterpret_cast<PGOCtxProfWriter*>(W)->write(N);
  });
  // Writer going out of scope will finish up the section.
}
```

The reader produces a data structure suitable for maintenance during IPO
transformations.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list