This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Eliminate write-only variables
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Jan Hubicka <hubicka at ucw dot cz>
- Cc: Sandra Loosemore <sandra at codesourcery dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, Jakub Jelinek <jakub at redhat dot com>
- Date: Wed, 4 Jun 2014 11:12:30 +0200
- Subject: Re: Eliminate write-only variables
- Authentication-results: sourceware.org; auth=none
- References: <53797044 dot 2050704 at codesourcery dot com> <537AD329 dot 7070502 at codesourcery dot com> <20140520042958 dot GD8734 at kam dot mff dot cuni dot cz> <CAFiYyc1R+AX6PYM2edpuQ9fpw89TFLZ3=wiXXaDT31CRZJaYxA at mail dot gmail dot com> <538A1D9B dot 4010901 at codesourcery dot com> <CAFiYyc0V+Qt35eq3fd_RxXgTdS1uYpE4oia2qcOW4f66REzEBA at mail dot gmail dot com> <20140602154413 dot GA16816 at kam dot mff dot cuni dot cz> <fef41708-6392-4dba-b2bd-17326fc565b3 at email dot android dot com> <20140602185935 dot GA14773 at kam dot mff dot cuni dot cz> <CAFiYyc0bZHC+Oqv1TkP_Pmfa5mp4nnkopwU3Rb2ekY19cxOHPw at mail dot gmail dot com> <20140603161948 dot GA24320 at kam dot mff dot cuni dot cz>
On Tue, Jun 3, 2014 at 6:19 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
>> On Mon, Jun 2, 2014 at 8:59 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
>> >>
>> >> Yeah, I discussed this with martin today on irc. For aliasing we'd like to know whether a decl possibly has its address taken. Currently we only trust TREE_ADDRESSABLE for statics - and lto might change those to hidden visibility public :(
>> >>
>> >> So we want deck_referred_to_by_single_function
>> >
>> > OK, I will implement this one in IPA mini-pass. It is easy.
>> > This property changes by clonning and inlining. What Martin wants to use it for?
>> > (I.e. my plan would be to compute it as last IPA pass making it useless for
>> > IPA analysis&propagation)
>>
>> He doesn't want to use it but we talked and he said he'd have a look.
>>
>> Note that it's important the decls are not refered to by global initializers
>> either.
>>
>> Why is a new pass necessary - can't the IPA reference maintaining code
>> update some flag in the varpool magically?
>
> If the code to add/remove reference was updating the flag, it would became out of
> date as we remove callgraph during the late compilation (we do not keep references for
> functions we already compiled).
> I do not want the flags to be computed before end of IPA queue so they won't become
> out of date as we clone/inline.
>
> We basically need to walk references and check that they are all functions &
> either one given function F or a clones inlined to it. Assuming that function
> does not have unbounded number of references to given variale, this is
> basically constant time test.
>>
>> >> and deck_may_have_address_taken.
>> >
>> > We currently clear TREE_ADDRESSABLE for statics that have no address taken at
>> > WPA time and that ought to keep the flag cleared at ltrans (I think I even made
>> > testcase for this)
>> >
>> > What I think we could improve is to not consider string functions as ADDR operations
>> > for this analysis, i.e. it is common to only memset to 0.
>> >
>> > How may_have_address_taken would differ here?
>>
>> I want tree.h:may_be_aliased to return false if a decl doesn't have its address
>> taken. We don't trust TREE_ADDRESSABLE for TREE_PUBLIC/DECL_EXTERNAL
>> decls because other TUs may take the address. I want the check to be replaced
>> with sth more symtab aware, that is, bring in benefits from LTO (and at the same
>> time be not confused by statics brought public with hidden visibility).
>
>
> I see, are you sure you need to ignore TREE_ADDRESSABLE for PUBLIC/EXTERNAL?
> I belive frontends are resposible to set them for all data that may have address
> taken (even externally) and IPA code maintains it - we clear the flagonly for
> variables that are static.
Not sure - we've always not trusted this flag on public/externals. Probably
because there could be aliases to them that have their address taken?
(well, that's true for locals as well ...)
That said, having a varpool way of querying whether a decl may be aliased
by a pointer would be nice (with bonus points of handling the alias case).
> Or we can just set the flag to true for externally visible vars ealry in IPA
> queue if this is false.
Well, let me do a simple check (remove the restriction and bootstrap/test).
Richard.
> Honza
>>
>> Richard.
>>
>> > Honza