This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Fix type merging deficiency during WPA


On Mon, Jul 11, 2016 at 3:28 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> So sth like
>>
>> Index: gcc/lto-streamer-out.c
>> ===================================================================
>> --- gcc/lto-streamer-out.c      (revision 238039)
>> +++ gcc/lto-streamer-out.c      (working copy)
>> @@ -996,7 +996,7 @@ hash_tree (struct streamer_tree_cache_d
>>    else
>>      hstate.add_flag (TREE_NO_WARNING (t));
>>    hstate.add_flag (TREE_NOTHROW (t));
>> -  hstate.add_flag (TREE_STATIC (t));
>> +  //hstate.add_flag (TREE_STATIC (t));
>>    hstate.add_flag (TREE_PROTECTED (t));
>>    hstate.add_flag (TREE_DEPRECATED (t));
>>    if (code != TREE_BINFO)
>> @@ -1050,7 +1050,7 @@ hash_tree (struct streamer_tree_cache_d
>>        hstate.add_flag (DECL_ARTIFICIAL (t));
>>        hstate.add_flag (DECL_USER_ALIGN (t));
>>        hstate.add_flag (DECL_PRESERVE_P (t));
>> -      hstate.add_flag (DECL_EXTERNAL (t));
>> +      //hstate.add_flag (DECL_EXTERNAL (t));
>>        hstate.add_flag (DECL_GIMPLE_REG_P (t));
>>        hstate.commit_flag ();
>>        hstate.add_int (DECL_ALIGN (t));
>> Index: gcc/lto/lto.c
>> ===================================================================
>> --- gcc/lto/lto.c       (revision 238039)
>> +++ gcc/lto/lto.c       (working copy)
>> @@ -1263,7 +1263,8 @@ compare_tree_sccs_1 (tree t1, tree t2, t
>>      tree t1_ = (E1), t2_ = (E2); \
>>      if (t1_ != t2_ \
>>         && (!t1_ || !t2_ \
>> -           || !TREE_VISITED (t2_) \
>> +           || (!TREE_VISITED (t2_) \
>> +               && !same_decls (t1_, t2_)) \
>>
>>             || (!TREE_ASM_WRITTEN (t2_) \
>>
>>                 && !compare_tree_sccs_1 (t1_, t2_, map)))) \
>>        return false; \
>>
>> plus the magic new function same_decls which would check if the trees are
>> var/function decls with the same assembler name. The function can't use
>> the cgraph as that is not yet read in unfortunately - I still think we
>> should do that so we can see the prevailing nodes early.
>
> OK, thanks for the hint, the attached patch where the call to same_decls is
> placed differently works on the testcase (modulo the gigi change I posted
> earlier today) but not on the original code...  It looks like the hash value
> computed in lto-streamer-out.c is stricter than the hash value computed for
> canonical types, I'm trying to pinpoint the difference.

As tree merging really replaces trees it has to error on the side of not merging
while canonical type merging has to error on the side of "merging" to make
types alias.

Btw, for the LTO_SET_PREVAIL can you introduce a LTO_SET_PREVAIL_EXPR
and use that for the fields that possibly can be expressions plus simply use
walk_tree for those (in case they are EXPR_P)?  Please split that part
out as well.

Richard.


>
>         * lto-streamer-out.c (hash_tree): Do not add the TREE_STATIC and
>         DECL_EXTERNAL flags for variable or function declarations.
> lto/
>         * lto.c (same_global_decl_p): New predicate.
>         (compare_tree_sccs_1): Use it in the comparison of pointer fields.
>         (walk_simple_constant_arithmetic): New function.
>         (LTO_SET_PREVAIL): Use it to fix up DECL nodes in simple expressions.
>
> --
> Eric Botcazou


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]