[llvm-dev] [RFC] LLVM Coroutines

David Chisnall via llvm-dev llvm-dev at lists.llvm.org
Thu Jun 9 01:25:54 PDT 2016

On 9 Jun 2016, at 06:57, Gor Nishanov via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> Though this
> proposal is motivated primarily by the desire to support C++ Coroutines [1],
> the llvm representation is language neutral and can be used to support
> coroutines in other languages as well.

I’m sorry if this is off-topic, but has anyone in WG21 yet come up with a sane proposal about how coroutines interact with thread-local storage?  In LLVM-compiled code, it is possible that the address of a thread-local variable will be cached to avoid repeated lookups.  In an environment that contains both coroutines and TLS, it is possible that the coroutine will be migrated to a different thread between suspension and resumption.  Does this mean that, for correctness, we must regard these suspension points as barriers that prevent loads or stores of thread-local variables and prevent caching of loads of addresses of thread-local variables?  Do we have to treat every function call as a suspension point, as no function can know whether it is executing in a coroutine or whether a function that it calls may trigger a thread migration?  This sounds as if it would cause noticeable performance regressions in code that makes heavy use of thread-local variables.


More information about the llvm-dev mailing list