[PATCH 4/4] Data structure is used for inline_summary struct.
Jan Hubicka
hubicka@ucw.cz
Thu Nov 13 16:04:00 GMT 2014
> + if (!inline_summary_summary)
> + inline_summary_summary = (inline_summary_cgraph_summary *) inline_summary_cgraph_summary::create_ggc (symtab);
Hehe, this is funny naming scheme.
Peraps inline_summary_d and inline_summary_t for the data and type?
> -
> -static void
> -inline_node_duplication_hook (struct cgraph_node *src,
> - struct cgraph_node *dst,
> - ATTRIBUTE_UNUSED void *data)
> +void
> +inline_summary_cgraph_summary::duplication_hook (cgraph_node *src,
> + cgraph_node *dst,
> + inline_summary *,
> + inline_summary *info)
Becuase those are no longer "hooks" but virtual function, I guess we could call them
simply duplicate/insert/remove.
In a way I would like to see these to be methods of the underlying type rather than
virtual methods of the summary, becuase these are operations on the data themselves.
I was thinking to model these by specual constructor and copy constructor
(taking the extra node pointer parameters) and standard destructor. I am not sure this
would be more understandable this way?
> -/* Need a typedef for inline_summary because of inline function
> - 'inline_summary' below. */
> -typedef struct inline_summary inline_summary_t;
> -extern GTY(()) vec<inline_summary_t, va_gc> *inline_summary_vec;
> +class GTY((user)) inline_summary_cgraph_summary: public cgraph_summary <inline_summary *>
> +{
> +public:
> + inline_summary_cgraph_summary (symbol_table *symtab, bool ggc):
> + cgraph_summary <inline_summary *> (symtab, ggc) {}
> +
> + static inline_summary_cgraph_summary *create_ggc (symbol_table *symtab)
> + {
> + inline_summary_cgraph_summary *summary = new (ggc_cleared_alloc <inline_summary_cgraph_summary> ()) inline_summary_cgraph_summary(symtab, true);
> + summary->disable_insertion_hook ();
> + return summary;
> + }
> +
> +
> + virtual void insertion_hook (cgraph_node *, inline_summary *);
> + virtual void removal_hook (cgraph_node *node, inline_summary *);
> + virtual void duplication_hook (cgraph_node *src, cgraph_node *dst, inline_summary *src_data, inline_summary *dst_data);
> +};
> +
> +extern GTY(()) cgraph_summary <inline_summary *> *inline_summary_summary;
All in all it looks better than original code. If we moved insert/
>
> /* Information kept about parameter of call site. */
> struct inline_param_summary
> @@ -249,10 +265,10 @@ void clone_inlined_nodes (struct cgraph_edge *e, bool, bool, int *,
> extern int ncalls_inlined;
> extern int nfunctions_inlined;
>
> -static inline struct inline_summary *
> -inline_summary (struct cgraph_node *node)
> +static inline inline_summary *
> +get_inline_summary (const struct cgraph_node *node)
> {
> - return &(*inline_summary_vec)[node->uid];
> + return (*inline_summary_summary)[node->summary_uid];
Hmm, i guess there is no way to avoid the (*...)? Otherwise it would be cleaner
to use inline_summary[...] instead of get_inline_summary IMO.
Thanks for working on this!
Honza
More information about the Gcc-patches
mailing list