<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi everyone,<div class=""><br class=""></div><div class="">I’m working on adding multithreading support to our programming language (<a href="http://crystal-lang.org" class="">http://crystal-lang.org</a>) and I’m facing an issue with thread local variables.</div><div class="">Since the language relies heavily on coroutines, basically the problem is that a function could start running on a thread, get suspended and continue running on a different thread.</div><div class=""><br class=""></div><div class="">So, for example, if I have this pseudocoe:</div><div class=""><br class=""></div><div class="">1. read / write thread local variable</div><div class="">2. do some context switch, might resume in a different thread</div><div class="">3. read / write same thread local variable</div><div class=""><br class=""></div><div class="">Now the real issue is that when compiling with optimizations, LLVM wont re-read the thread local address, and instead it will rely on the address stored on some register.</div><div class=""><br class=""></div><div class="">The question is: is there any way to force LLVM to re-read the thread local address each time? Or even better, is there any way to give hints about where the cached address is not reliable anymore?</div><div class=""><br class=""></div><div class="">Best regards!</div><div class="">- Juan</div><div class=""><br class=""></div><div class=""><br class=""></div></body></html>