* pt.c (lookup_template_class_1): Splice out abi_tag attribute if
[official-gcc.git] / gcc / ipa-ref.c
blob4b23f5fe574449f985bc311e3fc23b5ebee74ff1
1 /* Interprocedural reference lists.
2 Copyright (C) 2010-2014 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
10 version.
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.
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/>. */
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "tree.h"
25 #include "ggc.h"
26 #include "target.h"
27 #include "cgraph.h"
28 #include "ipa-utils.h"
30 /* Remove reference. */
32 void
33 ipa_ref::remove_reference ()
35 struct ipa_ref_list *list = referred_ref_list ();
36 struct ipa_ref_list *list2 = referring_ref_list ();
37 vec<ipa_ref_t, va_gc> *old_references = list2->references;
38 struct ipa_ref *last;
40 gcc_assert (list->referring[referred_index] == this);
42 last = list->referring.last ();
43 if (this != last)
45 if (use == IPA_REF_ALIAS)
47 /* If deleted item is IPA_REF_ALIAS, we have to move last
48 item of IPA_REF_LIST type to the deleted position. After that
49 we replace last node with deletion slot. */
50 struct ipa_ref *last_alias = list->last_alias ();
52 if (last_alias && referred_index < last_alias->referred_index
53 && last_alias != last)
55 unsigned last_alias_index = last_alias->referred_index;
57 list->referring[referred_index] = last_alias;
58 list->referring[referred_index]->referred_index = referred_index;
60 /* New position for replacement is previous index
61 of the last_alias. */
62 referred_index = last_alias_index;
66 list->referring[referred_index] = list->referring.last ();
67 list->referring[referred_index]->referred_index= referred_index;
69 list->referring.pop ();
71 last = &list2->references->last ();
73 struct ipa_ref *ref = this;
75 if (ref != last)
77 *ref = *last;
78 ref->referred_ref_list ()->referring[referred_index] = ref;
80 list2->references->pop ();
81 gcc_assert (list2->references == old_references);
84 /* Return true when execution of reference can lead to return from
85 function. */
87 bool
88 ipa_ref::cannot_lead_to_return ()
90 return dyn_cast <cgraph_node *> (referring)->cannot_return_p ();
93 /* Return reference list this reference is in. */
95 struct ipa_ref_list *
96 ipa_ref::referring_ref_list (void)
98 return &referring->ref_list;
101 /* Return reference list this reference is in. */
103 struct ipa_ref_list *
104 ipa_ref::referred_ref_list (void)
106 return &referred->ref_list;