stor-layout.c (finish_builtin_struct): Copy fields into the variants.
[gcc.git] / gcc / ipa-ref.c
1 /* Interprocedural reference lists.
2 Copyright (C) 2010-2014 Free Software Foundation, Inc.
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"
24 #include "tree.h"
25 #include "ggc.h"
26 #include "target.h"
27 #include "cgraph.h"
28 #include "ipa-utils.h"
29
30 /* Remove reference. */
31
32 void
33 ipa_ref::remove_reference ()
34 {
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;
39
40 gcc_assert (list->referring[referred_index] == this);
41 last = list->referring.last ();
42 if (this != last)
43 {
44 list->referring[referred_index] = list->referring.last ();
45 list->referring[referred_index]->referred_index
46 = referred_index;
47 }
48 list->referring.pop ();
49
50 last = &list2->references->last ();
51
52 struct ipa_ref *ref = this;
53
54 if (ref != last)
55 {
56 *ref = *last;
57 referred_ref_list ()->referring[referred_index] = ref;
58 }
59 list2->references->pop ();
60 gcc_assert (list2->references == old_references);
61 }
62
63 /* Return true when execution of reference can lead to return from
64 function. */
65
66 bool
67 ipa_ref::cannot_lead_to_return ()
68 {
69 return cgraph_node_cannot_return (dyn_cast <cgraph_node *> (referring));
70 }
71
72 /* Return reference list this reference is in. */
73
74 struct ipa_ref_list *
75 ipa_ref::referring_ref_list (void)
76 {
77 return &referring->ref_list;
78 }
79
80 /* Return reference list this reference is in. */
81
82 struct ipa_ref_list *
83 ipa_ref::referred_ref_list (void)
84 {
85 return &referred->ref_list;
86 }