<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/59500>59500</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Emulated TLS does not work on RISC-V
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
vit9696
</td>
</tr>
</table>
<pre>
For some reason llvm does not generate `__emutls_get_address` calls when using `-femulated-tls` on RISC-V. Example: `clang -C -target riscv32-gnu-linux -O3 -femulated-tls`.
```c
_Thread_local int a;
int fn(void)
{
if (a)
{
return 1;
}
return 0;
}
```
```
fn():
lui a0, %tprel_hi(a)
add a0, a0, tp, %tprel_add(a)
lw a0, %tprel_lo(a)(a0)
snez a0, a0
ret
```
REF: https://godbolt.org/z/fovqox7az
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8U01v4yAQ_TX4MnKExzFxDj70y9JKK63UVnuNiBk77BLIAk66_fUrnDRp2motCzS8N_NmEE-GoAdL1LDqllX3mRzjxvlmr-NSLEW2dupv0zoPwW0JPMngLBiz34JyFMC6CANZ8jISMMFXK9qO0YTVQHEllfIUAhMcOmlMgMOGLIxB2yFx8562o5GRVB7NxHIWHr893eU_ZwAPL3K7M8TKm8TtjLQD5HeQR-kHiuB16PYl5oMdc6Pt-AL5jxI-lZwxfs_4zWkV_Ph3x3j1vPEk1cq4ThrQNoJk5e37jHTWW4b13mnFcHnCFicSAIDugWEtz2A6uyKkz1McvYXiXP7Iuj8FJ5hf1N-gc8tfznEMpwaTfnlzrWpGPe2SM7wDhlXceTKrjf7U8MRS6h37uMbdVaZU6stUc_ioYdwbEesEfUgIll6vtM738J-xHx_a9Bo2Me5CmhVbhu3g1NqZOHN-YNi-Mmx7t__jXhbyNVNNqZblUmbUFGLBl_O54CLbNBXWJc5Rouj7XglB9QIlFaousKgJMdMNcsQCi7KoCjEXs7pSvej6Ocd1rXi9YHNOW6nNLDkhaWc6hJGaallxnhm5JhMmQyFaOsAEMsTkL9-knHw9DoHNudEhhkuVqKOh5uH0huH5-9PFZgfnf18cko3eNB-uQsfNuJ51bsuwTSVPW77z7hd1kWE7NRIYtlOj_wIAAP__4SEftQ">