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 "fold-const.h"
30 #include "hard-reg-set.h"
33 #include "ipa-utils.h"
35 /* Remove reference. */
38 ipa_ref::remove_reference ()
40 struct ipa_ref_list
*list
= referred_ref_list ();
41 struct ipa_ref_list
*list2
= referring_ref_list ();
42 vec
<ipa_ref_t
, va_gc
> *old_references
= list2
->references
;
45 gcc_assert (list
->referring
[referred_index
] == this);
47 last
= list
->referring
.last ();
50 if (use
== IPA_REF_ALIAS
)
52 /* If deleted item is IPA_REF_ALIAS, we have to move last
53 item of IPA_REF_LIST type to the deleted position. After that
54 we replace last node with deletion slot. */
55 struct ipa_ref
*last_alias
= list
->last_alias ();
57 if (last_alias
&& referred_index
< last_alias
->referred_index
58 && last_alias
!= last
)
60 unsigned last_alias_index
= last_alias
->referred_index
;
62 list
->referring
[referred_index
] = last_alias
;
63 list
->referring
[referred_index
]->referred_index
= referred_index
;
65 /* New position for replacement is previous index
67 referred_index
= last_alias_index
;
71 list
->referring
[referred_index
] = list
->referring
.last ();
72 list
->referring
[referred_index
]->referred_index
= referred_index
;
74 list
->referring
.pop ();
76 last
= &list2
->references
->last ();
78 struct ipa_ref
*ref
= this;
83 ref
->referred_ref_list ()->referring
[referred_index
] = ref
;
85 list2
->references
->pop ();
86 gcc_assert (list2
->references
== old_references
);
89 /* Return true when execution of reference can lead to return from
93 ipa_ref::cannot_lead_to_return ()
95 return dyn_cast
<cgraph_node
*> (referring
)->cannot_return_p ();
98 /* Return reference list this reference is in. */
100 struct ipa_ref_list
*
101 ipa_ref::referring_ref_list (void)
103 return &referring
->ref_list
;
106 /* Return reference list this reference is in. */
108 struct ipa_ref_list
*
109 ipa_ref::referred_ref_list (void)
111 return &referred
->ref_list
;