<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/112103>112103</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Clang] CS-IR PGO doesn't generate profiles with LTO enabled 
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          gitoss
      </td>
    </tr>
</table>

<pre>
    I'm trying to use IR+CS-IR PGO to optimize the SVT-AV1-PSY encoder https://github.com/gianni-rosato/svt-av1-psy/discussions/69#discussioncomment-10918641

A binary compiled with -fcs-profile-generate -fprofile-use= silently fails to generate any profiles if (thin or full) LTO is enabled. This happens on LLVM 17 (Visual Stdío built-in) and LLVM 19 (last official binary available).

This seems to be a problem with other source code, too https://www.reddit.com/r/LLVM/comments/182psjg/comment/lrdktnd/?context=3

This could be a bug or "works as designed" because LTO defers performing optimization until link time https://llvm.org/docs/LinkTimeOptimization.html - but context sensitive PGO performs a post-inline late instrumentation https://clang.llvm.org/docs/UsersManual.html

If whis is "wad" please a) add the information about incompatibility with -fcs-profile-generate and -flto to the documentation, b) add a clang error/warning if this combination is used or c) warn and auto-disable -flto if -fcs-profile-generate is used.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VMFu4zgM_RrlQjiI5aRJDj5kGmRRoIMOpt0Ce5QtOuZUlgxRTjb79Qs6btOdwc4lgQWJfHzv8RlmOnrEUq2-qNV-ZobUhlgeKQXmWRXspXxQet1BihfyR0gBBkZ4-K70l_vn7OE7fPvjSU5Dn6ijfxBSi_D8-pLtXvPs2_NfgL4OFiO0KfWsip3SB6UPR0rtUM3r0I0fxnvKYmCTgtIHPqXMnPKs54vSB0tcD8wUPCt9uNsqXdyO6tB16FOWL7b55m6Zq8VeLXbX3x1U5E28QB26nhxaOFNqIWtqzvoYGnKYHdFjNAkha96PBkZ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