This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Eliminate write-only variables
- From: Sandra Loosemore <sandra at codesourcery dot com>
- To: Jan Hubicka <hubicka at ucw dot cz>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Jakub Jelinek <jakub at redhat dot com>
- Date: Sun, 18 May 2014 14:12:08 -0600
- Subject: Re: Eliminate write-only variables
- Authentication-results: sourceware.org; auth=none
- References: <20140516172559 dot GF20755 at kam dot mff dot cuni dot cz>
On 05/16/2014 11:25 AM, Jan Hubicka wrote:
Hi,
this patch adds code to remove write only static variables. While analyzing
effectivity of LTO on firefox, I noticed that surprisingly large part of
binary's data segment is occupied by these. Fixed thus.
(this is quite trivial transformation, I just never considered it important
enough to work on it).
The patch goes by marking write only variables in ipa.c (at same time we
discover addressable flag) and also fixes handling of the flags for
aliases. References to variables are then removed by fixup_cfg.
As first cut, I only remove stores without side effects, so copies from
volatile variables are preserved. I also kill LHS of function calls.
I do not attempt to remove asm statements. This means that some references
may be left in the code and therefore the IPA code does not eliminate the
referneces after discovering write only variable and instead it relies
on dead variable elimination to do the job later. Consequently not all write
only variables are removed with WHOPR in the case the references ends up
in different partitions. Something I can address incrementally.
This patch seems quite similar in purpose to the remove_local_statics
optimization that Mentor has proposed, although the implementation is
quite different. Here is the last version of our patch, prepared by
Bernd Schmidt last year:
https://gcc.gnu.org/ml/gcc-patches/2013-06/msg00317.html
I think we can drop our patch from our local tree now, but it includes a
large number of test cases which I think are worth keeping on mainline.
A few of them fail with your implementation, though -- which might be
genuine bugs, or just different limitations of the two approaches. Can
you take a look?
The failing tests are remove-local-statics-{4,5,7,12,14b}.c.
-Sandra