On Thu, Jun 6, 2013 at 5:10 PM, Bernd Schmidt <ber...@codesourcery.com> wrote:
> On 06/06/2013 04:52 PM, Richard Biener wrote:
>> +      /* We cannot optimize away a static used in multiple functions (as
>> +        might happen in C++).  */
>> +      && !DECL_NONLOCAL(var)
>>
>> it may also happen trivially with inlining.  Which means a local pass can 
>> never
>> "remove" vars safely.
>
> This is why the pass isn't run if cgraph_function_possibly_inlined_p.
> Tested by remove-local-statics-14b.c.

I see (how ugly ;)).  Does that cover versioning via IPA CP as well for example?

>> In theory we have IPA reference which tries to figure out whether a local 
>> static
>> is read and/or written to (and from where).  It's of course quite early 
>> analysis
>> where FRE may not yet have optimized out all reads.
>>
>> But the trivial dead local static store elimination would simply eliminate
>> all write-only and !TREE_ADDRESSABLE vars (and statements storing
>> to it).
>>
>> For some reason this must be not enough so you write that local
>> analysis code.
>>
>> Thus - I'm asking you to double-check a trivial implementation using
>> the IPA reference result and double-check the issue with inlining
>> introducing out-of-current-function uses.
>
> I'm not sure what you're asking for here. The IPA passes seem to run
> much before PRE, and if you need an example why that's too early, try
> the remove-local-statics-7.c testcase.

Yes, that requires PRE.  I'm sure there are cases your pass doesn't
get either.  I was asking whether the particular benchmark would be
optimized by the simple IPA reference method.

Richard.

>
> Bernd
>

Reply via email to