]>
Commit | Line | Data |
---|---|---|
369451ec | 1 | /* Interprocedural reference lists. |
aeee4812 | 2 | Copyright (C) 2010-2023 Free Software Foundation, Inc. |
369451ec JH |
3 | Contributed by Jan Hubicka |
4 | ||
5 | This file is part of GCC. | |
6 | ||
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 | |
10 | version. | |
11 | ||
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 | |
15 | for more details. | |
16 | ||
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/>. */ | |
20 | ||
21 | #include "config.h" | |
22 | #include "system.h" | |
23 | #include "coretypes.h" | |
369451ec | 24 | #include "target.h" |
957060b5 | 25 | #include "tree.h" |
369451ec JH |
26 | #include "cgraph.h" |
27 | ||
d122681a | 28 | /* Remove reference. */ |
369451ec JH |
29 | |
30 | void | |
d122681a | 31 | ipa_ref::remove_reference () |
369451ec | 32 | { |
d122681a ML |
33 | struct ipa_ref_list *list = referred_ref_list (); |
34 | struct ipa_ref_list *list2 = referring_ref_list (); | |
369451ec JH |
35 | struct ipa_ref *last; |
36 | ||
d122681a | 37 | gcc_assert (list->referring[referred_index] == this); |
e55637b7 | 38 | |
9771b263 | 39 | last = list->referring.last (); |
d122681a | 40 | if (this != last) |
369451ec | 41 | { |
e55637b7 ML |
42 | if (use == IPA_REF_ALIAS) |
43 | { | |
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 (); | |
48 | ||
49 | if (last_alias && referred_index < last_alias->referred_index | |
50 | && last_alias != last) | |
51 | { | |
52 | unsigned last_alias_index = last_alias->referred_index; | |
53 | ||
54 | list->referring[referred_index] = last_alias; | |
55 | list->referring[referred_index]->referred_index = referred_index; | |
56 | ||
57 | /* New position for replacement is previous index | |
58 | of the last_alias. */ | |
59 | referred_index = last_alias_index; | |
60 | } | |
61 | } | |
62 | ||
d122681a | 63 | list->referring[referred_index] = list->referring.last (); |
e55637b7 | 64 | list->referring[referred_index]->referred_index= referred_index; |
369451ec | 65 | } |
9771b263 | 66 | list->referring.pop (); |
369451ec | 67 | |
7144270e | 68 | last = &list2->references.last (); |
d122681a ML |
69 | |
70 | struct ipa_ref *ref = this; | |
71 | ||
369451ec JH |
72 | if (ref != last) |
73 | { | |
74 | *ref = *last; | |
e55637b7 | 75 | ref->referred_ref_list ()->referring[referred_index] = ref; |
369451ec | 76 | } |
7144270e | 77 | list2->references.pop (); |
369451ec JH |
78 | } |
79 | ||
d122681a ML |
80 | /* Return true when execution of reference can lead to return from |
81 | function. */ | |
369451ec | 82 | |
f10ea640 | 83 | bool |
d122681a | 84 | ipa_ref::cannot_lead_to_return () |
f10ea640 | 85 | { |
d52f5295 | 86 | return dyn_cast <cgraph_node *> (referring)->cannot_return_p (); |
39e2db00 | 87 | } |
4502fe8d | 88 | |
d122681a | 89 | /* Return reference list this reference is in. */ |
4502fe8d | 90 | |
d122681a ML |
91 | struct ipa_ref_list * |
92 | ipa_ref::referring_ref_list (void) | |
4502fe8d | 93 | { |
d122681a | 94 | return &referring->ref_list; |
4502fe8d | 95 | } |
82338059 | 96 | |
d122681a | 97 | /* Return reference list this reference is in. */ |
82338059 | 98 | |
d122681a ML |
99 | struct ipa_ref_list * |
100 | ipa_ref::referred_ref_list (void) | |
82338059 | 101 | { |
d122681a | 102 | return &referred->ref_list; |
71cafea9 | 103 | } |