This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC][PATCH] Extend DCE to remove unnecessary new/delete-pairs
- From: Jeff Law <law at redhat dot com>
- To: Martin Sebor <msebor at gmail dot com>, Dominik Inführ <dominik dot infuehr at theobroma-systems dot com>, Jakub Jelinek <jakub at redhat dot com>
- Cc: Richard Biener <richard dot guenther at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 30 Nov 2017 18:23:36 -0700
- Subject: Re: [RFC][PATCH] Extend DCE to remove unnecessary new/delete-pairs
- Authentication-results: sourceware.org; auth=none
- References: <8305B5F4-2A96-4698-8C2E-3255658B5C12@theobroma-systems.com> <CAFiYyc2nZ4vSGa5d_ni0km2kwUtyd9+BScrKzxKdbhZV=t6d1g@mail.gmail.com> <20171122103742.GN14653@tucnak> <BC60F078-9257-4E4F-8D94-7C41F7C7B802@theobroma-systems.com> <ec89be92-a232-5e34-e482-493b9babb65b@gmail.com>
On 11/28/2017 09:11 PM, Martin Sebor wrote:
> On 11/27/2017 02:22 AM, Dominik Inführ wrote:
>> Thanks for all the reviews! I’ve revised the patch, the
>> operator_delete_flag is now stored in tree_decl_with_vis (there
>> already seem to be some FUNCTION_DECL-flags in there). I’ve also added
>> the option -fallocation-dce to disable this optimization. It
>> bootstraps and no regressions on aarch64 and x86_64.
>>
> It's great to be able to eliminate pairs of these calls. For
> unpaired calls, though, I think it would be even more useful to
> also issue a warning. Otherwise the elimination will mask bugs
> that might only show up without optimization, or with other
> compilers (such as older versions of GCC). I realize GCC doesn't
> warn for these bugs involving malloc, but I think it should for
> the same reason.
Aldy and I looked at this stuff a while ago -- to do anything reasonable
you have to build a much stronger static analysis engine than we've got
in GCC right now. THe false positive rate will be way too high to be
useful on real world code.
I don't see how the optimizatino changes anything WRT warnings though.
If you don't have a clear pair where all the proper preconditions are
met, then you don't do anything. Those preconditions would include that
you actually have a pair as opposed to just the allocation point.
Jeff