]>
Commit | Line | Data |
---|---|---|
8d810329 | 1 | /* Interprocedural reference lists. |
fbd26352 | 2 | Copyright (C) 2010-2019 Free Software Foundation, Inc. |
8d810329 | 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" | |
8d810329 | 24 | #include "target.h" |
7c29e30e | 25 | #include "tree.h" |
8d810329 | 26 | #include "cgraph.h" |
27 | ||
51ce5652 | 28 | /* Remove reference. */ |
8d810329 | 29 | |
30 | void | |
51ce5652 | 31 | ipa_ref::remove_reference () |
8d810329 | 32 | { |
51ce5652 | 33 | struct ipa_ref_list *list = referred_ref_list (); |
34 | struct ipa_ref_list *list2 = referring_ref_list (); | |
f1f41a6c | 35 | vec<ipa_ref_t, va_gc> *old_references = list2->references; |
8d810329 | 36 | struct ipa_ref *last; |
37 | ||
51ce5652 | 38 | gcc_assert (list->referring[referred_index] == this); |
e4a2b488 | 39 | |
f1f41a6c | 40 | last = list->referring.last (); |
51ce5652 | 41 | if (this != last) |
8d810329 | 42 | { |
e4a2b488 | 43 | if (use == IPA_REF_ALIAS) |
44 | { | |
45 | /* If deleted item is IPA_REF_ALIAS, we have to move last | |
46 | item of IPA_REF_LIST type to the deleted position. After that | |
47 | we replace last node with deletion slot. */ | |
48 | struct ipa_ref *last_alias = list->last_alias (); | |
49 | ||
50 | if (last_alias && referred_index < last_alias->referred_index | |
51 | && last_alias != last) | |
52 | { | |
53 | unsigned last_alias_index = last_alias->referred_index; | |
54 | ||
55 | list->referring[referred_index] = last_alias; | |
56 | list->referring[referred_index]->referred_index = referred_index; | |
57 | ||
58 | /* New position for replacement is previous index | |
59 | of the last_alias. */ | |
60 | referred_index = last_alias_index; | |
61 | } | |
62 | } | |
63 | ||
51ce5652 | 64 | list->referring[referred_index] = list->referring.last (); |
e4a2b488 | 65 | list->referring[referred_index]->referred_index= referred_index; |
8d810329 | 66 | } |
f1f41a6c | 67 | list->referring.pop (); |
8d810329 | 68 | |
f1f41a6c | 69 | last = &list2->references->last (); |
51ce5652 | 70 | |
71 | struct ipa_ref *ref = this; | |
72 | ||
8d810329 | 73 | if (ref != last) |
74 | { | |
75 | *ref = *last; | |
e4a2b488 | 76 | ref->referred_ref_list ()->referring[referred_index] = ref; |
8d810329 | 77 | } |
f1f41a6c | 78 | list2->references->pop (); |
8d810329 | 79 | gcc_assert (list2->references == old_references); |
80 | } | |
81 | ||
51ce5652 | 82 | /* Return true when execution of reference can lead to return from |
83 | function. */ | |
8d810329 | 84 | |
023a28e1 | 85 | bool |
51ce5652 | 86 | ipa_ref::cannot_lead_to_return () |
023a28e1 | 87 | { |
415d1b9a | 88 | return dyn_cast <cgraph_node *> (referring)->cannot_return_p (); |
c70f46b0 | 89 | } |
096295f6 | 90 | |
51ce5652 | 91 | /* Return reference list this reference is in. */ |
096295f6 | 92 | |
51ce5652 | 93 | struct ipa_ref_list * |
94 | ipa_ref::referring_ref_list (void) | |
096295f6 | 95 | { |
51ce5652 | 96 | return &referring->ref_list; |
096295f6 | 97 | } |
7d9f258f | 98 | |
51ce5652 | 99 | /* Return reference list this reference is in. */ |
7d9f258f | 100 | |
51ce5652 | 101 | struct ipa_ref_list * |
102 | ipa_ref::referred_ref_list (void) | |
7d9f258f | 103 | { |
51ce5652 | 104 | return &referred->ref_list; |
9df17e79 | 105 | } |