http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60092

--- Comment #14 from rguenther at suse dot de <rguenther at suse dot de> ---
On Thu, 6 Feb 2014, jakub at gcc dot gnu.org wrote:

> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60092
> 
> --- Comment #13 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
> (In reply to Richard Biener from comment #12)
> > (In reply to Andreas Schwab from comment #11)
> > > If a function is not allowed to change errno this must be explicitly
> > > documented.
> > 
> > That means
> > 
> > Index: gcc/tree-ssa-alias.c
> > ===================================================================
> > --- gcc/tree-ssa-alias.c.orig   2014-02-06 15:43:42.138266256 +0100
> > +++ gcc/tree-ssa-alias.c        2014-02-06 15:43:33.046266882 +0100
> > @@ -1847,7 +1847,9 @@ call_may_clobber_ref_p_1 (gimple call, a
> >             ao_ref dref;
> >             ao_ref_init_from_ptr_and_size (&dref, ptrptr,
> >                                            TYPE_SIZE_UNIT (ptr_type_node));
> > -           return refs_may_alias_p_1 (&dref, ref, false);
> > +           return (refs_may_alias_p_1 (&dref, ref, false)
> > +                   || (flag_errno_math
> > +                       && targetm.ref_may_alias_errno (ref)));
> >           }
> >         /* Freeing memory kills the pointed-to memory.  More importantly
> >            the call has to serve as a barrier for moving loads and stores
> > 
> > is necessary.
> 
> For posix_memalign?  I think errno can contain any value, except that library
> is not allowed to clear errno.
> So, IMHO *p = 1; posix_memalign (...); return *p; can be still optimized into
> return 1;, because if p = &errno; then *p after the call has undefined value
> (just known not to be zero).

But on allocation failure posix_memalign may set it to 2, no?  So
for

  errno = 0;
  posix_memalign ()
  errno = 0;
  ptr = malloc ();
  if (!ptr)
    perror ();

we may not DSE the 2nd errno = 0 store.

Richard.

Reply via email to