[PATCH] D26930: Teach optimizer that pthread_self does not trap. It can be speculatively executed.

Xin Tong via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 21 16:03:04 PST 2016


trentxintong added a comment.



In https://reviews.llvm.org/D26930#601975, @hfinkel wrote:

> In https://reviews.llvm.org/D26930#601972, @trentxintong wrote:
>
> > I, too, hope readnone+nounwind functions can be speculatively executed, but it does not seem to be the case =). Thats why i think we need to use TLI to teach the optimizer about functions which can.
>
>
>
>
> In https://reviews.llvm.org/D26930#601971, @joerg wrote:
>
> > Your example is UB.
>
>
> You're both right. We cannot speculate functions that might have UB. Thus, we cannot speculate general external functions (even if they're readnone, etc.). See also: https://reviews.llvm.org/D20116 where we're discussing adding a separate attribute for this.


@hfinkel I see, do you think it would be a good to add "speculatable" attribute to pthread_self in FuncAttr once the patch for the attribute lands so that it can be hoisted ? or we can use TLI in isSafeToSpeculativelyExecute function.


Repository:
  rL LLVM

https://reviews.llvm.org/D26930





More information about the llvm-commits mailing list