[PATCH] D32782: Add pthread_self function prototype and make it speculatable.

Xin Tong via llvm-commits llvm-commits at lists.llvm.org
Sat May 20 17:42:18 PDT 2017


On Sun, May 21, 2017 at 9:19 AM, Davide Italiano via Phabricator
<reviews at reviews.llvm.org> wrote:
> davide added a comment.
>
> OK, I think I found out the cause. I guess this patch was wrong, my bad.
> GCC doesn't do anything special with `pthread_self` per-se.
> What GCC does is speculating the `glibc` implementation of `pthread_self` is declared with `__attribute__(const)`.
> The semantic of the attribute is that of "The const attribute is specified as asserting that the function does not examine any data except the arguments. " [1]
> If the function has no arguments, it has to return the same value every time.
>
> Therefore, it speculates.
> I think that other libc implementation are free to not declare pthread_self with that attribute. In fact, from what I can see, the FreeBSD version doesn't use that argument.
> In other words, I don't think we're allowed to do anything with `pthread_self()` in general as POSIX specifies weaks guarantees.
>
> [1] https://sourceware.org/ml/libc-alpha/2016-04/msg00303.html
>

I see, thanks for the very detailed explanation ! I've reverted the patch
-Xin
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D32782
>
>
>



-- 
Software Engineer - Compiler Toolchain
Employee of Facebook Inc.


More information about the llvm-commits mailing list