From: "Martin Liška" <mliska@suse.cz>
To: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 4/6] Port ipa-cp to use cgraph_edge summary.
Date: Thu, 16 Jul 2015 14:08:00 -0000 [thread overview]
Message-ID: <55A7BA56.7040709@suse.cz> (raw)
In-Reply-To: <20150710141815.GC1819@virgil.suse.cz>
On 07/10/2015 04:18 PM, Martin Jambor wrote:
> Hi,
>
> I know the patch has been approved by Jeff, but please do not commit
> it before considering the following:
>
> On Thu, Jul 09, 2015 at 11:13:53AM +0200, Martin Liska wrote:
>> gcc/ChangeLog:
>>
>> 2015-07-03 Martin Liska <mliska@suse.cz>
>>
>> * ipa-cp.c (struct edge_clone_summary): New structure.
>> (class edge_clone_summary_t): Likewise.
>> (edge_clone_summary_t::initialize): New method.
>> (edge_clone_summary_t::duplicate): Likewise.
>> (get_next_cgraph_edge_clone): Remove.
>> (get_info_about_necessary_edges): Refactor using the new
>> data structure.
>> (gather_edges_for_value): Likewise.
>> (perhaps_add_new_callers): Likewise.
>> (ipcp_driver): Allocate and deallocate newly added
>> instance.
>> ---
>> gcc/ipa-cp.c | 198 ++++++++++++++++++++++++++++++++++-------------------------
>> 1 file changed, 113 insertions(+), 85 deletions(-)
>>
>> diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
>> index 16b9cde..8a50b63 100644
>> --- a/gcc/ipa-cp.c
>> +++ b/gcc/ipa-cp.c
>> @@ -2888,54 +2888,79 @@ ipcp_discover_new_direct_edges (struct cgraph_node *node,
>> inline_update_overall_summary (node);
>> }
>>
>> -/* Vector of pointers which for linked lists of clones of an original crgaph
>> - edge. */
>> +/* Edge clone summary. */
>>
>> -static vec<cgraph_edge *> next_edge_clone;
>> -static vec<cgraph_edge *> prev_edge_clone;
>> -
>> -static inline void
>> -grow_edge_clone_vectors (void)
>> +struct edge_clone_summary
>
> I's got constructors and destructors so it should be a class, reaally.
>
>> {
>> - if (next_edge_clone.length ()
>> - <= (unsigned) symtab->edges_max_uid)
>> - next_edge_clone.safe_grow_cleared (symtab->edges_max_uid + 1);
>> - if (prev_edge_clone.length ()
>> - <= (unsigned) symtab->edges_max_uid)
>> - prev_edge_clone.safe_grow_cleared (symtab->edges_max_uid + 1);
>> -}
>> + /* Default constructor. */
>> + edge_clone_summary (): edge_set (NULL), edge (NULL) {}
>>
>> -/* Edge duplication hook to grow the appropriate linked list in
>> - next_edge_clone. */
>> + /* Default destructor. */
>> + ~edge_clone_summary ()
>> + {
>> + gcc_assert (edge_set != NULL);
>>
>> -static void
>> -ipcp_edge_duplication_hook (struct cgraph_edge *src, struct cgraph_edge *dst,
>> - void *)
>> + if (edge != NULL)
>> + {
>> + gcc_checking_assert (edge_set->contains (edge));
>> + edge_set->remove (edge);
>> + }
>> +
>> + /* Release memory for an empty set. */
>> + if (edge_set->elements () == 0)
>> + delete edge_set;
>> + }
>> +
>> + hash_set <cgraph_edge *> *edge_set;
>> + cgraph_edge *edge;
>
> If the hash set is supposed to replace the linked list of edge clones,
> then a removal mechanism seems to be missing. The whole point of
> prev_edge_clone vector was to allow removal of edges from the linked
> list, because as speculative edges are thrown away, clones can be too
> and then we must remove the pointer from the list, or hash set.
>
> Have you tried -O3 LTOing Firefox with these changes?
>
> But I must say that I'm not convinced that converting the linked list
> into a hash_set is a good idea at all. Apart from the self-removal
> operation, the lists are always traversed linearly and in full, so
> except for using a C++-style iterator, I really do not see any point.
>
> Moreover, you seem to create a hash table for each and every edge,
> even when it has no clones, just to be able to enter the edge itself
> into it, and so not skip it when you iterate over all clones. That
> really seems like unjustifiable overhead. And the deletion in
> duplication hook is also very unappealing. So the bottom line is that
> while I like turning the two vectors into a summary, I do not like the
> hash set at all. If absolutely think it is a good idea, please make
> that change in a separate patch so that we can better argue about its
> merits.
>
> On the other hand, since the summaries are hash-based themselves, it
> would be great if they had a predicate to find out whether there is
> any summary for a given edge at all and have get_next_cgraph_edge_clone
> return false if there was none. That would actually save memory.
>
> Thanks,
>
> Martin
>
After a discussion with Martin, we made a decision to preserve current implementation
and not to port the IPA CP to he newly introduced summary.
Martin
next prev parent reply other threads:[~2015-07-16 14:06 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-09 11:07 [PATCH 0/6] {function,edge}_summary for IPA passes mliska
2015-07-09 11:07 ` [PATCH 1/6] hash_set: add iterator and remove method mliska
2015-07-09 17:05 ` Jeff Law
2015-07-09 11:08 ` [PATCH 5/6] Port IPA reference to function_summary infrastructure mliska
2015-07-09 17:35 ` Jeff Law
2015-07-09 20:46 ` Martin Liška
2015-07-10 13:30 ` Martin Jambor
2015-07-16 14:14 ` Martin Liška
2015-07-09 11:08 ` [PATCH 3/6] IPA inline: port inline_edge_summary to a new infrastructure mliska
2015-07-09 17:21 ` Jeff Law
2015-07-09 11:08 ` [PATCH 4/6] Port ipa-cp to use cgraph_edge summary mliska
2015-07-09 17:39 ` Jeff Law
2015-07-10 14:18 ` Martin Jambor
2015-07-16 14:08 ` Martin Liška [this message]
2015-07-09 11:08 ` [PATCH 2/6] Introduce new edge_summary class and replace ipa_edge_args_sum mliska
2015-07-09 17:15 ` Jeff Law
2015-07-09 20:45 ` Martin Liška
2015-07-10 13:31 ` Martin Jambor
2015-07-16 14:06 ` Martin Liška
2015-08-03 15:22 ` Martin Liška
2015-07-09 11:09 ` [PATCH 6/6] Migrate ipa-pure-const to function_summary mliska
2015-07-09 17:44 ` Jeff Law
2015-07-09 20:47 ` Martin Liška
2015-07-16 14:17 ` Martin Liška
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55A7BA56.7040709@suse.cz \
--to=mliska@suse.cz \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).