[PATCH] D46240: [llvm] Removing writeonly and readnone incompatibility.

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 1 08:56:16 PDT 2018


reames added a comment.

In https://reviews.llvm.org/D46240#1083768, @hfinkel wrote:

> In https://reviews.llvm.org/D46240#1083669, @reames wrote:
>
> > In https://reviews.llvm.org/D46240#1083286, @homerdin wrote:
> >
> > > I am working to enable functions that only write to memory to be hoisted out of loops and to combined by EarlyCSE, more specifically I am working to mark the math functions that only write to errno as writeonly then have them handled as writeonly functions.
> >
> >
> > You'll need something a bit stronger than an aliasing property.  You're going to specifically need to model *what* is written to errno.  At the moment, we don't have a good way to model a function which writes only to one specific global (errno) or to model what those writes are.
>
>
> I'm not sure that's true. If a function only writes, then what it writes must always be a function only of its arguments. So if I have:
>
>   foo(int, int*) writeonly;
>   
>   foo(a, b);
>   foo(a, b);
>   
>
> then, I think, we can CSE these calls to foo. foo might write to its second argument somewhere, and might write to globals, but since the arguments are the same (and it doesn't read any state otherwise), it must write the same thing each time.


Good point.  I agree this works and likely forms a good basis for what the errno case.


https://reviews.llvm.org/D46240





More information about the llvm-commits mailing list