# Address thread identification problems with coroutine

**URL:** <https://discourse.llvm.org/t/address-thread-identification-problems-with-coroutine/62015>\
**Category:** IR & Optimizations\
**Created:** [April 25, 2022, 8:14am UTC](https://discourse.llvm.org/t/address-thread-identification-problems-with-coroutine/62015 "2022-04-25T08:14:35Z")\
**Posts on this page:** 1\
**Showing post:** 25

<div class="post-metadata">

**Author:** ![jyknight](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/jyknight/32/1253_2.png) [@jyknight](https://discourse.llvm.org/u/jyknight)\
**Post date:** [April 29, 2022, 3:19pm UTC](https://discourse.llvm.org/t/address-thread-identification-problems-with-coroutine/62015/25 "2022-04-29T15:19:25Z")

</div>

> [@ChuanqiXu](#):
>
> To make sure that I don’t misunderstand, let me try to repeat your suggestion:
> 
> (1) Replace access of TLS variable with an intrinsic marked as `nounwind` , `readnone` , `willreturn` .
> 
> (2) Try to handle `readnone` problems in coroutines.

Replace _address computation_ of TLS variables, not access, but yes.

> [@](#):
>
> It looks like we could solve the thread-identity problems in coroutines in this approach. But I feel like it wouldn’t help with the general TLS access problem you said:

It does solve it, by making that IR not possible to write. In my not-really-fleshed-out idea here, `@x` should no longer be usable as a pointer, so `i32* @x` is impossible to write in IR – which is as it should be. You need an Instruction to retrieve the address for `@x`, and thus it’s clearly impossible to use in a global value initializer. Perhaps `@x` has become a token type of some sort, which can be passed to the intrinsic but isn’t otherwise usable?

> [@](#):
>
> But if we adopt the proposal you said, I feel like we must solve the two problems together, which seems like a little bit worse to me.

We _must_ solve the readnone problem, so this line of objection isn’t very persuasive to me. It’s not just a nice-to-have that we can ignore… And, additionally, I think we _do_ have good options for solving it.

---

_[View the full topic](https://discourse.llvm.org/t/address-thread-identification-problems-with-coroutine/62015)._
