2014-10-16 12:47:55 +02:00
|
|
|
/* Interprocedural semantic function equality pass
|
2016-01-04 15:30:50 +01:00
|
|
|
Copyright (C) 2014-2016 Free Software Foundation, Inc.
|
2014-10-16 12:47:55 +02:00
|
|
|
|
|
|
|
Contributed by Jan Hubicka <hubicka@ucw.cz> and Martin Liska <mliska@suse.cz>
|
|
|
|
|
|
|
|
This file is part of GCC.
|
|
|
|
|
|
|
|
GCC is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU General Public License as published by the Free
|
|
|
|
Software Foundation; either version 3, or (at your option) any later
|
|
|
|
version.
|
|
|
|
|
|
|
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with GCC; see the file COPYING3. If not see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
namespace ipa_icf {
|
|
|
|
class sem_item;
|
|
|
|
|
|
|
|
/* Congruence class encompasses a collection of either functions or
|
|
|
|
read-only variables. These items are considered to be equivalent
|
|
|
|
if not proved the oposite. */
|
|
|
|
class congruence_class
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/* Congruence class constructor for a new class with _ID. */
|
|
|
|
congruence_class (unsigned int _id): in_worklist (false), id(_id)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Destructor. */
|
|
|
|
~congruence_class ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Dump function prints all class members to a FILE with an INDENT. */
|
|
|
|
void dump (FILE *file, unsigned int indent = 0) const;
|
|
|
|
|
|
|
|
/* Returns true if there's a member that is used from another group. */
|
|
|
|
bool is_class_used (void);
|
|
|
|
|
|
|
|
/* Flag is used in case we want to remove a class from worklist and
|
|
|
|
delete operation is quite expensive for
|
|
|
|
the data structure (linked list). */
|
|
|
|
bool in_worklist;
|
|
|
|
|
|
|
|
/* Vector of all group members. */
|
|
|
|
auto_vec <sem_item *> members;
|
|
|
|
|
|
|
|
/* Global unique class identifier. */
|
|
|
|
unsigned int id;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Semantic item type enum. */
|
|
|
|
enum sem_item_type
|
|
|
|
{
|
|
|
|
FUNC,
|
|
|
|
VAR
|
|
|
|
};
|
|
|
|
|
2015-02-26 21:21:38 +01:00
|
|
|
/* Class is container for address references for a symtab_node. */
|
|
|
|
|
|
|
|
class symbol_compare_collection
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/* Constructor. */
|
|
|
|
symbol_compare_collection (symtab_node *node);
|
|
|
|
|
|
|
|
/* Destructor. */
|
|
|
|
~symbol_compare_collection ()
|
|
|
|
{
|
|
|
|
m_references.release ();
|
|
|
|
m_interposables.release ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Vector of address references. */
|
|
|
|
vec<symtab_node *> m_references;
|
|
|
|
|
|
|
|
/* Vector of interposable references. */
|
|
|
|
vec<symtab_node *> m_interposables;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Hash traits for symbol_compare_collection map. */
|
|
|
|
|
2015-06-25 19:16:51 +02:00
|
|
|
struct symbol_compare_hash : nofree_ptr_hash <symbol_compare_collection>
|
2015-02-26 21:21:38 +01:00
|
|
|
{
|
|
|
|
static hashval_t
|
2015-06-25 19:16:51 +02:00
|
|
|
hash (value_type v)
|
2015-02-26 21:21:38 +01:00
|
|
|
{
|
|
|
|
inchash::hash hstate;
|
|
|
|
hstate.add_int (v->m_references.length ());
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < v->m_references.length (); i++)
|
2015-03-24 22:51:08 +01:00
|
|
|
hstate.add_int (v->m_references[i]->ultimate_alias_target ()->order);
|
2015-02-26 21:21:38 +01:00
|
|
|
|
|
|
|
hstate.add_int (v->m_interposables.length ());
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < v->m_interposables.length (); i++)
|
2015-03-24 22:51:08 +01:00
|
|
|
hstate.add_int (v->m_interposables[i]->ultimate_alias_target ()->order);
|
2015-02-26 21:21:38 +01:00
|
|
|
|
|
|
|
return hstate.end ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
2015-06-25 19:16:51 +02:00
|
|
|
equal (value_type a, value_type b)
|
2015-02-26 21:21:38 +01:00
|
|
|
{
|
2015-02-27 20:05:30 +01:00
|
|
|
if (a->m_references.length () != b->m_references.length ()
|
|
|
|
|| a->m_interposables.length () != b->m_interposables.length ())
|
2015-02-26 21:21:38 +01:00
|
|
|
return false;
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < a->m_references.length (); i++)
|
|
|
|
if (a->m_references[i]->equal_address_to (b->m_references[i]) != 1)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < a->m_interposables.length (); i++)
|
|
|
|
if (!a->m_interposables[i]->semantically_equivalent_p
|
|
|
|
(b->m_interposables[i]))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-10-16 12:47:55 +02:00
|
|
|
/* Semantic item usage pair. */
|
|
|
|
class sem_usage_pair
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/* Constructor for key value pair, where _ITEM is key and _INDEX is a target. */
|
|
|
|
sem_usage_pair (sem_item *_item, unsigned int _index);
|
|
|
|
|
|
|
|
/* Target semantic item where an item is used. */
|
|
|
|
sem_item *item;
|
|
|
|
|
|
|
|
/* Index of usage of such an item. */
|
|
|
|
unsigned int index;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Semantic item is a base class that encapsulates all shared functionality
|
|
|
|
for both semantic function and variable items. */
|
|
|
|
class sem_item
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/* Semantic item constructor for a node of _TYPE, where STACK is used
|
|
|
|
for bitmap memory allocation. */
|
|
|
|
sem_item (sem_item_type _type, bitmap_obstack *stack);
|
|
|
|
|
|
|
|
/* Semantic item constructor for a node of _TYPE, where STACK is used
|
2016-11-22 10:18:37 +01:00
|
|
|
for bitmap memory allocation. The item is based on symtab node _NODE. */
|
|
|
|
sem_item (sem_item_type _type, symtab_node *_node, bitmap_obstack *stack);
|
2014-10-16 12:47:55 +02:00
|
|
|
|
|
|
|
virtual ~sem_item ();
|
|
|
|
|
|
|
|
/* Dump function for debugging purpose. */
|
|
|
|
DEBUG_FUNCTION void dump (void);
|
|
|
|
|
|
|
|
/* Initialize semantic item by info reachable during LTO WPA phase. */
|
|
|
|
virtual void init_wpa (void) = 0;
|
|
|
|
|
|
|
|
/* Semantic item initialization function. */
|
|
|
|
virtual void init (void) = 0;
|
|
|
|
|
|
|
|
/* Add reference to a semantic TARGET. */
|
|
|
|
void add_reference (sem_item *target);
|
|
|
|
|
|
|
|
/* Fast equality function based on knowledge known in WPA. */
|
|
|
|
virtual bool equals_wpa (sem_item *item,
|
|
|
|
hash_map <symtab_node *, sem_item *> &ignored_nodes) = 0;
|
|
|
|
|
|
|
|
/* Returns true if the item equals to ITEM given as arguemnt. */
|
|
|
|
virtual bool equals (sem_item *item,
|
|
|
|
hash_map <symtab_node *, sem_item *> &ignored_nodes) = 0;
|
|
|
|
|
|
|
|
/* References independent hash function. */
|
|
|
|
virtual hashval_t get_hash (void) = 0;
|
|
|
|
|
2015-11-12 16:16:00 +01:00
|
|
|
/* Set new hash value of the item. */
|
|
|
|
void set_hash (hashval_t hash);
|
|
|
|
|
2014-10-16 12:47:55 +02:00
|
|
|
/* Merges instance with an ALIAS_ITEM, where alias, thunk or redirection can
|
|
|
|
be applied. */
|
|
|
|
virtual bool merge (sem_item *alias_item) = 0;
|
|
|
|
|
|
|
|
/* Dump symbol to FILE. */
|
|
|
|
virtual void dump_to_file (FILE *file) = 0;
|
|
|
|
|
2015-03-22 23:47:06 +01:00
|
|
|
/* Update hash by address sensitive references. */
|
|
|
|
void update_hash_by_addr_refs (hash_map <symtab_node *,
|
|
|
|
sem_item *> &m_symtab_node_map);
|
|
|
|
|
|
|
|
/* Update hash by computed local hash values taken from different
|
|
|
|
semantic items. */
|
|
|
|
void update_hash_by_local_refs (hash_map <symtab_node *,
|
|
|
|
sem_item *> &m_symtab_node_map);
|
|
|
|
|
2014-10-16 12:47:55 +02:00
|
|
|
/* Return base tree that can be used for compatible_types_p and
|
|
|
|
contains_polymorphic_type_p comparison. */
|
|
|
|
static bool get_base_types (tree *t1, tree *t2);
|
|
|
|
|
2014-11-11 15:58:21 +01:00
|
|
|
/* Return true if target supports alias symbols. */
|
|
|
|
bool target_supports_symbol_aliases_p (void);
|
|
|
|
|
2014-10-16 12:47:55 +02:00
|
|
|
/* Item type. */
|
|
|
|
sem_item_type type;
|
|
|
|
|
|
|
|
/* Symtab node. */
|
|
|
|
symtab_node *node;
|
|
|
|
|
|
|
|
/* Declaration tree node. */
|
|
|
|
tree decl;
|
|
|
|
|
|
|
|
/* Semantic references used that generate congruence groups. */
|
|
|
|
vec <sem_item *> refs;
|
|
|
|
|
|
|
|
/* Pointer to a congruence class the item belongs to. */
|
|
|
|
congruence_class *cls;
|
|
|
|
|
|
|
|
/* Index of the item in a class belonging to. */
|
|
|
|
unsigned int index_in_class;
|
|
|
|
|
|
|
|
/* List of semantic items where the instance is used. */
|
|
|
|
vec <sem_usage_pair *> usages;
|
|
|
|
|
|
|
|
/* A bitmap with indices of all classes referencing this item. */
|
|
|
|
bitmap usage_index_bitmap;
|
|
|
|
|
|
|
|
/* List of tree references (either FUNC_DECL or VAR_DECL). */
|
|
|
|
vec <tree> tree_refs;
|
|
|
|
|
|
|
|
/* A set with symbol table references. */
|
|
|
|
hash_set <symtab_node *> refs_set;
|
|
|
|
|
2015-03-22 23:47:06 +01:00
|
|
|
/* Temporary hash used where hash values of references are added. */
|
|
|
|
hashval_t global_hash;
|
2014-10-16 12:47:55 +02:00
|
|
|
protected:
|
|
|
|
/* Cached, once calculated hash for the item. */
|
2015-03-02 01:54:46 +01:00
|
|
|
|
2015-03-24 22:51:08 +01:00
|
|
|
/* Accumulate to HSTATE a hash of expression EXP. */
|
2015-03-01 23:22:26 +01:00
|
|
|
static void add_expr (const_tree exp, inchash::hash &hstate);
|
2015-03-24 22:51:08 +01:00
|
|
|
/* Accumulate to HSTATE a hash of type T. */
|
|
|
|
static void add_type (const_tree t, inchash::hash &hstate);
|
2014-10-16 12:47:55 +02:00
|
|
|
|
2015-04-23 16:55:07 +02:00
|
|
|
/* Compare properties of symbol that does not affect semantics of symbol
|
|
|
|
itself but affects semantics of its references.
|
|
|
|
If ADDRESS is true, do extra checking needed for IPA_REF_ADDR. */
|
|
|
|
static bool compare_referenced_symbol_properties (symtab_node *used_by,
|
|
|
|
symtab_node *n1,
|
|
|
|
symtab_node *n2,
|
|
|
|
bool address);
|
|
|
|
|
2015-04-23 17:25:26 +02:00
|
|
|
/* Compare two attribute lists. */
|
|
|
|
static bool compare_attributes (const_tree list1, const_tree list2);
|
|
|
|
|
2015-04-23 16:55:07 +02:00
|
|
|
/* Hash properties compared by compare_referenced_symbol_properties. */
|
|
|
|
void hash_referenced_symbol_properties (symtab_node *ref,
|
|
|
|
inchash::hash &hstate,
|
|
|
|
bool address);
|
|
|
|
|
2015-03-02 01:54:46 +01:00
|
|
|
/* For a given symbol table nodes N1 and N2, we check that FUNCTION_DECLs
|
|
|
|
point to a same function. Comparison can be skipped if IGNORED_NODES
|
|
|
|
contains these nodes. ADDRESS indicate if address is taken. */
|
2015-04-23 16:55:07 +02:00
|
|
|
bool compare_symbol_references (hash_map <symtab_node *, sem_item *>
|
2015-03-02 01:54:46 +01:00
|
|
|
&ignored_nodes,
|
|
|
|
symtab_node *n1, symtab_node *n2,
|
|
|
|
bool address);
|
2015-11-12 16:16:00 +01:00
|
|
|
protected:
|
|
|
|
/* Hash of item. */
|
|
|
|
hashval_t m_hash;
|
2015-03-02 01:54:46 +01:00
|
|
|
|
2016-11-22 10:18:37 +01:00
|
|
|
/* Indicated whether a hash value has been set or not. */
|
|
|
|
bool m_hash_set;
|
|
|
|
|
2014-10-16 12:47:55 +02:00
|
|
|
private:
|
|
|
|
/* Initialize internal data structures. Bitmap STACK is used for
|
|
|
|
bitmap memory allocation process. */
|
|
|
|
void setup (bitmap_obstack *stack);
|
|
|
|
}; // class sem_item
|
|
|
|
|
|
|
|
class sem_function: public sem_item
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/* Semantic function constructor that uses STACK as bitmap memory stack. */
|
|
|
|
sem_function (bitmap_obstack *stack);
|
|
|
|
|
2016-11-22 10:18:37 +01:00
|
|
|
/* Constructor based on callgraph node _NODE.
|
2014-10-16 12:47:55 +02:00
|
|
|
Bitmap STACK is used for memory allocation. */
|
2016-11-22 10:18:37 +01:00
|
|
|
sem_function (cgraph_node *_node, bitmap_obstack *stack);
|
2014-10-16 12:47:55 +02:00
|
|
|
|
|
|
|
~sem_function ();
|
|
|
|
|
|
|
|
inline virtual void init_wpa (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void init (void);
|
|
|
|
virtual bool equals_wpa (sem_item *item,
|
|
|
|
hash_map <symtab_node *, sem_item *> &ignored_nodes);
|
|
|
|
virtual hashval_t get_hash (void);
|
|
|
|
virtual bool equals (sem_item *item,
|
|
|
|
hash_map <symtab_node *, sem_item *> &ignored_nodes);
|
|
|
|
virtual bool merge (sem_item *alias_item);
|
|
|
|
|
|
|
|
/* Dump symbol to FILE. */
|
|
|
|
virtual void dump_to_file (FILE *file)
|
|
|
|
{
|
|
|
|
gcc_assert (file);
|
|
|
|
dump_function_to_file (decl, file, TDF_DETAILS);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns cgraph_node. */
|
|
|
|
inline cgraph_node *get_node (void)
|
|
|
|
{
|
|
|
|
return dyn_cast <cgraph_node *> (node);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Improve accumulated hash for HSTATE based on a gimple statement STMT. */
|
2015-09-20 02:52:59 +02:00
|
|
|
void hash_stmt (gimple *stmt, inchash::hash &inchash);
|
2014-10-16 12:47:55 +02:00
|
|
|
|
|
|
|
/* Return true if polymorphic comparison must be processed. */
|
|
|
|
bool compare_polymorphic_p (void);
|
|
|
|
|
|
|
|
/* For a given call graph NODE, the function constructs new
|
|
|
|
semantic function item. */
|
|
|
|
static sem_function *parse (cgraph_node *node, bitmap_obstack *stack);
|
|
|
|
|
2015-06-22 09:12:22 +02:00
|
|
|
/* Perform additional checks needed to match types of used function
|
|
|
|
paramters. */
|
|
|
|
bool compatible_parm_types_p (tree, tree);
|
|
|
|
|
2014-10-16 12:47:55 +02:00
|
|
|
/* Exception handling region tree. */
|
|
|
|
eh_region region_tree;
|
|
|
|
|
|
|
|
/* Number of function arguments. */
|
|
|
|
unsigned int arg_count;
|
|
|
|
|
|
|
|
/* Total amount of edges in the function. */
|
|
|
|
unsigned int edge_count;
|
|
|
|
|
|
|
|
/* Vector of sizes of all basic blocks. */
|
|
|
|
vec <unsigned int> bb_sizes;
|
|
|
|
|
|
|
|
/* Control flow graph checksum. */
|
|
|
|
hashval_t cfg_checksum;
|
|
|
|
|
|
|
|
/* GIMPLE codes hash value. */
|
|
|
|
hashval_t gcode_hash;
|
|
|
|
|
|
|
|
/* Total number of SSA names used in the function. */
|
|
|
|
unsigned ssa_names_size;
|
|
|
|
|
|
|
|
/* Array of structures for all basic blocks. */
|
|
|
|
vec <ipa_icf_gimple::sem_bb *> bb_sorted;
|
2015-04-23 17:25:26 +02:00
|
|
|
|
|
|
|
/* Return true if parameter I may be used. */
|
|
|
|
bool param_used_p (unsigned int i);
|
2014-10-16 12:47:55 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
/* Calculates hash value based on a BASIC_BLOCK. */
|
|
|
|
hashval_t get_bb_hash (const ipa_icf_gimple::sem_bb *basic_block);
|
|
|
|
|
|
|
|
/* For given basic blocks BB1 and BB2 (from functions FUNC1 and FUNC),
|
|
|
|
true value is returned if phi nodes are semantically
|
|
|
|
equivalent in these blocks . */
|
|
|
|
bool compare_phi_node (basic_block bb1, basic_block bb2);
|
|
|
|
|
|
|
|
/* Basic blocks dictionary BB_DICT returns true if SOURCE index BB
|
|
|
|
corresponds to TARGET. */
|
2015-02-19 02:44:42 +01:00
|
|
|
bool bb_dict_test (vec<int> *bb_dict, int source, int target);
|
2014-10-16 12:47:55 +02:00
|
|
|
|
|
|
|
/* If cgraph edges E1 and E2 are indirect calls, verify that
|
|
|
|
ICF flags are the same. */
|
|
|
|
bool compare_edge_flags (cgraph_edge *e1, cgraph_edge *e2);
|
|
|
|
|
|
|
|
/* Processes function equality comparison. */
|
2015-04-24 02:58:25 +02:00
|
|
|
bool equals_private (sem_item *item);
|
2014-10-16 12:47:55 +02:00
|
|
|
|
|
|
|
/* Returns true if tree T can be compared as a handled component. */
|
|
|
|
static bool icf_handled_component_p (tree t);
|
|
|
|
|
|
|
|
/* Function checker stores binding between functions. */
|
|
|
|
ipa_icf_gimple::func_checker *m_checker;
|
|
|
|
|
|
|
|
/* COMPARED_FUNC is a function that we compare to. */
|
|
|
|
sem_function *m_compared_func;
|
|
|
|
}; // class sem_function
|
|
|
|
|
|
|
|
class sem_variable: public sem_item
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/* Semantic variable constructor that uses STACK as bitmap memory stack. */
|
|
|
|
sem_variable (bitmap_obstack *stack);
|
|
|
|
|
2016-11-22 10:18:37 +01:00
|
|
|
/* Constructor based on callgraph node _NODE.
|
2014-10-16 12:47:55 +02:00
|
|
|
Bitmap STACK is used for memory allocation. */
|
|
|
|
|
2016-11-22 10:18:37 +01:00
|
|
|
sem_variable (varpool_node *_node, bitmap_obstack *stack);
|
2014-10-16 12:47:55 +02:00
|
|
|
|
|
|
|
inline virtual void init_wpa (void) {}
|
|
|
|
|
|
|
|
/* Semantic variable initialization function. */
|
|
|
|
inline virtual void init (void)
|
|
|
|
{
|
|
|
|
decl = get_node ()->decl;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual hashval_t get_hash (void);
|
|
|
|
virtual bool merge (sem_item *alias_item);
|
|
|
|
virtual void dump_to_file (FILE *file);
|
|
|
|
virtual bool equals (sem_item *item,
|
|
|
|
hash_map <symtab_node *, sem_item *> &ignored_nodes);
|
|
|
|
|
|
|
|
/* Fast equality variable based on knowledge known in WPA. */
|
2015-03-02 01:54:46 +01:00
|
|
|
virtual bool equals_wpa (sem_item *item,
|
|
|
|
hash_map <symtab_node *, sem_item *> &ignored_nodes);
|
2014-10-16 12:47:55 +02:00
|
|
|
|
|
|
|
/* Returns varpool_node. */
|
|
|
|
inline varpool_node *get_node (void)
|
|
|
|
{
|
|
|
|
return dyn_cast <varpool_node *> (node);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Parser function that visits a varpool NODE. */
|
|
|
|
static sem_variable *parse (varpool_node *node, bitmap_obstack *stack);
|
|
|
|
|
|
|
|
private:
|
|
|
|
/* Compares trees T1 and T2 for semantic equality. */
|
|
|
|
static bool equals (tree t1, tree t2);
|
|
|
|
}; // class sem_variable
|
|
|
|
|
|
|
|
class sem_item_optimizer;
|
|
|
|
|
|
|
|
struct congruence_class_group
|
|
|
|
{
|
|
|
|
hashval_t hash;
|
|
|
|
sem_item_type type;
|
|
|
|
vec <congruence_class *> classes;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Congruence class set structure. */
|
2015-06-25 19:06:13 +02:00
|
|
|
struct congruence_class_group_hash : nofree_ptr_hash <congruence_class_group>
|
2014-10-16 12:47:55 +02:00
|
|
|
{
|
remove need for store_values_directly
This switches all hash_table users to use the layout that stores
elements of type value_type in the hash table instead of the one storing
value_type *. Since it becomes unused support for the value_type *
layout is removed.
gcc/
* hash-table.h: Remove version of hash_table that stored value_type *.
* asan.c, attribs.c, bitmap.c, cfg.c, cgraph.h, config/arm/arm.c,
config/i386/winnt.c, config/ia64/ia64.c, config/mips/mips.c,
config/sol2.c, coverage.c, cselib.c, dse.c, dwarf2cfi.c,
dwarf2out.c, except.c, gcse.c, genmatch.c, ggc-common.c,
gimple-ssa-strength-reduction.c, gimplify.c, haifa-sched.c,
hard-reg-set.h, hash-map.h, hash-set.h, ipa-devirt.c, ipa-icf.h,
ipa-profile.c, ira-color.c, ira-costs.c, loop-invariant.c,
loop-iv.c, loop-unroll.c, lto-streamer.h, plugin.c, postreload-gcse.c,
reginfo.c, statistics.c, store-motion.c, trans-mem.c, tree-cfg.c,
tree-eh.c, tree-hasher.h, tree-into-ssa.c, tree-parloops.c,
tree-sra.c, tree-ssa-coalesce.c, tree-ssa-dom.c, tree-ssa-live.c,
tree-ssa-loop-im.c, tree-ssa-loop-ivopts.c, tree-ssa-phiopt.c,
tree-ssa-pre.c, tree-ssa-reassoc.c, tree-ssa-sccvn.c,
tree-ssa-structalias.c, tree-ssa-tail-merge.c,
tree-ssa-threadupdate.c, tree-vectorizer.c, tree-vectorizer.h,
valtrack.h, var-tracking.c, vtable-verify.c, vtable-verify.h: Adjust.
libcc1/
* plugin.cc: Adjust for hash_table changes.
gcc/java/
* jcf-io.c: Adjust for hash_table changes.
gcc/lto/
* lto.c: Adjust for hash_table changes.
gcc/objc/
* objc-act.c: Adjust for hash_table changes.
From-SVN: r222213
2015-04-18 20:13:18 +02:00
|
|
|
static inline hashval_t hash (const congruence_class_group *item)
|
2014-10-16 12:47:55 +02:00
|
|
|
{
|
|
|
|
return item->hash;
|
|
|
|
}
|
|
|
|
|
remove need for store_values_directly
This switches all hash_table users to use the layout that stores
elements of type value_type in the hash table instead of the one storing
value_type *. Since it becomes unused support for the value_type *
layout is removed.
gcc/
* hash-table.h: Remove version of hash_table that stored value_type *.
* asan.c, attribs.c, bitmap.c, cfg.c, cgraph.h, config/arm/arm.c,
config/i386/winnt.c, config/ia64/ia64.c, config/mips/mips.c,
config/sol2.c, coverage.c, cselib.c, dse.c, dwarf2cfi.c,
dwarf2out.c, except.c, gcse.c, genmatch.c, ggc-common.c,
gimple-ssa-strength-reduction.c, gimplify.c, haifa-sched.c,
hard-reg-set.h, hash-map.h, hash-set.h, ipa-devirt.c, ipa-icf.h,
ipa-profile.c, ira-color.c, ira-costs.c, loop-invariant.c,
loop-iv.c, loop-unroll.c, lto-streamer.h, plugin.c, postreload-gcse.c,
reginfo.c, statistics.c, store-motion.c, trans-mem.c, tree-cfg.c,
tree-eh.c, tree-hasher.h, tree-into-ssa.c, tree-parloops.c,
tree-sra.c, tree-ssa-coalesce.c, tree-ssa-dom.c, tree-ssa-live.c,
tree-ssa-loop-im.c, tree-ssa-loop-ivopts.c, tree-ssa-phiopt.c,
tree-ssa-pre.c, tree-ssa-reassoc.c, tree-ssa-sccvn.c,
tree-ssa-structalias.c, tree-ssa-tail-merge.c,
tree-ssa-threadupdate.c, tree-vectorizer.c, tree-vectorizer.h,
valtrack.h, var-tracking.c, vtable-verify.c, vtable-verify.h: Adjust.
libcc1/
* plugin.cc: Adjust for hash_table changes.
gcc/java/
* jcf-io.c: Adjust for hash_table changes.
gcc/lto/
* lto.c: Adjust for hash_table changes.
gcc/objc/
* objc-act.c: Adjust for hash_table changes.
From-SVN: r222213
2015-04-18 20:13:18 +02:00
|
|
|
static inline int equal (const congruence_class_group *item1,
|
|
|
|
const congruence_class_group *item2)
|
2014-10-16 12:47:55 +02:00
|
|
|
{
|
|
|
|
return item1->hash == item2->hash && item1->type == item2->type;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct traverse_split_pair
|
|
|
|
{
|
|
|
|
sem_item_optimizer *optimizer;
|
|
|
|
class congruence_class *cls;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Semantic item optimizer includes all top-level logic
|
|
|
|
related to semantic equality comparison. */
|
|
|
|
class sem_item_optimizer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
sem_item_optimizer ();
|
|
|
|
~sem_item_optimizer ();
|
|
|
|
|
|
|
|
/* Function responsible for visiting all potential functions and
|
|
|
|
read-only variables that can be merged. */
|
|
|
|
void parse_funcs_and_vars (void);
|
|
|
|
|
2015-03-03 10:21:56 +01:00
|
|
|
/* Optimizer entry point which returns true in case it processes
|
|
|
|
a merge operation. True is returned if there's a merge operation
|
|
|
|
processed. */
|
|
|
|
bool execute (void);
|
2014-10-16 12:47:55 +02:00
|
|
|
|
|
|
|
/* Dump function. */
|
|
|
|
void dump (void);
|
|
|
|
|
|
|
|
/* Verify congruence classes if checking is enabled. */
|
[PATCH 7/9] ENABLE_CHECKING refactoring: middle-end, LTO FE
[PATCH 7/9] ENABLE_CHECKING refactoring: middle-end, LTO FE
gcc/lto/ChangeLog:
2015-10-27 Mikhail Maltsev <maltsevm@gmail.com>
* lto.c (unify_scc): Use flag_checking and remove ENABLE_CHECKING
conditionals.
(lto_fixup_state): Likewise.
(do_whole_program_analysis): Use
symtab_node::checking_verify_symtab_nodes and remove ENABLE_CHECKING
conditionals.
gcc/ChangeLog:
2015-10-27 Mikhail Maltsev <maltsevm@gmail.com>
* attribs.c (check_attribute_tables): New function, broken out from...
(init_attributes): Use it.
* cfgcleanup.c (try_optimize_cfg): Use flag_checking, CHECKING_P
gcc_checking_assert and checking_* functions to eliminate
ENABLE_CHECKING conditionals.
* cfgexpand.c (expand_goto, expand_debug_expr): Likewise.
(pass_expand::execute): Likewise.
* cgraphclones.c (symbol_table::materialize_all_clones): Likewise.
* cgraphunit.c (mark_functions_to_output): Likewise.
(cgraph_node::expand_thunk): Likewise.
(symbol_table::compile): Likewise.
* ddg.c (add_cross_iteration_register_deps): Likewise.
(create_ddg_all_sccs): Likewise.
* df-core.c (df_finish_pass, df_analyze): Likewise.
* diagnostic-core.h: Likewise.
* diagnostic.c (diagnostic_report_diagnostic): Likewise.
* dominance.c (calculate_dominance_info): Likewise.
* dwarf2out.c (add_AT_die_ref): Likewise.
(const_ok_for_output_1, mem_loc_descriptor): Likewise.
(loc_list_from_tree, gen_lexical_block_die): Likewise.
gen_type_die_with_usage, gen_type_die): Likewise.
(dwarf2out_decl): Likewise.
* emit-rtl.c (verify_rtx_sharing, reorder_insns_nobb): Likewise.
* except.c (duplicate_eh_regions): Likewise.
* fwprop.c (register_active_defs, update_df_init): Likewise.
(fwprop_init, fwprop_done): Likewise.
(update_uses): Likewise.
* ggc-page.c (ggc_grow): Likewise.
* gimplify.c (gimplify_body): Likewise.
(gimplify_hasher::equal): Likewise.
* graphite-isl-ast-to-gimple.c (graphite_verify): Likewise.
* graphite-scop-detection.c (canonicalize_loop_closed_ssa_form):
Likewise.
* graphite-sese-to-poly.c (rewrite_reductions_out_of_ssa): Likewise.
(rewrite_cross_bb_scalar_deps_out_of_ssa): Likwise.
* hash-table.h (::find_empty_slot_for_expand): Likewise.
* ifcvt.c (if_convert): Likewise.
* ipa-cp.c (ipcp_propagate_stage): Likewise.
* ipa-devirt.c (type_in_anonymous_namespace_p): Likewise.
(odr_type_p, odr_types_equivalent_p): Likewise.
(add_type_duplicate, get_odr_type): Likewise.
* ipa-icf.c (sem_item_optimizer::execute): Likewise.
(sem_item_optimizer::subdivide_classes_by_equality): Likewise.
(sem_item_optimizer::verify_classes): Likewise.
(sem_item_optimizer::traverse_congruence_split): Likewise.
(sem_item_optimizer::checking_verify_classes): New.
* ipa-icf.h (sem_item_optimizer::checking_verify_classes): Add new
method.
* cfgrtl.c (commit_edge_insertions): Likewise.
(fixup_reorder_chain, cfg_layout_finalize): Likewise.
(rtl_flow_call_edges_add): Likewise.
* cgraph.c (symbol_table::create_edge): Likewise.
(cgraph_edge::redirect_call_stmt_to_callee): Likewise.
* cgraph.h (symtab_node): Likewise.
(symtab_node::checking_verify_symtab_nodes): Define.
(cgraph_node::checking_verify_cgraph_nodes): Define.
* cfghooks.h (checking_verify_flow_info): Define.
* cfgloop.h (checking_verify_loop_structure): Define.
* dominance.h (checking_verify_dominators): Define.
* et-forest.c: Fix comment.
* ipa-inline-analysis.c (compute_inline_parameters): Use flag_checking,
CHECKING_P gcc_checking_assert and checking_* functions to eliminate
ENABLE_CHECKING conditionals.
* ipa-inline-transform.c (save_inline_function_body): Likewise.
* ipa-inline.c (inline_small_functions): Likewise.
(early_inliner): Likewise.
* ipa-inline.h (estimate_edge_growth): Likewise.
* ipa-visibility.c (function_and_variable_visibility): Likewise.
* ipa.c (symbol_table::remove_unreachable_nodes): Likewise.
(ipa_single_use): Likewise.
* ira-int.h: Likewise.
* ira.c (ira): Likewise.
* loop-doloop.c (doloop_optimize_loops): Likewise.
* loop-init.c (loop_optimizer_init, fix_loop_structure): Likewise.
* loop-invariant.c (move_loop_invariants): Likewise.
* lra-assigns.c (lra_assign): Likewise.
* lra-constraints.c (lra_constraints): Likewise.
* lra-eliminations.c (lra_eliminate): Likewise.
* lra-int.h (struct lra_reg): Likewise.
* lra-lives.c (check_pseudos_live_through_calls): Likewise.
(lra_create_live_ranges_1): Likewise.
* lra-remat.c (create_remat_bb_data): Likewise.
* lra.c (lra_update_insn_recog_data, restore_scratches): Likewise.
(lra): Likewise.
(check_rtl): Always define. Remove incorrect guard around
extract_constrain_insn call.
* lto-cgraph.c (input_cgraph_1: Use flag_checking,
CHECKING_P gcc_checking_assert and checking_* functions to eliminate
ENABLE_CHECKING conditionals.
* lto-streamer-out.c (DFS::DFS): Likewise.
(lto_output): Likewise.
* lto-streamer.c (lto_streamer_init): Likewise.
* omp-low.c (scan_omp_target, expand_omp_taskreg): Likewise.
expand_omp_target, execute_expand_omp): Likewise.
(lower_omp_target): Likewise.
* passes.c (execute_function_todo): Likewise.
(execute_todo, execute_one_pass): Likewise.
(verify_curr_properties): Always define.
* predict.c (tree_estimate_probability: Use flag_checking,
CHECKING_P gcc_checking_assert and checking_* functions to eliminate
ENABLE_CHECKING conditionals.
(propagate_freq): Likewise.
* pretty-print.c (pp_format): Likewise.
* real.c (real_to_decimal_for_mode): Likewise.
* recog.c (split_all_insns): Likewise.
* regcprop.c (kill_value_one_regno): Likewise.
(copy_value): Likewise.
(validate_value_data): Define unconditionally.
* reload.c: Fix comment.
* timevar.c: Include options.h
* tree-ssa.h (checking_verify_ssa): Define.
* tree-ssa-loop-manip.h (checking_verify_loop_closed_ssa): Define.
* sched-deps.c (CHECK): Remove unused macro.
(add_or_update_dep_1, sd_add_dep: Use flag_checking, CHECKING_P
gcc_checking_assert and checking_* functions to eliminate
ENABLE_CHECKING conditionals.
* sel-sched-ir.c (free_regset_pool, tidy_control_flow): Likewise.
* sel-sched.c (struct moveop_static_params): Likewise.
(find_best_reg_for_expr, move_cond_jump): Likewise.
(move_op_orig_expr_not_found): Likewise.
(code_motion_process_successors, move_op): Likewise.
* ssa-iterators.h (first_readonly_imm_use): Likewise.
(next_readonly_imm_use): Likewise.
* store-motion.c (compute_store_table): Likewise.
* symbol-summary.h (function_summary::function_summary): Likewise.
* target.h (cumulative_args_t): Likewise.
(get_cumulative_args, pack_cumulative_args): Likewise.
* timevar.c: (timer::print): Likewise.
* trans-mem.c (ipa_tm_execute): Likewise.
* tree-cfg.c (move_stmt_op): Likewise.
(move_sese_region_to_fn): Likewise.
(gimple_flow_call_edges_add): Likewise.
* tree-cfgcleanup.c (cleanup_tree_cfg_noloop, repair_loop_structures):
Likewise.
* tree-eh.c (remove_unreachable_handlers): Likewise.
* tree-if-conv.c (pass_if_conversion::execute): Likewise.
* tree-inline.c (expand_call_inline, optimize_inline_calls): Likewise.
* tree-into-ssa.c (update_ssa): Likewise.
* tree-loop-distribution.c (pass_loop_distribution::execute): Likewise.
* tree-outof-ssa.c (eliminate_useless_phis, rewrite_trees): Likewise.
* tree-parloops.c (pass_parallelize_loops::execute): Likewise.
* tree-predcom.c (suitable_component_p): Likewise.
* tree-profile.c (gimple_gen_const_delta_profiler): Likewise.
* tree-ssa-alias.c (refs_may_alias_p_1): Likewise.
* tree-ssa-live.c (verify_live_on_entry): Likewise.
* tree-ssa-live.h (register_ssa_partition): Likewise.
* tree-ssa-loop-ivcanon.c (tree_unroll_loops_completely): Likewise.
* tree-ssa-loop-manip.c (add_exit_phi): Likewise.
(tree_transform_and_unroll_loop): Likewise.
* tree-ssa-math-opts.c (pass_cse_reciprocals::execute): Likewise.
* tree-ssa-operands.c (get_expr_operands): Likewise.
* tree-ssa-propagate.c (replace_exp_1): Likewise.
* tree-ssa-structalias.c (rewrite_constraints): Likewise.
* tree-ssa-ter.c (free_temp_expr_table): Likewise.
* tree-ssa-threadupdate.c (duplicate_thread_path): Likewise.
* tree-ssanames.c (release_ssa_name_fn): Likewise.
* tree-stdarg.c (expand_ifn_va_arg): Likewise.
* tree-vect-loop-manip.c
(slpeel_tree_duplicate_loop_to_edge_cfg): Likewise.
(slpeel_checking_verify_cfg_after_peeling): Likewise.
(vect_do_peeling_for_loop_bound): Likewise.
(vect_do_peeling_for_alignment): Likewise.
* tree-vrp.c (supports_overflow_infinity): Likewise.
(set_value_range): Likewise.
* tree.c (free_lang_data_in_cgraph): Likewise.
* value-prof.c (gimple_remove_histogram_value): Likewise.
(free_hist): Likewise.
* var-tracking.c (canonicalize_values_star): Likewise.
(compute_bb_dataflow, vt_find_locations, vt_emit_notes): Likewise.
From-SVN: r229470
2015-10-28 02:05:53 +01:00
|
|
|
void checking_verify_classes (void);
|
|
|
|
|
|
|
|
/* Verify congruence classes. */
|
2014-10-16 12:47:55 +02:00
|
|
|
void verify_classes (void);
|
|
|
|
|
|
|
|
/* Write IPA ICF summary for symbols. */
|
|
|
|
void write_summary (void);
|
|
|
|
|
2015-07-13 06:46:34 +02:00
|
|
|
/* Read IPA ICF summary for symbols. */
|
2014-10-16 12:47:55 +02:00
|
|
|
void read_summary (void);
|
|
|
|
|
|
|
|
/* Callgraph removal hook called for a NODE with a custom DATA. */
|
|
|
|
static void cgraph_removal_hook (cgraph_node *node, void *data);
|
|
|
|
|
|
|
|
/* Varpool removal hook called for a NODE with a custom DATA. */
|
|
|
|
static void varpool_removal_hook (varpool_node *node, void *data);
|
|
|
|
|
|
|
|
/* Worklist of congruence classes that can potentially
|
|
|
|
refine classes of congruence. */
|
|
|
|
std::list<congruence_class *> worklist;
|
|
|
|
|
|
|
|
/* Remove semantic ITEM and release memory. */
|
|
|
|
void remove_item (sem_item *item);
|
|
|
|
|
|
|
|
/* Remove symtab NODE triggered by symtab removal hooks. */
|
|
|
|
void remove_symtab_node (symtab_node *node);
|
|
|
|
|
|
|
|
/* Register callgraph and varpool hooks. */
|
|
|
|
void register_hooks (void);
|
|
|
|
|
|
|
|
/* Unregister callgraph and varpool hooks. */
|
|
|
|
void unregister_hooks (void);
|
|
|
|
|
|
|
|
/* Adds a CLS to hashtable associated by hash value. */
|
|
|
|
void add_class (congruence_class *cls);
|
|
|
|
|
|
|
|
/* Gets a congruence class group based on given HASH value and TYPE. */
|
|
|
|
congruence_class_group *get_group_by_hash (hashval_t hash,
|
|
|
|
sem_item_type type);
|
|
|
|
|
2015-03-24 22:51:08 +01:00
|
|
|
/* Because types can be arbitrarily large, avoid quadratic bottleneck. */
|
|
|
|
hash_map<const_tree, hashval_t> m_type_hash_cache;
|
2014-10-16 12:47:55 +02:00
|
|
|
private:
|
|
|
|
|
2015-03-22 23:47:06 +01:00
|
|
|
/* For each semantic item, append hash values of references. */
|
|
|
|
void update_hash_by_addr_refs ();
|
|
|
|
|
2014-10-16 12:47:55 +02:00
|
|
|
/* Congruence classes are built by hash value. */
|
|
|
|
void build_hash_based_classes (void);
|
|
|
|
|
|
|
|
/* Semantic items in classes having more than one element and initialized.
|
|
|
|
In case of WPA, we load function body. */
|
|
|
|
void parse_nonsingleton_classes (void);
|
|
|
|
|
|
|
|
/* Equality function for semantic items is used to subdivide existing
|
|
|
|
classes. If IN_WPA, fast equality function is invoked. */
|
|
|
|
void subdivide_classes_by_equality (bool in_wpa = false);
|
|
|
|
|
2015-02-26 21:21:38 +01:00
|
|
|
/* Subdivide classes by address and interposable references
|
|
|
|
that members of the class reference.
|
|
|
|
Example can be a pair of functions that have an address
|
|
|
|
taken from a function. If these addresses are different the class
|
|
|
|
is split. */
|
|
|
|
unsigned subdivide_classes_by_sensitive_refs();
|
|
|
|
|
2014-10-16 12:47:55 +02:00
|
|
|
/* Debug function prints all informations about congruence classes. */
|
|
|
|
void dump_cong_classes (void);
|
|
|
|
|
|
|
|
/* Build references according to call graph. */
|
|
|
|
void build_graph (void);
|
|
|
|
|
|
|
|
/* Iterative congruence reduction function. */
|
|
|
|
void process_cong_reduction (void);
|
|
|
|
|
|
|
|
/* After reduction is done, we can declare all items in a group
|
|
|
|
to be equal. PREV_CLASS_COUNT is start number of classes
|
2015-03-03 10:21:56 +01:00
|
|
|
before reduction. True is returned if there's a merge operation
|
|
|
|
processed. */
|
|
|
|
bool merge_classes (unsigned int prev_class_count);
|
2014-10-16 12:47:55 +02:00
|
|
|
|
|
|
|
/* Adds a newly created congruence class CLS to worklist. */
|
|
|
|
void worklist_push (congruence_class *cls);
|
|
|
|
|
|
|
|
/* Pops a class from worklist. */
|
|
|
|
congruence_class *worklist_pop ();
|
|
|
|
|
|
|
|
/* Every usage of a congruence class CLS is a candidate that can split the
|
|
|
|
collection of classes. Bitmap stack BMSTACK is used for bitmap
|
|
|
|
allocation. */
|
|
|
|
void do_congruence_step (congruence_class *cls);
|
|
|
|
|
|
|
|
/* Tests if a class CLS used as INDEXth splits any congruence classes.
|
|
|
|
Bitmap stack BMSTACK is used for bitmap allocation. */
|
|
|
|
void do_congruence_step_for_index (congruence_class *cls, unsigned int index);
|
|
|
|
|
|
|
|
/* Makes pairing between a congruence class CLS and semantic ITEM. */
|
|
|
|
static void add_item_to_class (congruence_class *cls, sem_item *item);
|
|
|
|
|
|
|
|
/* Disposes split map traverse function. CLS is congruence
|
|
|
|
class, BSLOT is bitmap slot we want to release. DATA is mandatory,
|
|
|
|
but unused argument. */
|
|
|
|
static bool release_split_map (congruence_class * const &cls, bitmap const &b,
|
|
|
|
traverse_split_pair *pair);
|
|
|
|
|
|
|
|
/* Process split operation for a cognruence class CLS,
|
|
|
|
where bitmap B splits congruence class members. DATA is used
|
|
|
|
as argument of split pair. */
|
|
|
|
static bool traverse_congruence_split (congruence_class * const &cls,
|
|
|
|
bitmap const &b,
|
|
|
|
traverse_split_pair *pair);
|
|
|
|
|
|
|
|
/* Reads a section from LTO stream file FILE_DATA. Input block for DATA
|
|
|
|
contains LEN bytes. */
|
|
|
|
void read_section (lto_file_decl_data *file_data, const char *data,
|
|
|
|
size_t len);
|
|
|
|
|
|
|
|
/* Removes all callgraph and varpool nodes that are marked by symtab
|
|
|
|
as deleted. */
|
|
|
|
void filter_removed_items (void);
|
|
|
|
|
|
|
|
/* Vector of semantic items. */
|
|
|
|
vec <sem_item *> m_items;
|
|
|
|
|
|
|
|
/* A set containing all items removed by hooks. */
|
|
|
|
hash_set <symtab_node *> m_removed_items_set;
|
|
|
|
|
|
|
|
/* Hashtable of congruence classes */
|
|
|
|
hash_table <congruence_class_group_hash> m_classes;
|
|
|
|
|
|
|
|
/* Count of congruence classes. */
|
|
|
|
unsigned int m_classes_count;
|
|
|
|
|
|
|
|
/* Map data structure maps symtab nodes to semantic items. */
|
|
|
|
hash_map <symtab_node *, sem_item *> m_symtab_node_map;
|
|
|
|
|
|
|
|
/* Set to true if a splitter class is removed. */
|
|
|
|
bool splitter_class_removed;
|
|
|
|
|
|
|
|
/* Global unique class id counter. */
|
|
|
|
static unsigned int class_id;
|
|
|
|
|
|
|
|
/* Callgraph node removal hook holder. */
|
|
|
|
cgraph_node_hook_list *m_cgraph_node_hooks;
|
|
|
|
|
|
|
|
/* Varpool node removal hook holder. */
|
|
|
|
varpool_node_hook_list *m_varpool_node_hooks;
|
|
|
|
|
|
|
|
/* Bitmap stack. */
|
|
|
|
bitmap_obstack m_bmstack;
|
|
|
|
}; // class sem_item_optimizer
|
|
|
|
|
|
|
|
} // ipa_icf namespace
|