ehds opened a new pull request, #2156:

   ### What problem does this PR solve?
   Issue Number:,,,,
   Problem Summary:
   编译器会优化 thread_local 的变量的读写,如果在函数过程中间,线程发生切换(bthread 切换到另一个线程执行),那么 
thread_local 变量需要重新获当前运行线程的,而不应该使用之前的旧值。
   经测试,Apple M1 Apple clang version 14.0.0, 编译依然存在该问题。
   gcc 通过开启 fno-gcse 选项禁止该优化,clang 未能找到对应控制选项。
   ### What is changed and the side effects?
   1. 新增 `NOT_ALLOW_OPTIMIZE_THREAD_LOCAL_ACCESS` 用于控制是否允许编译器优化,如果为 true 
是,对应的thread local 变量必须通过 noinline 的函数调用方式来获取最新值,绕开编译器的优化。
   Side effects:
   - Performance effects(性能影响):
   - Breaking backward compatibility(向后兼容性): 
   ### Check List:
   - Please make sure your changes are compilable(请确保你的更改可以通过编译).
   - When providing us with a new feature, it is best to add related 
tests(如果你向我们增加一个新的功能, 请添加相关测试).
   - Please follow [Contributor Covenant Code of 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail:

For queries about this service, please contact Infrastructure at:

To unsubscribe, e-mail:
For additional commands, e-mail:

Reply via email to