GCC Middle and Back End API Reference
cgraph.h
Go to the documentation of this file.
1/* Callgraph handling code.
2 Copyright (C) 2003-2026 Free Software Foundation, Inc.
3 Contributed by Jan Hubicka
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
9Software Foundation; either version 3, or (at your option) any later
10version.
11
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
20
21#ifndef GCC_CGRAPH_H
22#define GCC_CGRAPH_H
23
24#include "profile-count.h"
25#include "ipa-ref.h"
26#include "plugin-api.h"
28
29extern void debuginfo_early_init (void);
30extern void debuginfo_init (void);
31extern void debuginfo_fini (void);
32extern void debuginfo_start (void);
33extern void debuginfo_stop (void);
34extern void debuginfo_early_start (void);
35extern void debuginfo_early_stop (void);
36
37class ipa_opt_pass_d;
39
40/* Toplevel consists of functions, variables and assembly.
41 Make sure toplevel_type_names in symtab.cc is kept in sync
42 with this.
43 TODO: add labels and CONST_DECLs. */
53
54/* Section names are stored as reference counted strings in GGC safe hashtable
55 (to make them survive through PCH). */
56
57struct GTY((for_user)) section_hash_entry
58{
60 char *name; /* As long as this datastructure stays in GGC, we cannot put
61 string at the tail of structure of GGC dies in horrible
62 way */
63};
64
65struct section_name_hasher : ggc_ptr_hash<section_hash_entry>
66{
67 typedef const char *compare_type;
68
69 static hashval_t hash (section_hash_entry *);
70 static bool equal (section_hash_entry *, const char *);
71};
72
74{
75 /* Not yet set by cgraph_function_body_availability. */
77 /* Function body/variable initializer is unknown. */
79 /* Function body/variable initializer is known but might be replaced
80 by a different one from other compilation unit and thus needs to
81 be dealt with a care. Like AVAIL_NOT_AVAILABLE it can have
82 arbitrary side effects on escaping variables and functions, while
83 like AVAILABLE it might access static variables. */
85 /* Function body/variable initializer is known and will be used in final
86 program. */
88 /* Function body/variable initializer is known and all it's uses are
89 explicitly visible within current unit (i.e. it's address is never taken
90 and it is not exported to other units). Currently used only for
91 functions. */
93};
94
95/* Classification of symbols WRT partitioning. */
97{
98 /* External declarations are ignored by partitioning algorithms and they are
99 added into the boundary later via compute_ltrans_boundary. */
101 /* Partitioned symbols are put into one of partitions. */
103 /* Duplicated symbols (such as comdat or constant pool references) are
104 copied into every node needing them via add_symbol_to_partition. */
106};
107
108/* Base of all toplevel entries.
109 Inherited by symtab_node and asm_node. */
110struct GTY ((desc ("%h.type"), tag ("TOPLEVEL_BASE"),
111 chain_next("%h.next"),
112 chain_prev("%h.previous"))) toplevel_node {
113 /* Constructor. */
114 explicit toplevel_node (toplevel_type t)
115 : lto_file_data (NULL), order (-1), type (t)
116 {}
118 /* File stream where this node is being written to. */
121 /* Linked list of toplevel entries. */
122 toplevel_node *next = nullptr;
123 toplevel_node *previous = nullptr;
125 /* Ordering of all cgraph nodes. */
126 int order;
128 /* Type of the node. */
129 ENUM_BITFIELD (toplevel_type) type : 8;
130};
131
132/* Base of all entries in the symbol table.
133 The symtab_node is inherited by cgraph and varpol nodes. */
134struct GTY ((tag ("SYMTAB_SYMBOL")))
136{
137public:
159 {}
160
161 /* Return name. */
162 const char *name () const;
163
164 /* Return dump name. */
165 const char *dump_name () const;
166
167 /* Return asm name. */
168 const char *asm_name () const;
169
170 /* Return dump name with assembler name. */
171 const char *dump_asm_name () const;
172
173 /* Return visibility name. */
174 const char *get_visibility_string () const;
175
176 /* Return type_name name. */
177 const char *get_symtab_type_string () const;
178
179 /* Add node into symbol table. This function is not used directly, but via
180 cgraph/varpool node creation routines. */
181 void register_symbol (void);
182
183 /* Remove symbol from symbol table. */
184 void remove (void);
185
186 /* Undo any definition or use of the symbol. */
187 void reset (bool preserve_comdat_group = false);
188
189 /* Dump symtab node to F. */
190 void dump (FILE *f);
191
192 /* Dump symtab callgraph in graphviz format. */
193 void dump_graphviz (FILE *f);
194
195 /* Dump symtab node to stderr. */
196 void DEBUG_FUNCTION debug (void);
197
198 /* Verify consistency of node. */
199 void DEBUG_FUNCTION verify (void);
200
201 /* Return ipa reference from this symtab_node to
202 REFERRED_NODE or REFERRED_VARPOOL_NODE. USE_TYPE specify type
203 of the use and STMT the statement (if it exists). */
204 ipa_ref *create_reference (symtab_node *referred_node,
205 enum ipa_ref_use use_type);
206
207 /* Return ipa reference from this symtab_node to
208 REFERRED_NODE or REFERRED_VARPOOL_NODE. USE_TYPE specify type
209 of the use and STMT the statement (if it exists). */
210 ipa_ref *create_reference (symtab_node *referred_node,
211 enum ipa_ref_use use_type, gimple *stmt);
212
213 /* If VAL is a reference to a function or a variable, add a reference from
214 this symtab_node to the corresponding symbol table node. Return the new
215 reference or NULL if none was created. */
216 ipa_ref *maybe_create_reference (tree val, gimple *stmt);
217
218 /* Clone all references from symtab NODE to this symtab_node. */
219 void clone_references (symtab_node *node);
220
221 /* Remove all stmt references in non-speculative references.
222 Those are not maintained during inlining & clonning.
223 The exception are speculative references that are updated along
224 with callgraph edges associated with them. */
225 void clone_referring (symtab_node *node);
226
227 /* Clone reference REF to this symtab_node and set its stmt to STMT. */
228 ipa_ref *clone_reference (ipa_ref *ref, gimple *stmt);
229
230 /* Find the structure describing a reference to REFERRED_NODE of USE_TYPE and
231 associated with statement STMT or LTO_STMT_UID. */
232 ipa_ref *find_reference (symtab_node *referred_node, gimple *stmt,
233 unsigned int lto_stmt_uid,
234 enum ipa_ref_use use_type);
235
236 /* Remove all references that are associated with statement STMT. */
237 void remove_stmt_references (gimple *stmt);
238
239 /* Remove all stmt references in non-speculative references.
240 Those are not maintained during inlining & clonning.
241 The exception are speculative references that are updated along
242 with callgraph edges associated with them. */
243 void clear_stmts_in_references (void);
244
245 /* Remove all references in ref list. */
246 void remove_all_references (void);
247
248 /* Remove all referring items in ref list. */
249 void remove_all_referring (void);
250
251 /* Dump references in ref list to FILE. */
252 void dump_references (FILE *file);
253
254 /* Dump referring in list to FILE. */
255 void dump_referring (FILE *);
256
257 /* Get number of references for this node. */
258 inline unsigned num_references (void)
259 {
260 return ref_list.references.length ();
261 }
262
263 /* Iterates I-th reference in the list, REF is also set. */
264 ipa_ref *iterate_reference (unsigned i, ipa_ref *&ref);
265
266 /* Iterates I-th referring item in the list, REF is also set. */
267 ipa_ref *iterate_referring (unsigned i, ipa_ref *&ref);
268
269 /* Iterates I-th referring alias item in the list, REF is also set. */
270 ipa_ref *iterate_direct_aliases (unsigned i, ipa_ref *&ref);
271
272 /* Return true if symtab node and TARGET represents
273 semantically equivalent symbols. */
274 bool semantically_equivalent_p (symtab_node *target);
275
276 /* Classify symbol symtab node for partitioning. */
278
279 /* Return comdat group. */
281 {
282 return x_comdat_group;
284
285 /* Return comdat group as identifier_node. */
286 tree get_comdat_group_id ()
287 {
288 if (x_comdat_group && TREE_CODE (x_comdat_group) != IDENTIFIER_NODE)
289 x_comdat_group = DECL_ASSEMBLER_NAME (x_comdat_group);
290 return x_comdat_group;
292
293 /* Set comdat group. */
294 void set_comdat_group (tree group)
295 {
296 gcc_checking_assert (!group || TREE_CODE (group) == IDENTIFIER_NODE
297 || DECL_P (group));
298 x_comdat_group = group;
300
301 /* Return section as string. */
302 const char * get_section () const
303 {
304 if (!x_section)
305 return NULL;
306 return x_section->name;
307 }
308
309 /* Remove node from same comdat group. */
310 void remove_from_same_comdat_group (void);
311
312 /* Add this symtab_node to the same comdat group that OLD is in. */
313 void add_to_same_comdat_group (symtab_node *old_node);
314
315 /* Dissolve the same_comdat_group list in which NODE resides. */
316 void dissolve_same_comdat_group_list (void);
317
318 /* Return true when symtab_node is known to be used from other (non-LTO)
319 object file. Known only when doing LTO via linker plugin. */
320 bool used_from_object_file_p (void);
321
322 /* Walk the alias chain to return the symbol NODE is alias of.
323 If NODE is not an alias, return NODE.
324 When AVAILABILITY is non-NULL, get minimal availability in the chain.
325 When REF is non-NULL, assume that reference happens in symbol REF
326 when determining the availability. */
327 symtab_node *ultimate_alias_target (enum availability *avail = NULL,
328 struct symtab_node *ref = NULL);
329
330 /* Return next reachable static symbol with initializer after NODE. */
331 inline symtab_node *next_defined_symbol (void);
332
333 /* Add reference recording that symtab node is alias of TARGET.
334 If TRANSPARENT is true make the alias to be transparent alias.
335 The function can fail in the case of aliasing cycles; in this case
336 it returns false. */
337 bool resolve_alias (symtab_node *target, bool transparent = false);
338
339 /* C++ FE sometimes change linkage flags after producing same
340 body aliases. */
341 void fixup_same_cpp_alias_visibility (symtab_node *target);
342
343 /* Call callback on symtab node and aliases associated to this node.
344 When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are
345 skipped. */
346 bool call_for_symbol_and_aliases (bool (*callback) (symtab_node *, void *),
347 void *data,
348 bool include_overwrite);
349
350 /* If node cannot be interposable by static or dynamic linker to point to
351 different definition, return this symbol. Otherwise look for alias with
352 such property and if none exists, introduce new one. */
353 symtab_node *noninterposable_alias (void);
354
355 /* Return node that alias is aliasing. */
356 inline symtab_node *get_alias_target (void);
357
358 /* Return DECL that alias is aliasing. */
359 inline tree get_alias_target_tree ();
360
361 /* Set section for symbol and its aliases. */
362 void set_section (const char *section);
363
364 /* Like set_section, but copying the section name from another node. */
365 void set_section (const symtab_node &other);
366
367 /* Set section, do not recurse into aliases.
368 When one wants to change section of symbol and its aliases,
369 use set_section. */
370 void set_section_for_node (const char *section);
371
372 /* Like set_section_for_node, but copying the section name from another
373 node. */
374 void set_section_for_node (const symtab_node &other);
375
376 /* Set initialization priority to PRIORITY. */
377 void set_init_priority (priority_type priority);
378
379 /* Return the initialization priority. */
380 priority_type get_init_priority ();
381
382 /* Return availability of NODE when referenced from REF. */
383 enum availability get_availability (symtab_node *ref = NULL);
384
385 /* During LTO stream-in this predicate can be used to check whether node
386 in question prevails in the linking to save some memory usage. */
387 bool prevailing_p (void);
388
389 /* Return true if NODE binds to current definition in final executable
390 when referenced from REF. If REF is NULL return conservative value
391 for any reference. */
392 bool binds_to_current_def_p (symtab_node *ref = NULL);
393
394 /* Make DECL local. */
395 void make_decl_local (void);
396
397 /* Copy visibility from N. */
398 void copy_visibility_from (symtab_node *n);
399
400 /* Return desired alignment of the definition. This is NOT alignment useful
401 to access THIS, because THIS may be interposable and DECL_ALIGN should
402 be used instead. It however must be guaranteed when output definition
403 of THIS. */
404 unsigned int definition_alignment ();
405
406 /* Return true if alignment can be increased. */
407 bool can_increase_alignment_p ();
408
409 /* Increase alignment of symbol to ALIGN. */
410 void increase_alignment (unsigned int align);
411
412 /* Return true if list contains an alias. */
413 bool has_aliases_p (void);
414
415 /* Return true when the symbol is real symbol, i.e. it is not inline clone
416 or abstract function kept for debug info purposes only. */
417 bool real_symbol_p (void);
418
419 /* Return true when the symbol needs to be output to the LTO symbol table. */
420 bool output_to_lto_symbol_table_p (void);
421
422 /* Determine if symbol declaration is needed. That is, visible to something
423 either outside this translation unit, something magic in the system
424 configury. This function is used just during symbol creation. */
425 bool needed_p (void);
426
427 /* Return true if this symbol is a function from the C frontend specified
428 directly in RTL form (with "__RTL"). */
429 bool native_rtl_p () const;
430
431 /* Return true when there are references to the node. */
432 bool referred_to_p (bool include_self = true);
433
434 /* Return true if symbol can be discarded by linker from the binary.
435 Assume that symbol is used (so there is no need to take into account
436 garbage collecting linkers)
437
438 This can happen for comdats, commons and weaks when they are prevailed
439 by other definition at static linking time. */
440 inline bool
441 can_be_discarded_p (void)
442 {
443 return ((DECL_EXTERNAL (decl)
445 || ((get_comdat_group ()
446 || DECL_COMMON (decl)
448 && ((resolution != LDPR_PREVAILING_DEF
449 && resolution != LDPR_PREVAILING_DEF_IRONLY_EXP)
450 || flag_incremental_link)
451 && resolution != LDPR_PREVAILING_DEF_IRONLY));
452 }
453
454 /* Return true if NODE is local to a particular COMDAT group, and must not
455 be named from outside the COMDAT. This is used for C++ decloned
456 constructors. */
457 inline bool comdat_local_p (void)
458 {
459 return (same_comdat_group && !TREE_PUBLIC (decl));
460 }
461
462 /* Return true if ONE and TWO are part of the same COMDAT group. */
463 inline bool in_same_comdat_group_p (symtab_node *target);
464
465 /* Return true if symbol is known to be nonzero, assume that
466 flag_delete_null_pointer_checks is equal to delete_null_pointer_checks. */
467 bool nonzero_address (bool delete_null_pointer_checks);
468
469 /* Return true if symbol is known to be nonzero. */
470 bool nonzero_address ();
471
472 /* Return 0 if symbol is known to have different address than S2,
473 Return 1 if symbol is known to have same address as S2,
474 return 2 otherwise.
475
476 If MEMORY_ACCESSED is true, assume that both memory pointer to THIS
477 and S2 is going to be accessed. This eliminates the situations when
478 either THIS or S2 is NULL and is useful for comparing bases when deciding
479 about memory aliasing. */
480 int equal_address_to (symtab_node *s2, bool memory_accessed = false);
481
482 /* Return true if symbol's address may possibly be compared to other
483 symbol's address. */
484 bool address_matters_p ();
485
486 /* Return true if NODE's address can be compared. This use properties
487 of NODE only and does not look if the address is actually taken in
488 interesting way. For that use ADDRESS_MATTERS_P instead. */
489 bool address_can_be_compared_p (void);
491 /* Return symbol table node associated with DECL, if any,
492 and NULL otherwise. */
493 static inline symtab_node *get (const_tree decl)
494 {
495 /* Check that we are called for sane type of object - functions
496 and static or external variables. */
497 gcc_checking_assert (TREE_CODE (decl) == FUNCTION_DECL
498 || (TREE_CODE (decl) == VAR_DECL
500 || in_lto_p)));
501 /* Check that the mapping is sane - perhaps this check can go away,
502 but at the moment frontends tends to corrupt the mapping by calling
503 memcpy/memset on the tree nodes. */
504 gcc_checking_assert (!decl->decl_with_vis.symtab_node
505 || decl->decl_with_vis.symtab_node->decl == decl);
506 return decl->decl_with_vis.symtab_node;
507 }
508
509 /* Try to find a symtab node for declaration DECL and if it does not
510 exist or if it corresponds to an inline clone, create a new one. */
511 static inline symtab_node * get_create (tree node);
512
513 /* Return the cgraph node that has ASMNAME for its DECL_ASSEMBLER_NAME.
514 Return NULL if there's no such node. */
515 static symtab_node *get_for_asmname (const_tree asmname);
516
517 /* Check symbol table for callees of IFUNC resolvers. */
518 static void check_ifunc_callee_symtab_nodes (void);
519
520 /* Verify symbol table for internal consistency. */
521 static DEBUG_FUNCTION void verify_symtab_nodes (void);
522
523 /* Perform internal consistency checks, if they are enabled. */
524 static inline void checking_verify_symtab_nodes (void);
525
526 /* Get unique identifier of the node. */
527 inline int get_uid () const
528 {
529 return m_uid;
531
532 /* The symbols resolution. */
533 ENUM_BITFIELD (ld_plugin_symbol_resolution) resolution : 8;
534
535 /*** Flags representing the symbol type. ***/
537 /* True when symbol corresponds to a definition in current unit.
538 set via finalize_function or finalize_decl */
539 unsigned definition : 1;
540 /* True when symbol is an alias.
541 Set by assemble_alias. */
542 unsigned alias : 1;
543 /* When true the alias is translated into its target symbol either by GCC
544 or assembler (it also may just be a duplicate declaration of the same
545 linker name).
546
547 Currently transparent aliases come in three different flavors
548 - aliases having the same assembler name as their target (aka duplicated
549 declarations). In this case the assembler names compare via
550 assembler_names_equal_p and weakref is false
551 - aliases that are renamed at a time being output to final file
552 by varasm.cc. For those DECL_ASSEMBLER_NAME have
553 IDENTIFIER_TRANSPARENT_ALIAS set and thus also their assembler
554 name must be unique.
555 Weakrefs belong to this category when we target assembler without
556 .weakref directive.
557 - weakrefs that are renamed by assembler via .weakref directive.
558 In this case the alias may or may not be definition (depending if
559 target declaration was seen by the compiler), weakref is set.
560 Unless we are before renaming statics, assembler names are different.
562 Given that we now support duplicate declarations, the second option is
563 redundant and will be removed. */
564 unsigned transparent_alias : 1;
565 /* True when alias is a weakref. */
566 unsigned weakref : 1;
567 /* C++ frontend produce same body aliases and extra name aliases for
568 virtual functions and vtables that are obviously equivalent.
569 Those aliases are bit special, especially because C++ frontend
570 visibility code is so ugly it cannot get them right at first time
571 and their visibility needs to be copied from their "masters" at
572 the end of parsing. */
573 unsigned cpp_implicit_alias : 1;
574 /* The alias is a symbol version. */
575 unsigned symver : 1;
576 /* Set once the definition was analyzed. The list of references and
577 other properties are built during analysis. */
578 unsigned analyzed : 1;
579 /* Set for write-only variables. */
580 unsigned writeonly : 1;
581 /* Visibility of symbol was used for further optimization; do not
582 permit further changes. */
583 unsigned refuse_visibility_changes : 1;
584
585 /*** Visibility and linkage flags. ***/
586
587 /* Set when function is visible by other units. */
588 unsigned externally_visible : 1;
589 /* Don't reorder to other symbols having this set. */
590 unsigned no_reorder : 1;
591 /* The symbol will be assumed to be used in an invisible way (like
592 by an toplevel asm statement). */
593 unsigned force_output : 1;
594 /* Like FORCE_OUTPUT, but in the case it is ABI requiring the symbol to be
595 exported. Unlike FORCE_OUTPUT this flag gets cleared to symbols promoted
596 to static and it does not inhibit optimization. */
597 unsigned forced_by_abi : 1;
598 /* Referenced from toplevel assembly. Must not be removed.
599 Static symbol may be renamed. Global symbol should not be renamed.
600 Unlike force_output, can be on declarations. */
601 unsigned ref_by_asm : 1;
602 /* Set when asm_name must remain in TU partition.
603 Used to guarantee not renaming of static ref_by_asm symbols. */
605 /* Set when body (or any references) must remain in TU partition.
606 Used on symbols referring/calling must_remain_in_tu_name. */
607 unsigned must_remain_in_tu_body : 1;
608 /* True when the name is known to be unique and thus it does not need mangling. */
609 unsigned unique_name : 1;
610 /* Specify whether the section was set by user or by
611 compiler via -ffunction-sections. */
612 unsigned implicit_section : 1;
613 /* True when body and other characteristics have been removed by
614 symtab_remove_unreachable_nodes. */
615 unsigned body_removed : 1;
616 /* True when symbol should comply to -fsemantic-interposition flag. */
617 unsigned semantic_interposition : 1;
618
619 /*** WHOPR Partitioning flags.
620 These flags are used at ltrans stage when only part of the callgraph is
621 available. ***/
622
623 /* Set when variable is used from other LTRANS partition. */
624 unsigned used_from_other_partition : 1;
625 /* Set when function is available in the other LTRANS partition.
626 During WPA output it is used to mark nodes that are present in
627 multiple partitions. */
628 unsigned in_other_partition : 1;
629
630
631
632 /*** other flags. ***/
633
634 /* Set when symbol has address taken. */
635 unsigned address_taken : 1;
636 /* Set when init priority is set. */
637 unsigned in_init_priority_hash : 1;
639 /* Set when symbol needs to be streamed into LTO bytecode for LTO, or in case
640 of offloading, for separate compilation for a different target. */
641 unsigned need_lto_streaming : 1;
642
643 /* Set when symbol can be streamed into bytecode for offloading. */
644 unsigned offloadable : 1;
645
646 /* Set when symbol is an IFUNC resolver. */
647 unsigned ifunc_resolver : 1;
649
650 /* Declaration representing the symbol. */
651 tree decl;
652
653 /* Linked list of symbols with the same asm name. There may be multiple
654 entries for single symbol name during LTO, because symbols are renamed
655 only after partitioning.
656
657 Because inline clones are kept in the assembler name has, they also produce
658 duplicate entries.
660 There are also several long standing bugs where frontends and builtin
661 code produce duplicated decls. */
664
665 /* Circular list of nodes in the same comdat group if non-NULL. */
667
668 /* Vectors of referring and referenced entities. */
669 ipa_ref_list GTY((skip)) ref_list;
670
671 /* Alias target. May be either DECL pointer or ASSEMBLER_NAME pointer
672 depending to what was known to frontend on the creation time.
673 Once alias is resolved, this pointer become NULL. */
675
676 void *GTY ((skip)) aux;
677
678 /* Comdat group the symbol is in. Can be private if GGC allowed that. */
680
681 /* Section name. Again can be private, if allowed. */
683
684protected:
685 /* Dump base fields of symtab nodes to F. Not to be used directly. */
686 void dump_base (FILE *);
687
688 /* Verify common part of symtab node. */
689 bool DEBUG_FUNCTION verify_base (void);
690
691 /* Remove node from symbol table. This function is not used directly, but via
692 cgraph/varpool node removal routines. */
693 void unregister (struct clone_info *);
694
695 /* Return the initialization and finalization priority information for
696 DECL. If there is no previous priority information, a freshly
697 allocated structure is returned. */
698 struct symbol_priority_map *priority_info (void);
699
700 /* Worker for call_for_symbol_and_aliases_1. */
701 bool call_for_symbol_and_aliases_1 (bool (*callback) (symtab_node *, void *),
702 void *data,
703 bool include_overwrite);
704private:
705 /* Unique id of the node. */
706 int m_uid;
707
708 /* Workers for set_section. */
709 static bool set_section_from_string (symtab_node *n, void *s);
710 static bool set_section_from_node (symtab_node *n, void *o);
711
712 /* Worker for symtab_resolve_alias. */
713 static bool set_implicit_section (symtab_node *n, void *);
714
715 /* Worker searching noninterposable alias. */
716 static bool noninterposable_alias (symtab_node *node, void *data);
717
718 /* Worker for ultimate_alias_target. */
720 symtab_node *ref = NULL);
721
722 /* Get dump name with normal or assembly name. */
723 const char *get_dump_name (bool asm_name_p) const;
725
726inline void
728{
729 if (flag_checking)
732
733/* Walk all aliases for NODE. */
734#define FOR_EACH_ALIAS(NODE, ALIAS) \
735 for (unsigned ALIAS##_iter_ = 0; \
736 (NODE)->iterate_direct_aliases (ALIAS##_iter_, ALIAS); \
737 ALIAS##_iter_++)
738
739/* This is the information that is put into the cgraph local structure
740 to recover a function. */
741struct lto_file_decl_data;
742
743extern const char * const cgraph_availability_names[];
744extern const char * const ld_plugin_symbol_resolution_names[];
745extern const char * const tls_model_names[];
747/* Represent which DECL tree (or reference to such tree)
748 will be replaced by another tree while versioning. */
750{
751 /* The new (replacing) tree. */
753 /* Parameter number to replace, when old_tree is NULL. */
754 int parm_num;
755 /* Set if the newly added reference should not be an address one, but a load
756 one from the operand of the ADDR_EXPR in NEW_TREE. This is for cases when
757 the corresponding parameter p is used only as *p. */
777};
778
779/* Function arguments in the original function of a SIMD clone.
780 Supplementary data for `struct simd_clone'. */
781
783 /* Original function argument as it originally existed in
784 DECL_ARGUMENTS. */
787 /* orig_arg's function (or for extern functions type from
788 TYPE_ARG_TYPES). */
790
791 /* If argument is a vector, this holds the vector version of
792 orig_arg that after adjusting the argument types will live in
793 DECL_ARGUMENTS. Otherwise, this is NULL.
795 This basically holds:
796 vector(simdlen) __typeof__(orig_arg) new_arg. */
798
799 /* vector_arg's type (or for extern functions new vector type. */
801
802 /* If argument is a vector, this holds the array where the simd
803 argument is held while executing the simd clone function. This
804 is a local variable in the cloned function. Its content is
805 copied from vector_arg upon entry to the clone.
807 This basically holds:
808 __typeof__(orig_arg) simd_array[simdlen]. */
811 /* A SIMD clone's argument can be either linear (constant or
812 variable), uniform, or vector. */
814
815 /* Variable alignment if available, otherwise 0. */
816 unsigned int alignment;
817
818 /* For arg_type SIMD_CLONE_ARG_TYPE_LINEAR_*CONSTANT_STEP this is
819 the constant linear step, if arg_type is
820 SIMD_CLONE_ARG_TYPE_LINEAR_*VARIABLE_STEP, this is index of
821 the uniform argument holding the step, otherwise 0.
822 For arg_type SIMD_CLONE_ARG_TYPE_MASK and a mask_mode that is
823 not VOIDmode, this is the number of mask arguments. */
824 HOST_WIDE_INT linear_step;
825};
827/* Specific data for a SIMD function clone. */
829struct GTY(()) cgraph_simd_clone {
830 /* Number of words in the SIMD lane associated with this clone. */
833 /* Number of annotated function arguments in `args'. This is
834 usually the number of named arguments in FNDECL. */
835 unsigned int nargs;
836
837 /* Max hardware vector size in bits for integral vectors. */
839
840 /* Max hardware vector size in bits for floating point vectors. */
842
843 /* Machine mode of the mask argument(s), if they are to be passed
844 as bitmasks in integer argument(s). VOIDmode if masks are passed
845 as vectors of characteristic type. */
846 machine_mode mask_mode;
847
848 /* The mangling character for a given vector size. This is used
849 to determine the ISA mangling bit as specified in the Intel
850 Vector ABI. */
851 unsigned char vecsize_mangle;
853 /* True if this is the masked, in-branch version of the clone,
854 otherwise false. */
855 unsigned int inbranch : 1;
856
857 /* Doubly linked list of SIMD clones. */
859
860 /* Original cgraph node the SIMD clones were created for. */
862
863 /* Annotated function arguments for the original function. */
864 cgraph_simd_clone_arg GTY((length ("%h.nargs"))) args[1];
866
867/* Function Multiversioning info. */
868struct GTY((for_user)) cgraph_function_version_info {
869 /* The cgraph_node for which the function version info is stored. */
871 /* Chains all the semantically identical function versions. The
872 first function in this chain is the version_info node of the
873 default function. */
875 /* If this version node corresponds to a dispatcher for function
876 versions, this points to the version info node of the default
877 function, the first node in the chain. */
879 /* If this node corresponds to a function version, this points
880 to the dispatcher function decl, which is the function that must
881 be called to execute the right function version at run-time.
882
883 If this cgraph node is a dispatcher (if dispatcher_function is
884 true, in the cgraph_node struct) for function versions, this
885 points to resolver function, which holds the function body of the
886 dispatcher. The dispatcher decl is an alias to the resolver
887 function decl. */
889
890 /* The assmbly name of the function set before version mangling. */
891 tree assembler_name;
892};
893
894#define DEFCIFCODE(code, type, string) CIF_ ## code,
895/* Reasons for inlining failures. */
896
898#include "cif-code.def"
899 CIF_N_REASONS
900};
903{
906};
908struct cgraph_edge;
910struct cgraph_edge_hasher : ggc_ptr_hash<cgraph_edge>
911{
912 typedef gimple *compare_type;
913
914 static hashval_t hash (cgraph_edge *);
915 static hashval_t hash (gimple *);
916 static bool equal (cgraph_edge *, gimple *);
917};
918
919/* The cgraph data structure.
920 Each function decl has assigned cgraph_node listing callees and callers. */
922struct GTY((tag ("SYMTAB_FUNCTION"))) cgraph_node : public symtab_node
923{
924 friend class symbol_table;
925
926 /* Constructor. */
927 explicit cgraph_node ()
933 inlined_to (NULL), rtl (NULL),
934 count (profile_count::uninitialized ()),
935 count_materialization_scale (REG_BR_PROB_BASE), profile_id (0),
936 unit_id (0), tp_first_run (0), thunk (false),
937 used_as_abstract_origin (false),
938 lowered (false), process (false), frequency (NODE_FREQUENCY_NORMAL),
939 only_called_at_startup (false), only_called_at_exit (false),
940 tm_clone (false), dispatcher_function (false),
941 dispatcher_resolver_function (false), is_target_clone (false),
942 calls_comdat_local (false),
943 icf_merged (false), nonfreeing_fn (false), merged_comdat (false),
944 merged_extern_inline (false), parallelized_function (false),
945 split_part (false), indirect_call_target (false), local (false),
946 versionable (false), can_change_signature (false),
947 redefined_extern_inline (false), tm_may_enter_irr (false),
948 ipcp_clone (false), gc_candidate (false),
949 called_by_ifunc_resolver (false), has_omp_variant_constructs (false),
950 m_summary_id (-1)
951 {}
952
953 /* Remove the node from cgraph and all inline clones inlined into it.
954 Skip however removal of FORBIDDEN_NODE and return true if it needs to be
955 removed. This allows to call the function from outer loop walking clone
956 tree. */
957 bool remove_symbol_and_inline_clones (cgraph_node *forbidden_node = NULL);
958
959 /* Record all references from cgraph_node that are taken
960 in statement STMT. */
961 void record_stmt_references (gimple *stmt);
962
963 /* Like cgraph_set_call_stmt but walk the clone tree and update all
964 clones sharing the same function body.
965 When WHOLE_SPECULATIVE_EDGES is true, all three components of
966 speculative edge gets updated. Otherwise we update only direct
967 call. */
968 void set_call_stmt_including_clones (gimple *old_stmt, gcall *new_stmt,
969 bool update_speculative = true);
970
971 /* Walk the alias chain to return the function cgraph_node is alias of.
972 Walk through thunk, too.
973 When AVAILABILITY is non-NULL, get minimal availability in the chain.
974 When REF is non-NULL, assume that reference happens in symbol REF
975 when determining the availability. */
976 cgraph_node *function_symbol (enum availability *avail = NULL,
977 struct symtab_node *ref = NULL);
978
979 /* Walk the alias chain to return the function cgraph_node is alias of.
980 Walk through non virtual thunks, too. Thus we return either a function
981 or a virtual thunk node.
982 When AVAILABILITY is non-NULL, get minimal availability in the chain.
983 When REF is non-NULL, assume that reference happens in symbol REF
984 when determining the availability. */
985 cgraph_node *function_or_virtual_thunk_symbol
986 (enum availability *avail = NULL,
987 struct symtab_node *ref = NULL);
988
989 /* Create node representing clone of N executed COUNT times. Decrease
990 the execution counts from original node too.
991 The new clone will have decl set to DECL that may or may not be the same
992 as decl of N.
993
994 When UPDATE_ORIGINAL is true, the counts are subtracted from the original
995 function's profile to reflect the fact that part of execution is handled
996 by node.
997 When CALL_DUPLICATION_HOOK is true, the ipa passes are acknowledged about
998 the new clone. Otherwise the caller is responsible for doing so later.
999
1000 If the new node is being inlined into another one, NEW_INLINED_TO should be
1001 the outline function the new one is (even indirectly) inlined to.
1002 All hooks will see this in node's inlined_to, when invoked.
1003 Should be NULL if the node is not inlined.
1004
1005 SUFFIX is string that is appended to the original name, it should only be
1006 NULL if NEW_INLINED_TO is not NULL or if the clone being created is
1007 temporary and a record about it should not be added into the ipa-clones
1008 dump file. */
1009 cgraph_node *create_clone (tree decl, profile_count count,
1010 bool update_original,
1011 vec<cgraph_edge *> redirect_callers,
1012 bool call_duplication_hook,
1013 cgraph_node *new_inlined_to,
1014 ipa_param_adjustments *param_adjustments,
1015 const char *suffix);
1016
1017 /* Create callgraph node clone with new declaration. The actual body will be
1018 copied later at compilation stage. The name of the new clone will be
1019 constructed from the name of the original node, SUFFIX and NUM_SUFFIX. */
1020 cgraph_node *create_virtual_clone (const vec<cgraph_edge *> &redirect_callers,
1021 vec<ipa_replace_map *, va_gc> *tree_map,
1022 ipa_param_adjustments *param_adjustments,
1023 const char * suffix, unsigned num_suffix);
1024
1025 /* Remove the node from the tree of virtual and inline clones and make it a
1026 standalone node - not a clone any more. */
1027 void remove_from_clone_tree ();
1028
1029 /* cgraph node being removed from symbol table; see if its entry can be
1030 replaced by other inline clone. */
1031 cgraph_node *find_replacement (struct clone_info *);
1032
1033 /* Create a new cgraph node which is the new version of
1034 callgraph node. REDIRECT_CALLERS holds the callers
1035 edges which should be redirected to point to
1036 NEW_VERSION. ALL the callees edges of the node
1037 are cloned to the new version node. Return the new
1038 version node.
1039
1040 If non-NULL BLOCK_TO_COPY determine what basic blocks
1041 was copied to prevent duplications of calls that are dead
1042 in the clone.
1043
1044 SUFFIX is string that is appended to the original name. */
1045
1046 cgraph_node *create_version_clone (tree new_decl,
1047 vec<cgraph_edge *> redirect_callers,
1048 bitmap bbs_to_copy,
1049 const char *suffix = NULL);
1050
1051 /* Perform function versioning.
1052 Function versioning includes copying of the tree and
1053 a callgraph update (creating a new cgraph node and updating
1054 its callees and callers).
1055
1056 REDIRECT_CALLERS varray includes the edges to be redirected
1057 to the new version.
1058
1059 TREE_MAP is a mapping of tree nodes we want to replace with
1060 new ones (according to results of prior analysis).
1061
1062 If non-NULL PARAM_ADJUSTMENTS determine how function formal parameters
1063 should be modified in the new version and if it should return void.
1064 If non-NULL BLOCK_TO_COPY determine what basic blocks to copy.
1065 If non_NULL NEW_ENTRY determine new entry BB of the clone.
1066 SUFFIX is a string that will be used to create a new name for the new
1067 function.
1068
1069 If TARGET_ATTRIBUTES is non-null, when creating a new declaration,
1070 add the attributes to DECL_ATTRIBUTES. And call valid_attribute_p
1071 that will promote value of the attribute DECL_FUNCTION_SPECIFIC_TARGET
1072 of the declaration.
1073
1074 If VERSION_DECL is set true, use clone_function_name_numbered for the
1075 function clone. Otherwise, use clone_function_name.
1076
1077 Return the new version's cgraph node. */
1078 cgraph_node *create_version_clone_with_body
1079 (vec<cgraph_edge *> redirect_callers,
1080 vec<ipa_replace_map *, va_gc> *tree_map,
1081 ipa_param_adjustments *param_adjustments,
1082 bitmap bbs_to_copy, basic_block new_entry_block, const char *suffix,
1083 tree target_attributes = NULL_TREE, bool version_decl = true);
1084
1085 /* Insert a new cgraph_function_version_info node into cgraph_fnver_htab
1086 corresponding to cgraph_node. */
1087 cgraph_function_version_info *insert_new_function_version (void);
1088
1089 /* Get the cgraph_function_version_info node corresponding to node. */
1090 cgraph_function_version_info *function_version (void);
1091
1092 /* Discover all functions and variables that are trivially needed, analyze
1093 them as well as all functions and variables referred by them */
1094 void analyze (void);
1095
1096 /* Add thunk alias into callgraph. The alias declaration is ALIAS and it
1097 aliases DECL with an adjustments made into the first parameter.
1098 See comments in struct symtab-thunks.h for detail on the parameters. */
1099 cgraph_node * create_thunk (tree alias, tree, bool this_adjusting,
1100 HOST_WIDE_INT fixed_offset,
1101 HOST_WIDE_INT virtual_value,
1102 HOST_WIDE_INT indirect_offset,
1103 tree virtual_offset,
1104 tree real_alias);
1105
1106
1107 /* Return node that alias is aliasing. */
1108 inline cgraph_node *get_alias_target (void);
1109
1110 /* Given function symbol, walk the alias chain to return the function node
1111 is alias of. Do not walk through thunks.
1112 When AVAILABILITY is non-NULL, get minimal availability in the chain.
1113 When REF is non-NULL, assume that reference happens in symbol REF
1114 when determining the availability. */
1115
1116 cgraph_node *ultimate_alias_target (availability *availability = NULL,
1117 symtab_node *ref = NULL);
1118
1119 /* Call expand_thunk on all callers that are thunks and analyze those
1120 nodes that were expanded. */
1121 void expand_all_artificial_thunks ();
1122
1123 /* Assemble thunks and aliases associated to node. */
1124 void assemble_thunks_and_aliases (void);
1125
1126 /* Expand function specified by node. */
1127 void expand (void);
1128
1129 /* Creates a wrapper from cgraph_node to TARGET node. Thunk is used for this
1130 kind of wrapper method. */
1131 void create_wrapper (cgraph_node *target);
1132
1133 /* Verify cgraph nodes of the cgraph node. */
1134 void DEBUG_FUNCTION verify_node (void);
1135
1136 /* Remove function from symbol table. */
1137 void remove (void);
1138
1139 /* Dump call graph node to file F. */
1140 void dump (FILE *f);
1141
1142 /* Dump call graph node to file F. */
1143 void dump_graphviz (FILE *f);
1144
1145 /* Dump call graph node to stderr. */
1146 void DEBUG_FUNCTION debug (void);
1147
1148 /* When doing LTO, read cgraph_node's body from disk if it is not already
1149 present. */
1150 bool get_untransformed_body ();
1151
1152 /* Prepare function body. When doing LTO, read cgraph_node's body from disk
1153 if it is not already present. When some IPA transformations are scheduled,
1154 apply them. */
1155 bool get_body ();
1156
1157 void materialize_clone (void);
1158
1159 /* Release memory used to represent body of function.
1160 Use this only for functions that are released before being translated to
1161 target code (i.e. RTL). Functions that are compiled to RTL and beyond
1162 are free'd in final.cc via free_after_compilation(). */
1163 void release_body (bool keep_arguments = false);
1164
1165 /* Return the DECL_STRUCT_FUNCTION of the function. */
1166 struct function *get_fun () const;
1167
1168 /* Bring cgraph node local. */
1169 void make_local (void);
1170
1171 /* Likewise indicate that a node is having address taken. */
1172 void mark_address_taken (void);
1173
1174 /* Set finalization priority to PRIORITY. */
1175 void set_fini_priority (priority_type priority);
1176
1177 /* Return the finalization priority. */
1178 priority_type get_fini_priority (void);
1179
1180 /* Create edge from a given function to CALLEE in the cgraph. */
1181 cgraph_edge *create_edge (cgraph_node *callee,
1182 gcall *call_stmt, profile_count count,
1183 bool cloning_p = false);
1184
1185 /* Create an indirect edge to a (yet-)undetermined callee. CALL_STMT is the
1186 corresponding statement, if available, ECF_FLAGS and COUNT are
1187 corresponding gimple call flags and profiling count respectively.
1188 CLONING_P should be set if properties that are copied from an original
1189 edge should not be calculated. */
1190
1191 cgraph_edge *create_indirect_edge (gcall *call_stmt, int ecf_flags,
1192 profile_count count,
1193 bool cloning_p = false);
1194
1195 /* Like cgraph_create_edge walk the clone tree and update all clones sharing
1196 same function body. If clones already have edge for OLD_STMT; only
1197 update the edge same way as cgraph_set_call_stmt_including_clones does. */
1198 void create_edge_including_clones (cgraph_node *callee,
1199 gimple *old_stmt, gcall *stmt,
1200 profile_count count,
1201 cgraph_inline_failed_t reason);
1202
1203 /* Return the callgraph edge representing the GIMPLE_CALL statement
1204 CALL_STMT. */
1205 cgraph_edge *get_edge (gimple *call_stmt);
1206
1207 /* Collect all callers of cgraph_node and its aliases that are known to lead
1208 to NODE (i.e. are not overwritable) and that are not thunks. */
1209 auto_vec<cgraph_edge *> collect_callers (void);
1210
1211 /* Remove all callers from the node. */
1212 void remove_callers (void);
1213
1214 /* Remove all callees from the node. */
1215 void remove_callees (void);
1216
1217 /* Return function availability. See cgraph.h for description of individual
1218 return values. */
1219 enum availability get_availability (symtab_node *ref = NULL);
1220
1221 /* Set TREE_NOTHROW on cgraph_node's decl and on aliases of the node
1222 if any to NOTHROW. */
1223 bool set_nothrow_flag (bool nothrow);
1224
1225 /* SET DECL_IS_MALLOC on cgraph_node's decl and on aliases of the node
1226 if any. */
1227 bool set_malloc_flag (bool malloc_p);
1228
1229 /* SET TREE_THIS_VOLATILE on cgraph_node's decl and on aliases of the node
1230 if any. */
1231 bool set_noreturn_flag (bool noreturn_p);
1232
1233 /* If SET_CONST is true, mark function, aliases and thunks to be ECF_CONST.
1234 If SET_CONST if false, clear the flag.
1235
1236 When setting the flag be careful about possible interposition and
1237 do not set the flag for functions that can be interposed and set pure
1238 flag for functions that can bind to other definition.
1239
1240 Return true if any change was done. */
1241
1242 bool set_const_flag (bool set_const, bool looping);
1243
1244 /* Set DECL_PURE_P on cgraph_node's decl and on aliases of the node
1245 if any to PURE.
1246
1247 When setting the flag, be careful about possible interposition.
1248 Return true if any change was done. */
1249
1250 bool set_pure_flag (bool pure, bool looping);
1251
1252 /* Add attribute ATTR to cgraph_node's decl and on aliases of the node
1253 if any. */
1254 bool add_detected_attribute (const char *attr);
1255
1256 /* Call callback on function and aliases associated to the function.
1257 When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are
1258 skipped. */
1259
1260 bool call_for_symbol_and_aliases (bool (*callback) (cgraph_node *,
1261 void *),
1262 void *data, bool include_overwritable);
1263
1264 /* Call callback on cgraph_node, thunks and aliases associated to NODE.
1265 When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are
1266 skipped. When EXCLUDE_VIRTUAL_THUNKS is true, virtual thunks are
1267 skipped. */
1268 bool call_for_symbol_thunks_and_aliases (bool (*callback) (cgraph_node *node,
1269 void *data),
1270 void *data,
1271 bool include_overwritable,
1272 bool exclude_virtual_thunks = false);
1273
1274 /* Likewise indicate that a node is needed, i.e. reachable via some
1275 external means. */
1276 inline void mark_force_output (void);
1277
1278 /* Return true when function can be marked local. */
1279 bool local_p (void);
1280
1281 /* Return true if cgraph_node can be made local for API change.
1282 Extern inline functions and C++ COMDAT functions can be made local
1283 at the expense of possible code size growth if function is used in multiple
1284 compilation units. */
1285 bool can_be_local_p (void);
1286
1287 /* Return true when cgraph_node cannot return or throw and thus
1288 it is safe to ignore its side effects for IPA analysis. */
1289 bool cannot_return_p (void);
1290
1291 /* Return true when function cgraph_node and all its aliases are only called
1292 directly.
1293 i.e. it is not externally visible, address was not taken and
1294 it is not used in any other non-standard way. */
1295 bool only_called_directly_p (void);
1296
1297 /* Returns TRUE iff THIS is a descendant of N in the clone tree. */
1298 bool is_clone_of (cgraph_node *n) const;
1299
1300 /* Turn profile to global0. Walk into inlined functions. */
1301 void make_profile_local ();
1302
1303 /* Turn profile to global0. Walk into inlined functions. */
1304 void make_profile_global0 (profile_quality quality);
1305
1306 /* Scale profile by NUM/DEN. Walk into inlined funtion. */
1307 void apply_scale (profile_count num, profile_count den);
1308
1309 /* Scale profile to given IPA_COUNT.
1310 IPA_COUNT should pass ipa_p () with a single exception.
1311 It can be also GUESSED_LOCAL in case we want to
1312 drop any IPA info about the profile. */
1313 void scale_profile_to (profile_count ipa_count);
1314
1315 /* Return true when function is only called directly or it has alias.
1316 i.e. it is not externally visible, address was not taken and
1317 it is not used in any other non-standard way. */
1318 inline bool only_called_directly_or_aliased_p (void);
1319
1320 /* Return true when function cgraph_node can be expected to be removed
1321 from program when direct calls in this compilation unit are removed.
1322
1323 As a special case COMDAT functions are
1324 cgraph_can_remove_if_no_direct_calls_p while the are not
1325 cgraph_only_called_directly_p (it is possible they are called from other
1326 unit)
1327
1328 This function behaves as cgraph_only_called_directly_p because eliminating
1329 all uses of COMDAT function does not make it necessarily disappear from
1330 the program unless we are compiling whole program or we do LTO. In this
1331 case we know we win since dynamic linking will not really discard the
1332 linkonce section.
1333
1334 If WILL_INLINE is true, assume that function will be inlined into all the
1335 direct calls. */
1336 bool will_be_removed_from_program_if_no_direct_calls_p
1337 (bool will_inline = false);
1338
1339 /* Return true when function can be removed from callgraph
1340 if all direct calls and references are eliminated. The function does
1341 not take into account comdat groups. */
1342 bool can_remove_if_no_direct_calls_and_refs_p (void);
1343
1344 /* Return true when function cgraph_node and its aliases can be removed from
1345 callgraph if all direct calls are eliminated.
1346 If WILL_INLINE is true, assume that function will be inlined into all the
1347 direct calls. */
1348 bool can_remove_if_no_direct_calls_p (bool will_inline = false);
1349
1350 /* Return true when callgraph node is a function with Gimple body defined
1351 in current unit. Functions can also be define externally or they
1352 can be thunks with no Gimple representation.
1353
1354 Note that at WPA stage, the function body may not be present in memory. */
1355 inline bool has_gimple_body_p (void);
1356
1357 /* Return true if this node represents a former, i.e. an expanded, thunk. */
1358 bool former_thunk_p (void);
1359
1360 /* Check if function calls comdat local. This is used to recompute
1361 calls_comdat_local flag after function transformations. */
1362 bool check_calls_comdat_local_p ();
1363
1364 /* Return true if function should be optimized for size. */
1365 enum optimize_size_level optimize_for_size_p (void);
1366
1367 /* Dump the callgraph to file F. */
1368 static void dump_cgraph (FILE *f);
1370 /* Dump the call graph to stderr. */
1371 static inline
1372 void debug_cgraph (void)
1373 {
1374 dump_cgraph (stderr);
1376
1377 /* Get summary id of the node. */
1378 inline int get_summary_id ()
1379 {
1380 return m_summary_id;
1381 }
1382
1383 /* Adds DECL to the FN_V structure of semantically identical functions. */
1384 static void add_function_version (cgraph_function_version_info *fn_v,
1385 tree decl);
1386
1387 /* Remove the cgraph_function_version_info and cgraph_node for DECL. This
1388 DECL is a duplicate declaration. */
1389 static void delete_function_version_by_decl (tree decl);
1390
1391 static void delete_function_version (cgraph_function_version_info *);
1392
1393 /* Add the function FNDECL to the call graph.
1394 Unlike finalize_function, this function is intended to be used
1395 by middle end and allows insertion of new function at arbitrary point
1396 of compilation. The function can be either in high, low or SSA form
1397 GIMPLE.
1398
1399 The function is assumed to be reachable and have address taken (so no
1400 API breaking optimizations are performed on it).
1401
1402 Main work done by this function is to enqueue the function for later
1403 processing to avoid need the passes to be re-entrant. */
1404 static void add_new_function (tree fndecl, bool lowered);
1405
1406 /* Return callgraph node for given symbol and check it is a function. */
1407 static inline cgraph_node *get (const_tree decl)
1408 {
1409 gcc_checking_assert (TREE_CODE (decl) == FUNCTION_DECL);
1411 }
1412
1413 /* DECL has been parsed. Take it, queue it, compile it at the whim of the
1414 logic in effect. If NO_COLLECT is true, then our caller cannot stand to
1415 have the garbage collector run at the moment. We would need to either
1416 create a new GC context, or just not compile right now. */
1417 static void finalize_function (tree, bool);
1418
1419 /* Return cgraph node assigned to DECL. Create new one when needed. */
1420 static cgraph_node * create (tree decl);
1421
1422 /* Try to find a call graph node for declaration DECL and if it does not
1423 exist or if it corresponds to an inline clone, create a new one. */
1424 static cgraph_node * get_create (tree);
1425
1426 /* Return local info for the compiled function. */
1427 static cgraph_node *local_info_node (tree decl);
1428
1429 /* Return RTL info for the compiled function. */
1430 static struct cgraph_rtl_info *rtl_info (const_tree);
1431
1432 /* Return the cgraph node that has ASMNAME for its DECL_ASSEMBLER_NAME.
1433 Return NULL if there's no such node. */
1434 static cgraph_node *get_for_asmname (tree asmname);
1435
1436 /* Attempt to mark ALIAS as an alias to DECL. Return alias node if
1437 successful and NULL otherwise.
1438 Same body aliases are output whenever the body of DECL is output,
1439 and cgraph_node::get (ALIAS) transparently
1440 returns cgraph_node::get (DECL). */
1441 static cgraph_node * create_same_body_alias (tree alias, tree decl);
1442
1443 /* Verify whole cgraph structure. */
1444 static void DEBUG_FUNCTION verify_cgraph_nodes (void);
1445
1446 /* Verify cgraph, if consistency checking is enabled. */
1447 static inline void checking_verify_cgraph_nodes (void);
1448
1449 /* Worker to bring NODE local. */
1450 static bool make_local (cgraph_node *node, void *);
1451
1452 /* Mark ALIAS as an alias to DECL. DECL_NODE is cgraph node representing
1453 the function body is associated
1454 with (not necessarily cgraph_node (DECL). */
1455 static cgraph_node *create_alias (tree alias, tree target);
1456
1457 /* Return true if NODE has thunk. */
1458 static bool has_thunk_p (cgraph_node *node, void *);
1459
1462 /* List of edges representing indirect calls with a yet undetermined
1463 callee. */
1469 /* For functions with many calls sites it holds map from call expression
1470 to the edge to speed up cgraph_edge function. */
1472 /* Declaration node used to be clone of. */
1475 /* If this is a SIMD clone, this points to the SIMD specific
1476 information for it. */
1478 /* If this function has SIMD clones, this points to the first clone. */
1480
1481 /* Interprocedural passes scheduled to have their transform functions
1482 applied next time we execute local pass on them. We maintain it
1483 per-function in order to allow IPA passes to introduce new functions. */
1486 /* For inline clones this points to the function they will be
1487 inlined into. */
1489
1491
1492 /* Expected number of executions: calculated in profile.cc. */
1494 /* How to scale counts at materialization time; used to merge
1495 LTO units with different number of profile runs. */
1497 /* ID assigned by the profiling. */
1498 unsigned int profile_id;
1499 /* ID of the translation unit. */
1500 int unit_id;
1501 /* Time profiler: first run of function. */
1503
1504 /* True when symbol is a thunk. */
1505 unsigned thunk : 1;
1506 /* Set when decl is an abstract function pointed to by the
1507 ABSTRACT_DECL_ORIGIN of a reachable function. */
1508 unsigned used_as_abstract_origin : 1;
1509 /* Set once the function is lowered (i.e. its CFG is built). */
1510 unsigned lowered : 1;
1511 /* Set once the function has been instantiated and its callee
1512 lists created. */
1513 unsigned process : 1;
1514 /* How commonly executed the node is. Initialized during branch
1515 probabilities pass. */
1516 ENUM_BITFIELD (node_frequency) frequency : 2;
1517 /* True when function can only be called at startup (from static ctor). */
1518 unsigned only_called_at_startup : 1;
1519 /* True when function can only be called at startup (from static dtor). */
1520 unsigned only_called_at_exit : 1;
1521 /* True when function is the transactional clone of a function which
1522 is called only from inside transactions. */
1523 /* ?? We should be able to remove this. We have enough bits in
1524 cgraph to calculate it. */
1525 unsigned tm_clone : 1;
1526 /* True if this decl is a dispatcher for function versions. */
1527 unsigned dispatcher_function : 1;
1528 /* True if this decl is a resolver for function versions. */
1529 unsigned dispatcher_resolver_function : 1;
1530 /* True this is part of a multiversioned set and this version comes from a
1531 target_clone attribute. Or if this is a dispatched symbol or resolver
1532 and the default version comes from a target_clones. */
1533 unsigned is_target_clone : 1;
1534 /* True if this decl calls a COMDAT-local function. This is set up in
1535 compute_fn_summary and inline_call. */
1536 unsigned calls_comdat_local : 1;
1537 /* True if node has been created by merge operation in IPA-ICF. */
1538 unsigned icf_merged: 1;
1539 /* True if call to node can't result in a call to free, munmap or
1540 other operation that could make previously non-trapping memory
1541 accesses trapping. */
1542 unsigned nonfreeing_fn : 1;
1543 /* True if there was multiple COMDAT bodies merged by lto-symtab. */
1544 unsigned merged_comdat : 1;
1545 /* True if this def was merged with extern inlines. */
1546 unsigned merged_extern_inline : 1;
1547 /* True if function was created to be executed in parallel. */
1548 unsigned parallelized_function : 1;
1549 /* True if function is part split out by ipa-split. */
1550 unsigned split_part : 1;
1551 /* True if the function appears as possible target of indirect call. */
1553 /* Set when function is visible in current compilation unit only and
1554 its address is never taken. */
1555 unsigned local : 1;
1556 /* False when there is something makes versioning impossible. */
1557 unsigned versionable : 1;
1558 /* False when function calling convention and signature cannot be changed.
1559 This is the case when __builtin_apply_args is used. */
1561 /* True when the function has been originally extern inline, but it is
1562 redefined now. */
1563 unsigned redefined_extern_inline : 1;
1564 /* True if the function may enter serial irrevocable mode. */
1565 unsigned tm_may_enter_irr : 1;
1566 /* True if this was a clone created by ipa-cp. */
1567 unsigned ipcp_clone : 1;
1568 /* True if the function should only be emitted if it is used. This flag
1569 is set for local SIMD clones when they are created and cleared if the
1570 vectorizer uses them. */
1571 unsigned gc_candidate : 1;
1572 /* Set if the function is called by an IFUNC resolver. */
1573 unsigned called_by_ifunc_resolver : 1;
1574 /* True if the function contains unresolved OpenMP metadirectives. */
1575 unsigned has_omp_variant_constructs : 1;
1576
1577private:
1578
1579 /* Summary id that is recycled. */
1580 int m_summary_id;
1581
1582 /* Worker for call_for_symbol_and_aliases. */
1583 bool call_for_symbol_and_aliases_1 (bool (*callback) (cgraph_node *,
1584 void *),
1585 void *data, bool include_overwritable);
1586};
1588/* A cgraph node set is a collection of cgraph nodes. A cgraph node
1589 can appear in multiple sets. */
1591{
1595
1596typedef cgraph_node_set_def *cgraph_node_set;
1597typedef struct varpool_node_set_def *varpool_node_set;
1598
1599struct varpool_node;
1601/* A varpool node set is a collection of varpool nodes. A varpool node
1602 can appear in multiple sets. */
1604{
1608
1609/* Iterator structure for cgraph node sets. */
1611{
1613 unsigned index;
1615
1616/* Iterator structure for varpool node sets. */
1618{
1620 unsigned index;
1621};
1622
1623/* Context of polymorphic call. It represent information about the type of
1624 instance that may reach the call. This is used by ipa-devirt walkers of the
1625 type inheritance graph. */
1626
1628public:
1629 /* The called object appears in an object of type OUTER_TYPE
1630 at offset OFFSET. When information is not 100% reliable, we
1631 use SPECULATIVE_OUTER_TYPE and SPECULATIVE_OFFSET. */
1632 HOST_WIDE_INT offset;
1633 HOST_WIDE_INT speculative_offset;
1636 /* True if outer object may be in construction or destruction. */
1637 unsigned maybe_in_construction : 1;
1638 /* True if outer object may be of derived type. */
1640 /* True if speculative outer object may be of derived type. We always
1641 speculate that construction does not happen. */
1643 /* True if the context is invalid and all calls should be redirected
1644 to BUILTIN_UNREACHABLE. */
1645 unsigned invalid : 1;
1646 /* True if the outer type is dynamic. */
1647 unsigned dynamic : 1;
1648
1649 /* Build empty "I know nothing" context. */
1651 /* Build polymorphic call context for indirect call E. */
1653 /* Build polymorphic call context for IP invariant CST.
1654 If specified, OTR_TYPE specify the type of polymorphic call
1655 that takes CST+OFFSET as a parameter. */
1656 ipa_polymorphic_call_context (tree cst, tree otr_type = NULL,
1657 HOST_WIDE_INT offset = 0);
1658 /* Build context for pointer REF contained in FNDECL at statement STMT.
1659 if INSTANCE is non-NULL, return pointer to the object described by
1660 the context. */
1661 ipa_polymorphic_call_context (tree fndecl, tree ref, gimple *stmt,
1662 tree *instance = NULL);
1663
1664 /* Look for vtable stores or constructor calls to work out dynamic type
1665 of memory location. */
1666 bool get_dynamic_type (tree, tree, tree, gimple *, unsigned *);
1667
1668 /* Make context non-speculative. */
1669 void clear_speculation ();
1670
1671 /* Produce context specifying all derived types of OTR_TYPE. If OTR_TYPE is
1672 NULL, the context is set to dummy "I know nothing" setting. */
1673 void clear_outer_type (tree otr_type = NULL);
1674
1675 /* Walk container types and modify context to point to actual class
1676 containing OTR_TYPE (if non-NULL) as base class.
1677 Return true if resulting context is valid.
1678
1679 When CONSIDER_PLACEMENT_NEW is false, reject contexts that may be made
1680 valid only via allocation of new polymorphic type inside by means
1681 of placement new.
1682
1683 When CONSIDER_BASES is false, only look for actual fields, not base types
1684 of TYPE. */
1685 bool restrict_to_inner_class (tree otr_type,
1686 bool consider_placement_new = true,
1687 bool consider_bases = true);
1688
1689 /* Adjust all offsets in contexts by given number of bits. */
1690 void offset_by (HOST_WIDE_INT);
1691 /* Use when we cannot track dynamic type change. This speculatively assume
1692 type change is not happening. */
1693 void possible_dynamic_type_change (bool, tree otr_type = NULL);
1694 /* Assume that both THIS and a given context is valid and strengthen THIS
1695 if possible. Return true if any strengthening was made.
1696 If actual type the context is being used in is known, OTR_TYPE should be
1697 set accordingly. This improves quality of combined result. */
1700
1701 /* Return TRUE if context is fully useless. */
1702 bool useless_p () const;
1703 /* Return TRUE if this context conveys the same information as X. */
1704 bool equal_to (const ipa_polymorphic_call_context &x) const;
1705
1706 /* Dump human readable context to F. If NEWLINE is true, it will be
1707 terminated by a newline. */
1708 void dump (FILE *f, bool newline = true) const;
1709 void DEBUG_FUNCTION debug () const;
1710
1711 /* LTO streaming. */
1712 void stream_out (struct output_block *) const;
1713 void stream_in (class lto_input_block *, class data_in *data_in);
1714
1715private:
1716 bool combine_speculation_with (tree, HOST_WIDE_INT, bool, tree);
1717 bool meet_speculation_with (tree, HOST_WIDE_INT, bool, tree);
1718 void set_by_decl (tree, HOST_WIDE_INT);
1719 bool set_by_invariant (tree, tree, HOST_WIDE_INT);
1720 bool speculation_consistent_p (tree, HOST_WIDE_INT, bool, tree) const;
1721 void make_speculative (tree otr_type = NULL);
1722};
1723
1724/* Denotes the kind of call that a particular cgraph_indirect_call_info
1725 instance describes. */
1726
1728 /* Unspecified kind. Only to be used when no information about the call
1729 statement is available or it does not fall into any of the other
1730 categories. */
1732 /* A normal indirect call when the target is an SSA_NAME. */
1734 /* Call of a virtual method when the target is an OBJ_TYPE_REF which conforms
1735 to virtual_method_call_p. */
1737 /* Must be last */
1739};
1740
1741/* The base class containing additional information about all kinds of indirect
1742 calls. It can also be used when no information about the call statement is
1743 available or it does not fall into any of the other categories. */
1744
1745class GTY((desc ("%h.kind"), tag ("CIIK_UNSPECIFIED")))
1747{
1748public:
1749 cgraph_indirect_call_info (int flags)
1750 : ecf_flags (flags), param_index (-1), kind (CIIK_UNSPECIFIED),
1753 : ecf_flags (flags), param_index (-1), kind (k),
1754 num_speculative_call_targets (0) {}
1755
1756 /* Dump human readable information about the indirect call to F. If NEWLINE
1757 is true, it will be terminated by a newline. */
1758 void dump (FILE *f, bool newline = true) const;
1759 void DEBUG_FUNCTION debug () const;
1760
1761 /* ECF flags determined from the caller. */
1762 int ecf_flags;
1763 /* If we can relate this call target to a specific formal parameter of the
1764 caller, then this is its index. Otherwise set to -1. */
1765 int param_index;
1767 /* Identifier of the specific type of indirect info this actually is. */
1769 /* Number of speculative call targets. */
1770 unsigned num_speculative_call_targets : 16;
1771};
1773/* Structure containing additional information about non-virtual indirect calls
1774 where the target is an SSA_NAME. */
1776class GTY((tag ("CIIK_SIMPLE")))
1778{
1779public:
1780 cgraph_simple_indirect_info (int flags)
1782 rec_type (NULL_TREE), fld_offset (0), agg_contents (false),
1783 member_ptr (false), fnptr_loaded_from_record (false), by_ref (false),
1785 {}
1786
1787 /* When agg_content is set, an offset where the call pointer is located
1788 within the aggregate. */
1789 HOST_WIDE_INT offset;
1790 /* Only meaningful if fnptr_loaded_from_record is set. Then it contains the
1791 type of the record from which the target of the call was loaded. */
1792 tree rec_type;
1793 /* Only meaningful if fnptr_loaded_from_record is set. Then it contains the
1794 offset in bytes within the type above from which the target of the call
1795 was loaded. */
1796 unsigned fld_offset;
1798 /* Set when the call is a call of a pointer loaded from contents of an
1799 aggregate at offset. */
1800 unsigned agg_contents : 1;
1801 /* Set when this is a call through a member pointer. */
1802 unsigned member_ptr : 1;
1803 /* Set if the function is a call of a pointer loaded from a record type
1804 stored in otr_type at offset offset. */
1805 unsigned fnptr_loaded_from_record : 1;
1806 /* When the agg_contents bit is set, this one determines whether the
1807 destination is loaded from a parameter passed by reference. */
1808 unsigned by_ref : 1;
1809 /* When the agg_contents bit is set, this one determines whether we can
1810 deduce from the function body that the loaded value from the reference is
1811 never modified between the invocation of the function and the load
1812 point. */
1813 unsigned guaranteed_unmodified : 1;
1814};
1816/* Structure containing additional information about non-virtual indirect calls
1817 when the target is an OBJ_TYPE_REF which conforms to
1818 virtual_method_call_p. */
1819
1820class GTY((tag ("CIIK_POLYMORPHIC")))
1823public:
1826 otr_token (0), otr_type (nullptr), offset (0), vptr_changed (true)
1827 {}
1830 HOST_WIDE_INT token, tree type)
1834
1835 /* Return true if the information is usable for devirtualization. This can
1836 happen if part of the required information is not streamed in yet and for
1837 some cases we determine it is no longer useful to attempt to use the
1838 information too. */
1839 bool usable_p () const
1840 {
1841 return !!otr_type;
1842 }
1843 /* Mark this information as not useful for devirtualization. Return true if
1844 it was considered useful until now. */
1845 bool mark_unusable ()
1846 {
1847 bool r = !!otr_type;
1849 return r;
1850 }
1852 /* Context of the polymorphic call; use only when POLYMORPHIC flag is set. */
1854 /* OBJ_TYPE_REF_TOKEN of a polymorphic call (if polymorphic is set). */
1855 HOST_WIDE_INT otr_token;
1856 /* Type of the object from OBJ_TYPE_REF_OBJECT. */
1857 tree otr_type;
1858 /* The offset from the point where the parameter identified by param_index to
1859 the point where the corresponding object appears. */
1860 HOST_WIDE_INT offset;
1861
1862 /* For polymorphic calls this specify whether the virtual table pointer
1863 may have changed in between function entry and the call. */
1864 unsigned vptr_changed : 1;
1865};
1866
1867/* Return true if ii is a cgraph_polymorphic_indirect_info that is usable_p. */
1868
1869inline bool
1870usable_polymorphic_info_p (cgraph_indirect_call_info *ii)
1874 return pii && pii->usable_p ();
1876
1877class GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"),
1878 for_user)) cgraph_edge
1879{
1880public:
1881 friend struct cgraph_node;
1882 friend class symbol_table;
1883
1884 /* Remove EDGE from the cgraph. */
1885 static void remove (cgraph_edge *edge);
1886
1887 /* Change field call_stmt of edge E to NEW_STMT. If UPDATE_DERIVED_EDGES and
1888 E is any component of speculative edge, then update all components.
1889 Speculations can be resolved in the process and EDGE can be removed and
1890 deallocated. Return the edge that now represents the call. If
1891 UPDATE_DERIVED_EDGES and E is a part of a callback edge, update all
1892 associated edges and return the callback-carrying edge. */
1893 static cgraph_edge *set_call_stmt (cgraph_edge *e, gcall *new_stmt,
1894 bool update_derived_edges = true);
1895
1896 /* Redirect callee of the edge to N. The function does not update underlying
1897 call expression. */
1898 void redirect_callee (cgraph_node *n);
1899
1900 /* If the edge does not lead to a thunk, simply redirect it to N. Otherwise
1901 create one or more equivalent thunks for N and redirect E to the first in
1902 the chain. Note that it is then necessary to call
1903 n->expand_all_artificial_thunks once all callers are redirected. */
1904 void redirect_callee_duplicating_thunks (cgraph_node *n);
1905
1906 /* Make an indirect edge with an unknown callee an ordinary edge leading to
1907 CALLEE. Speculations can be resolved in the process and EDGE can be
1908 removed and deallocated. Return the edge that now represents the
1909 call. */
1910 static cgraph_edge *make_direct (cgraph_edge *edge, cgraph_node *callee);
1911
1912 /* Returns the next speculative_id based on currently in use
1913 for the given statement for the edge.
1914 Returns 0 if no speculative edges exist for this statement. */
1915 int get_next_speculative_id ();
1916
1917 /* Turn edge into speculative call calling N2. Update
1918 the profile so the direct call is taken COUNT times
1919 with FREQUENCY. speculative_id is used to link direct calls with their
1920 corresponding IPA_REF_ADDR references when representing speculative calls.
1921 */
1922 cgraph_edge *make_speculative (cgraph_node *n2, profile_count direct_count,
1923 unsigned int speculative_id = 0);
1924
1925 /* Create a callback edge, representing an indirect call to n2
1926 passed to a function by argument. Sets has_callback flag of the original
1927 edge. Both edges are attached to the same call statement. Returns created
1928 callback edge. */
1929 cgraph_edge *make_callback (cgraph_node *n2, unsigned int callback_hash);
1930
1931 /* Returns the callback-carrying edge of a callback edge or NULL, if such edge
1932 cannot be found. An edge is considered callback-carrying, if it has it's
1933 has_callback flag set and shares it's call statement with the edge
1934 this method is caled on. */
1935 cgraph_edge *get_callback_carrying_edge ();
1936
1937 /* Returns the first callback edge in the list of callees of the caller node.
1938 Note that the edges might be in arbitrary order. Must be called on a
1939 callback or callback-carrying edge. */
1940 cgraph_edge *first_callback_edge ();
1941
1942 /* Given a callback edge, returns the next callback edge belonging to the same
1943 callback-carrying edge. Must be called on a callback edge, not the
1944 callback-carrying edge. */
1945 cgraph_edge *next_callback_edge ();
1946
1947 /* When called on a callback-carrying edge, removes all of its attached
1948 callback edges and sets has_callback to FALSE. */
1949 void purge_callback_edges ();
1950
1951 /* Speculative call consists of an indirect edge and one or more
1952 direct edge+ref pairs. Speculative will expand to the following sequence:
1953
1954 if (call_dest == target1) // reference to target1
1955 target1 (); // direct call to target1
1956 else if (call_dest == target2) // reference to targt2
1957 target2 (); // direct call to target2
1958 else
1959 call_dest (); // indirect call
1960
1961 Before the expansion we will have indirect call and the direct call+ref
1962 pairs all linked to single statement.
1963
1964 Note that ref may point to different symbol than the corresponding call
1965 becuase the speculated edge may have been optimized (redirected to
1966 a clone) or inlined.
1967
1968 Given an edge which is part of speculative call, return the first
1969 direct call edge in the speculative call sequence.
1970
1971 In the example above called on any cgraph edge in the sequence it will
1972 return direct call to target1. */
1974
1975 /* Return next speculative call target or NULL if there is none.
1976 All targets are required to form an interval in the callee list.
1977
1978 In example above, if called on call to target1 it will return call to
1979 target2. */
1981 {
1982 cgraph_edge *e = this;
1984
1985 if (e->next_callee && e->next_callee->speculative
1986 && e->next_callee->call_stmt == e->call_stmt
1987 && e->next_callee->lto_stmt_uid == e->lto_stmt_uid)
1988 return e->next_callee;
1989 return NULL;
1990 }
1991
1992 /* When called on any edge in the speculative call return the (unique)
1993 indirect call edge in the speculative call sequence. */
1994 cgraph_edge *speculative_call_indirect_edge ()
1995 {
1996 gcc_checking_assert (speculative);
1997 if (!callee)
1998 return this;
1999 for (cgraph_edge *e2 = caller->indirect_calls;
2000 true; e2 = e2->next_callee)
2001 if (e2->speculative
2002 && call_stmt == e2->call_stmt
2003 && lto_stmt_uid == e2->lto_stmt_uid)
2004 return e2;
2005 }
2006
2007 /* When called on any edge in speculative call and when given any target
2008 of ref which is speculated to it returns the corresponding direct call.
2010 In example above if called on function target2 it will return call to
2011 target2. */
2013
2014 /* Return REF corresponding to direct call in the specualtive call
2015 sequence. */
2017 {
2018 ipa_ref *ref;
2019
2021 for (unsigned int i = 0; caller->iterate_reference (i, ref); i++)
2022 if (ref->speculative && ref->speculative_id == speculative_id
2023 && ref->stmt == (gimple *)call_stmt
2024 && ref->lto_stmt_uid == lto_stmt_uid)
2025 return ref;
2026 gcc_unreachable ();
2027 }
2028
2029 /* Speculative call edge turned out to be direct call to CALLEE_DECL. Remove
2030 the speculative call sequence and return edge representing the call, the
2031 original EDGE can be removed and deallocated. It is up to caller to
2032 redirect the call as appropriate. Return the edge that now represents the
2033 call.
2034
2035 For "speculative" indirect call that contains multiple "speculative"
2036 targets (i.e. edge->indirect_info->num_speculative_call_targets > 1),
2037 decrease the count and only remove current direct edge.
2038
2039 If no speculative direct call left to the speculative indirect call, remove
2040 the speculative of both the indirect call and corresponding direct edge.
2041
2042 It is up to caller to iteratively resolve each "speculative" direct call
2043 and redirect the call as appropriate. */
2044 static cgraph_edge *resolve_speculation (cgraph_edge *edge,
2045 tree callee_decl = NULL);
2046
2047 /* If necessary, change the function declaration in the call statement
2048 associated with edge E so that it corresponds to the edge callee.
2049 Speculations can be resolved in the process and EDGE can be removed and
2050 deallocated.
2051
2052 The edge could be one of speculative direct call generated from speculative
2053 indirect call. In this circumstance, decrease the speculative targets
2054 count (i.e. num_speculative_call_targets) and redirect call stmt to the
2055 corresponding i-th target. If no speculative direct call left to the
2056 speculative indirect call, remove "speculative" of the indirect call and
2057 also redirect stmt to it's final direct target.
2058
2059 When called from within tree-inline, KILLED_SSAs has to contain the
2060 pointer to killed_new_ssa_names within the copy_body_data structure and
2061 SSAs discovered to be useless (if LHS is removed) will be added to it,
2062 otherwise it needs to be NULL.
2063
2064 It is up to caller to iteratively transform each "speculative"
2065 direct call as appropriate. */
2066 static gimple *redirect_call_stmt_to_callee (cgraph_edge *e,
2067 hash_set <tree>
2068 *killed_ssas = nullptr);
2069
2070 /* Create clone of edge in the node N represented
2071 by CALL_EXPR the callgraph. */
2072 cgraph_edge * clone (cgraph_node *n, gcall *call_stmt, unsigned stmt_uid,
2074 bool update_original);
2075
2076 /* Verify edge count and frequency. */
2077 bool verify_count ();
2078
2079 /* Return true when call of edge cannot lead to return from caller
2080 and thus it is safe to ignore its side effects for IPA analysis
2081 when computing side effects of the caller. */
2082 bool cannot_lead_to_return_p (void);
2083
2084 /* Return true when the edge represents a direct recursion. */
2085 bool recursive_p (void);
2086
2087 /* Return true if the edge may be considered hot after scalling its count. */
2088 bool maybe_hot_p ();
2090 /* Return true if the edge may be considered hot after scalling its count
2091 (i.e. assume that optimization would reduce runtime for callee,
2092 possibly significantly). */
2093 bool maybe_hot_p (sreal scale);
2094
2095 /* Get unique identifier of the edge. */
2096 inline int get_uid ()
2097 {
2098 return m_uid;
2099 }
2100
2101 /* Get summary id of the edge. */
2102 inline int get_summary_id ()
2103 {
2104 return m_summary_id;
2105 }
2106
2107 /* Rebuild cgraph edges for current function node. This needs to be run after
2108 passes that don't update the cgraph. */
2109 static unsigned int rebuild_edges (void);
2110
2111 /* Rebuild cgraph references for current function node. This needs to be run
2112 after passes that don't update the cgraph. */
2113 static void rebuild_references (void);
2114
2115 /* During LTO stream in this can be used to check whether call can possibly
2116 be internal to the current translation unit. */
2119 /* Return num_speculative_targets of this edge. */
2122 /* Expected number of executions: calculated in profile.cc. */
2131 /* Additional information about an indirect call. Not cleared when an edge
2132 becomes direct. */
2134 void *GTY ((skip (""))) aux;
2135 /* When equal to CIF_OK, inline this call. Otherwise, points to the
2136 explanation why function was not inlined. */
2138 /* The stmt_uid of call_stmt. This is used by LTO to recover the call_stmt
2139 when the function is serialized in. */
2140 unsigned int lto_stmt_uid;
2141 /* speculative id is used to link direct calls with their corresponding
2142 IPA_REF_ADDR references when representing speculative calls. */
2143 unsigned int speculative_id : 16;
2144 /* Whether this edge was made direct by indirect inlining. */
2145 unsigned int indirect_inlining_edge : 1;
2146 /* Whether this edge describes an indirect call with an undetermined
2147 callee. */
2148 unsigned int indirect_unknown_callee : 1;
2149 /* Whether this edge is still a dangling */
2150 /* True if the corresponding CALL stmt cannot be inlined. */
2151 unsigned int call_stmt_cannot_inline_p : 1;
2152 /* Can this call throw externally? */
2153 unsigned int can_throw_external : 1;
2154 /* Edges with SPECULATIVE flag represents indirect calls that was
2155 speculatively turned into direct (i.e. by profile feedback).
2156 The final code sequence will have form:
2157
2158 if (call_target == expected_fn)
2159 expected_fn ();
2160 else
2161 call_target ();
2162
2163 Every speculative call is represented by three components attached
2164 to a same call statement:
2165 1) a direct call (to expected_fn)
2166 2) an indirect call (to call_target)
2167 3) a IPA_REF_ADDR reference to expected_fn.
2168
2169 Optimizers may later redirect direct call to clone, so 1) and 3)
2170 do not need to necessarily agree with destination. */
2171 unsigned int speculative : 1;
2172 /* Edges with CALLBACK flag represent indirect calls to functions passed
2173 to their callers by argument. This is useful in cases, where the body
2174 of these caller functions is not known, e. g. qsort in glibc or
2175 GOMP_parallel in libgomp. These edges are never made into real calls,
2176 but are used instead to optimize these callback functions and later replace
2177 their addresses with their optimized versions. Edges with this flag set
2178 share their call statement with their callback-carrying edge. */
2179 unsigned int callback : 1;
2180 /* Edges with this flag set have one or more callback edges attached. They
2181 share their call statements with this edge. This flag represents the fact
2182 that the callee of this edge takes a function and it's parameters by
2183 argument and calls it at a later time. */
2184 unsigned int has_callback : 1;
2185 /* Used to pair callback edges and the attributes that originated them
2186 together. Currently the index of the callback argument, retrieved
2187 from the attribute. */
2188 unsigned int callback_id : 16;
2189 /* Set to true when caller is a constructor or destructor of polymorphic
2190 type. */
2191 unsigned in_polymorphic_cdtor : 1;
2192
2193 /* Return true if call must bind to current definition. */
2194 bool binds_to_current_def_p ();
2195
2196 /* Expected frequency of executions within the function.
2197 When set to CGRAPH_FREQ_BASE, the edge is expected to be called once
2198 per function call. The range is 0 to CGRAPH_FREQ_MAX. */
2199 int frequency ();
2200
2201 /* Expected frequency of executions within the function. */
2203
2204 /* Expected frequency of executions within the function.
2205 If edge is speculative, sum all its indirect targets. */
2207private:
2208 /* Unique id of the edge. */
2209 int m_uid;
2210
2211 /* Summary id that is recycled. */
2212 int m_summary_id;
2213
2214 /* Remove the edge from the list of the callers of the callee. */
2215 void remove_caller (void);
2216
2217 /* Remove the edge from the list of the callees of the caller. */
2218 void remove_callee (void);
2219
2220 /* Set callee N of call graph edge and add it to the corresponding set of
2221 callers. */
2222 void set_callee (cgraph_node *n);
2223
2224 /* Output flags of edge to a file F. */
2225 void dump_edge_flags (FILE *f);
2226
2227 /* Dump edge to stderr. */
2230 /* Verify that call graph edge corresponds to DECL from the associated
2231 statement. Return true if the verification should fail. */
2232 bool verify_corresponds_to_fndecl (tree decl);
2233};
2235#define CGRAPH_FREQ_BASE 1000
2236#define CGRAPH_FREQ_MAX 100000
2238/* The varpool data structure.
2239 Each static variable decl has assigned varpool_node. */
2240
2241struct GTY((tag ("SYMTAB_VARIABLE"))) varpool_node : public symtab_node
2242{
2243 /* Constructor. */
2244 explicit varpool_node ()
2247 {}
2248
2249 /* Dump given varpool node to F. */
2250 void dump (FILE *f);
2251
2252 /* Dump given varpool node to stderr. */
2253 void DEBUG_FUNCTION debug (void);
2254
2255 /* Remove variable from symbol table. */
2256 void remove (void);
2257
2258 /* Remove node initializer when it is no longer needed. */
2259 void remove_initializer (void);
2260
2261 void analyze (void);
2262
2263 /* Return variable availability. */
2265
2266 /* When doing LTO, read variable's constructor from disk if
2267 it is not already present. */
2268 tree get_constructor (void);
2269
2270 /* Return true if variable has constructor that can be used for folding. */
2271 bool ctor_useable_for_folding_p (void);
2272
2273 /* For given variable pool node, walk the alias chain to return the function
2274 the variable is alias of. Do not walk through thunks.
2275 When AVAILABILITY is non-NULL, get minimal availability in the chain.
2276 When REF is non-NULL, assume that reference happens in symbol REF
2277 when determining the availability. */
2280
2281 /* Return node that alias is aliasing. */
2282 inline varpool_node *get_alias_target (void);
2283
2284 /* Output one variable, if necessary. Return whether we output it. */
2285 bool assemble_decl (void);
2286
2287 /* For variables in named sections make sure get_variable_section
2288 is called before we switch to those sections. Then section
2289 conflicts between read-only and read-only requiring relocations
2290 sections can be resolved. */
2291 void finalize_named_section_flags (void);
2292
2293 /* Call callback on varpool symbol and aliases associated to varpool symbol.
2294 When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are
2295 skipped. */
2296 bool call_for_symbol_and_aliases (bool (*callback) (varpool_node *, void *),
2297 void *data,
2298 bool include_overwritable);
2299
2300 /* Return true when variable should be considered externally visible. */
2301 bool externally_visible_p (void);
2302
2303 /* Return true when all references to variable must be visible
2304 in ipa_ref_list.
2305 i.e. if the variable is not externally visible or not used in some magic
2306 way (asm statement or such).
2307 The magic uses are all summarized in force_output flag. */
2308 inline bool all_refs_explicit_p ();
2309
2310 /* Return true when variable can be removed from variable pool
2311 if all direct calls are eliminated. */
2312 inline bool can_remove_if_no_refs_p (void);
2313
2314 /* Add the variable DECL to the varpool.
2315 Unlike finalize_decl function is intended to be used
2316 by middle end and allows insertion of new variable at arbitrary point
2317 of compilation. */
2318 static void add (tree decl);
2319
2320 /* Return varpool node for given symbol and check it is a function. */
2321 static inline varpool_node *get (const_tree decl);
2322
2323 /* Mark DECL as finalized. By finalizing the declaration, frontend instruct
2324 the middle end to output the variable to asm file, if needed or externally
2325 visible. */
2326 static void finalize_decl (tree decl);
2327
2328 /* Attempt to mark ALIAS as an alias to DECL. Return TRUE if successful.
2329 Extra name aliases are output whenever DECL is output. */
2331
2332 /* Attempt to mark ALIAS as an alias to DECL. Return TRUE if successful.
2333 Extra name aliases are output whenever DECL is output. */
2334 static varpool_node * create_alias (tree, tree);
2335
2336 /* Dump the variable pool to F. */
2337 static void dump_varpool (FILE *f);
2338
2339 /* Dump the variable pool to stderr. */
2340 static void DEBUG_FUNCTION debug_varpool (void);
2341
2342 /* Allocate new callgraph node and insert it into basic data structures. */
2343 static varpool_node *create_empty (void);
2344
2345 /* Return varpool node assigned to DECL. Create new one when needed. */
2346 static varpool_node *get_create (tree decl);
2347
2348 /* Given an assembler name, lookup node. */
2350
2351 /* Set when variable is scheduled to be assembled. */
2352 unsigned output : 1;
2353
2354 /* Set if the variable is dynamically initialized, except for
2355 function local statics. */
2356 unsigned dynamically_initialized : 1;
2358 ENUM_BITFIELD(tls_model) tls_model : 3;
2359
2360 /* Set if the variable is known to be used by single function only.
2361 This is computed by ipa_single_use pass and used by late optimizations
2362 in places where optimization would be valid for local static variable
2363 if we did not do any inter-procedural code movement. */
2364 unsigned used_by_single_function : 1;
2365
2366private:
2367 /* Assemble thunks and aliases associated to varpool node. */
2368 void assemble_aliases (void);
2369
2370 /* Worker for call_for_node_and_aliases. */
2371 bool call_for_symbol_and_aliases_1 (bool (*callback) (varpool_node *, void *),
2372 void *data,
2373 bool include_overwritable);
2374};
2375
2376/* Every top level asm statement is put into a asm_node. */
2377
2378struct GTY ((tag ("TOPLEVEL_ASM"))) asm_node: public toplevel_node {
2381 {}
2382 /* String for this asm node. */
2383 tree asm_str;
2384 /* Vector of referenced symbols used for LTO partitioning.
2385 Not populated in flag_ltrans. */
2386 vec<symtab_node*> GTY ((skip)) symbols_referenced;
2387};
2389
2390/* Report whether or not THIS symtab node is a function, aka cgraph_node. */
2391
2392template <>
2393template <>
2394inline bool
2396{
2397 return p && p->type == SYMTAB_FUNCTION;
2399
2400/* Report whether or not THIS symtab node is a variable, aka varpool_node. */
2401
2402template <>
2403template <>
2404inline bool
2406{
2407 return p && p->type == SYMTAB_VARIABLE;
2409
2410/* Report whether or not THIS toplevel node is a function, aka cgraph_node. */
2411
2412template <>
2413template <>
2414inline bool
2416{
2417 return p && p->type == SYMTAB_FUNCTION;
2419
2420/* Report whether or not THIS toplevel node is a variable, aka varpool_node. */
2421
2422template <>
2423template <>
2424inline bool
2426{
2427 return p && p->type == SYMTAB_VARIABLE;
2429
2430/* Report whether or not THIS toplevel node is a symtab_node. */
2431
2432template <>
2433template <>
2434inline bool
2436{
2437 return p && p->type >= SYMTAB_SYMBOL;
2438}
2440/* Report whether or not THIS toplevel node is a toplevel assembly, aka
2441 asm_node. */
2442
2443template <>
2444template <>
2445inline bool
2447{
2448 return p && p->type == TOPLEVEL_ASM;
2450
2451/* Report whether or not THIS indirect info is a known simple one. */
2452
2453template <>
2454template <>
2455inline bool
2457{
2458 return p && p->kind == CIIK_SIMPLE;
2459}
2461/* Likewise, but const qualified. */
2462
2463template <>
2464template <>
2465inline bool
2466is_a_helper <const cgraph_simple_indirect_info *>
2468{
2469 return p && p->kind == CIIK_SIMPLE;
2470}
2472/* Report whether or not THIS indirect info is a known polymorphic one. */
2473
2474template <>
2475template <>
2476inline bool
2477is_a_helper <cgraph_polymorphic_indirect_info *>
2479{
2480 return p && p->kind == CIIK_POLYMORPHIC;
2481}
2483/* Likewise, but const qualified. */
2484
2485template <>
2486template <>
2487inline bool
2488is_a_helper <const cgraph_polymorphic_indirect_info *>
2491 return p && p->kind == CIIK_POLYMORPHIC;
2492}
2493
2494typedef void (*cgraph_edge_hook)(cgraph_edge *, void *);
2495typedef void (*cgraph_node_hook)(cgraph_node *, void *);
2496typedef void (*varpool_node_hook)(varpool_node *, void *);
2497typedef void (*cgraph_2edge_hook)(cgraph_edge *, cgraph_edge *, void *);
2498typedef void (*cgraph_2node_hook)(cgraph_node *, cgraph_node *, void *);
2499
2506/* Map from a symbol to initialization/finalization priorities. */
2507struct GTY(()) symbol_priority_map {
2509 priority_type fini;
2511
2513{
2514 /* Frontend is parsing and finalizing functions. */
2515 PARSING,
2516 /* Callgraph is being constructed. It is safe to add new functions. */
2518 /* Callgraph is being streamed-in at LTO time. */
2520 /* Callgraph is built and early IPA passes are being run. */
2522 /* Callgraph is built and all functions are transformed to SSA form. */
2524 /* All inline decisions are done; it is now possible to remove extern inline
2525 functions and virtual call targets. */
2527 /* Functions are now ordered and being passed to RTL expanders. */
2529 /* All cgraph expansion is done. */
2530 FINISHED
2531};
2532
2533struct asmname_hasher : ggc_ptr_hash <symtab_node>
2534{
2535 typedef const_tree compare_type;
2536
2537 static hashval_t hash (symtab_node *n);
2538 static bool equal (symtab_node *n, const_tree t);
2539};
2540
2541/* Core summaries maintained about symbols. */
2543struct thunk_info;
2544template <class T> class function_summary;
2545typedef function_summary <thunk_info *> thunk_summary;
2546
2548template <class T> class function_summary;
2549typedef function_summary <clone_info *> clone_summary;
2550
2551class GTY((tag ("SYMTAB"))) symbol_table
2552{
2553public:
2554 friend struct symtab_node;
2555 friend struct cgraph_node;
2556 friend struct cgraph_edge;
2557
2558 symbol_table ():
2563 order (0), max_unit (0), global_info_ready (false), state (PARSING),
2572 {
2573 }
2574
2575 /* Initialize callgraph dump file. */
2576 void initialize (void);
2577
2578 /* Register a top-level asm statement ASM_STR. */
2579 inline asm_node *finalize_toplevel_asm (tree asm_str);
2580
2581 /* Analyze the whole compilation unit once it is parsed completely. */
2582 void finalize_compilation_unit (void);
2583
2584 /* C++ frontend produce same body aliases all over the place, even before PCH
2585 gets streamed out. It relies on us linking the aliases with their function
2586 in order to do the fixups, but ipa-ref is not PCH safe. Consequently we
2587 first produce aliases without links, but once C++ FE is sure it won't
2588 stream PCH we build the links via this function. */
2589 void process_same_body_aliases (void);
2590
2591 /* Perform simple optimizations based on callgraph. */
2592 void compile (void);
2593
2594 /* Process CGRAPH_NEW_FUNCTIONS and perform actions necessary to add these
2595 functions into callgraph in a way so they look like ordinary reachable
2596 functions inserted into callgraph already at construction time. */
2597 void process_new_functions (void);
2598
2599 /* Register a symbol NODE. */
2600 inline void register_symbol (symtab_node *node);
2601
2602 inline void
2603 clear_asm_symbols (void)
2604 {
2605 asmnodes = NULL;
2607 }
2608
2609 /* Perform reachability analysis and reclaim all unreachable nodes. */
2610 bool remove_unreachable_nodes (FILE *file);
2611
2612 /* Optimization of function bodies might've rendered some variables as
2613 unnecessary so we want to avoid these from being compiled. Re-do
2614 reachability starting from variables that are either externally visible
2615 or was referred from the asm output routines. */
2616 void remove_unreferenced_decls (void);
2617
2618 /* Unregister a symbol NODE. */
2619 inline void unregister (symtab_node *node);
2620
2621 /* Allocate new callgraph node and insert it into basic data structures. */
2622 cgraph_node *create_empty (void);
2623
2624 /* Release a callgraph NODE. */
2625 void release_symbol (cgraph_node *node);
2626
2627 /* Output all variables enqueued to be assembled. */
2628 bool output_variables (void);
2629
2630 /* Weakrefs may be associated to external decls and thus not output
2631 at expansion time. Emit all necessary aliases. */
2632 void output_weakrefs (void);
2633
2634 /* Return first static symbol with definition. */
2635 inline symtab_node *first_symbol (void);
2636
2637 /* Return first assembler symbol. */
2638 inline asm_node *
2639 first_asm_symbol (void)
2640 {
2641 return asmnodes;
2642 }
2643
2644 /* Return first static symbol with definition. */
2645 inline symtab_node *first_defined_symbol (void);
2646
2647 /* Return first variable. */
2648 inline varpool_node *first_variable (void);
2649
2650 /* Return next variable after NODE. */
2651 inline varpool_node *next_variable (varpool_node *node);
2652
2653 /* Return first static variable with initializer. */
2654 inline varpool_node *first_static_initializer (void);
2655
2656 /* Return next static variable with initializer after NODE. */
2657 inline varpool_node *next_static_initializer (varpool_node *node);
2658
2659 /* Return first static variable with definition. */
2660 inline varpool_node *first_defined_variable (void);
2661
2662 /* Return next static variable with definition after NODE. */
2663 inline varpool_node *next_defined_variable (varpool_node *node);
2664
2665 /* Return first function with body defined. */
2666 inline cgraph_node *first_defined_function (void);
2667
2668 /* Return next function with body defined after NODE. */
2669 inline cgraph_node *next_defined_function (cgraph_node *node);
2670
2671 /* Return first function. */
2672 inline cgraph_node *first_function (void);
2673
2674 /* Return next function. */
2675 inline cgraph_node *next_function (cgraph_node *node);
2676
2677 /* Return first function with body defined. */
2678 cgraph_node *first_function_with_gimple_body (void);
2679
2680 /* Return next reachable static variable with initializer after NODE. */
2681 inline cgraph_node *next_function_with_gimple_body (cgraph_node *node);
2682
2683 /* Register HOOK to be called with DATA on each removed edge. */
2684 cgraph_edge_hook_list *add_edge_removal_hook (cgraph_edge_hook hook,
2685 void *data);
2686
2687 /* Remove ENTRY from the list of hooks called on removing edges. */
2688 void remove_edge_removal_hook (cgraph_edge_hook_list *entry);
2689
2690 /* Register HOOK to be called with DATA on each removed node. */
2691 cgraph_node_hook_list *add_cgraph_removal_hook (cgraph_node_hook hook,
2692 void *data);
2693
2694 /* Remove ENTRY from the list of hooks called on removing nodes. */
2695 void remove_cgraph_removal_hook (cgraph_node_hook_list *entry);
2696
2697 /* Register HOOK to be called with DATA on each removed node. */
2698 varpool_node_hook_list *add_varpool_removal_hook (varpool_node_hook hook,
2699 void *data);
2700
2701 /* Remove ENTRY from the list of hooks called on removing nodes. */
2702 void remove_varpool_removal_hook (varpool_node_hook_list *entry);
2703
2704 /* Register HOOK to be called with DATA on each inserted node. */
2705 cgraph_node_hook_list *add_cgraph_insertion_hook (cgraph_node_hook hook,
2706 void *data);
2707
2708 /* Remove ENTRY from the list of hooks called on inserted nodes. */
2709 void remove_cgraph_insertion_hook (cgraph_node_hook_list *entry);
2710
2711 /* Register HOOK to be called with DATA on each inserted node. */
2712 varpool_node_hook_list *add_varpool_insertion_hook (varpool_node_hook hook,
2713 void *data);
2714
2715 /* Remove ENTRY from the list of hooks called on inserted nodes. */
2716 void remove_varpool_insertion_hook (varpool_node_hook_list *entry);
2717
2718 /* Register HOOK to be called with DATA on each duplicated edge. */
2719 cgraph_2edge_hook_list *add_edge_duplication_hook (cgraph_2edge_hook hook,
2720 void *data);
2721 /* Remove ENTRY from the list of hooks called on duplicating edges. */
2722 void remove_edge_duplication_hook (cgraph_2edge_hook_list *entry);
2723
2724 /* Register HOOK to be called with DATA on each duplicated node. */
2725 cgraph_2node_hook_list *add_cgraph_duplication_hook (cgraph_2node_hook hook,
2726 void *data);
2727
2728 /* Remove ENTRY from the list of hooks called on duplicating nodes. */
2729 void remove_cgraph_duplication_hook (cgraph_2node_hook_list *entry);
2730
2731 /* Call all edge removal hooks. */
2732 void call_edge_removal_hooks (cgraph_edge *e);
2733
2734 /* Call all node insertion hooks. */
2735 void call_cgraph_insertion_hooks (cgraph_node *node);
2736
2737 /* Call all node removal hooks. */
2738 void call_cgraph_removal_hooks (cgraph_node *node);
2739
2740 /* Call all node duplication hooks. */
2741 void call_cgraph_duplication_hooks (cgraph_node *node, cgraph_node *node2);
2742
2743 /* Call all edge duplication hooks. */
2744 void call_edge_duplication_hooks (cgraph_edge *cs1, cgraph_edge *cs2);
2745
2746 /* Call all node removal hooks. */
2747 void call_varpool_removal_hooks (varpool_node *node);
2748
2749 /* Call all node insertion hooks. */
2750 void call_varpool_insertion_hooks (varpool_node *node);
2751
2752 /* Arrange node to be first in its entry of assembler_name_hash. */
2753 void symtab_prevail_in_asm_name_hash (symtab_node *node);
2754
2755 /* Initialize asm name hash unless. */
2756 void symtab_initialize_asm_name_hash (void);
2757
2758 /* Set the DECL_ASSEMBLER_NAME and update symtab hashtables. */
2760
2761 /* Dump symbol table to F. */
2762 void dump (FILE *f);
2763
2764 /* Dump symbol table to F in graphviz format. */
2765 void dump_graphviz (FILE *f);
2766
2767 /* Dump symbol table to stderr. */
2768 void DEBUG_FUNCTION debug (void);
2769
2770 /* Assign a new summary ID for the callgraph NODE. */
2771 inline int assign_summary_id (cgraph_node *node)
2772 {
2773 if (!cgraph_released_summary_ids.is_empty ())
2774 node->m_summary_id = cgraph_released_summary_ids.pop ();
2775 else
2776 node->m_summary_id = cgraph_max_summary_id++;
2777
2778 return node->m_summary_id;
2779 }
2780
2781 /* Assign a new summary ID for the callgraph EDGE. */
2782 inline int assign_summary_id (cgraph_edge *edge)
2783 {
2784 if (!edge_released_summary_ids.is_empty ())
2785 edge->m_summary_id = edge_released_summary_ids.pop ();
2786 else
2787 edge->m_summary_id = edges_max_summary_id++;
2788
2789 return edge->m_summary_id;
2792 /* Return true if assembler names NAME1 and NAME2 leads to the same symbol
2793 name. */
2794 static bool assembler_names_equal_p (const char *name1, const char *name2);
2796 int cgraph_count;
2797 int cgraph_max_uid;
2799
2800 int edges_count;
2803
2804 /* Vector of released summary IDS for cgraph nodes. */
2807 /* Vector of released summary IDS for cgraph nodes. */
2809
2810 /* Return symbol used to separate symbol name from suffix. */
2811 static char symbol_suffix_separator ();
2812
2814 asm_node* GTY(()) asmnodes;
2817 /* The order index of the next symtab node to be created. This is
2818 used so that we can sort the cgraph nodes in order by when we saw
2819 them, to support -fno-toplevel-reorder. */
2820 int order;
2822 /* Maximal unit ID used. */
2824
2825 /* Set when whole unit has been analyzed so we can access global info. */
2826 bool global_info_ready;
2827 /* What state callgraph is in right now. */
2829 /* Set when the cgraph is fully build and the basic flags are computed. */
2833
2834 /* Hash table used to hold sections. */
2837 /* Hash table used to convert assembler names into nodes. */
2839
2840 /* Hash table used to hold init priorities. */
2842
2843 FILE* GTY ((skip)) dump_file;
2844
2845 FILE* GTY ((skip)) ipa_clones_dump_file;
2847 hash_set <const cgraph_node *> GTY ((skip)) cloned_nodes;
2848
2849 /* Thunk annotations. */
2851
2852 /* Virtual clone annotations. */
2854
2855private:
2856 /* Allocate a cgraph_edge structure and fill it with data according to the
2857 parameters of which only CALLEE can be NULL (when creating an indirect
2858 call edge). CLONING_P should be set if properties that are copied from an
2859 original edge should not be calculated. */
2861 gcall *call_stmt, profile_count count,
2862 bool indir_unknown_callee, bool cloning_p);
2863
2864 /* Put the edge onto the free list. */
2865 void free_edge (cgraph_edge *e);
2866
2867 /* Insert NODE to assembler name hash. */
2868 void insert_to_assembler_name_hash (symtab_node *node, bool with_clones);
2869
2870 /* Remove NODE from assembler name hash. */
2871 void unlink_from_assembler_name_hash (symtab_node *node, bool with_clones);
2873 /* Hash asmnames ignoring the user specified marks. */
2874 static hashval_t decl_assembler_name_hash (const_tree asmname);
2876 /* Compare ASMNAME with the DECL_ASSEMBLER_NAME of DECL. */
2878
2879 friend struct asmname_hasher;
2880
2881 /* List of hooks triggered when an edge is removed. */
2883 /* List of hooks trigger_red when a cgraph node is removed. */
2885 /* List of hooks triggered when an edge is duplicated. */
2887 /* List of hooks triggered when a node is duplicated. */
2889 /* List of hooks triggered when an function is inserted. */
2891 /* List of hooks triggered when an variable is inserted. */
2893 /* List of hooks triggered when a node is removed. */
2896
2897extern GTY(()) symbol_table *symtab;
2898
2900
2901inline hashval_t
2906}
2907
2908inline bool
2910{
2911 return symbol_table::decl_assembler_name_equal (n->decl, t);
2912}
2913
2914/* In cgraph.cc */
2915void cgraph_cc_finalize (void);
2917
2918void cgraph_update_edges_for_call_stmt (gimple *, tree, gimple *);
2920
2923
2924/* In cgraphunit.cc */
2925void cgraphunit_cc_finalize (void);
2926int tp_first_run_node_cmp (const void *pa, const void *pb);
2927
2928/* In symtab-thunks.cc */
2929void symtab_thunks_cc_finalize (void);
2930
2931/* Initialize datastructures so DECL is a function in lowered gimple form.
2932 IN_SSA is true if the gimple is in SSA. */
2933basic_block init_lowered_empty_function (tree, bool, profile_count);
2934
2935tree thunk_adjust (gimple_stmt_iterator *, tree, bool, HOST_WIDE_INT, tree,
2936 HOST_WIDE_INT);
2937/* In cgraphclones.cc */
2938
2939tree clone_function_name_numbered (const char *name, const char *suffix);
2940tree clone_function_name_numbered (tree decl, const char *suffix);
2941tree clone_function_name (const char *name, const char *suffix,
2942 unsigned long number);
2943tree clone_function_name (tree decl, const char *suffix,
2944 unsigned long number);
2945tree clone_function_name (tree decl, const char *suffix);
2946tree clone_identifier (tree decl, const char *suffix,
2947 bool filter_suffix = false);
2948
2949void tree_function_versioning (tree, tree, vec<ipa_replace_map *, va_gc> *,
2950 ipa_param_adjustments *,
2951 bool, bitmap, basic_block);
2952
2953void dump_callgraph_transformation (const cgraph_node *original,
2954 const cgraph_node *clone,
2955 const char *suffix);
2956void set_new_clone_decl_and_node_flags (cgraph_node *new_node);
2957/* In cgraphbuild.cc */
2960
2961/* In ipa.cc */
2962void cgraph_build_static_cdtor (char which, tree body, int priority);
2963bool ipa_discover_variable_flags (void);
2964
2965/* In varpool.cc */
2967
2968/* In ipa-inline-analysis.cc */
2970bool speculation_useful_p (struct cgraph_edge *e, bool anticipate_inlining);
2971
2972/* Return true when the symbol is real symbol, i.e. it is not inline clone
2973 or abstract function kept for debug info purposes only. */
2974inline bool
2976{
2977 cgraph_node *cnode;
2978
2979 if (DECL_ABSTRACT_P (decl))
2980 return false;
2982 return false;
2983 if (!is_a <cgraph_node *> (this))
2984 return true;
2985 cnode = dyn_cast <cgraph_node *> (this);
2986 if (cnode->inlined_to)
2987 return false;
2988 return true;
2989}
2990
2991/* Return true if DECL should have entry in symbol table if used.
2992 Those are functions and static & external variables. */
2993
2994inline bool
2997 return (TREE_CODE (decl) == FUNCTION_DECL
2998 || (VAR_P (decl)
2999 && (TREE_STATIC (decl) || DECL_EXTERNAL (decl))));
3000}
3001
3002inline bool
3004{
3005 symtab_node *source = this;
3006
3007 if (cgraph_node *cn = dyn_cast <cgraph_node *> (target))
3008 {
3009 if (cn->inlined_to)
3010 source = cn->inlined_to;
3011 }
3012 if (cgraph_node *cn = dyn_cast <cgraph_node *> (target))
3013 {
3014 if (cn->inlined_to)
3015 target = cn->inlined_to;
3016 }
3018 return source->get_comdat_group () == target->get_comdat_group ();
3019}
3020
3021/* Return node that alias is aliasing. */
3022
3023inline symtab_node *
3025{
3026 ipa_ref *ref = NULL;
3027 iterate_reference (0, ref);
3029 return ref->referred;
3030}
3031
3032/* Return the DECL (or identifier) that alias is aliasing. Unlike the above,
3033 this works whether or not the alias has been analyzed already. */
3034
3035inline tree
3037{
3038 if (alias_target)
3040 return get_alias_target ()->decl;
3041}
3042
3043/* Return next reachable static symbol with initializer after the node. */
3044
3045inline symtab_node *
3047{
3049
3050 for (; node1; node1 = safe_as_a<symtab_node *>(node1->next))
3051 if (node1->definition)
3052 return node1;
3054 return NULL;
3055}
3056
3057/* Iterates I-th reference in the list, REF is also set. */
3058
3059inline ipa_ref *
3061{
3062 ref_list.references.iterate (i, &ref);
3064 return ref;
3065}
3066
3067/* Iterates I-th referring item in the list, REF is also set. */
3068
3069inline ipa_ref *
3071{
3072 ref_list.referring.iterate (i, &ref);
3074 return ref;
3075}
3076
3077/* Iterates I-th referring alias item in the list, REF is also set. */
3078
3079inline ipa_ref *
3081{
3082 ref_list.referring.iterate (i, &ref);
3083
3084 if (ref && ref->use != IPA_REF_ALIAS)
3085 return NULL;
3087 return ref;
3088}
3089
3090/* Return true if list contains an alias. */
3091
3092inline bool
3094{
3095 ipa_ref *ref = NULL;
3096
3097 return (iterate_direct_aliases (0, ref) != NULL);
3098}
3099
3100/* Return true when RESOLUTION indicate that linker will use
3101 the symbol from non-LTO object files. */
3102
3103inline bool
3104resolution_used_from_other_file_p (enum ld_plugin_symbol_resolution resolution)
3105{
3106 return (resolution == LDPR_PREVAILING_DEF
3107 || resolution == LDPR_PREEMPTED_REG
3108 || resolution == LDPR_RESOLVED_EXEC
3109 || resolution == LDPR_RESOLVED_DYN);
3110}
3111
3112/* Return true when symtab_node is known to be used from other (non-LTO)
3113 object file. Known only when doing LTO via linker plugin. */
3114
3115inline bool
3117{
3118 if (!TREE_PUBLIC (decl) || DECL_EXTERNAL (decl))
3119 return false;
3120 if (resolution_used_from_other_file_p (resolution))
3121 return true;
3122 return false;
3123}
3124
3125/* Return varpool node for given symbol and check it is a function. */
3126
3127inline varpool_node *
3129{
3132}
3133
3134/* Register a symbol NODE. */
3135
3136inline void
3138{
3139 node->next = nodes;
3140 node->previous = NULL;
3141
3142 if (nodes)
3143 nodes->previous = node;
3144 nodes = node;
3145
3146 nodes->m_uid = cgraph_max_uid++;
3147
3148 if (node->order == -1)
3149 node->order = order++;
3150}
3151
3152/* Register a top-level asm statement ASM_STR. */
3153
3154asm_node *
3156{
3157 asm_node *node;
3158
3159 node = new (ggc_cleared_alloc<asm_node> ()) asm_node (asm_str);
3160 node->order = order++;
3161
3162 if (asmnodes == NULL)
3163 asmnodes = node;
3164 else
3165 asm_last_node->next = node;
3168 return node;
3169}
3170
3171/* Unregister a symbol NODE. */
3172inline void
3174{
3175 if (node->previous)
3176 node->previous->next = node->next;
3177 else
3178 nodes = safe_as_a<symtab_node *>(node->next);
3179
3180 if (node->next)
3181 node->next->previous = node->previous;
3182
3183 node->next = NULL;
3184 node->previous = NULL;
3185}
3186
3187/* Release a callgraph NODE with UID and put in to the list of free nodes. */
3188
3189inline void
3191{
3192 cgraph_count--;
3193 if (node->m_summary_id != -1)
3194 cgraph_released_summary_ids.safe_push (node->m_summary_id);
3195 ggc_free (node);
3196}
3197
3198/* Return first static symbol with definition. */
3201{
3202 return nodes;
3203}
3204
3205/* Walk all symbols. */
3206#define FOR_EACH_SYMBOL(node) \
3207 for ((node) = symtab->first_symbol (); (node); \
3208 (node) = safe_as_a<symtab_node *>((node)->next))
3209
3210/* Return first static symbol with definition. */
3211inline symtab_node *
3213{
3215
3216 for (node = nodes; node;
3218 if (node->definition)
3219 return node;
3220
3221 return NULL;
3222}
3223
3224/* Walk all symbols with definitions in current unit. */
3225#define FOR_EACH_DEFINED_SYMBOL(node) \
3226 for ((node) = symtab->first_defined_symbol (); (node); \
3227 (node) = node->next_defined_symbol ())
3228
3229/* Return first variable. */
3230inline varpool_node *
3232{
3234 for (node = nodes; node; node = safe_as_a<symtab_node *>(node->next))
3236 return vnode;
3237 return NULL;
3238}
3239
3240/* Return next variable after NODE. */
3241inline varpool_node *
3243{
3245 for (; node1; node1 = safe_as_a<symtab_node *>(node1->next))
3246 if (varpool_node *vnode1 = dyn_cast <varpool_node *> (node1))
3247 return vnode1;
3248 return NULL;
3249}
3250/* Walk all variables. */
3251#define FOR_EACH_VARIABLE(node) \
3252 for ((node) = symtab->first_variable (); \
3253 (node); \
3254 (node) = symtab->next_variable ((node)))
3255
3256/* Return first static variable with initializer. */
3257inline varpool_node *
3259{
3261 for (node = nodes; node; node = safe_as_a<symtab_node *>(node->next))
3262 {
3264 if (vnode && DECL_INITIAL (node->decl))
3265 return vnode;
3266 }
3267 return NULL;
3268}
3269
3270/* Return next static variable with initializer after NODE. */
3271inline varpool_node *
3272symbol_table::next_static_initializer (varpool_node *node)
3273{
3274 symtab_node *node1 = safe_as_a<symtab_node *>(node->next);
3275 for (; node1; node1 = safe_as_a<symtab_node *>(node1->next))
3276 {
3277 varpool_node *vnode1 = dyn_cast <varpool_node *> (node1);
3278 if (vnode1 && DECL_INITIAL (node1->decl))
3279 return vnode1;
3280 }
3281 return NULL;
3282}
3283
3284/* Walk all static variables with initializer set. */
3285#define FOR_EACH_STATIC_INITIALIZER(node) \
3286 for ((node) = symtab->first_static_initializer (); (node); \
3287 (node) = symtab->next_static_initializer (node))
3288
3289/* Return first static variable with definition. */
3290inline varpool_node *
3292{
3294 for (node = nodes; node; node = safe_as_a<symtab_node *>(node->next))
3295 {
3297 if (vnode && vnode->definition)
3298 return vnode;
3299 }
3300 return NULL;
3301}
3302
3303/* Return next static variable with definition after NODE. */
3304inline varpool_node *
3305symbol_table::next_defined_variable (varpool_node *node)
3306{
3307 symtab_node *node1 = safe_as_a<symtab_node *>(node->next);
3308 for (; node1; node1 = safe_as_a<symtab_node *>(node1->next))
3309 {
3311 if (vnode1 && vnode1->definition)
3312 return vnode1;
3313 }
3314 return NULL;
3315}
3316/* Walk all variables with definitions in current unit. */
3317#define FOR_EACH_DEFINED_VARIABLE(node) \
3318 for ((node) = symtab->first_defined_variable (); (node); \
3319 (node) = symtab->next_defined_variable (node))
3320
3321/* Return first function with body defined. */
3322inline cgraph_node *
3324{
3326 for (node = nodes; node; node = safe_as_a<symtab_node *>(node->next))
3327 {
3329 if (cn && cn->definition)
3330 return cn;
3331 }
3332 return NULL;
3333}
3334
3335/* Return next function with body defined after NODE. */
3336inline cgraph_node *
3337symbol_table::next_defined_function (cgraph_node *node)
3338{
3339 symtab_node *node1 = safe_as_a<symtab_node *>(node->next);
3340 for (; node1; node1 = safe_as_a<symtab_node *>(node1->next))
3341 {
3342 cgraph_node *cn1 = dyn_cast <cgraph_node *> (node1);
3343 if (cn1 && cn1->definition)
3344 return cn1;
3345 }
3346 return NULL;
3347}
3348
3349/* Walk all functions with body defined. */
3350#define FOR_EACH_DEFINED_FUNCTION(node) \
3351 for ((node) = symtab->first_defined_function (); (node); \
3352 (node) = symtab->next_defined_function ((node)))
3353
3354/* Return first function. */
3355inline cgraph_node *
3357{
3359 for (node = nodes; node; node = safe_as_a<symtab_node *>(node->next))
3361 return cn;
3362 return NULL;
3363}
3364
3365/* Return next function. */
3366inline cgraph_node *
3368{
3370 for (; node1; node1 = safe_as_a<symtab_node *>(node1->next))
3372 return cn1;
3373 return NULL;
3374}
3375
3376/* Return first function with body defined. */
3377inline cgraph_node *
3379{
3381 for (node = nodes; node; node = safe_as_a<symtab_node *>(node->next))
3382 {
3384 if (cn && cn->has_gimple_body_p ())
3385 return cn;
3386 }
3387 return NULL;
3388}
3389
3390/* Return next reachable static variable with initializer after NODE. */
3391inline cgraph_node *
3393{
3394 symtab_node *node1 = safe_as_a<symtab_node *>(node->next);
3395 for (; node1; node1 = safe_as_a<symtab_node *>(node1->next))
3396 {
3397 cgraph_node *cn1 = dyn_cast <cgraph_node *> (node1);
3398 if (cn1 && cn1->has_gimple_body_p ())
3399 return cn1;
3400 }
3401 return NULL;
3402}
3404/* Walk all functions. */
3405#define FOR_EACH_FUNCTION(node) \
3406 for ((node) = symtab->first_function (); (node); \
3407 (node) = symtab->next_function ((node)))
3408
3409/* Walk all functions but precompute so a node can be deleted if needed. */
3410#define FOR_EACH_FUNCTION_REMOVABLE(node) \
3411 cgraph_node *next; \
3412 for ((node) = symtab->first_function (), \
3413 next = (node) ? symtab->next_function ((node)) : NULL; (node); \
3414 (node) = next, next = (node) ? symtab->next_function ((node)) : NULL)
3415
3416/* Return true when callgraph node is a function with Gimple body defined
3417 in current unit. Functions can also be define externally or they
3418 can be thunks with no Gimple representation.
3419
3420 Note that at WPA stage, the function body may not be present in memory. */
3421
3422inline bool
3424{
3425 return definition && !thunk && !alias;
3426}
3427
3428/* Walk all functions with body defined. */
3429#define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \
3430 for ((node) = symtab->first_function_with_gimple_body (); (node); \
3431 (node) = symtab->next_function_with_gimple_body (node))
3433/* Uniquize all constants that appear in memory.
3434 Each constant in memory thus far output is recorded
3435 in `const_desc_table'. */
3436
3437struct GTY((for_user)) constant_descriptor_tree {
3438 /* A MEM for the constant. */
3439 rtx rtl;
3441 /* The value of the constant. */
3442 tree value;
3443
3444 /* Hash of value. Computing the hash from value each time
3445 hashfn is called can't work properly, as that means recursive
3446 use of the hash table during hash table expansion. */
3447 hashval_t hash;
3449
3450/* Return true when function is only called directly or it has alias.
3451 i.e. it is not externally visible, address was not taken and
3452 it is not used in any other non-standard way. */
3453
3454inline bool
3456{
3457 gcc_assert (!inlined_to);
3458 return (!force_output && !address_taken
3459 && !ref_by_asm
3460 && !ifunc_resolver
3461 && !used_from_other_partition
3462 && !DECL_VIRTUAL_P (decl)
3465 && !used_from_object_file_p ()
3467}
3468
3469/* Return true when function can be removed from callgraph
3470 if all direct calls are eliminated. */
3471
3472inline bool
3474{
3475 gcc_checking_assert (!inlined_to);
3476 /* Extern inlines can always go, we will use the external definition. */
3477 if (DECL_EXTERNAL (decl))
3478 return true;
3479 /* When function is needed, we cannot remove it. */
3480 if (force_output || used_from_other_partition || ref_by_asm)
3481 return false;
3484 return false;
3485 /* Only COMDAT functions can be removed if externally visible. */
3486 if (externally_visible
3487 && ((!DECL_COMDAT (decl) || ifunc_resolver)
3488 || forced_by_abi
3489 || used_from_object_file_p ()))
3490 return false;
3491 return true;
3492}
3493
3494/* Verify cgraph, if consistency checking is enabled. */
3495
3496inline void
3498{
3499 if (flag_checking)
3501}
3502
3503/* Return true when variable can be removed from variable pool
3504 if all direct calls are eliminated. */
3505
3506inline bool
3508{
3509 if (DECL_EXTERNAL (decl))
3510 return true;
3511 return (!force_output && !used_from_other_partition
3512 && !ref_by_asm
3513 && ((DECL_COMDAT (decl)
3514 && !forced_by_abi
3515 && !used_from_object_file_p ())
3516 || !externally_visible
3518}
3520/* Return true when all references to variable must be visible in ipa_ref_list.
3521 i.e. if the variable is not externally visible or not used in some magic
3522 way (asm statement or such).
3523 The magic uses are all summarized in force_output flag. */
3524
3525inline bool
3527{
3528 return (definition
3529 && !externally_visible
3530 && !used_from_other_partition
3531 && !ref_by_asm
3532 && !force_output);
3533}
3534
3535struct tree_descriptor_hasher : ggc_ptr_hash<constant_descriptor_tree>
3536{
3537 static hashval_t hash (constant_descriptor_tree *);
3538 static bool equal (constant_descriptor_tree *, constant_descriptor_tree *);
3539};
3541/* Constant pool accessor function. */
3543
3544/* Return node that alias is aliasing. */
3545
3546inline cgraph_node *
3552/* Return node that alias is aliasing. */
3553
3554inline varpool_node *
3556{
3558}
3559
3560/* Walk the alias chain to return the symbol NODE is alias of.
3561 If NODE is not an alias, return NODE.
3562 When AVAILABILITY is non-NULL, get minimal availability in the chain.
3563 When REF is non-NULL, assume that reference happens in symbol REF
3564 when determining the availability. */
3565
3566inline symtab_node *
3568 symtab_node *ref)
3569{
3570 if (!alias)
3571 {
3572 if (availability)
3574 return this;
3575 }
3576
3578}
3579
3580/* Given function symbol, walk the alias chain to return the function node
3581 is alias of. Do not walk through thunks.
3582 When AVAILABILITY is non-NULL, get minimal availability in the chain.
3583 When REF is non-NULL, assume that reference happens in symbol REF
3584 when determining the availability. */
3585
3586inline cgraph_node *
3588 symtab_node *ref)
3589{
3592 if (!n && availability)
3594 return n;
3595}
3596
3597/* For given variable pool node, walk the alias chain to return the function
3598 the variable is alias of. Do not walk through thunks.
3599 When AVAILABILITY is non-NULL, get minimal availability in the chain.
3600 When REF is non-NULL, assume that reference happens in symbol REF
3601 when determining the availability. */
3602
3603inline varpool_node *
3605 symtab_node *ref)
3606{
3609
3610 if (!n && availability)
3612 return n;
3613}
3614
3615/* Set callee N of call graph edge and add it to the corresponding set of
3616 callers. */
3617
3618inline void
3620{
3621 prev_caller = NULL;
3622 if (n->callers)
3623 n->callers->prev_caller = this;
3624 next_caller = n->callers;
3625 n->callers = this;
3626 callee = n;
3627}
3628
3629/* Return true when the edge represents a direct recursion. */
3630
3631inline bool
3633{
3634 cgraph_node *c = callee->ultimate_alias_target ();
3635 if (caller->inlined_to)
3636 return caller->inlined_to->decl == c->decl;
3637 else
3638 return caller->decl == c->decl;
3639}
3640
3641/* Remove the edge from the list of the callers of the callee. */
3642
3643inline void
3645{
3646 gcc_assert (!indirect_unknown_callee);
3647 if (prev_caller)
3648 prev_caller->next_caller = next_caller;
3649 if (next_caller)
3650 next_caller->prev_caller = prev_caller;
3652 callee->callers = next_caller;
3653}
3654
3655/* Return true if call must bind to current definition. */
3656
3657inline bool
3659{
3660 if (callee)
3661 return callee->binds_to_current_def_p (caller);
3662 else
3663 return false;
3665
3666/* Expected frequency of executions within the function.
3667 When set to CGRAPH_FREQ_BASE, the edge is expected to be called once
3668 per function call. The range is 0 to CGRAPH_FREQ_MAX. */
3669
3670inline int
3672{
3673 return count.to_cgraph_frequency (caller->inlined_to
3675 : caller->count);
3676}
3677
3678
3679/* Return true if the TM_CLONE bit is set for a given FNDECL. */
3680inline bool
3682{
3683 cgraph_node *n = cgraph_node::get (fndecl);
3684 if (n)
3685 return n->tm_clone;
3686 return false;
3687}
3688
3689/* Likewise indicate that a node is needed, i.e. reachable via some
3690 external means. */
3691
3692inline void
3694{
3697}
3698
3699/* Return true if function should be optimized for size. */
3700
3701inline enum optimize_size_level
3703{
3704 if (opt_for_fn (decl, optimize_size))
3705 return OPTIMIZE_SIZE_MAX;
3706 if (count == profile_count::zero ())
3707 return OPTIMIZE_SIZE_MAX;
3710 else
3712}
3713
3714/* Return symtab_node for NODE or create one if it is not present
3715 in symtab. */
3716
3717inline symtab_node *
3719{
3720 if (VAR_P (node))
3722 else
3724}
3725
3726/* Return availability of NODE when referenced from REF. */
3727
3728inline enum availability
3730{
3731 if (is_a <cgraph_node *> (this))
3732 return dyn_cast <cgraph_node *> (this)->get_availability (ref);
3733 else
3734 return dyn_cast <varpool_node *> (this)->get_availability (ref);
3735}
3736
3737/* Call callback on symtab node and aliases associated to this node.
3738 When INCLUDE_OVERWRITABLE is false, overwritable symbols are skipped. */
3739
3740inline bool
3742 void *),
3743 void *data,
3744 bool include_overwritable)
3745{
3746 if (include_overwritable
3747 || get_availability () > AVAIL_INTERPOSABLE)
3748 {
3749 if (callback (this, data))
3750 return true;
3751 }
3752 if (has_aliases_p ())
3753 return call_for_symbol_and_aliases_1 (callback, data, include_overwritable);
3754 return false;
3756
3757/* Call callback on function and aliases associated to the function.
3758 When INCLUDE_OVERWRITABLE is false, overwritable symbols are
3759 skipped. */
3760
3761inline bool
3763 void *),
3764 void *data,
3765 bool include_overwritable)
3766{
3767 if (include_overwritable
3768 || get_availability () > AVAIL_INTERPOSABLE)
3769 {
3770 if (callback (this, data))
3771 return true;
3772 }
3773 if (has_aliases_p ())
3774 return call_for_symbol_and_aliases_1 (callback, data, include_overwritable);
3775 return false;
3777
3778/* Call callback on varpool symbol and aliases associated to varpool symbol.
3779 When INCLUDE_OVERWRITABLE is false, overwritable symbols are
3780 skipped. */
3781
3782inline bool
3784 void *),
3785 void *data,
3786 bool include_overwritable)
3787{
3788 if (include_overwritable
3789 || get_availability () > AVAIL_INTERPOSABLE)
3790 {
3791 if (callback (this, data))
3792 return true;
3793 }
3794 if (has_aliases_p ())
3795 return call_for_symbol_and_aliases_1 (callback, data, include_overwritable);
3796 return false;
3797}
3798
3799/* Return true if reference may be used in address compare. */
3800
3801inline bool
3803{
3804 if (use != IPA_REF_ADDR)
3805 return false;
3806 /* Addresses taken from virtual tables are never compared. */
3807 if (is_a <varpool_node *> (referring)
3808 && DECL_VIRTUAL_P (referring->decl))
3809 return false;
3810 return referred->address_can_be_compared_p ();
3811}
3812
3813/* Build polymorphic call context for indirect call E. */
3814
3815inline
3817{
3820 *this = pii->context;
3821}
3822
3823/* Build empty "I know nothing" context. */
3824
3825inline
3827{
3828 clear_speculation ();
3830 invalid = false;
3831}
3832
3833/* Make context non-speculative. */
3834
3835inline void
3837{
3838 speculative_outer_type = NULL;
3839 speculative_offset = 0;
3841}
3842
3843/* Produce context specifying all derived types of OTR_TYPE. If OTR_TYPE is
3844 NULL, the context is set to dummy "I know nothing" setting. */
3845
3846inline void
3848{
3849 outer_type = otr_type ? TYPE_MAIN_VARIANT (otr_type) : NULL;
3850 offset = 0;
3851 maybe_derived_type = true;
3853 dynamic = true;
3854}
3855
3856/* Adjust all offsets in contexts by OFF bits. */
3857
3858inline void
3860{
3861 if (outer_type)
3862 offset += off;
3864 speculative_offset += off;
3865}
3866
3867/* Return TRUE if context is fully useless. */
3868
3869inline bool
3871{
3872 return (!outer_type && !speculative_outer_type);
3873}
3874
3875/* When using fprintf (or similar), problems can arise with
3876 transient generated strings. Many string-generation APIs
3877 only support one result being alive at once (e.g. by
3878 returning a pointer to a statically-allocated buffer).
3879
3880 If there is more than one generated string within one
3881 fprintf call: the first string gets evicted or overwritten
3882 by the second, before fprintf is fully evaluated.
3883 See e.g. PR/53136.
3884
3885 This function provides a workaround for this, by providing
3886 a simple way to create copies of these transient strings,
3887 without the need to have explicit cleanup:
3888
3889 fprintf (dumpfile, "string 1: %s string 2:%s\n",
3890 xstrdup_for_dump (EXPR_1),
3891 xstrdup_for_dump (EXPR_2));
3892
3893 This is actually a simple wrapper around ggc_strdup, but
3894 the name documents the intent. We require that no GC can occur
3895 within the fprintf call. */
3896
3897inline const char *
3898xstrdup_for_dump (const char *transient_str)
3900 return ggc_strdup (transient_str);
3901}
3902
3903/* During LTO stream-in this predicate can be used to check whether node
3904 in question prevails in the linking to save some memory usage. */
3905inline bool
3907{
3908 return definition && ((!TREE_PUBLIC (decl) && !DECL_EXTERNAL (decl))
3909 || previous_sharing_asm_name == NULL);
3910}
3911
3912extern GTY(()) symbol_table *saved_symtab;
3913
3914#if CHECKING_P
3915
3916namespace selftest {
3917
3918/* An RAII-style class for use in selftests for temporarily using a different
3919 symbol_table, so that such tests can be isolated from each other. */
3920
3921class symbol_table_test
3922{
3923 public:
3924 /* Constructor. Override "symtab". */
3925 symbol_table_test ();
3926
3927 /* Destructor. Restore the saved_symtab. */
3928 ~symbol_table_test ();
3929};
3930
3931} // namespace selftest
3932
3933#endif /* CHECKING_P */
3934
3935#endif /* GCC_CGRAPH_H */
void analyze_toplevel_extended_asm()
Definition asm-toplevel.cc:97
gcov_type apply_scale(gcov_type freq, gcov_type scale)
Definition basic-block.h:573
state
Definition cfgbuild.cc:168
void cgraph_update_edges_for_call_stmt(gimple *old_stmt, tree old_decl, gimple *new_stmt)
Definition cgraph.cc:2083
bool cgraph_function_possibly_inlined_p(tree decl)
Definition cgraph.cc:2781
symbol_table * symtab
Definition cgraph.cc:82
cgraph_inline_failed_type_t cgraph_inline_failed_type(cgraph_inline_failed_t reason)
Definition cgraph.cc:2451
const char *const cgraph_availability_names[]
Definition cgraph.cc:2467
void release_function_body(tree decl)
Definition cgraph.cc:2187
symbol_table * saved_symtab
Definition cgraph.cc:4867
void cgraph_cc_finalize(void)
Definition cgraph.cc:4716
const char * cgraph_inline_failed_string(cgraph_inline_failed_t reason)
Definition cgraph.cc:2433
symtab_state
Definition cgraph.h:2506
@ LTO_STREAMING
Definition cgraph.h:2512
@ IPA
Definition cgraph.h:2514
@ PARSING
Definition cgraph.h:2508
@ EXPANSION
Definition cgraph.h:2521
@ IPA_SSA_AFTER_INLINING
Definition cgraph.h:2519
@ FINISHED
Definition cgraph.h:2523
@ IPA_SSA
Definition cgraph.h:2516
@ CONSTRUCTION
Definition cgraph.h:2510
const char * cgraph_inline_failed_string(cgraph_inline_failed_t)
Definition cgraph.cc:2433
void(* cgraph_edge_hook)(cgraph_edge *, void *)
Definition cgraph.h:2487
const char * xstrdup_for_dump(const char *transient_str)
Definition cgraph.h:3891
void debuginfo_early_stop(void)
Definition cgraphunit.cc:2554
cgraph_indirect_info_kind
Definition cgraph.h:1724
@ CIIK_UNSPECIFIED
Definition cgraph.h:1728
@ CIIK_N_KINDS
Definition cgraph.h:1735
@ CIIK_POLYMORPHIC
Definition cgraph.h:1733
@ CIIK_SIMPLE
Definition cgraph.h:1730
void debuginfo_start(void)
Definition cgraphunit.cc:2530
void(* cgraph_node_hook)(cgraph_node *, void *)
Definition cgraph.h:2488
tree ctor_for_folding(tree)
Definition varpool.cc:397
struct varpool_node_set_def * varpool_node_set
Definition cgraph.h:1594
cgraph_inline_failed_type_t cgraph_inline_failed_type(cgraph_inline_failed_t)
Definition cgraph.cc:2451
bool ipa_discover_variable_flags(void)
Definition ipa.cc:791
void symtab_thunks_cc_finalize(void)
Definition symtab-thunks.cc:663
void release_function_body(tree)
Definition cgraph.cc:2187
void(* cgraph_2node_hook)(cgraph_node *, cgraph_node *, void *)
Definition cgraph.h:2491
int compute_call_stmt_bb_frequency(tree, basic_block bb)
Definition cgraphbuild.cc:203
void debuginfo_early_init(void)
Definition cgraphunit.cc:2490
cgraph_inline_failed_type_t
Definition cgraph.h:900
@ CIF_FINAL_NORMAL
Definition cgraph.h:901
@ CIF_FINAL_ERROR
Definition cgraph.h:902
void set_new_clone_decl_and_node_flags(cgraph_node *new_node)
Definition cgraphclones.cc:180
bool speculation_useful_p(struct cgraph_edge *e, bool anticipate_inlining)
Definition ipa-inline.cc:1965
bool cgraph_function_possibly_inlined_p(tree)
Definition cgraph.cc:2781
symbol_table * symtab
Definition cgraph.cc:82
void debuginfo_stop(void)
Definition cgraphunit.cc:2538
void record_references_in_initializer(tree, bool)
Definition cgraphbuild.cc:408
cgraph_node_set_def * cgraph_node_set
Definition cgraph.h:1593
basic_block init_lowered_empty_function(tree, bool, profile_count)
Definition cgraphunit.cc:1738
tree clone_function_name_numbered(const char *name, const char *suffix)
Definition cgraphclones.cc:526
void tree_function_versioning(tree, tree, vec< ipa_replace_map *, va_gc > *, ipa_param_adjustments *, bool, bitmap, basic_block)
Definition tree-inline.cc:6329
hash_table< tree_descriptor_hasher > * constant_pool_htab(void)
Definition varasm.cc:3359
void(* cgraph_2edge_hook)(cgraph_edge *, cgraph_edge *, void *)
Definition cgraph.h:2490
void dump_callgraph_transformation(const cgraph_node *original, const cgraph_node *clone, const char *suffix)
Definition cgraphclones.cc:339
bool usable_polymorphic_info_p(cgraph_indirect_call_info *ii)
Definition cgraph.h:1864
bool decl_is_tm_clone(const_tree fndecl)
Definition cgraph.h:3674
void cgraphunit_cc_finalize(void)
Definition cgraphunit.cc:2635
tree clone_function_name(const char *name, const char *suffix, unsigned long number)
Definition cgraphclones.cc:557
void cgraph_build_static_cdtor(char which, tree body, int priority)
Definition ipa.cc:944
availability
Definition cgraph.h:74
@ AVAIL_UNSET
Definition cgraph.h:76
@ AVAIL_LOCAL
Definition cgraph.h:92
@ AVAIL_NOT_AVAILABLE
Definition cgraph.h:78
@ AVAIL_INTERPOSABLE
Definition cgraph.h:84
@ AVAIL_AVAILABLE
Definition cgraph.h:87
void debuginfo_early_start(void)
Definition cgraphunit.cc:2546
int tp_first_run_node_cmp(const void *pa, const void *pb)
Definition cgraphunit.cc:1955
void debuginfo_fini(void)
Definition cgraphunit.cc:2519
symbol_partitioning_class
Definition cgraph.h:97
@ SYMBOL_EXTERNAL
Definition cgraph.h:100
@ SYMBOL_PARTITION
Definition cgraph.h:102
@ SYMBOL_DUPLICATE
Definition cgraph.h:105
tree thunk_adjust(gimple_stmt_iterator *, tree, bool, HOST_WIDE_INT, tree, HOST_WIDE_INT)
Definition symtab-thunks.cc:190
void initialize_inline_failed(struct cgraph_edge *)
Definition ipa-inline-analysis.cc:104
tree clone_identifier(tree decl, const char *suffix, bool filter_suffix=false)
Definition cgraphclones.cc:618
bool decl_in_symtab_p(const_tree decl)
Definition cgraph.h:2988
ipa_opt_pass_d * ipa_opt_pass
Definition cgraph.h:38
void cgraph_update_edges_for_call_stmt(gimple *, tree, gimple *)
Definition cgraph.cc:2083
function_summary< thunk_info * > thunk_summary
Definition cgraph.h:2538
void analyze_toplevel_extended_asm(void)
Definition asm-toplevel.cc:97
toplevel_type
Definition cgraph.h:45
@ TOPLEVEL_MAX
Definition cgraph.h:51
@ TOPLEVEL_ASM
Definition cgraph.h:47
@ TOPLEVEL_BASE
Definition cgraph.h:46
@ SYMTAB_FUNCTION
Definition cgraph.h:49
@ SYMTAB_SYMBOL
Definition cgraph.h:48
@ SYMTAB_VARIABLE
Definition cgraph.h:50
const char *const ld_plugin_symbol_resolution_names[]
Definition symtab.cc:45
const char *const tls_model_names[]
Definition varpool.cc:40
cgraph_simd_clone_arg_type
Definition cgraph.h:759
@ SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP
Definition cgraph.h:763
@ SIMD_CLONE_ARG_TYPE_LINEAR_REF_VARIABLE_STEP
Definition cgraph.h:768
@ SIMD_CLONE_ARG_TYPE_LINEAR_VAL_VARIABLE_STEP
Definition cgraph.h:772
@ SIMD_CLONE_ARG_TYPE_VECTOR
Definition cgraph.h:760
@ SIMD_CLONE_ARG_TYPE_LINEAR_UVAL_VARIABLE_STEP
Definition cgraph.h:770
@ SIMD_CLONE_ARG_TYPE_LINEAR_UVAL_CONSTANT_STEP
Definition cgraph.h:769
@ SIMD_CLONE_ARG_TYPE_LINEAR_VARIABLE_STEP
Definition cgraph.h:764
@ SIMD_CLONE_ARG_TYPE_MASK
Definition cgraph.h:773
@ SIMD_CLONE_ARG_TYPE_UNIFORM
Definition cgraph.h:761
@ SIMD_CLONE_ARG_TYPE_LINEAR_REF_CONSTANT_STEP
Definition cgraph.h:767
@ SIMD_CLONE_ARG_TYPE_LINEAR_VAL_CONSTANT_STEP
Definition cgraph.h:771
void(* varpool_node_hook)(varpool_node *, void *)
Definition cgraph.h:2489
function_summary< clone_info * > clone_summary
Definition cgraph.h:2542
vec< cgraph_node * > cgraph_new_nodes
Definition cgraphunit.cc:217
void cgraph_cc_finalize(void)
Definition cgraph.cc:4716
cgraph_inline_failed_t
Definition cgraph.h:894
void debuginfo_init(void)
Definition cgraphunit.cc:2506
bool resolution_used_from_other_file_p(enum ld_plugin_symbol_resolution resolution)
Definition cgraph.h:3097
Definition cgraph.h:1872
ipa_ref * speculative_call_target_ref()
Definition cgraph.h:2009
void purge_callback_edges()
Definition cgraph.cc:1450
cgraph_edge * speculative_call_indirect_edge()
Definition cgraph.h:1987
unsigned int indirect_inlining_edge
Definition cgraph.h:2138
void remove_caller(void)
Definition cgraph.cc:1216
profile_count count
Definition cgraph.h:2116
cgraph_node * callee
Definition cgraph.h:2118
void dump_edge_flags(FILE *f)
Definition cgraph.cc:2473
static cgraph_edge * make_direct(cgraph_edge *edge, cgraph_node *callee)
Definition cgraph.cc:1621
bool binds_to_current_def_p()
Definition cgraph.h:3651
unsigned int callback
Definition cgraph.h:2172
cgraph_edge * prev_caller
Definition cgraph.h:2119
cgraph_edge * next_caller
Definition cgraph.h:2120
unsigned int can_throw_external
Definition cgraph.h:2146
static cgraph_edge * resolve_speculation(cgraph_edge *edge, tree callee_decl=NULL)
Definition cgraph.cc:1533
int m_summary_id
Definition cgraph.h:2205
int m_uid
Definition cgraph.h:2202
void redirect_callee(cgraph_node *n)
Definition cgraph.cc:1695
unsigned in_polymorphic_cdtor
Definition cgraph.h:2184
cgraph_edge * next_speculative_call_target()
Definition cgraph.h:1973
sreal sreal_frequency()
Definition cgraph.cc:4764
unsigned int speculative_id
Definition cgraph.h:2136
cgraph_indirect_call_info * indirect_info
Definition cgraph.h:2126
static unsigned int rebuild_edges(void)
Definition cgraphbuild.cc:424
cgraph_edge * make_speculative(cgraph_node *n2, profile_count direct_count, unsigned int speculative_id=0)
Definition cgraph.cc:1317
static void rebuild_references(void)
Definition cgraphbuild.cc:469
friend class symbol_table
Definition cgraph.h:1875
unsigned int call_stmt_cannot_inline_p
Definition cgraph.h:2144
int get_summary_id()
Definition cgraph.h:2095
int num_speculative_call_targets_p(void)
Definition cgraph.cc:4829
void set_callee(cgraph_node *n)
Definition cgraph.h:3612
bool maybe_hot_p()
Definition cgraph.cc:3474
cgraph_edge * get_callback_carrying_edge()
Definition cgraph.cc:1397
unsigned int lto_stmt_uid
Definition cgraph.h:2133
void DEBUG_FUNCTION debug(void)
Definition cgraph.cc:2501
bool possibly_call_in_translation_unit_p(void)
Definition cgraph.cc:4795
cgraph_edge * speculative_call_for_target(cgraph_node *)
Definition cgraph.cc:1604
cgraph_node * caller
Definition cgraph.h:2117
enum cgraph_inline_failed_t inline_failed
Definition cgraph.h:2130
unsigned int speculative
Definition cgraph.h:2164
void remove_callee(void)
Definition cgraph.h:3637
static void remove(cgraph_edge *edge)
Definition cgraph.cc:1252
cgraph_edge * first_callback_edge()
Definition cgraph.cc:1415
static gimple * redirect_call_stmt_to_callee(cgraph_edge *e, hash_set< tree > *killed_ssas=nullptr)
Definition cgraph.cc:1758
bool verify_count()
Definition cgraph.cc:3729
unsigned int indirect_unknown_callee
Definition cgraph.h:2141
int get_uid()
Definition cgraph.h:2089
bool cannot_lead_to_return_p(void)
Definition cgraph.cc:3387
unsigned int callback_id
Definition cgraph.h:2181
cgraph_edge * clone(cgraph_node *n, gcall *call_stmt, unsigned stmt_uid, profile_count num, profile_count den, bool update_original)
Definition cgraphclones.cc:98
cgraph_edge * next_callback_edge()
Definition cgraph.cc:1433
cgraph_edge * make_callback(cgraph_node *n2, unsigned int callback_hash)
Definition cgraph.cc:1365
sreal combined_sreal_frequency()
Definition cgraph.cc:4775
bool recursive_p(void)
Definition cgraph.h:3625
int frequency()
Definition cgraph.h:3664
unsigned int has_callback
Definition cgraph.h:2177
cgraph_edge * first_speculative_call_target()
Definition cgraph.cc:1469
cgraph_edge * next_callee
Definition cgraph.h:2122
int get_next_speculative_id()
Definition cgraph.cc:1273
void * aux
Definition cgraph.h:2127
static cgraph_edge * set_call_stmt(cgraph_edge *e, gcall *new_stmt, bool update_derived_edges=true)
Definition cgraph.cc:962
gcall * call_stmt
Definition cgraph.h:2123
bool verify_corresponds_to_fndecl(tree decl)
Definition cgraph.cc:3763
friend struct cgraph_node
Definition cgraph.h:1874
cgraph_edge * prev_callee
Definition cgraph.h:2121
void redirect_callee_duplicating_thunks(cgraph_node *n)
Definition cgraphclones.cc:295
Definition cgraph.h:1743
cgraph_indirect_call_info(int flags)
Definition cgraph.h:1745
void DEBUG_FUNCTION debug() const
Definition cgraph.cc:2773
int ecf_flags
Definition cgraph.h:1758
cgraph_indirect_call_info(enum cgraph_indirect_info_kind k, int flags)
Definition cgraph.h:1748
int param_index
Definition cgraph.h:1761
void dump(FILE *f, bool newline=true) const
Definition cgraph.cc:2731
enum cgraph_indirect_info_kind kind
Definition cgraph.h:1764
unsigned num_speculative_call_targets
Definition cgraph.h:1766
Definition cgraph.h:1816
bool mark_unusable()
Definition cgraph.h:1839
cgraph_polymorphic_indirect_info(int flags)
Definition cgraph.h:1818
bool usable_p() const
Definition cgraph.h:1833
ipa_polymorphic_call_context context
Definition cgraph.h:1847
HOST_WIDE_INT otr_token
Definition cgraph.h:1849
tree otr_type
Definition cgraph.h:1851
unsigned vptr_changed
Definition cgraph.h:1858
cgraph_polymorphic_indirect_info(int flags, const ipa_polymorphic_call_context &ctx, HOST_WIDE_INT token, tree type)
Definition cgraph.h:1822
HOST_WIDE_INT offset
Definition cgraph.h:1854
HOST_WIDE_INT offset
Definition cgraph.h:1784
unsigned by_ref
Definition cgraph.h:1803
unsigned member_ptr
Definition cgraph.h:1797
unsigned fld_offset
Definition cgraph.h:1791
unsigned guaranteed_unmodified
Definition cgraph.h:1808
unsigned agg_contents
Definition cgraph.h:1795
cgraph_simple_indirect_info(int flags)
Definition cgraph.h:1775
unsigned fnptr_loaded_from_record
Definition cgraph.h:1800
tree rec_type
Definition cgraph.h:1787
Definition lto-streamer.h:756
Definition genoutput.cc:150
Definition symbol-summary.h:163
Definition hash-map.h:40
Definition hash-set.h:37
Definition hash-table.h:375
Definition tree-pass.h:142
Definition ipa-param-manipulation.h:211
Definition cgraph.h:1624
void dump(FILE *f, bool newline=true) const
Definition ipa-polymorphic-call.cc:618
bool combine_speculation_with(tree, HOST_WIDE_INT, bool, tree)
Definition ipa-polymorphic-call.cc:1916
void offset_by(HOST_WIDE_INT)
Definition cgraph.h:3852
bool speculation_consistent_p(tree, HOST_WIDE_INT, bool, tree) const
Definition ipa-polymorphic-call.cc:1858
tree outer_type
Definition cgraph.h:1631
unsigned invalid
Definition cgraph.h:1642
unsigned speculative_maybe_derived_type
Definition cgraph.h:1639
HOST_WIDE_INT speculative_offset
Definition cgraph.h:1630
void DEBUG_FUNCTION debug() const
Definition ipa-polymorphic-call.cc:657
unsigned dynamic
Definition cgraph.h:1644
void clear_speculation()
Definition cgraph.h:3829
void clear_outer_type(tree otr_type=NULL)
Definition cgraph.h:3840
unsigned maybe_in_construction
Definition cgraph.h:1634
bool useless_p() const
Definition cgraph.h:3863
ipa_polymorphic_call_context()
Definition cgraph.h:3819
bool meet_with(ipa_polymorphic_call_context, tree otr_type=NULL)
Definition ipa-polymorphic-call.cc:2440
bool set_by_invariant(tree, tree, HOST_WIDE_INT)
Definition ipa-polymorphic-call.cc:762
tree speculative_outer_type
Definition cgraph.h:1632
void make_speculative(tree otr_type=NULL)
Definition ipa-polymorphic-call.cc:2339
bool equal_to(const ipa_polymorphic_call_context &x) const
Definition ipa-polymorphic-call.cc:2388
HOST_WIDE_INT offset
Definition cgraph.h:1629
void possible_dynamic_type_change(bool, tree otr_type=NULL)
Definition ipa-polymorphic-call.cc:2364
bool get_dynamic_type(tree, tree, tree, gimple *, unsigned *)
Definition ipa-polymorphic-call.cc:1568
void set_by_decl(tree, HOST_WIDE_INT)
Definition ipa-polymorphic-call.cc:733
void stream_in(class lto_input_block *, class data_in *data_in)
Definition ipa-polymorphic-call.cc:695
void stream_out(struct output_block *) const
Definition ipa-polymorphic-call.cc:665
bool restrict_to_inner_class(tree otr_type, bool consider_placement_new=true, bool consider_bases=true)
Definition ipa-polymorphic-call.cc:129
bool meet_speculation_with(tree, HOST_WIDE_INT, bool, tree)
Definition ipa-polymorphic-call.cc:2013
unsigned maybe_derived_type
Definition cgraph.h:1636
bool combine_with(ipa_polymorphic_call_context, tree otr_type=NULL)
Definition ipa-polymorphic-call.cc:2109
Definition lto-streamer.h:338
Definition sreal.h:41
Definition cgraph.h:2545
varpool_node_hook_list * add_varpool_removal_hook(varpool_node_hook hook, void *data)
Definition varpool.cc:53
varpool_node * next_defined_variable(varpool_node *node)
Definition cgraph.h:3298
int order
Definition cgraph.h:2813
varpool_node * first_variable(void)
Definition cgraph.h:3224
cgraph_node * first_defined_function(void)
Definition cgraph.h:3316
void change_decl_assembler_name(tree decl, tree name)
Definition symtab.cc:274
varpool_node * next_static_initializer(varpool_node *node)
Definition cgraph.h:3265
hash_table< asmname_hasher > * assembler_name_hash
Definition cgraph.h:2831
void free_edge(cgraph_edge *e)
Definition cgraph.cc:1238
vec< int > edge_released_summary_ids
Definition cgraph.h:2801
int assign_summary_id(cgraph_edge *edge)
Definition cgraph.h:2775
cgraph_2edge_hook_list * add_edge_duplication_hook(cgraph_2edge_hook hook, void *data)
Definition cgraph.cc:574
static char symbol_suffix_separator()
Definition symtab.cc:2576
void remove_cgraph_duplication_hook(cgraph_2node_hook_list *entry)
Definition cgraph.cc:632
void DEBUG_FUNCTION debug(void)
Definition symtab.cc:1068
varpool_node_hook_list * m_first_varpool_insertion_hook
Definition cgraph.h:2885
static bool decl_assembler_name_equal(tree decl, const_tree asmname)
Definition symtab.cc:142
symbol_table()
Definition cgraph.h:2551
cgraph_edge * create_edge(cgraph_node *caller, cgraph_node *callee, gcall *call_stmt, profile_count count, bool indir_unknown_callee, bool cloning_p)
Definition cgraph.cc:1067
symtab_node * first_defined_symbol(void)
Definition cgraph.h:3205
bool global_info_ready
Definition cgraph.h:2819
void clear_asm_symbols(void)
Definition cgraph.h:2596
bool function_flags_ready
Definition cgraph.h:2823
thunk_summary * m_thunks
Definition cgraph.h:2843
friend struct cgraph_edge
Definition cgraph.h:2549
bool output_variables(void)
Definition varpool.cc:733
void remove_varpool_removal_hook(varpool_node_hook_list *entry)
Definition varpool.cc:70
cgraph_edge_hook_list * m_first_edge_removal_hook
Definition cgraph.h:2875
asm_node * asmnodes
Definition cgraph.h:2807
void call_cgraph_duplication_hooks(cgraph_node *node, cgraph_node *node2)
Definition cgraph.cc:644
friend struct symtab_node
Definition cgraph.h:2547
int edges_count
Definition cgraph.h:2793
void compile(void)
Definition cgraphunit.cc:2343
static bool assembler_names_equal_p(const char *name1, const char *name2)
Definition symtab.cc:104
FILE * ipa_clones_dump_file
Definition cgraph.h:2838
cgraph_node * next_defined_function(cgraph_node *node)
Definition cgraph.h:3330
void remove_varpool_insertion_hook(varpool_node_hook_list *entry)
Definition varpool.cc:111
void call_edge_removal_hooks(cgraph_edge *e)
Definition cgraph.cc:479
asm_node * first_asm_symbol(void)
Definition cgraph.h:2632
void release_symbol(cgraph_node *node)
Definition cgraph.h:3183
cgraph_2node_hook_list * m_first_cgraph_duplicated_hook
Definition cgraph.h:2881
cgraph_node_hook_list * add_cgraph_insertion_hook(cgraph_node_hook hook, void *data)
Definition cgraph.cc:545
cgraph_node * next_function(cgraph_node *node)
Definition cgraph.h:3360
hash_table< section_name_hasher > * section_hash
Definition cgraph.h:2828
void output_weakrefs(void)
Definition cgraphunit.cc:2313
bool remove_unreachable_nodes(FILE *file)
Definition ipa.cc:310
void remove_cgraph_insertion_hook(cgraph_node_hook_list *entry)
Definition cgraph.cc:562
void unregister(symtab_node *node)
Definition cgraph.h:3166
cgraph_2node_hook_list * add_cgraph_duplication_hook(cgraph_2node_hook hook, void *data)
Definition cgraph.cc:615
void process_same_body_aliases(void)
Definition cgraphunit.cc:721
varpool_node_hook_list * m_first_varpool_removal_hook
Definition cgraph.h:2887
cgraph_node_hook_list * add_cgraph_removal_hook(cgraph_node_hook hook, void *data)
Definition cgraph.cc:491
clone_summary * m_clones
Definition cgraph.h:2846
hash_set< const cgraph_node * > cloned_nodes
Definition cgraph.h:2840
void initialize(void)
Definition cgraph.cc:430
cgraph_node * next_function_with_gimple_body(cgraph_node *node)
Definition cgraph.h:3385
int cgraph_max_summary_id
Definition cgraph.h:2791
void call_cgraph_insertion_hooks(cgraph_node *node)
Definition cgraph.cc:532
FILE * dump_file
Definition cgraph.h:2836
static hashval_t decl_assembler_name_hash(const_tree asmname)
Definition symtab.cc:82
varpool_node_hook_list * add_varpool_insertion_hook(varpool_node_hook hook, void *data)
Definition varpool.cc:94
void finalize_compilation_unit(void)
Definition cgraphunit.cc:2562
void process_new_functions(void)
Definition cgraphunit.cc:302
void symtab_initialize_asm_name_hash(void)
Definition symtab.cc:260
friend struct asmname_hasher
Definition cgraph.h:2872
int cgraph_max_uid
Definition cgraph.h:2790
void dump_graphviz(FILE *f)
Definition symtab.cc:1058
bool cpp_implicit_aliases_done
Definition cgraph.h:2825
cgraph_node_hook_list * m_first_cgraph_removal_hook
Definition cgraph.h:2877
asm_node * finalize_toplevel_asm(tree asm_str)
Definition cgraph.h:3148
cgraph_node * create_empty(void)
Definition cgraph.cc:442
symtab_node * first_symbol(void)
Definition cgraph.h:3193
int cgraph_count
Definition cgraph.h:2789
cgraph_node * first_function(void)
Definition cgraph.h:3349
void call_cgraph_removal_hooks(cgraph_node *node)
Definition cgraph.cc:520
int max_unit
Definition cgraph.h:2816
vec< int > cgraph_released_summary_ids
Definition cgraph.h:2798
enum symtab_state state
Definition cgraph.h:2821
void remove_edge_removal_hook(cgraph_edge_hook_list *entry)
Definition cgraph.cc:467
cgraph_edge_hook_list * add_edge_removal_hook(cgraph_edge_hook hook, void *data)
Definition cgraph.cc:450
varpool_node * first_static_initializer(void)
Definition cgraph.h:3251
int assign_summary_id(cgraph_node *node)
Definition cgraph.h:2764
cgraph_node_hook_list * m_first_cgraph_insertion_hook
Definition cgraph.h:2883
symtab_node * nodes
Definition cgraph.h:2806
void dump(FILE *f)
Definition symtab.cc:1049
void register_symbol(symtab_node *node)
Definition cgraph.h:3130
void call_varpool_insertion_hooks(varpool_node *node)
Definition varpool.cc:123
varpool_node * first_defined_variable(void)
Definition cgraph.h:3284
int edges_max_uid
Definition cgraph.h:2794
void remove_cgraph_removal_hook(cgraph_node_hook_list *entry)
Definition cgraph.cc:508
void symtab_prevail_in_asm_name_hash(symtab_node *node)
Definition symtab.cc:251
cgraph_2edge_hook_list * m_first_edge_duplicated_hook
Definition cgraph.h:2879
cgraph_node * first_function_with_gimple_body(void)
Definition cgraph.h:3371
void insert_to_assembler_name_hash(symtab_node *node, bool with_clones)
Definition symtab.cc:162
void call_edge_duplication_hooks(cgraph_edge *cs1, cgraph_edge *cs2)
Definition cgraph.cc:603
void remove_edge_duplication_hook(cgraph_2edge_hook_list *entry)
Definition cgraph.cc:591
varpool_node * next_variable(varpool_node *node)
Definition cgraph.h:3235
void unlink_from_assembler_name_hash(symtab_node *node, bool with_clones)
Definition symtab.cc:203
friend struct cgraph_node
Definition cgraph.h:2548
void call_varpool_removal_hooks(varpool_node *node)
Definition varpool.cc:82
asm_node * asm_last_node
Definition cgraph.h:2808
hash_map< symtab_node *, symbol_priority_map > * init_priority_hash
Definition cgraph.h:2834
int edges_max_summary_id
Definition cgraph.h:2795
void remove_unreferenced_decls(void)
Definition varpool.cc:629
bool debug
Definition collect-utils.cc:34
struct basic_block_def * basic_block
Definition coretypes.h:372
struct rtx_def * rtx
Definition coretypes.h:57
optimize_size_level
Definition coretypes.h:477
@ OPTIMIZE_SIZE_BALANCED
Definition coretypes.h:481
@ OPTIMIZE_SIZE_NO
Definition coretypes.h:479
@ OPTIMIZE_SIZE_MAX
Definition coretypes.h:483
class edge_def * edge
Definition coretypes.h:369
tls_model
Definition coretypes.h:212
@ TLS_MODEL_NONE
Definition coretypes.h:213
union section section
Definition coretypes.h:161
node_frequency
Definition coretypes.h:271
@ NODE_FREQUENCY_NORMAL
Definition coretypes.h:279
@ NODE_FREQUENCY_UNLIKELY_EXECUTED
Definition coretypes.h:274
const union tree_node * const_tree
Definition coretypes.h:98
#define GTY(x)
Definition coretypes.h:41
class bitmap_head * bitmap
Definition coretypes.h:51
union tree_node * tree
Definition coretypes.h:97
static unsigned int count[debug_counter_number_of_counters]
Definition dbgcnt.cc:50
FILE * dump_file
Definition dumpfile.cc:63
void change_decl_assembler_name(tree, tree)
static type_p type(options_p *optsp, bool nested)
Definition gengtype-parse.cc:883
void ggc_free(void *)
Definition genmatch.cc:52
T * ggc_cleared_alloc(ALONE_CXX_MEM_STAT_INFO)
Definition ggc.h:217
#define ggc_strdup(S)
Definition ggc.h:281
bool set_comdat_group(symtab_node *symbol, void *head_p)
Definition ipa-comdats.cc:208
ipa_ref_use
Definition ipa-ref.h:31
@ IPA_REF_ALIAS
Definition ipa-ref.h:35
@ IPA_REF_ADDR
Definition ipa-ref.h:34
static int frequency
Definition ira-costs.cc:107
bool is_a(U *p)
Definition is-a.h:230
T safe_as_a(U *p)
Definition is-a.h:264
T as_a(U *p)
Definition is-a.h:253
T dyn_cast(U *p)
Definition is-a.h:280
Definition custom-sarif-properties/state-graphs.h:33
const json::string_property function
@ n
Definition graphviz.h:249
Definition dump-context.h:31
void dump(const T &obj)
Definition dump.h:70
section * get_section(const char *, unsigned int, tree, bool not_existing=false)
Definition varasm.cc:291
poly_int< NUM_POLY_INT_COEFFS, unsigned HOST_WIDE_INT > poly_uint64
Definition poly-int-types.h:25
poly_int< N, C > r
Definition poly-int.h:774
i
Definition poly-int.h:776
profile_quality
Definition profile-count.h:30
#define REG_BR_PROB_BASE
Definition profile-count.h:75
rtx find_replacement(rtx *loc)
Definition reload.cc:6383
Definition cgraph.h:2371
tree asm_str
Definition cgraph.h:2376
vec< symtab_node * > symbols_referenced
Definition cgraph.h:2379
asm_node(tree asm_str)
Definition cgraph.h:2372
Definition cgraph.h:2527
static bool equal(symtab_node *n, const_tree t)
Definition cgraph.h:2902
static hashval_t hash(symtab_node *n)
Definition cgraph.h:2895
const_tree compare_type
Definition cgraph.h:2528
Definition cgraph.cc:99
Definition cgraph.cc:106
Definition cgraph.h:908
static bool equal(cgraph_edge *, gimple *)
Definition cgraph.cc:851
static hashval_t hash(cgraph_edge *)
Definition cgraph.cc:831
gimple * compare_type
Definition cgraph.h:909
Definition cgraph.cc:85
Definition cgraph.h:865
tree assembler_name
Definition cgraph.h:888
cgraph_node * this_node
Definition cgraph.h:867
cgraph_function_version_info * next
Definition cgraph.h:875
cgraph_function_version_info * prev
Definition cgraph.h:871
tree dispatcher_resolver
Definition cgraph.h:885
Definition cgraph.cc:92
Definition cgraph.h:1588
hash_map< cgraph_node *, size_t > * map
Definition cgraph.h:1589
vec< cgraph_node * > nodes
Definition cgraph.h:1590
Definition cgraph.h:1608
cgraph_node_set set
Definition cgraph.h:1609
unsigned index
Definition cgraph.h:1610
Definition cgraph.h:920
static cgraph_node * get(const_tree decl)
Definition cgraph.h:1404
cgraph_edge * indirect_calls
Definition cgraph.h:1461
void scale_profile_to(profile_count ipa_count)
Definition cgraph.cc:287
unsigned only_called_at_startup
Definition cgraph.h:1515
cgraph_node()
Definition cgraph.h:924
void DEBUG_FUNCTION debug(void)
Definition cgraph.cc:2710
void create_wrapper(cgraph_node *target)
Definition cgraphunit.cc:2650
struct cgraph_rtl_info * rtl
Definition cgraph.h:1487
bool can_remove_if_no_direct_calls_p(bool will_inline=false)
Definition cgraph.cc:3491
static void dump_cgraph(FILE *f)
Definition cgraph.cc:2718
enum node_frequency frequency
Definition cgraph.h:1513
void make_local(void)
Definition cgraph.cc:2946
enum availability get_availability(symtab_node *ref=NULL)
Definition cgraph.cc:2791
unsigned split_part
Definition cgraph.h:1547
unsigned nonfreeing_fn
Definition cgraph.h:1539
bool former_thunk_p(void)
Definition cgraph.cc:4850
void DEBUG_FUNCTION verify_node(void)
Definition cgraph.cc:3953
cgraph_node * create_thunk(tree alias, tree, bool this_adjusting, HOST_WIDE_INT fixed_offset, HOST_WIDE_INT virtual_value, HOST_WIDE_INT indirect_offset, tree virtual_offset, tree real_alias)
Definition cgraph.cc:769
int count_materialization_scale
Definition cgraph.h:1493
unsigned int profile_id
Definition cgraph.h:1495
cgraph_edge * create_edge(cgraph_node *callee, gcall *call_stmt, profile_count count, bool cloning_p=false)
Definition cgraph.cc:1144
unsigned thunk
Definition cgraph.h:1502
void analyze(void)
Definition cgraphunit.cc:628
cgraph_function_version_info * insert_new_function_version(void)
Definition cgraph.cc:321
bool set_const_flag(bool set_const, bool looping)
Definition cgraph.cc:3274
unsigned tm_clone
Definition cgraph.h:1522
bool can_remove_if_no_direct_calls_and_refs_p(void)
Definition cgraph.h:3466
bool get_body()
Definition cgraph.cc:4656
unsigned lowered
Definition cgraph.h:1507
int unit_id
Definition cgraph.h:1497
cgraph_edge * callers
Definition cgraph.h:1458
void set_call_stmt_including_clones(gimple *old_stmt, gcall *new_stmt, bool update_speculative=true)
Definition cgraphclones.cc:850
void expand_all_artificial_thunks()
Definition cgraphclones.cc:308
void remove(void)
Definition cgraph.cc:2262
unsigned icf_merged
Definition cgraph.h:1535
cgraph_node * next_sibling_clone
Definition cgraph.h:1462
cgraph_node * find_replacement(struct clone_info *)
Definition cgraphclones.cc:755
void remove_callees(void)
Definition cgraph.cc:2117
static void checking_verify_cgraph_nodes(void)
Definition cgraph.h:3490
cgraph_node * clones
Definition cgraph.h:1464
unsigned can_change_signature
Definition cgraph.h:1557
unsigned is_target_clone
Definition cgraph.h:1530
static void DEBUG_FUNCTION verify_cgraph_nodes(void)
Definition cgraph.cc:4516
static void add_function_version(cgraph_function_version_info *fn_v, tree decl)
Definition cgraph.cc:375
cgraph_node * get_alias_target(void)
Definition cgraph.h:3540
bool check_calls_comdat_local_p()
Definition cgraph.cc:4837
static cgraph_node * create_same_body_alias(tree alias, tree decl)
Definition cgraph.cc:744
void record_stmt_references(gimple *stmt)
Definition cgraphbuild.cc:291
cgraph_node * function_or_virtual_thunk_symbol(enum availability *avail=NULL, struct symtab_node *ref=NULL)
Definition cgraph.cc:4565
bool has_gimple_body_p(void)
Definition cgraph.h:3416
static void add_new_function(tree fndecl, bool lowered)
Definition cgraphunit.cc:530
static bool has_thunk_p(cgraph_node *node, void *)
Definition cgraph.cc:4753
void remove_from_clone_tree()
Definition cgraphclones.cc:1200
unsigned calls_comdat_local
Definition cgraph.h:1533
cgraph_node * inlined_to
Definition cgraph.h:1485
cgraph_edge * create_indirect_edge(gcall *call_stmt, int ecf_flags, profile_count count, bool cloning_p=false)
Definition cgraph.cc:1172
friend class symbol_table
Definition cgraph.h:921
void make_profile_local()
Definition cgraph.cc:185
bool local_p(void)
Definition ipa-visibility.cc:113
cgraph_node * clone_of
Definition cgraph.h:1465
bool cannot_return_p(void)
Definition cgraph.cc:3371
static void delete_function_version_by_decl(tree decl)
Definition cgraph.cc:359
void dump(FILE *f)
Definition cgraph.cc:2515
priority_type get_fini_priority(void)
Definition symtab.cc:1859
bool set_malloc_flag(bool malloc_p)
Definition cgraph.cc:3041
bool call_for_symbol_and_aliases(bool(*callback)(cgraph_node *, void *), void *data, bool include_overwritable)
Definition cgraph.h:3755
unsigned gc_candidate
Definition cgraph.h:1568
void apply_scale(profile_count num, profile_count den)
Definition cgraph.cc:265
cgraph_node * function_symbol(enum availability *avail=NULL, struct symtab_node *ref=NULL)
Definition cgraph.cc:4538
struct function * get_fun() const
Definition cgraph.cc:4698
void mark_force_output(void)
Definition cgraph.h:3686
void create_edge_including_clones(cgraph_node *callee, gimple *old_stmt, gcall *stmt, profile_count count, cgraph_inline_failed_t reason)
Definition cgraphclones.cc:910
unsigned only_called_at_exit
Definition cgraph.h:1517
void dump_graphviz(FILE *f)
Definition cgraph.cc:2694
void release_body(bool keep_arguments=false)
Definition cgraph.cc:2229
profile_count count
Definition cgraph.h:1490
static cgraph_node * get_create(tree)
Definition cgraph.cc:687
bool set_nothrow_flag(bool nothrow)
Definition cgraph.cc:2993
cgraph_simd_clone * simdclone
Definition cgraph.h:1474
unsigned called_by_ifunc_resolver
Definition cgraph.h:1570
bool set_noreturn_flag(bool noreturn_p)
Definition cgraph.cc:3136
cgraph_node * create_version_clone_with_body(vec< cgraph_edge * > redirect_callers, vec< ipa_replace_map *, va_gc > *tree_map, ipa_param_adjustments *param_adjustments, bitmap bbs_to_copy, basic_block new_entry_block, const char *suffix, tree target_attributes=NULL_TREE, bool version_decl=true)
Definition cgraphclones.cc:1095
void expand(void)
Definition cgraphunit.cc:1827
vec< ipa_opt_pass, va_heap, vl_ptr > ipa_transforms_to_apply
Definition cgraph.h:1481
static cgraph_node * create_alias(tree alias, tree target)
Definition cgraph.cc:718
cgraph_edge * callees
Definition cgraph.h:1457
bool remove_symbol_and_inline_clones(cgraph_node *forbidden_node=NULL)
Definition cgraphclones.cc:963
hash_table< cgraph_edge_hasher > * call_site_hash
Definition cgraph.h:1468
unsigned indirect_call_target
Definition cgraph.h:1549
bool call_for_symbol_and_aliases_1(bool(*callback)(cgraph_node *, void *), void *data, bool include_overwritable)
Definition cgraph.cc:4732
bool only_called_directly_p(void)
Definition cgraph.cc:3622
void assemble_thunks_and_aliases(void)
Definition cgraphunit.cc:1784
unsigned ipcp_clone
Definition cgraph.h:1564
cgraph_function_version_info * function_version(void)
Definition cgraph.cc:172
static void finalize_function(tree, bool)
Definition cgraphunit.cc:452
bool can_be_local_p(void)
Definition cgraph.cc:2866
bool call_for_symbol_thunks_and_aliases(bool(*callback)(cgraph_node *node, void *data), void *data, bool include_overwritable, bool exclude_virtual_thunks=false)
Definition cgraph.cc:2878
unsigned merged_comdat
Definition cgraph.h:1541
unsigned dispatcher_resolver_function
Definition cgraph.h:1526
static cgraph_node * local_info_node(tree decl)
Definition cgraph.cc:2396
void materialize_clone(void)
Definition cgraphclones.cc:1216
unsigned parallelized_function
Definition cgraph.h:1545
static void debug_cgraph(void)
Definition cgraph.h:1369
unsigned versionable
Definition cgraph.h:1554
int m_summary_id
Definition cgraph.h:1577
unsigned has_omp_variant_constructs
Definition cgraph.h:1572
auto_vec< cgraph_edge * > collect_callers(void)
Definition cgraph.cc:3662
cgraph_node * prev_sibling_clone
Definition cgraph.h:1463
cgraph_edge * get_edge(gimple *call_stmt)
Definition cgraph.cc:906
unsigned local
Definition cgraph.h:1552
unsigned process
Definition cgraph.h:1510
static void delete_function_version(cgraph_function_version_info *)
Definition cgraph.cc:338
void make_profile_global0(profile_quality quality)
Definition cgraph.cc:207
void mark_address_taken(void)
Definition cgraph.cc:2372
unsigned redefined_extern_inline
Definition cgraph.h:1560
cgraph_node * create_virtual_clone(const vec< cgraph_edge * > &redirect_callers, vec< ipa_replace_map *, va_gc > *tree_map, ipa_param_adjustments *param_adjustments, const char *suffix, unsigned num_suffix)
Definition cgraphclones.cc:663
int tp_first_run
Definition cgraph.h:1499
static cgraph_node * create(tree decl)
Definition cgraph.cc:658
bool will_be_removed_from_program_if_no_direct_calls_p(bool will_inline=false)
Definition cgraph.cc:3563
tree former_clone_of
Definition cgraph.h:1470
bool get_untransformed_body()
Definition cgraph.cc:4587
bool is_clone_of(cgraph_node *n) const
Definition cgraph.cc:3632
bool only_called_directly_or_aliased_p(void)
Definition cgraph.h:3448
cgraph_node * create_version_clone(tree new_decl, vec< cgraph_edge * > redirect_callers, bitmap bbs_to_copy, const char *suffix=NULL)
Definition cgraphclones.cc:1016
cgraph_node * ultimate_alias_target(availability *availability=NULL, symtab_node *ref=NULL)
Definition cgraph.h:3580
static cgraph_node * get_for_asmname(tree asmname)
Definition cgraph.cc:814
cgraph_node * simd_clones
Definition cgraph.h:1476
unsigned merged_extern_inline
Definition cgraph.h:1543
bool add_detected_attribute(const char *attr)
Definition cgraph.cc:3089
int get_summary_id()
Definition cgraph.h:1375
cgraph_node * create_clone(tree decl, profile_count count, bool update_original, vec< cgraph_edge * > redirect_callers, bool call_duplication_hook, cgraph_node *new_inlined_to, ipa_param_adjustments *param_adjustments, const char *suffix)
Definition cgraphclones.cc:402
void set_fini_priority(priority_type priority)
Definition symtab.cc:1910
unsigned dispatcher_function
Definition cgraph.h:1524
enum optimize_size_level optimize_for_size_p(void)
Definition cgraph.h:3695
bool set_pure_flag(bool pure, bool looping)
Definition cgraph.cc:3357
void remove_callers(void)
Definition cgraph.cc:2154
unsigned used_as_abstract_origin
Definition cgraph.h:1505
unsigned tm_may_enter_irr
Definition cgraph.h:1562
static struct cgraph_rtl_info * rtl_info(const_tree)
Definition cgraph.cc:2408
Definition rtl.h:4629
Definition cgraph.h:779
unsigned int alignment
Definition cgraph.h:813
tree orig_arg
Definition cgraph.h:782
HOST_WIDE_INT linear_step
Definition cgraph.h:821
enum cgraph_simd_clone_arg_type arg_type
Definition cgraph.h:810
tree orig_type
Definition cgraph.h:786
tree vector_arg
Definition cgraph.h:794
tree vector_type
Definition cgraph.h:797
tree simd_array
Definition cgraph.h:806
Definition cgraph.h:826
cgraph_node * next_clone
Definition cgraph.h:855
poly_uint64 vecsize_int
Definition cgraph.h:835
unsigned int inbranch
Definition cgraph.h:852
poly_uint64 vecsize_float
Definition cgraph.h:838
machine_mode mask_mode
Definition cgraph.h:843
cgraph_simd_clone_arg args[1]
Definition cgraph.h:861
cgraph_node * prev_clone
Definition cgraph.h:855
poly_uint64 simdlen
Definition cgraph.h:828
cgraph_node * origin
Definition cgraph.h:858
unsigned int nargs
Definition cgraph.h:832
unsigned char vecsize_mangle
Definition cgraph.h:848
Definition symtab-clones.h:25
Definition cgraph.h:3430
hashval_t hash
Definition cgraph.h:3440
rtx rtl
Definition cgraph.h:3432
tree value
Definition cgraph.h:3435
Definition genautomata.cc:499
Definition gimple.h:352
Definition hash-traits.h:321
Definition gimple-iterator.h:26
Definition gimple.h:221
Definition ipa-ref.h:75
vec< ipa_ref_t *, va_heap, vl_ptr > referring
Definition ipa-ref.h:136
vec< ipa_ref_t, va_heap, vl_ptr > references
Definition ipa-ref.h:133
Definition ipa-ref.h:40
unsigned int speculative
Definition ipa-ref.h:67
enum ipa_ref_use use
Definition ipa-ref.h:66
gimple * stmt
Definition ipa-ref.h:60
symtab_node * referred
Definition ipa-ref.h:59
unsigned int speculative_id
Definition ipa-ref.h:65
bool address_matters_p()
Definition cgraph.h:3795
unsigned int lto_stmt_uid
Definition ipa-ref.h:61
symtab_node * referring
Definition ipa-ref.h:58
Definition cgraph.h:747
unsigned force_load_ref
Definition cgraph.h:755
tree new_tree
Definition cgraph.h:749
int parm_num
Definition cgraph.h:751
static bool test(const U *p)
Definition is-a.h:211
static bool test(U *p)
Definition lto-streamer.h:567
Definition lto-streamer.h:709
Definition profile-count.h:765
static profile_count zero()
Definition profile-count.h:813
Definition cgraph.h:58
int ref_count
Definition cgraph.h:59
char * name
Definition cgraph.h:60
Definition cgraph.h:66
const char * compare_type
Definition cgraph.h:67
static hashval_t hash(section_hash_entry *)
Definition symtab.cc:365
static bool equal(section_hash_entry *, const char *)
Definition symtab.cc:373
Definition cgraph.h:2500
priority_type fini
Definition cgraph.h:2502
priority_type init
Definition cgraph.h:2501
Definition cgraph.h:133
static bool set_implicit_section(symtab_node *n, void *)
Definition symtab.cc:1926
unsigned in_init_priority_hash
Definition cgraph.h:634
void dump_graphviz(FILE *f)
Definition symtab.cc:1042
symtab_node * get_alias_target(void)
Definition cgraph.h:3017
tree get_alias_target_tree()
Definition cgraph.h:3029
unsigned used_from_other_partition
Definition cgraph.h:621
const char * get_visibility_string() const
Definition symtab.cc:890
tree get_comdat_group_id()
Definition cgraph.h:283
tree x_comdat_group
Definition cgraph.h:676
void add_to_same_comdat_group(symtab_node *old_node)
Definition symtab.cc:495
tree alias_target
Definition cgraph.h:671
bool native_rtl_p() const
Definition cgraphunit.cc:227
ipa_ref * iterate_reference(unsigned i, ipa_ref *&ref)
Definition cgraph.h:3053
void dump(FILE *f)
Definition symtab.cc:1033
unsigned weakref
Definition cgraph.h:563
unsigned address_taken
Definition cgraph.h:632
bool address_matters_p()
Definition symtab.cc:2464
unsigned definition
Definition cgraph.h:536
static symtab_node * get(const_tree decl)
Definition cgraph.h:490
bool referred_to_p(bool include_self=true)
Definition cgraphunit.cc:426
priority_type get_init_priority()
Definition symtab.cc:1847
unsigned num_references(void)
Definition cgraph.h:255
ipa_ref * clone_reference(ipa_ref *ref, gimple *stmt)
Definition symtab.cc:743
void clone_references(symtab_node *node)
Definition symtab.cc:703
bool output_to_lto_symbol_table_p(void)
Definition symtab.cc:2648
const char * dump_asm_name() const
Definition symtab.cc:599
section_hash_entry * x_section
Definition cgraph.h:679
unsigned externally_visible
Definition cgraph.h:585
static DEBUG_FUNCTION void verify_symtab_nodes(void)
Definition symtab.cc:1482
void copy_visibility_from(symtab_node *n)
Definition symtab.cc:1601
bool has_aliases_p(void)
Definition cgraph.h:3086
struct symbol_priority_map * priority_info(void)
Definition symtab.cc:1872
const char * get_dump_name(bool asm_name_p) const
Definition symtab.cc:580
void unregister(struct clone_info *)
Definition symtab.cc:452
unsigned unique_name
Definition cgraph.h:606
void DEBUG_FUNCTION debug(void)
Definition symtab.cc:1098
void set_section(const char *section)
Definition symtab.cc:1830
const char * get_section() const
Definition cgraph.h:299
unsigned need_lto_streaming
Definition cgraph.h:638
symtab_node * next_defined_symbol(void)
Definition cgraph.h:3039
unsigned cpp_implicit_alias
Definition cgraph.h:570
void set_comdat_group(tree group)
Definition cgraph.h:291
void dump_base(FILE *)
Definition symtab.cc:907
void DEBUG_FUNCTION verify(void)
Definition symtab.cc:1370
bool call_for_symbol_and_aliases_1(bool(*callback)(symtab_node *, void *), void *data, bool include_overwrite)
Definition symtab.cc:2424
const char * name() const
Definition symtab.cc:567
void clear_stmts_in_references(void)
Definition symtab.cc:801
static void check_ifunc_callee_symtab_nodes(void)
Definition symtab.cc:1450
unsigned forced_by_abi
Definition cgraph.h:594
ipa_ref * find_reference(symtab_node *referred_node, gimple *stmt, unsigned int lto_stmt_uid, enum ipa_ref_use use_type)
Definition symtab.cc:761
enum availability get_availability(symtab_node *ref=NULL)
Definition cgraph.h:3722
void set_section_for_node(const char *section)
Definition symtab.cc:1754
symtab_node * ultimate_alias_target_1(enum availability *avail=NULL, symtab_node *ref=NULL)
Definition symtab.cc:1656
void remove_from_same_comdat_group(void)
Definition symtab.cc:429
friend class symbol_table
Definition cgraph.h:135
ipa_ref * maybe_create_reference(tree val, gimple *stmt)
Definition symtab.cc:672
int get_uid() const
Definition cgraph.h:524
symtab_node * same_comdat_group
Definition cgraph.h:663
void remove_all_references(void)
Definition symtab.cc:825
bool prevailing_p(void)
Definition cgraph.h:3899
unsigned ref_by_asm
Definition cgraph.h:598
unsigned no_reorder
Definition cgraph.h:587
void * aux
Definition cgraph.h:673
int equal_address_to(symtab_node *s2, bool memory_accessed=false)
Definition symtab.cc:2312
unsigned transparent_alias
Definition cgraph.h:561
unsigned implicit_section
Definition cgraph.h:609
bool address_can_be_compared_p(void)
Definition cgraph.cc:150
enum ld_plugin_symbol_resolution resolution
Definition cgraph.h:530
void clone_referring(symtab_node *node)
Definition symtab.cc:723
bool resolve_alias(symtab_node *target, bool transparent=false)
Definition symtab.cc:1938
symtab_node * previous_sharing_asm_name
Definition cgraph.h:660
bool can_be_discarded_p(void)
Definition cgraph.h:438
void remove_stmt_references(gimple *stmt)
Definition symtab.cc:782
unsigned semantic_interposition
Definition cgraph.h:614
static symtab_node * get_for_asmname(const_tree asmname)
Definition symtab.cc:1077
static symtab_node * get_create(tree node)
Definition cgraph.h:3711
unsigned refuse_visibility_changes
Definition cgraph.h:580
symtab_node(toplevel_type t)
Definition cgraph.h:138
ipa_ref * create_reference(symtab_node *referred_node, enum ipa_ref_use use_type)
Definition symtab.cc:609
void dump_references(FILE *file)
Definition symtab.cc:845
enum symbol_partitioning_class get_partitioning_class(void)
Definition symtab.cc:2167
tree decl
Definition cgraph.h:648
void dissolve_same_comdat_group_list(void)
Definition symtab.cc:530
unsigned must_remain_in_tu_name
Definition cgraph.h:601
unsigned symver
Definition cgraph.h:572
unsigned alias
Definition cgraph.h:539
void make_decl_local(void)
Definition symtab.cc:1536
bool binds_to_current_def_p(symtab_node *ref=NULL)
Definition symtab.cc:2591
ipa_ref * iterate_direct_aliases(unsigned i, ipa_ref *&ref)
Definition cgraph.h:3073
bool semantically_equivalent_p(symtab_node *target)
Definition symtab.cc:2133
void remove_all_referring(void)
Definition symtab.cc:835
void reset(bool preserve_comdat_group=false)
Definition cgraphunit.cc:393
unsigned offloadable
Definition cgraph.h:641
void fixup_same_cpp_alias_visibility(symtab_node *target)
Definition symtab.cc:1718
bool in_same_comdat_group_p(symtab_node *target)
Definition cgraph.h:2996
const char * dump_name() const
Definition symtab.cc:593
unsigned must_remain_in_tu_body
Definition cgraph.h:604
static bool set_section_from_node(symtab_node *n, void *o)
Definition symtab.cc:1820
unsigned writeonly
Definition cgraph.h:577
const char * asm_name() const
Definition symtab.cc:557
unsigned int definition_alignment()
Definition symtab.cc:2565
void dump_referring(FILE *)
Definition symtab.cc:862
unsigned body_removed
Definition cgraph.h:612
symtab_node * noninterposable_alias(void)
Definition symtab.cc:2056
static void checking_verify_symtab_nodes(void)
Definition cgraph.h:724
ipa_ref_list ref_list
Definition cgraph.h:666
bool DEBUG_FUNCTION verify_base(void)
Definition symtab.cc:1115
unsigned force_output
Definition cgraph.h:590
static bool set_section_from_string(symtab_node *n, void *s)
Definition symtab.cc:1810
void register_symbol(void)
Definition symtab.cc:412
tree get_comdat_group()
Definition cgraph.h:277
symtab_node * ultimate_alias_target(enum availability *avail=NULL, struct symtab_node *ref=NULL)
Definition cgraph.h:3560
const char * get_symtab_type_string() const
Definition symtab.cc:899
bool real_symbol_p(void)
Definition cgraph.h:2968
unsigned analyzed
Definition cgraph.h:575
bool nonzero_address()
Definition symtab.cc:2298
void remove(void)
Definition symtab.cc:484
bool call_for_symbol_and_aliases(bool(*callback)(symtab_node *, void *), void *data, bool include_overwrite)
Definition cgraph.h:3734
int m_uid
Definition cgraph.h:703
bool comdat_local_p(void)
Definition cgraph.h:454
bool needed_p(void)
Definition cgraphunit.cc:240
unsigned in_other_partition
Definition cgraph.h:625
ipa_ref * iterate_referring(unsigned i, ipa_ref *&ref)
Definition cgraph.h:3063
symtab_node * next_sharing_asm_name
Definition cgraph.h:659
void set_init_priority(priority_type priority)
Definition symtab.cc:1893
bool used_from_object_file_p(void)
Definition cgraph.h:3109
bool can_increase_alignment_p()
Definition symtab.cc:2473
unsigned ifunc_resolver
Definition cgraph.h:644
Definition symtab-thunks.h:36
Definition gengtype-parse.cc:40
Definition cgraph.h:110
enum toplevel_type type
Definition cgraph.h:127
toplevel_node * next
Definition cgraph.h:120
int order
Definition cgraph.h:124
toplevel_node * previous
Definition cgraph.h:121
struct lto_file_decl_data * lto_file_data
Definition cgraph.h:117
toplevel_node(toplevel_type t)
Definition cgraph.h:112
Definition cgraph.h:3529
static bool equal(constant_descriptor_tree *, constant_descriptor_tree *)
Definition varasm.cc:3490
static hashval_t hash(constant_descriptor_tree *)
Definition varasm.cc:3367
Definition gengtype.h:252
Definition loop-invariant.cc:78
Definition vec.h:283
Definition varpool.cc:45
Definition cgraph.h:1601
hash_map< varpool_node *, size_t > * map
Definition cgraph.h:1602
vec< varpool_node * > nodes
Definition cgraph.h:1603
Definition cgraph.h:1615
varpool_node_set set
Definition cgraph.h:1616
unsigned index
Definition cgraph.h:1617
Definition cgraph.h:2235
bool can_remove_if_no_refs_p(void)
Definition cgraph.h:3500
static void dump_varpool(FILE *f)
Definition varpool.cc:244
void remove_initializer(void)
Definition varpool.cc:192
static varpool_node * create_extra_name_alias(tree alias, tree decl)
Definition varpool.cc:796
void dump(FILE *f)
Definition varpool.cc:210
bool call_for_symbol_and_aliases_1(bool(*callback)(varpool_node *, void *), void *data, bool include_overwritable)
Definition varpool.cc:819
bool externally_visible_p(void)
Definition ipa-visibility.cc:265
void analyze(void)
Definition varpool.cc:522
static varpool_node * create_empty(void)
Definition varpool.cc:136
void DEBUG_FUNCTION debug(void)
Definition varpool.cc:237
static varpool_node * get_create(tree decl)
Definition varpool.cc:143
static varpool_node * get_for_asmname(tree asmname)
Definition varpool.cc:263
bool call_for_symbol_and_aliases(bool(*callback)(varpool_node *, void *), void *data, bool include_overwritable)
Definition cgraph.h:3776
unsigned output
Definition cgraph.h:2345
varpool_node()
Definition cgraph.h:2237
varpool_node * ultimate_alias_target(availability *availability=NULL, symtab_node *ref=NULL)
Definition cgraph.h:3597
static varpool_node * create_alias(tree, tree)
Definition varpool.cc:776
static void add(tree decl)
Definition varpool.cc:474
tree get_constructor(void)
Definition varpool.cc:275
varpool_node * get_alias_target(void)
Definition cgraph.h:3548
static varpool_node * get(const_tree decl)
Definition cgraph.h:3121
bool assemble_decl(void)
Definition varpool.cc:564
bool all_refs_explicit_p()
Definition cgraph.h:3519
void assemble_aliases(void)
Definition varpool.cc:544
static void finalize_decl(tree decl)
Definition cgraphunit.cc:968
availability get_availability(symtab_node *ref=NULL)
Definition varpool.cc:489
enum tls_model tls_model
Definition cgraph.h:2351
bool ctor_useable_for_folding_p(void)
Definition varpool.cc:319
void remove(void)
Definition varpool.cc:172
unsigned dynamically_initialized
Definition cgraph.h:2349
unsigned used_by_single_function
Definition cgraph.h:2357
static void DEBUG_FUNCTION debug_varpool(void)
Definition varpool.cc:256
void finalize_named_section_flags(void)
Definition varpool.cc:719
Definition vec.h:450
Definition vec.h:271
#define NULL
Definition system.h:50
#define gcc_assert(EXPR)
Definition system.h:817
#define gcc_unreachable()
Definition system.h:844
#define true
Definition system.h:890
#define false
Definition system.h:891
#define DEBUG_FUNCTION
Definition system.h:1191
#define gcc_checking_assert(EXPR)
Definition system.h:824
unsigned short priority_type
Definition tree-core.h:1104
use_type
Definition tree-ssa-loop-ivopts.cc:195
static void mark_address_taken(tree ref)
Definition tree-ssa-operands.cc:619
static unsigned int increase_alignment(void)
Definition tree-vectorizer.cc:1709
#define DECL_ASSEMBLER_NAME(NODE)
Definition tree.h:3341
#define DECL_HAS_VALUE_EXPR_P(NODE)
Definition tree.h:3104
#define DECL_SECTION_NAME(NODE)
Definition tree.h:3378
#define DECL_STATIC_CONSTRUCTOR(NODE)
Definition tree.h:3581
#define TYPE_MAIN_VARIANT(NODE)
Definition tree.h:2394
#define DECL_WEAK(NODE)
Definition tree.h:3308
#define DECL_STATIC_DESTRUCTOR(NODE)
Definition tree.h:3584
#define TREE_CODE(NODE)
Definition tree.h:325
#define DECL_ABSTRACT_P(NODE)
Definition tree.h:3007
#define DECL_COMDAT(NODE)
Definition tree.h:3323
#define opt_for_fn(fndecl, opt)
Definition tree.h:6385
#define DECL_INITIAL(NODE)
Definition tree.h:2927
#define TREE_STATIC(NODE)
Definition tree.h:773
#define DECL_COMMON(NODE)
Definition tree.h:3299
#define DECL_EXTERNAL(NODE)
Definition tree.h:3021
#define TREE_PUBLIC(NODE)
Definition tree.h:863
#define DECL_VIRTUAL_P(NODE)
Definition tree.h:3036
#define VAR_P(NODE)
Definition tree.h:236
#define NULL_TREE
Definition tree.h:318
#define DECL_P(NODE)
Definition tree.h:232
Definition output.h:517
static bool set_implicit_section(struct symtab_node *n, void *data)
Definition varasm.cc:476
constexpr vnull vNULL
Definition vec.h:569