> diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
> new file mode 100644
> index 0000000..8a13dca
> --- /dev/null
> +++ b/gcc/ipa-icf.c
> +/* Itializes internal structures according to given number of
initialize
> + if (is_a_helper<cgraph_node *>::test (node))
shouldn't you just use is_a<cgraph_node*> (node) ?
> +sem_item_optimizer::filter_removed_items (void)
> +{
> + vec <sem_item *> filtered;
> + filtered.create (m_items.length());
use auto_vec here?
> + m_items.release ();
> +
> + for (unsigned int i = 0; i < filtered.length(); i++)
> + m_items.safe_push (filtered[i]);
hrm, maybe adding vec::swap makes sense.
> + if (c->members.length() > 1)
> + {
> + vec <sem_item *> new_vector;
> + new_vector.create (c->members.length ());
same comment about auto_vec and swap.
> +bool
> +sem_item_optimizer::release_split_map (__attribute__((__unused__))
> congruence_class *
> + const &cls,
> + __attribute__((__unused__)) bitmap const
> &b,
that one is definitly used
> + __attribute__((__unused__))
> traverse_split_pair *pair)
Why can't you just leave the arguments unnamed to fix the warning?
> +sem_item_optimizer::do_congruence_step_for_index (congruence_class *cls,
> + unsigned int index)
> +{
> + hash_map <congruence_class *, bitmap> *split_map =
> + new hash_map <congruence_class *, bitmap> ();
why aren't you putting the hash_map on the stack? in any case it looks
like you fail to delete it when your done with it.
> diff --git a/gcc/ipa-icf.h b/gcc/ipa-icf.h
> new file mode 100644
> index 0000000..d328dd6
> --- /dev/null
> +++ b/gcc/ipa-icf.h
> @@ -0,0 +1,743 @@
> +/* Prints string STRING to a FILE with a given number of SPACE_COUNT. */
> +#define FPUTS_SPACES(file, space_count, string) \
> + do \
> + { \
> + fprintf (file, "%*s" string, space_count, " "); \
seems like you could do this with a static inline function.
> +/* Prints a MESSAGE to dump_file if exists. */
> +#define SE_DUMP_MESSAGE(message) \
> + do \
> + { \
> + if (dump_file && (dump_flags & TDF_DETAILS)) \
> + fprintf (dump_file, " debug message: %s (%s:%u)\n", message,
> __func__, __LINE__); \
a inline function that used the builtins like the memory statis stuff
might be slightly less ugly imho
> +/* Logs a MESSAGE to dump_file if exists and returns false. */
> +#define SE_EXIT_FALSE_WITH_MSG(message) \
> + do \
> + { \
> + if (dump_file && (dump_flags & TDF_DETAILS)) \
> + fprintf (dump_file, " false returned: '%s' (%s:%u)\n", message,
> __func__, __LINE__); \
> + return false; \
> + } \
> + while (false);
ugh macros that effect control flow, instead maybe define a inline
function that does the logging and then returns the value you want your
function to return so you can write
if (whatever)
return SE_LOG (NULL, "something or other");
?
> +/* Forward declaration for sem_func class. */
> +class sem_item;
comment is wrong, and imho useless.
> + /* Initializes internal structures according to given number of
> + source and target SSA names. The number of source names is SSA_SOURCE,
> + respectively SSA_TARGET. */
> + func_checker (unsigned ssa_source, unsigned sss_target);
ssa_target?
> + /* Source to target edge map. */
> + hash_map <edge, edge> *m_edge_map;
is there a reason to not embedd these in the object? you seem to create
them in the ctor and delete them in the dtor, so I expect they have teh
same lifetime.
> +/* Basic block struct for sematic equality pass. */
semantic?
> +typedef struct sem_bb
you don't need the typedef in C++
> + /* Item type. */
> + enum sem_item_type type;
loose the enum keyword since you don't need it?
> +class sem_function: public sem_item
> +{
> + /* COMPARED_FUNC is a function that we compare to. */
> + sem_function *m_compared_func;
this feels like a weird place for this, would func_checker maybe make
more sense as a place to put it?
> +class sem_variable: public sem_item
> +{
> + /* Initializes references to other semantic functions/variables. */
> + inline virtual void init_refs ()
iirc defining with in a class definition implies inline.
> +typedef struct congruence_class_group
> +{
> + hashval_t hash;
> + sem_item_type type;
> + vec <congruence_class *> classes;
> +} congruence_class_group_t;
lose the typedef?
> + /* Returns true if a congruence class CLS is presented in worklist. */
s/presented/present/ ?
Trev