<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/74022>74022</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Rework Clang PGO documentation
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
zamazan4ik
</td>
</tr>
</table>
<pre>
Here I want to propose several suggestions to the Clang PGO [documentation](https://clang.llvm.org/docs/UsersManual.html#profile-guided-optimization).
We need to add information about LLVM runtime functions to the PGO documentation. Right now it does not cover at all provided by LLVM PGO-oriented functions like `__llvm_profile_write_buffer` and other functions from https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/profile/InstrProfiling.h (and probably other files - I am not familiar much yet with this piece of LLVM). Knowing which functions are provided by the instrumentation runtime and how to use them is important for users since in many cases they want to implement manual logic with dumping PGO profiles. Right now only a small subset of these functions are covered in https://clang.llvm.org/docs/SourceBasedCodeCoverage.html#running-the-instrumented-program - we need to move these descriptions to the main PGO documentation and extend it.
Here are some examples of existing usages:
* YugabyteDB: https://github.com/yugabyte/yugabyte-db/commit/34cb791ed9d3d5f8ae9a9b9e9181a46485e1981d
* Symbolicator: https://github.com/getsentry/symbolicator/issues/1334
We need to write LLVM profdata backward and forward compatibility guarantees directly in the Clang PGO documentation. Right now this information is located here - https://clang.llvm.org/docs/SourceBasedCodeCoverage.html#format-compatibility-guarantees . Having this information in the "SourceBasedCodeCoverage" can be confusing for the users since this at least the source-code coverage in terms of PGO refers only to FE PGO. But Clang also supports IR PGO (the recommended way to do PGO with Clang nowadays). As far as I understand, from the profile format point of view, the guarantees are the same - it should be documented as well.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVstu28gS_ZrWpiBBbEm2uNDCj6vEuAkSJLh3MCujyC6SPe4H0Q8rzNcPqqXY0gSeBzAbm3ZX1-PUOYfEGHXviHZicys29zPMafBh9x0tfke31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