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

    <tr>
        <th>Summary</th>
        <td>
            `-mfunction-return=thunk-extern` does not affect sanitizer constructors
        </td>
    </tr>

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

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

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

<pre>
    As reported by @nathanchance [here](https://lore.kernel.org/llvm/Ys7pLq+tQk5xEa%2FB@dev-arch.thelio-3990X/), mixing `-mfunction-return=thunk-extern` with various sanitizers is not producing mitigated sanitizer constructor functions.

I know exactly what this is; the front-end attributes functions during clang's CodeGen of LLVM IR that they should be fn_ret_thunk_extern.  Then LLVM synthesizes new functions without knowledge that new functions should have these attributes.  We've seen this before, I think with stack protectors (`nossp`, `ssp`, etc).

I will fix this, but marking it a blocker for the clang-15 release, and to have something to point to so I can pause ongoing backporting issues related to retbleed for this.

cc @topperc @AaronBallman @kees 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyNVE2P4zYM_TXOhUjgyLGTHHyY7OwWA0wPLYp-nAayTMday5IrSpOkv76UMu3sLHooEEcfpPj4yCd1rr-1DwQeF-cD9tDdoNiVVoZRWpU-hKI-jeixqB8LcRhDWKioHgrxhX_GedxM6C2ajfPntGNeZx7-oP3y_GchTuGnqb5-loWoxZcTR-7xdS29GjdhRKPdujoey99zsGMhPsGsr9qeoWjK9TxEq4J2du0xRG-L6jGM0U5rvAZGZBe46DDCq_TaRQKSVgf9F3oCTWBdgMW7PqoUb2bLWSZ-_3qBcpaCjyo4D_9A0aYoH4vy4f7_BJN1F8CrVMHc4DLKAGHUKX5RnXiKMHhnwxptDzIEr7sYkN6jQR99gldGWi7OnuCT6_EHtOAGeH7-9Ud4-pnD5LB4AxpdNNwCDmtfmPRL5vty57sB-GXkk_kY3SyfIObBTPHyDWIqiYshZ26wP-M9_kenN6BRviYzEn6TPeP8hpwrmwgZLxPucOBOpwY9pQ073UtPQaoplTlgKiMBC4T7Yh3RwmPy5-F9gUFxn7-r8UUbA4O-ZqTkxWnALP2UKqcDSOiMUywy4Bxy0XM519uaVWtQUs5LcguCu1MiN2PK8px2FqdtSBNynLySFhYZmbGzZ5dcOqaQtJ_RiCKmy2CyVvgQd6EzyPM7tv4oEKXSZQluWdDn6YNkPZykMTPj8HpCDrfq26o_Vke5CjoYbP-nuHuHdxnLYeDy_rdyaRW9aT9eyjO3JnYb5eb3-5iGNTfqK0fi5Z0oT-qm3u5WY7s7HhrVqMMwbKuD7PfNYRDqsCubartv-oNYGdmhoZbfgkKILrKaRW6vEG_iFvw-rHQrSiHK_bbaNjtRVhu5H4TsDmqo1dDU-4FrgrPUZpMSSk_Gyrc5Nw5JbDSaAr0bJZE-W8Q3XKvV1CPJaKzme_4GKiNL3rffGVeZY5sJ_g0yVqny">