1 /* Interprocedural reference lists.
2 Copyright (C) 2010-2024 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/>. */
23 #include "coretypes.h"
28 /* Remove reference. */
31 ipa_ref::remove_reference ()
33 struct ipa_ref_list
*list
= referred_ref_list ();
34 struct ipa_ref_list
*list2
= referring_ref_list ();
37 gcc_assert (list
->referring
[referred_index
] == this);
39 last
= list
->referring
.last ();
42 if (use
== IPA_REF_ALIAS
)
44 /* If deleted item is IPA_REF_ALIAS, we have to move last
45 item of IPA_REF_LIST type to the deleted position. After that
46 we replace last node with deletion slot. */
47 struct ipa_ref
*last_alias
= list
->last_alias ();
49 if (last_alias
&& referred_index
< last_alias
->referred_index
50 && last_alias
!= last
)
52 unsigned last_alias_index
= last_alias
->referred_index
;
54 list
->referring
[referred_index
] = last_alias
;
55 list
->referring
[referred_index
]->referred_index
= referred_index
;
57 /* New position for replacement is previous index
59 referred_index
= last_alias_index
;
63 list
->referring
[referred_index
] = list
->referring
.last ();
64 list
->referring
[referred_index
]->referred_index
= referred_index
;
66 list
->referring
.pop ();
68 last
= &list2
->references
.last ();
70 struct ipa_ref
*ref
= this;
75 ref
->referred_ref_list ()->referring
[referred_index
] = ref
;
77 list2
->references
.pop ();
80 /* Return true when execution of reference can lead to return from
84 ipa_ref::cannot_lead_to_return ()
86 return dyn_cast
<cgraph_node
*> (referring
)->cannot_return_p ();
89 /* Return reference list this reference is in. */
92 ipa_ref::referring_ref_list (void)
94 return &referring
->ref_list
;
97 /* Return reference list this reference is in. */
100 ipa_ref::referred_ref_list (void)
102 return &referred
->ref_list
;