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

    <tr>
        <th>Summary</th>
        <td>
            [CIR] Upstream support for thread local variables
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            ClangIR
      </td>
    </tr>

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

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

<pre>
    ### Overview
Upstream support for handling thread local variables in ClangIR. 

This will need to be layered on top of existing global variable handling. There are some places in the current code marked by 

` assert(!cir::MissingFeatures::opGlobalThreadLocal());`

or

` assert(!cir::MissingFeatures::opLoadStoreThreadLocal());`

where code must be added, but additional changes are required.

Some support for thread local variable handling is missing even in the incubator project. That will require new CIR development to fully implement, but it should be guided by clang's LLVM IR generation code.

### Suggested minimal test case
```
__thread int a;
```
### Existing incubator tests
clang/test/CIR/CodeGen/tls.c
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJycVF9r5DYQ_zTyy3CLLK_t7IMf9nL1EchRSNK-HmNpYqsnS67-bLrfvsh2ulcIFArCRjL6ze_PjDEEPVqijtWfWf2lwBQn5zu06voDr8b5YnDq2jFRbQt-vZC_aHpj_PzbEqInnCGkZXE-wqvzMKFVRtsR4uQJFRgn0cAFvcbBUABt4d6gHR-eDsD4mfHzy6QDvGljwBIpiA4GAoNX8qTAWYhuAfcK9JcOMQOPxg0_Qf5T8QAvE3kC9ATBzQSLQblVjBOBTN6TjSCdIpjR_yAFw3XnwBoOGAL5yMQdE6XUnlVnVp2_6RC0HXvCmDyF7dAtX1cOL6vEx6xwvXbKq_rMGr6hOv__0B8dqufoPP1XgbdV8KYohZiNQ6VIMXEPQ4p5o6N2Fg3ICe1IYXXH059Je1KHDeU5m_Vzhh9Gd0tWB5g34kAXsu8GayvTgNF5WLz7g2TMgWDcot1LgqU3uH94AkUXMm6ZcyLRwWsy5gp6Xgzlo3f-OkKYXDIqKxuTVltmMjcQE22Ax8ffv8HDE4xkyWOWurqxC7t17XMaRwqRFMza6hkNRAoRJAba8tkXP3__vqvXNgJms__9_Yb5y3tD3oRn0MD4eSfY5z0T_f3DU346RV_J5mMTDrJQXaVO1QkL6sq2rrk4NWVbTJ2UdXunqOGlFHfYDjS8kuS1QJRN2R6bQneCi5rflULwsqraw1GJQcmhOYmjak-NYEdOM2pzMOYyH5wfCx1Coq6sK9HywuBAJqwTL8Q-jEyIPP6-y1c-DWkM7MiNDjHcQKKOZv1RZD31F_hw_j8e-yJ5000xLmuPi56JftRxSsNBupmJPtfYX5_27mGiX1kHJvqd-KUTfwcAAP__cquJnw">