GCC Middle and Back End API Reference
ipa-ref.h
Go to the documentation of this file.
1/* IPA reference lists.
2 Copyright (C) 2010-2024 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_IPA_REF_H
22#define GCC_IPA_REF_H
23
24struct cgraph_node;
25struct varpool_node;
26struct symtab_node;
27
28
29/* How the reference is done. */
37
38/* Record of reference in callgraph or varpool. */
39struct ipa_ref
40{
41public:
42 /* Remove reference. */
43 void remove_reference ();
44
45 /* Return true when execution of reference can lead to return from
46 function. */
48
49 /* Return true if reference may be used in address compare. */
50 bool address_matters_p ();
51
52 /* Return reference list this reference is in. */
53 struct ipa_ref_list * referring_ref_list (void);
54
55 /* Return reference list this reference is in. */
56 struct ipa_ref_list * referred_ref_list (void);
57
61 unsigned int lto_stmt_uid;
62 unsigned int referred_index;
63 /* speculative id is used to link direct calls with their corresponding
64 IPA_REF_ADDR references when representing speculative calls. */
65 unsigned int speculative_id : 16;
66 ENUM_BITFIELD (ipa_ref_use) use:3;
67 unsigned int speculative:1;
68};
69
70typedef struct ipa_ref ipa_ref_t;
71
72
73/* List of references. This is stored in both callgraph and varpool nodes. */
75{
76public:
77 /* Return first reference in list or NULL if empty. */
78 struct ipa_ref *first_reference (void)
79 {
80 if (!references.length ())
81 return NULL;
82 return &references[0];
83 }
84
85 /* Return first referring ref in list or NULL if empty. */
86 struct ipa_ref *first_referring (void)
87 {
88 if (!referring.length ())
89 return NULL;
90 return referring[0];
91 }
92
93 /* Return first referring alias. */
94 struct ipa_ref *first_alias (void)
95 {
96 struct ipa_ref *r = first_referring ();
97
98 return r && r->use == IPA_REF_ALIAS ? r : NULL;
99 }
100
101 /* Return last referring alias. */
102 struct ipa_ref *last_alias (void)
103 {
104 unsigned int i = 0;
105
106 for(i = 0; i < referring.length (); i++)
107 if (referring[i]->use != IPA_REF_ALIAS)
108 break;
109
110 return i == 0 ? NULL : referring[i - 1];
111 }
112
113 /* Return true if the symbol has an alias. */
114 bool inline has_aliases_p (void)
115 {
116 return first_alias ();
117 }
118
119 /* Clear reference list. */
120 void clear (void)
121 {
122 referring.create (0);
123 references.create (0);
124 }
125
126 /* Return number of references. */
127 unsigned int nreferences (void)
128 {
129 return references.length ();
130 }
131
132 /* Store actual references in references vector. */
134 /* Referring is vector of pointers to references. It must not live in GGC space
135 or GGC will try to mark middle of references vectors. */
137};
138
139#endif /* GCC_IPA_REF_H */
ipa_ref_use
Definition ipa-ref.h:31
@ IPA_REF_STORE
Definition ipa-ref.h:33
@ IPA_REF_LOAD
Definition ipa-ref.h:32
@ IPA_REF_ALIAS
Definition ipa-ref.h:35
@ IPA_REF_ADDR
Definition ipa-ref.h:34
poly_int< N, C > r
Definition poly-int.h:774
i
Definition poly-int.h:776
Definition cgraph.h:875
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
void clear(void)
Definition ipa-ref.h:120
unsigned int nreferences(void)
Definition ipa-ref.h:127
struct ipa_ref * first_reference(void)
Definition ipa-ref.h:78
struct ipa_ref * first_alias(void)
Definition ipa-ref.h:94
struct ipa_ref * last_alias(void)
Definition ipa-ref.h:102
bool has_aliases_p(void)
Definition ipa-ref.h:114
struct ipa_ref * first_referring(void)
Definition ipa-ref.h:86
Definition ipa-ref.h:40
unsigned int speculative
Definition ipa-ref.h:67
bool cannot_lead_to_return()
Definition ipa-ref.cc:84
enum ipa_ref_use use
Definition ipa-ref.h:66
struct ipa_ref_list * referred_ref_list(void)
Definition ipa-ref.cc:100
struct ipa_ref_list * referring_ref_list(void)
Definition ipa-ref.cc:92
gimple * stmt
Definition ipa-ref.h:60
symtab_node * referred
Definition ipa-ref.h:59
void remove_reference()
Definition ipa-ref.cc:31
unsigned int speculative_id
Definition ipa-ref.h:65
unsigned int referred_index
Definition ipa-ref.h:62
bool address_matters_p()
Definition cgraph.h:3458
unsigned int lto_stmt_uid
Definition ipa-ref.h:61
symtab_node * referring
Definition ipa-ref.h:58
Definition cgraph.h:106
Definition loop-invariant.cc:78
Definition cgraph.h:2000
Definition vec.h:450
#define NULL
Definition system.h:50