1 /* Interprocedural reference lists.
2 Copyright (C) 2010-2015 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"
27 #include "double-int.h"
35 #include "fold-const.h"
40 #include "plugin-api.h"
42 #include "hard-reg-set.h"
47 #include "ipa-utils.h"
49 /* Remove reference. */
52 ipa_ref::remove_reference ()
54 struct ipa_ref_list *list = referred_ref_list ();
55 struct ipa_ref_list *list2 = referring_ref_list ();
56 vec<ipa_ref_t, va_gc> *old_references = list2->references;
59 gcc_assert (list->referring[referred_index] == this);
61 last = list->referring.last ();
64 if (use == IPA_REF_ALIAS)
66 /* If deleted item is IPA_REF_ALIAS, we have to move last
67 item of IPA_REF_LIST type to the deleted position. After that
68 we replace last node with deletion slot. */
69 struct ipa_ref *last_alias = list->last_alias ();
71 if (last_alias && referred_index < last_alias->referred_index
72 && last_alias != last)
74 unsigned last_alias_index = last_alias->referred_index;
76 list->referring[referred_index] = last_alias;
77 list->referring[referred_index]->referred_index = referred_index;
79 /* New position for replacement is previous index
81 referred_index = last_alias_index;
85 list->referring[referred_index] = list->referring.last ();
86 list->referring[referred_index]->referred_index= referred_index;
88 list->referring.pop ();
90 last = &list2->references->last ();
92 struct ipa_ref *ref = this;
97 ref->referred_ref_list ()->referring[referred_index] = ref;
99 list2->references->pop ();
100 gcc_assert (list2->references == old_references);
103 /* Return true when execution of reference can lead to return from
107 ipa_ref::cannot_lead_to_return ()
109 return dyn_cast <cgraph_node *> (referring)->cannot_return_p ();
112 /* Return reference list this reference is in. */
114 struct ipa_ref_list *
115 ipa_ref::referring_ref_list (void)
117 return &referring->ref_list;
120 /* Return reference list this reference is in. */
122 struct ipa_ref_list *
123 ipa_ref::referred_ref_list (void)
125 return &referred->ref_list;