]>
Commit | Line | Data |
---|---|---|
52200d03 | 1 | /* Interprocedural semantic function equality pass |
d353bf18 | 2 | Copyright (C) 2014-2015 Free Software Foundation, Inc. |
52200d03 | 3 | |
4 | Contributed by Jan Hubicka <hubicka@ucw.cz> and Martin Liska <mliska@suse.cz> | |
5 | ||
6 | This file is part of GCC. | |
7 | ||
8 | GCC is free software; you can redistribute it and/or modify it under | |
9 | the terms of the GNU General Public License as published by the Free | |
10 | Software Foundation; either version 3, or (at your option) any later | |
11 | version. | |
12 | ||
13 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
14 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 | for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with GCC; see the file COPYING3. If not see | |
20 | <http://www.gnu.org/licenses/>. */ | |
21 | ||
22 | namespace ipa_icf { | |
23 | class sem_item; | |
24 | ||
25 | /* Congruence class encompasses a collection of either functions or | |
26 | read-only variables. These items are considered to be equivalent | |
27 | if not proved the oposite. */ | |
28 | class congruence_class | |
29 | { | |
30 | public: | |
31 | /* Congruence class constructor for a new class with _ID. */ | |
32 | congruence_class (unsigned int _id): in_worklist (false), id(_id) | |
33 | { | |
34 | } | |
35 | ||
36 | /* Destructor. */ | |
37 | ~congruence_class () | |
38 | { | |
39 | } | |
40 | ||
41 | /* Dump function prints all class members to a FILE with an INDENT. */ | |
42 | void dump (FILE *file, unsigned int indent = 0) const; | |
43 | ||
44 | /* Returns true if there's a member that is used from another group. */ | |
45 | bool is_class_used (void); | |
46 | ||
47 | /* Flag is used in case we want to remove a class from worklist and | |
48 | delete operation is quite expensive for | |
49 | the data structure (linked list). */ | |
50 | bool in_worklist; | |
51 | ||
52 | /* Vector of all group members. */ | |
53 | auto_vec <sem_item *> members; | |
54 | ||
55 | /* Global unique class identifier. */ | |
56 | unsigned int id; | |
57 | }; | |
58 | ||
59 | /* Semantic item type enum. */ | |
60 | enum sem_item_type | |
61 | { | |
62 | FUNC, | |
63 | VAR | |
64 | }; | |
65 | ||
0e62482d | 66 | /* Class is container for address references for a symtab_node. */ |
67 | ||
68 | class symbol_compare_collection | |
69 | { | |
70 | public: | |
71 | /* Constructor. */ | |
72 | symbol_compare_collection (symtab_node *node); | |
73 | ||
74 | /* Destructor. */ | |
75 | ~symbol_compare_collection () | |
76 | { | |
77 | m_references.release (); | |
78 | m_interposables.release (); | |
79 | } | |
80 | ||
81 | /* Vector of address references. */ | |
82 | vec<symtab_node *> m_references; | |
83 | ||
84 | /* Vector of interposable references. */ | |
85 | vec<symtab_node *> m_interposables; | |
86 | }; | |
87 | ||
88 | /* Hash traits for symbol_compare_collection map. */ | |
89 | ||
091deb37 | 90 | struct symbol_compare_hash : nofree_ptr_hash <symbol_compare_collection> |
0e62482d | 91 | { |
92 | static hashval_t | |
091deb37 | 93 | hash (value_type v) |
0e62482d | 94 | { |
95 | inchash::hash hstate; | |
96 | hstate.add_int (v->m_references.length ()); | |
97 | ||
98 | for (unsigned i = 0; i < v->m_references.length (); i++) | |
4a34b76a | 99 | hstate.add_int (v->m_references[i]->ultimate_alias_target ()->order); |
0e62482d | 100 | |
101 | hstate.add_int (v->m_interposables.length ()); | |
102 | ||
103 | for (unsigned i = 0; i < v->m_interposables.length (); i++) | |
4a34b76a | 104 | hstate.add_int (v->m_interposables[i]->ultimate_alias_target ()->order); |
0e62482d | 105 | |
106 | return hstate.end (); | |
107 | } | |
108 | ||
109 | static bool | |
091deb37 | 110 | equal (value_type a, value_type b) |
0e62482d | 111 | { |
f52caa41 | 112 | if (a->m_references.length () != b->m_references.length () |
113 | || a->m_interposables.length () != b->m_interposables.length ()) | |
0e62482d | 114 | return false; |
115 | ||
116 | for (unsigned i = 0; i < a->m_references.length (); i++) | |
117 | if (a->m_references[i]->equal_address_to (b->m_references[i]) != 1) | |
118 | return false; | |
119 | ||
120 | for (unsigned i = 0; i < a->m_interposables.length (); i++) | |
121 | if (!a->m_interposables[i]->semantically_equivalent_p | |
122 | (b->m_interposables[i])) | |
123 | return false; | |
124 | ||
125 | return true; | |
126 | } | |
127 | }; | |
128 | ||
129 | ||
52200d03 | 130 | /* Semantic item usage pair. */ |
131 | class sem_usage_pair | |
132 | { | |
133 | public: | |
134 | /* Constructor for key value pair, where _ITEM is key and _INDEX is a target. */ | |
135 | sem_usage_pair (sem_item *_item, unsigned int _index); | |
136 | ||
137 | /* Target semantic item where an item is used. */ | |
138 | sem_item *item; | |
139 | ||
140 | /* Index of usage of such an item. */ | |
141 | unsigned int index; | |
142 | }; | |
143 | ||
144 | /* Semantic item is a base class that encapsulates all shared functionality | |
145 | for both semantic function and variable items. */ | |
146 | class sem_item | |
147 | { | |
148 | public: | |
149 | /* Semantic item constructor for a node of _TYPE, where STACK is used | |
150 | for bitmap memory allocation. */ | |
151 | sem_item (sem_item_type _type, bitmap_obstack *stack); | |
152 | ||
153 | /* Semantic item constructor for a node of _TYPE, where STACK is used | |
154 | for bitmap memory allocation. The item is based on symtab node _NODE | |
155 | with computed _HASH. */ | |
156 | sem_item (sem_item_type _type, symtab_node *_node, hashval_t _hash, | |
157 | bitmap_obstack *stack); | |
158 | ||
159 | virtual ~sem_item (); | |
160 | ||
161 | /* Dump function for debugging purpose. */ | |
162 | DEBUG_FUNCTION void dump (void); | |
163 | ||
164 | /* Initialize semantic item by info reachable during LTO WPA phase. */ | |
165 | virtual void init_wpa (void) = 0; | |
166 | ||
167 | /* Semantic item initialization function. */ | |
168 | virtual void init (void) = 0; | |
169 | ||
170 | /* Add reference to a semantic TARGET. */ | |
171 | void add_reference (sem_item *target); | |
172 | ||
52200d03 | 173 | /* Fast equality function based on knowledge known in WPA. */ |
174 | virtual bool equals_wpa (sem_item *item, | |
175 | hash_map <symtab_node *, sem_item *> &ignored_nodes) = 0; | |
176 | ||
177 | /* Returns true if the item equals to ITEM given as arguemnt. */ | |
178 | virtual bool equals (sem_item *item, | |
179 | hash_map <symtab_node *, sem_item *> &ignored_nodes) = 0; | |
180 | ||
181 | /* References independent hash function. */ | |
182 | virtual hashval_t get_hash (void) = 0; | |
183 | ||
184 | /* Merges instance with an ALIAS_ITEM, where alias, thunk or redirection can | |
185 | be applied. */ | |
186 | virtual bool merge (sem_item *alias_item) = 0; | |
187 | ||
188 | /* Dump symbol to FILE. */ | |
189 | virtual void dump_to_file (FILE *file) = 0; | |
190 | ||
4765f5e5 | 191 | /* Update hash by address sensitive references. */ |
192 | void update_hash_by_addr_refs (hash_map <symtab_node *, | |
193 | sem_item *> &m_symtab_node_map); | |
194 | ||
195 | /* Update hash by computed local hash values taken from different | |
196 | semantic items. */ | |
197 | void update_hash_by_local_refs (hash_map <symtab_node *, | |
198 | sem_item *> &m_symtab_node_map); | |
199 | ||
52200d03 | 200 | /* Return base tree that can be used for compatible_types_p and |
201 | contains_polymorphic_type_p comparison. */ | |
52200d03 | 202 | static bool get_base_types (tree *t1, tree *t2); |
203 | ||
e1daea7b | 204 | /* Return true if target supports alias symbols. */ |
205 | bool target_supports_symbol_aliases_p (void); | |
206 | ||
52200d03 | 207 | /* Item type. */ |
208 | sem_item_type type; | |
209 | ||
210 | /* Symtab node. */ | |
211 | symtab_node *node; | |
212 | ||
213 | /* Declaration tree node. */ | |
214 | tree decl; | |
215 | ||
216 | /* Semantic references used that generate congruence groups. */ | |
217 | vec <sem_item *> refs; | |
218 | ||
219 | /* Pointer to a congruence class the item belongs to. */ | |
220 | congruence_class *cls; | |
221 | ||
222 | /* Index of the item in a class belonging to. */ | |
223 | unsigned int index_in_class; | |
224 | ||
225 | /* List of semantic items where the instance is used. */ | |
226 | vec <sem_usage_pair *> usages; | |
227 | ||
228 | /* A bitmap with indices of all classes referencing this item. */ | |
229 | bitmap usage_index_bitmap; | |
230 | ||
231 | /* List of tree references (either FUNC_DECL or VAR_DECL). */ | |
232 | vec <tree> tree_refs; | |
233 | ||
234 | /* A set with symbol table references. */ | |
235 | hash_set <symtab_node *> refs_set; | |
236 | ||
4765f5e5 | 237 | /* Hash of item. */ |
238 | hashval_t hash; | |
239 | ||
240 | /* Temporary hash used where hash values of references are added. */ | |
241 | hashval_t global_hash; | |
52200d03 | 242 | protected: |
243 | /* Cached, once calculated hash for the item. */ | |
2aaa1027 | 244 | |
4a34b76a | 245 | /* Accumulate to HSTATE a hash of expression EXP. */ |
d5d259d4 | 246 | static void add_expr (const_tree exp, inchash::hash &hstate); |
4a34b76a | 247 | /* Accumulate to HSTATE a hash of type T. */ |
248 | static void add_type (const_tree t, inchash::hash &hstate); | |
52200d03 | 249 | |
c2f8a09e | 250 | /* Compare properties of symbol that does not affect semantics of symbol |
251 | itself but affects semantics of its references. | |
252 | If ADDRESS is true, do extra checking needed for IPA_REF_ADDR. */ | |
253 | static bool compare_referenced_symbol_properties (symtab_node *used_by, | |
254 | symtab_node *n1, | |
255 | symtab_node *n2, | |
256 | bool address); | |
257 | ||
b08f05cd | 258 | /* Compare two attribute lists. */ |
259 | static bool compare_attributes (const_tree list1, const_tree list2); | |
260 | ||
c2f8a09e | 261 | /* Hash properties compared by compare_referenced_symbol_properties. */ |
262 | void hash_referenced_symbol_properties (symtab_node *ref, | |
263 | inchash::hash &hstate, | |
264 | bool address); | |
265 | ||
2aaa1027 | 266 | /* For a given symbol table nodes N1 and N2, we check that FUNCTION_DECLs |
267 | point to a same function. Comparison can be skipped if IGNORED_NODES | |
268 | contains these nodes. ADDRESS indicate if address is taken. */ | |
c2f8a09e | 269 | bool compare_symbol_references (hash_map <symtab_node *, sem_item *> |
2aaa1027 | 270 | &ignored_nodes, |
271 | symtab_node *n1, symtab_node *n2, | |
272 | bool address); | |
273 | ||
52200d03 | 274 | private: |
275 | /* Initialize internal data structures. Bitmap STACK is used for | |
276 | bitmap memory allocation process. */ | |
277 | void setup (bitmap_obstack *stack); | |
278 | }; // class sem_item | |
279 | ||
280 | class sem_function: public sem_item | |
281 | { | |
282 | public: | |
283 | /* Semantic function constructor that uses STACK as bitmap memory stack. */ | |
284 | sem_function (bitmap_obstack *stack); | |
285 | ||
286 | /* Constructor based on callgraph node _NODE with computed hash _HASH. | |
287 | Bitmap STACK is used for memory allocation. */ | |
288 | sem_function (cgraph_node *_node, hashval_t _hash, bitmap_obstack *stack); | |
289 | ||
290 | ~sem_function (); | |
291 | ||
292 | inline virtual void init_wpa (void) | |
293 | { | |
52200d03 | 294 | } |
295 | ||
296 | virtual void init (void); | |
297 | virtual bool equals_wpa (sem_item *item, | |
298 | hash_map <symtab_node *, sem_item *> &ignored_nodes); | |
299 | virtual hashval_t get_hash (void); | |
300 | virtual bool equals (sem_item *item, | |
301 | hash_map <symtab_node *, sem_item *> &ignored_nodes); | |
302 | virtual bool merge (sem_item *alias_item); | |
303 | ||
304 | /* Dump symbol to FILE. */ | |
305 | virtual void dump_to_file (FILE *file) | |
306 | { | |
307 | gcc_assert (file); | |
308 | dump_function_to_file (decl, file, TDF_DETAILS); | |
309 | } | |
310 | ||
52200d03 | 311 | /* Returns cgraph_node. */ |
312 | inline cgraph_node *get_node (void) | |
313 | { | |
314 | return dyn_cast <cgraph_node *> (node); | |
315 | } | |
316 | ||
317 | /* Improve accumulated hash for HSTATE based on a gimple statement STMT. */ | |
42acab1c | 318 | void hash_stmt (gimple *stmt, inchash::hash &inchash); |
52200d03 | 319 | |
320 | /* Return true if polymorphic comparison must be processed. */ | |
321 | bool compare_polymorphic_p (void); | |
322 | ||
323 | /* For a given call graph NODE, the function constructs new | |
324 | semantic function item. */ | |
325 | static sem_function *parse (cgraph_node *node, bitmap_obstack *stack); | |
326 | ||
3dafd1b4 | 327 | /* Perform additional checks needed to match types of used function |
328 | paramters. */ | |
329 | bool compatible_parm_types_p (tree, tree); | |
330 | ||
52200d03 | 331 | /* Exception handling region tree. */ |
332 | eh_region region_tree; | |
333 | ||
52200d03 | 334 | /* Number of function arguments. */ |
335 | unsigned int arg_count; | |
336 | ||
337 | /* Total amount of edges in the function. */ | |
338 | unsigned int edge_count; | |
339 | ||
340 | /* Vector of sizes of all basic blocks. */ | |
341 | vec <unsigned int> bb_sizes; | |
342 | ||
343 | /* Control flow graph checksum. */ | |
344 | hashval_t cfg_checksum; | |
345 | ||
346 | /* GIMPLE codes hash value. */ | |
347 | hashval_t gcode_hash; | |
348 | ||
349 | /* Total number of SSA names used in the function. */ | |
350 | unsigned ssa_names_size; | |
351 | ||
352 | /* Array of structures for all basic blocks. */ | |
353 | vec <ipa_icf_gimple::sem_bb *> bb_sorted; | |
b08f05cd | 354 | |
355 | /* Return true if parameter I may be used. */ | |
356 | bool param_used_p (unsigned int i); | |
52200d03 | 357 | |
358 | private: | |
359 | /* Calculates hash value based on a BASIC_BLOCK. */ | |
360 | hashval_t get_bb_hash (const ipa_icf_gimple::sem_bb *basic_block); | |
361 | ||
362 | /* For given basic blocks BB1 and BB2 (from functions FUNC1 and FUNC), | |
363 | true value is returned if phi nodes are semantically | |
364 | equivalent in these blocks . */ | |
365 | bool compare_phi_node (basic_block bb1, basic_block bb2); | |
366 | ||
367 | /* Basic blocks dictionary BB_DICT returns true if SOURCE index BB | |
368 | corresponds to TARGET. */ | |
8ed0255a | 369 | bool bb_dict_test (vec<int> *bb_dict, int source, int target); |
52200d03 | 370 | |
52200d03 | 371 | /* If cgraph edges E1 and E2 are indirect calls, verify that |
372 | ICF flags are the same. */ | |
373 | bool compare_edge_flags (cgraph_edge *e1, cgraph_edge *e2); | |
374 | ||
52200d03 | 375 | /* Processes function equality comparison. */ |
b3b9039b | 376 | bool equals_private (sem_item *item); |
52200d03 | 377 | |
378 | /* Returns true if tree T can be compared as a handled component. */ | |
379 | static bool icf_handled_component_p (tree t); | |
380 | ||
381 | /* Function checker stores binding between functions. */ | |
382 | ipa_icf_gimple::func_checker *m_checker; | |
383 | ||
384 | /* COMPARED_FUNC is a function that we compare to. */ | |
385 | sem_function *m_compared_func; | |
386 | }; // class sem_function | |
387 | ||
388 | class sem_variable: public sem_item | |
389 | { | |
390 | public: | |
391 | /* Semantic variable constructor that uses STACK as bitmap memory stack. */ | |
392 | sem_variable (bitmap_obstack *stack); | |
393 | ||
394 | /* Constructor based on callgraph node _NODE with computed hash _HASH. | |
395 | Bitmap STACK is used for memory allocation. */ | |
396 | ||
397 | sem_variable (varpool_node *_node, hashval_t _hash, bitmap_obstack *stack); | |
398 | ||
399 | inline virtual void init_wpa (void) {} | |
400 | ||
401 | /* Semantic variable initialization function. */ | |
402 | inline virtual void init (void) | |
403 | { | |
404 | decl = get_node ()->decl; | |
52200d03 | 405 | } |
406 | ||
407 | virtual hashval_t get_hash (void); | |
408 | virtual bool merge (sem_item *alias_item); | |
409 | virtual void dump_to_file (FILE *file); | |
410 | virtual bool equals (sem_item *item, | |
411 | hash_map <symtab_node *, sem_item *> &ignored_nodes); | |
412 | ||
413 | /* Fast equality variable based on knowledge known in WPA. */ | |
2aaa1027 | 414 | virtual bool equals_wpa (sem_item *item, |
415 | hash_map <symtab_node *, sem_item *> &ignored_nodes); | |
52200d03 | 416 | |
417 | /* Returns varpool_node. */ | |
418 | inline varpool_node *get_node (void) | |
419 | { | |
420 | return dyn_cast <varpool_node *> (node); | |
421 | } | |
422 | ||
423 | /* Parser function that visits a varpool NODE. */ | |
424 | static sem_variable *parse (varpool_node *node, bitmap_obstack *stack); | |
425 | ||
52200d03 | 426 | private: |
52200d03 | 427 | /* Compares trees T1 and T2 for semantic equality. */ |
428 | static bool equals (tree t1, tree t2); | |
52200d03 | 429 | }; // class sem_variable |
430 | ||
431 | class sem_item_optimizer; | |
432 | ||
433 | struct congruence_class_group | |
434 | { | |
435 | hashval_t hash; | |
436 | sem_item_type type; | |
437 | vec <congruence_class *> classes; | |
438 | }; | |
439 | ||
440 | /* Congruence class set structure. */ | |
770ff93b | 441 | struct congruence_class_group_hash : nofree_ptr_hash <congruence_class_group> |
52200d03 | 442 | { |
9969c043 | 443 | static inline hashval_t hash (const congruence_class_group *item) |
52200d03 | 444 | { |
445 | return item->hash; | |
446 | } | |
447 | ||
9969c043 | 448 | static inline int equal (const congruence_class_group *item1, |
449 | const congruence_class_group *item2) | |
52200d03 | 450 | { |
451 | return item1->hash == item2->hash && item1->type == item2->type; | |
452 | } | |
453 | }; | |
454 | ||
455 | struct traverse_split_pair | |
456 | { | |
457 | sem_item_optimizer *optimizer; | |
458 | class congruence_class *cls; | |
459 | }; | |
460 | ||
461 | /* Semantic item optimizer includes all top-level logic | |
462 | related to semantic equality comparison. */ | |
463 | class sem_item_optimizer | |
464 | { | |
465 | public: | |
466 | sem_item_optimizer (); | |
467 | ~sem_item_optimizer (); | |
468 | ||
469 | /* Function responsible for visiting all potential functions and | |
470 | read-only variables that can be merged. */ | |
471 | void parse_funcs_and_vars (void); | |
472 | ||
796859e5 | 473 | /* Optimizer entry point which returns true in case it processes |
474 | a merge operation. True is returned if there's a merge operation | |
475 | processed. */ | |
476 | bool execute (void); | |
52200d03 | 477 | |
478 | /* Dump function. */ | |
479 | void dump (void); | |
480 | ||
481 | /* Verify congruence classes if checking is enabled. */ | |
382ecba7 | 482 | void checking_verify_classes (void); |
483 | ||
484 | /* Verify congruence classes. */ | |
52200d03 | 485 | void verify_classes (void); |
486 | ||
487 | /* Write IPA ICF summary for symbols. */ | |
488 | void write_summary (void); | |
489 | ||
47ae02b7 | 490 | /* Read IPA ICF summary for symbols. */ |
52200d03 | 491 | void read_summary (void); |
492 | ||
493 | /* Callgraph removal hook called for a NODE with a custom DATA. */ | |
494 | static void cgraph_removal_hook (cgraph_node *node, void *data); | |
495 | ||
496 | /* Varpool removal hook called for a NODE with a custom DATA. */ | |
497 | static void varpool_removal_hook (varpool_node *node, void *data); | |
498 | ||
499 | /* Worklist of congruence classes that can potentially | |
500 | refine classes of congruence. */ | |
501 | std::list<congruence_class *> worklist; | |
502 | ||
503 | /* Remove semantic ITEM and release memory. */ | |
504 | void remove_item (sem_item *item); | |
505 | ||
506 | /* Remove symtab NODE triggered by symtab removal hooks. */ | |
507 | void remove_symtab_node (symtab_node *node); | |
508 | ||
509 | /* Register callgraph and varpool hooks. */ | |
510 | void register_hooks (void); | |
511 | ||
512 | /* Unregister callgraph and varpool hooks. */ | |
513 | void unregister_hooks (void); | |
514 | ||
515 | /* Adds a CLS to hashtable associated by hash value. */ | |
516 | void add_class (congruence_class *cls); | |
517 | ||
518 | /* Gets a congruence class group based on given HASH value and TYPE. */ | |
519 | congruence_class_group *get_group_by_hash (hashval_t hash, | |
520 | sem_item_type type); | |
521 | ||
4a34b76a | 522 | /* Because types can be arbitrarily large, avoid quadratic bottleneck. */ |
523 | hash_map<const_tree, hashval_t> m_type_hash_cache; | |
52200d03 | 524 | private: |
525 | ||
4765f5e5 | 526 | /* For each semantic item, append hash values of references. */ |
527 | void update_hash_by_addr_refs (); | |
528 | ||
52200d03 | 529 | /* Congruence classes are built by hash value. */ |
530 | void build_hash_based_classes (void); | |
531 | ||
532 | /* Semantic items in classes having more than one element and initialized. | |
533 | In case of WPA, we load function body. */ | |
534 | void parse_nonsingleton_classes (void); | |
535 | ||
536 | /* Equality function for semantic items is used to subdivide existing | |
537 | classes. If IN_WPA, fast equality function is invoked. */ | |
538 | void subdivide_classes_by_equality (bool in_wpa = false); | |
539 | ||
0e62482d | 540 | /* Subdivide classes by address and interposable references |
541 | that members of the class reference. | |
542 | Example can be a pair of functions that have an address | |
543 | taken from a function. If these addresses are different the class | |
544 | is split. */ | |
545 | unsigned subdivide_classes_by_sensitive_refs(); | |
546 | ||
52200d03 | 547 | /* Debug function prints all informations about congruence classes. */ |
548 | void dump_cong_classes (void); | |
549 | ||
550 | /* Build references according to call graph. */ | |
551 | void build_graph (void); | |
552 | ||
553 | /* Iterative congruence reduction function. */ | |
554 | void process_cong_reduction (void); | |
555 | ||
556 | /* After reduction is done, we can declare all items in a group | |
557 | to be equal. PREV_CLASS_COUNT is start number of classes | |
796859e5 | 558 | before reduction. True is returned if there's a merge operation |
559 | processed. */ | |
560 | bool merge_classes (unsigned int prev_class_count); | |
52200d03 | 561 | |
562 | /* Adds a newly created congruence class CLS to worklist. */ | |
563 | void worklist_push (congruence_class *cls); | |
564 | ||
565 | /* Pops a class from worklist. */ | |
566 | congruence_class *worklist_pop (); | |
567 | ||
568 | /* Every usage of a congruence class CLS is a candidate that can split the | |
569 | collection of classes. Bitmap stack BMSTACK is used for bitmap | |
570 | allocation. */ | |
571 | void do_congruence_step (congruence_class *cls); | |
572 | ||
573 | /* Tests if a class CLS used as INDEXth splits any congruence classes. | |
574 | Bitmap stack BMSTACK is used for bitmap allocation. */ | |
575 | void do_congruence_step_for_index (congruence_class *cls, unsigned int index); | |
576 | ||
577 | /* Makes pairing between a congruence class CLS and semantic ITEM. */ | |
578 | static void add_item_to_class (congruence_class *cls, sem_item *item); | |
579 | ||
580 | /* Disposes split map traverse function. CLS is congruence | |
581 | class, BSLOT is bitmap slot we want to release. DATA is mandatory, | |
582 | but unused argument. */ | |
583 | static bool release_split_map (congruence_class * const &cls, bitmap const &b, | |
584 | traverse_split_pair *pair); | |
585 | ||
586 | /* Process split operation for a cognruence class CLS, | |
587 | where bitmap B splits congruence class members. DATA is used | |
588 | as argument of split pair. */ | |
589 | static bool traverse_congruence_split (congruence_class * const &cls, | |
590 | bitmap const &b, | |
591 | traverse_split_pair *pair); | |
592 | ||
593 | /* Reads a section from LTO stream file FILE_DATA. Input block for DATA | |
594 | contains LEN bytes. */ | |
595 | void read_section (lto_file_decl_data *file_data, const char *data, | |
596 | size_t len); | |
597 | ||
598 | /* Removes all callgraph and varpool nodes that are marked by symtab | |
599 | as deleted. */ | |
600 | void filter_removed_items (void); | |
601 | ||
602 | /* Vector of semantic items. */ | |
603 | vec <sem_item *> m_items; | |
604 | ||
605 | /* A set containing all items removed by hooks. */ | |
606 | hash_set <symtab_node *> m_removed_items_set; | |
607 | ||
608 | /* Hashtable of congruence classes */ | |
609 | hash_table <congruence_class_group_hash> m_classes; | |
610 | ||
611 | /* Count of congruence classes. */ | |
612 | unsigned int m_classes_count; | |
613 | ||
614 | /* Map data structure maps symtab nodes to semantic items. */ | |
615 | hash_map <symtab_node *, sem_item *> m_symtab_node_map; | |
616 | ||
617 | /* Set to true if a splitter class is removed. */ | |
618 | bool splitter_class_removed; | |
619 | ||
620 | /* Global unique class id counter. */ | |
621 | static unsigned int class_id; | |
622 | ||
623 | /* Callgraph node removal hook holder. */ | |
624 | cgraph_node_hook_list *m_cgraph_node_hooks; | |
625 | ||
626 | /* Varpool node removal hook holder. */ | |
627 | varpool_node_hook_list *m_varpool_node_hooks; | |
628 | ||
629 | /* Bitmap stack. */ | |
630 | bitmap_obstack m_bmstack; | |
631 | }; // class sem_item_optimizer | |
632 | ||
633 | } // ipa_icf namespace |