This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Isolate erroneous paths optimization -- preserve *0.
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Jeff Law <law at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 14 Nov 2013 01:41:15 -0800
- Subject: Re: [PATCH] Isolate erroneous paths optimization -- preserve *0.
- Authentication-results: sourceware.org; auth=none
- References: <5271F493 dot 4020308 at redhat dot com> <CAFiYyc1JiWcH05crFnO9tMdouw=Z3TDgexpCTOfX4ezMsF-oTw at mail dot gmail dot com> <CAKOQZ8ytOYug0+FFP6kR_yov1N_D6NERT3Y-n6806xp2GqyPkQ at mail dot gmail dot com> <1586972 dot iyObK3nBib at polaris> <52804ACB dot 9010206 at redhat dot com> <52825A74 dot 8070806 at redhat dot com>
On Tue, Nov 12, 2013 at 8:42 AM, Jeff Law <law@redhat.com> wrote:
> On 11/10/13 20:11, Jeff Law wrote:
>>
>> OK. It sounds like there's a pretty general consensus that we ought ot
>> go ahead and leave in a load/store of a NULL pointer. I'll go ahead and
>> run with that. I'll probably just emit SSA_NAME = *0, unless someone
>> thinks we ought ot distinguish between loads and stores, emitting
>> SSA_NAME = *0 and *0 = 0 for the two cases respectively.
>
> [ ... ]
> Here's a patch which arranges to leave a null pointer dereferece in the IL.
> For a memory load through a null pointer, we just leave the statement as-is
> since the LHS is going to be a throw-away SSA_NAME. For a store through a
> null pointer, we try to simplify the RHS when it's trivially easy to do so
> (when the RHS is an integral type). This allows DCE to sometimes do a
> better job if the RHS is something that was computed on the isolated path.
> This could be easily extended to floating types, vectors and structures if
> someone is interested. We issue the builtin_trap after the null
> dereference.
>
> For other cases (invalid NULL argument, invalid NULL return), we continue to
> issue the builtin trap in the same manner we did before.
>
> I've adjusted the existing tests and added a new one which verifies the RHS
> of a store through a null pointer is simplified.
>
> Bootstrapped and regression tested on x86_64-unknown-linux-gnu. Installed on
> the trunk.
>
>
>
> * gimple-ssa-isolate-paths.c (check_loadstore): New function.
> (insert_trap_and_remove_trailing_statements): New argument OP which
> is the NULL pointer. Emit the trap after the load/store through
> the NULL pointer. Simplify the RHS of a store through a NULL
> pointer
> when trivial to do so.
> (isolate_path): Corresponding changes.
> (gimple_ssa_isolate_erroneous_path): Likewise.
>
This caused:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59127
--
H.J.