1 /* IPA reference lists.
2 Copyright (C) 2010-2014 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/>. */
26 /* How the reference is done. */
27 enum GTY(()) ipa_ref_use
35 /* Record of reference in callgraph or varpool. */
36 struct GTY(()) ipa_ref
39 /* Remove reference. */
40 void remove_reference ();
42 /* Return true when execution of reference can lead to return from
44 bool cannot_lead_to_return ();
46 /* Return reference list this reference is in. */
47 struct ipa_ref_list
* referring_ref_list (void);
49 /* Return reference list this reference is in. */
50 struct ipa_ref_list
* referred_ref_list (void);
52 symtab_node
*referring
;
53 symtab_node
*referred
;
55 unsigned int lto_stmt_uid
;
56 unsigned int referred_index
;
57 ENUM_BITFIELD (ipa_ref_use
) use
:2;
58 unsigned int speculative
:1;
61 typedef struct ipa_ref ipa_ref_t
;
62 typedef struct ipa_ref
*ipa_ref_ptr
;
65 /* List of references. This is stored in both callgraph and varpool nodes. */
66 struct GTY(()) ipa_ref_list
69 /* Return first reference in list or NULL if empty. */
70 struct ipa_ref
*first_reference (void)
72 if (!vec_safe_length (references
))
74 return &(*references
)[0];
77 /* Return first referring ref in list or NULL if empty. */
78 struct ipa_ref
*first_referring (void)
80 if (!referring
.length ())
85 /* Return first referring alias. */
86 struct ipa_ref
*first_alias (void)
88 struct ipa_ref
*r
= first_referring ();
90 return r
&& r
->use
== IPA_REF_ALIAS
? r
: NULL
;
93 /* Return last referring alias. */
94 struct ipa_ref
*last_alias (void)
98 for(i
= 0; i
< referring
.length (); i
++)
99 if (referring
[i
]->use
!= IPA_REF_ALIAS
)
102 return i
== 0 ? NULL
: referring
[i
- 1];
105 /* Return true if the symbol has an alias. */
106 bool inline has_aliases_p (void)
108 return first_alias ();
111 /* Clear reference list. */
114 referring
.create (0);
118 /* Return number of references. */
119 unsigned int nreferences (void)
121 return vec_safe_length (references
);
124 /* Store actual references in references vector. */
125 vec
<ipa_ref_t
, va_gc
> *references
;
126 /* Referring is vector of pointers to references. It must not live in GGC space
127 or GGC will try to mark middle of references vectors. */
128 vec
<ipa_ref_ptr
> GTY((skip
)) referring
;