PR tree-optimization/45605

H.J. Lu hjl.tools@gmail.com
Tue Sep 21 18:25:00 GMT 2010


On Tue, Sep 21, 2010 at 5:25 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Mon, Sep 20, 2010 at 6:50 AM, Jan Hubicka <hubicka@ucw.cz> wrote:
>> Hi,
>> I've tested the other part of previous patch and comitted everything except
>> for the code introducing folding itself as they address other latent issues.
>>
>> The problem with folders being called before cgraph&varpool are built is common
>> to issue I was addressing by my earlier string_constant patch that was refused
>> as too confusing.
>>
>> Constant constructors are just special case of wider issue that with linker
>> plugin or WHOPR we do have more knowledge about what is locally bound than
>> in normal compilation.
>>
>> After discussion with Richard on IRC, we got to conclusion that to address the
>> issue we probably should store resolution decisions into varpool and cgraph nodes.
>> Varpool's const_value_known and cgraph+varpool used_in_object_file flags can
>> then be turned into predicates looking into resolutions and DECL flags. Also
>> binds_local_p can be strenghtened to look up resolution info and take it into
>> account when dealing with weak, external and comdat decls.
>>
>> I have patch for this change, but since it is tricky by itself (updates
>> binds_local_p logic, adds logic into lto-symtab to bookkeep what values come
>> from linker and what was decided in GCC, etc.) I decided to break those
>> changes.  This is patch that goes half way by introducing const_value_known_p
>> predicate while keeping current way of passing const_value_known flag from WPA
>> to LTRANS.
>>
>> I updated the predicate to work on CONST_DECL, automatic vars, other decls and
>> vars w/o varpool entries allocated (yet), so it can be used more conveniently.
>> Now when one has non function/method DECL, it is possible use this predicate to
>> test whether it makes sense to look at DECL_INITIAL to get the constructor.
>> One no longer needs to special case constant pool, CONST_DECL, and check that
>> variable is static before attempting to do so.
>>
>> This finally lets us to do the statement folding during gimplification without
>> ICEs.
>>
>> Bootstrapped/regtested x86_64-linux, OK?
>>
>> Honza
>>
>>        * cgraph.h (const_value_known_p): Declare.
>>        (varpool_decide_const_value_known): Remove.
>>        * tree-ssa-ccp.c (get_base_constructor): Use it.
>>        * lto-cgraph.c (compute_ltrans_boundary): Likewise.
>>        * expr.c (string_constant): Likewise.
>>        * tree-ssa-loop-ivcanon.c (constant_after_peeling): Likewise.
>>        * ipa.c (ipa_discover_readonly_nonaddressable_var,
>>        function_and_variable_visibility): Likewise.
>>        * gimplify.c (gimplify_call_expr): Likewise.
>>        * gimple-fold.c (get_symbol_constant_value): Likewise.
>>        * varpool.c (varpool_decide_const_value_known): Replace by...
>>        (const_value_known_p): ... this one; handle other kinds of DECLs
>>        too and work for automatic vars.
>>        (varpool_finalize_decl): Use const_value_known_p.
>>
>>        * lto.c (lto_promote_cross_file_statics): Use const_value_known_p.
>>
>>        * g++.dg/tree-ssa/pr45605.C: New testcase.
>
> This caused:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45738
>

This also caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45741


-- 
H.J.



More information about the Gcc-patches mailing list