This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix expand_builtin_atomic_fetch_op for pre-op (PR80902)
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: Jeff Law <law at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 7 Jul 2017 06:56:09 -0500
- Subject: Re: [PATCH] Fix expand_builtin_atomic_fetch_op for pre-op (PR80902)
- Authentication-results: sourceware.org; auth=none
- References: <dd888f582418c5e1d257ed149c4bc0d6b057bd78.1495972471.git.segher@kernel.crashing.org> <118e5c72-72b3-3600-4df1-abe70b8cfc6a@redhat.com>
On Thu, Jun 22, 2017 at 10:59:05PM -0600, Jeff Law wrote:
> On 05/28/2017 06:31 AM, Segher Boessenkool wrote:
> > __atomic_add_fetch adds a value to some memory, and returns the result.
> > If there is no direct support for this, expand_builtin_atomic_fetch_op
> > is asked to implement this as __atomic_fetch_add (which returns the
> > original value of the mem), followed by the addition. Now, the
> > __atomic_add_fetch could have been a tail call, but we shouldn't
> > perform the __atomic_fetch_add as a tail call: following code would
> > not be executed, and in fact thrown away because there is a barrier
> > after tail calls.
> Hmmm. I wonder if we have similar problems elsewhere. For example
> expand_builtin_int_roundingfn_2, stack_protect_epilogue,
> expand_builtin_trap (though this one probably isn't broken in practice),
> expand_ifn_atomic_compare_exchange_into_call.
>
> OK, but please check the other instances where we call expand_call, then
> continue generating code afterwards. Fixing those can be a follow-up patch.
We certainly have similar problems elsewhere.
I'm doing tests detecting whenever we create dead code (right after a
barrier); it finds a few things, mostly harmless, but there are quite
a few places where we create dead code during expand. This will take
a while, but it will need to happen during stage 1... I'm trying to
fit it in :-/
Segher