<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63022>63022</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[coroutines] Compiler incorrectly caches thread_local address across suspend-points in some scenarios
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
fpoliakov
</td>
</tr>
</table>
<pre>
The compiler (still) caches the thread_local variable addresses across the suspend points.
[A supposed fix](https://reviews.llvm.org/D135550) (which followed the discussion [here](https://discourse.llvm.org/t/rfc-unify-memory-effect-attributes/65579)) landed, and it indeed fixes many of the original issues. Another relevant closed issue on Github is [here](https://github.com/llvm/llvm-project/issues/47179).
However, it seems that the issue persists and in some cases TLS behavior isn't preserved, with some other parts (likely loop optimizer?..) messes up with the fix, still resulting in TLS variable address being cached.
Here is the example link showing the issue: https://godbolt.org/z/cz3PPqrcW
cc @ChuanqiXu9 as the implementer of the original fix, maybe you have any thoughts on it?.. Thanks for your work on the issue!
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVD2P4zYQ_TV0M7AhU5JXKlTs7cK5IsUBWSDpAoocmRNTpI5D2ef99QEl7wcuQYoAglRwNPPem8enmOnkETtRfxH180bNyYbYDVNwpM7hsumDuXUvFkGHcSKHEYRsOJFzQraglbbIkCxCshGV-dMFrRxcVCTVOwRlTERmZFA6Bl5LeeYJvYEpkE-8E8WzKB5F_eUReJ6mwGhgoB-ifhaysSlNLMpHIY9CHiNeCK-8c-4y7kI8CXl83pd1XRcZjZDN1ZK2MATnwhXNMs0Q65mZggdRf7EY8d8656owR8bPvVMeOejt7Gm4bUccQ7xtcRhQp61KKVI_J2Qhj4e6fmiFzA845Q0aIZ9AeQOUgLzBlRIyjMrfIAwLshDpRF45IOYZeQePPiSLESI6vCifQLtFjeUcgodfKNm5B-L_onJainY6jEIeM5v7ZzvF8BfqTGodKOSxetgvwN-WsLy_hiteMGYKlIARx7w3lRbQK5YJIxMnXjl64DAiaJUX_fLrb9CjVRcKEYi9kA8JpoiM8bLqcqVk1z9WupOKifP2HJ3R3cCFMEGYEo30ilGUx90uCzuuRpqntUEGk20in2DxI0Tk2SXypwwoo_jZhdBjPl1Ma-6Mv2LMnJZu-EONk0Nw5M_ANlxz9TtnUT7CT0IH0weX7mZ5FfKoX8tv375H_ftnObUGURVPdlb-O_0xt6DWcZSHjegTxn844k5sVLce4RZmsOqCkL2TbJhPNnG2A6VFHHixyp8ZhhBzbYRriOd8_oFd7jemK01btmqD3f7Q1FW7l1WzsZ1uTFUfKqnathyafS8Ph8bUylTlvnnQWG6ok4Usi7rcF0VRVPtdKxs0UjbD3rSHQz2IqsBRkXu_OptlaHcoCyk3TvXoeAkYKT1e3xDJnDexW5zZzycWVeGypT66JEpuSSYdYpgTeWRRP8PTWxKR1yFG1MndPpLoUwq9rf0ePffY2a6x8-5a1uhVpMCbObru_1-lhe3fAQAA__8OGMqR">