1 /* IPA reference lists.
2 Copyright (C) 2010-2018 Free Software Foundation, Inc.
3 Contributed by Jan Hubicka
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
29 /* How the reference is done. */
30 enum GTY(()) ipa_ref_use
39 /* Record of reference in callgraph or varpool. */
40 struct GTY(()) ipa_ref
43 /* Remove reference. */
44 void remove_reference ();
46 /* Return true when execution of reference can lead to return from
48 bool cannot_lead_to_return ();
50 /* Return true if refernece may be used in address compare. */
51 bool address_matters_p ();
53 /* Return reference list this reference is in. */
54 struct ipa_ref_list
* referring_ref_list (void);
56 /* Return reference list this reference is in. */
57 struct ipa_ref_list
* referred_ref_list (void);
59 symtab_node
*referring
;
60 symtab_node
*referred
;
62 unsigned int lto_stmt_uid
;
63 unsigned int referred_index
;
64 ENUM_BITFIELD (ipa_ref_use
) use
:3;
65 unsigned int speculative
:1;
68 typedef struct ipa_ref ipa_ref_t
;
69 typedef struct ipa_ref
*ipa_ref_ptr
;
72 /* List of references. This is stored in both callgraph and varpool nodes. */
73 struct GTY(()) ipa_ref_list
76 /* Return first reference in list or NULL if empty. */
77 struct ipa_ref
*first_reference (void)
79 if (!vec_safe_length (references
))
81 return &(*references
)[0];
84 /* Return first referring ref in list or NULL if empty. */
85 struct ipa_ref
*first_referring (void)
87 if (!referring
.length ())
92 /* Return first referring alias. */
93 struct ipa_ref
*first_alias (void)
95 struct ipa_ref
*r
= first_referring ();
97 return r
&& r
->use
== IPA_REF_ALIAS
? r
: NULL
;
100 /* Return last referring alias. */
101 struct ipa_ref
*last_alias (void)
105 for(i
= 0; i
< referring
.length (); i
++)
106 if (referring
[i
]->use
!= IPA_REF_ALIAS
)
109 return i
== 0 ? NULL
: referring
[i
- 1];
112 /* Return true if the symbol has an alias. */
113 bool inline has_aliases_p (void)
115 return first_alias ();
118 /* Clear reference list. */
121 referring
.create (0);
125 /* Return number of references. */
126 unsigned int nreferences (void)
128 return vec_safe_length (references
);
131 /* Store actual references in references vector. */
132 vec
<ipa_ref_t
, va_gc
> *references
;
133 /* Referring is vector of pointers to references. It must not live in GGC space
134 or GGC will try to mark middle of references vectors. */
135 vec
<ipa_ref_ptr
> GTY((skip
)) referring
;
138 #endif /* GCC_IPA_REF_H */