annotate gcc/cgraphbuild.c @ 16:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents f6334be47118
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /* Callgraph construction.
16
kono
parents: 14
diff changeset
2 Copyright (C) 2003-2017 Free Software Foundation, Inc.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 Contributed by Jan Hubicka
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 This file is part of GCC.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 GCC is free software; you can redistribute it and/or modify it under
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 the terms of the GNU General Public License as published by the Free
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 Software Foundation; either version 3, or (at your option) any later
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 version.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 for more details.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 along with GCC; see the file COPYING3. If not see
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 #include "config.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 #include "system.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 #include "coretypes.h"
16
kono
parents: 14
diff changeset
24 #include "backend.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 #include "tree.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 #include "gimple.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 #include "tree-pass.h"
16
kono
parents: 14
diff changeset
28 #include "cgraph.h"
kono
parents: 14
diff changeset
29 #include "gimple-fold.h"
kono
parents: 14
diff changeset
30 #include "gimple-iterator.h"
kono
parents: 14
diff changeset
31 #include "gimple-walk.h"
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
32 #include "ipa-utils.h"
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
33 #include "except.h"
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
34
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
35 /* Context of record_reference. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
36 struct record_reference_ctx
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
37 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
38 bool only_vars;
16
kono
parents: 14
diff changeset
39 class varpool_node *varpool_node;
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
40 };
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 /* Walk tree and record all calls and references to functions/variables.
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
43 Called via walk_tree: TP is pointer to tree to be examined.
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
44 When DATA is non-null, record references to callgraph.
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
45 */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 static tree
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
48 record_reference (tree *tp, int *walk_subtrees, void *data)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 tree t = *tp;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 tree decl;
16
kono
parents: 14
diff changeset
52 record_reference_ctx *ctx = (record_reference_ctx *)data;
kono
parents: 14
diff changeset
53
kono
parents: 14
diff changeset
54 t = canonicalize_constructor_val (t, NULL);
kono
parents: 14
diff changeset
55 if (!t)
kono
parents: 14
diff changeset
56 t = *tp;
kono
parents: 14
diff changeset
57 else if (t != *tp)
kono
parents: 14
diff changeset
58 *tp = t;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 switch (TREE_CODE (t))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 case VAR_DECL:
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
63 case FUNCTION_DECL:
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
64 gcc_unreachable ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 case FDESC_EXPR:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 case ADDR_EXPR:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 /* Record dereferences to the functions. This makes the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 functions reachable unconditionally. */
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
71 decl = get_base_var (*tp);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
72 if (TREE_CODE (decl) == FUNCTION_DECL)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
73 {
16
kono
parents: 14
diff changeset
74 cgraph_node *node = cgraph_node::get_create (decl);
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
75 if (!ctx->only_vars)
16
kono
parents: 14
diff changeset
76 node->mark_address_taken ();
kono
parents: 14
diff changeset
77 ctx->varpool_node->create_reference (node, IPA_REF_ADDR);
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
78 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
79
16
kono
parents: 14
diff changeset
80 if (VAR_P (decl))
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
81 {
16
kono
parents: 14
diff changeset
82 varpool_node *vnode = varpool_node::get_create (decl);
kono
parents: 14
diff changeset
83 ctx->varpool_node->create_reference (vnode, IPA_REF_ADDR);
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
84 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
85 *walk_subtrees = 0;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
87
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 default:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 /* Save some cycles by not walking types and declaration as we
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 won't find anything useful there anyway. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 if (IS_TYPE_OR_DECL_P (*tp))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 *walk_subtrees = 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
98
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 return NULL_TREE;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
102 /* Record references to typeinfos in the type list LIST. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
103
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
104 static void
16
kono
parents: 14
diff changeset
105 record_type_list (cgraph_node *node, tree list)
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
106 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
107 for (; list; list = TREE_CHAIN (list))
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
108 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
109 tree type = TREE_VALUE (list);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
110
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
111 if (TYPE_P (type))
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
112 type = lookup_type_for_runtime (type);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
113 STRIP_NOPS (type);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
114 if (TREE_CODE (type) == ADDR_EXPR)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
115 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
116 type = TREE_OPERAND (type, 0);
16
kono
parents: 14
diff changeset
117 if (VAR_P (type))
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
118 {
16
kono
parents: 14
diff changeset
119 varpool_node *vnode = varpool_node::get_create (type);
kono
parents: 14
diff changeset
120 node->create_reference (vnode, IPA_REF_ADDR);
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
121 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
122 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
123 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
124 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
125
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
126 /* Record all references we will introduce by producing EH tables
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
127 for NODE. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
128
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
129 static void
16
kono
parents: 14
diff changeset
130 record_eh_tables (cgraph_node *node, function *fun)
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
131 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
132 eh_region i;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
133
14
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
134 if (DECL_FUNCTION_PERSONALITY (node->decl))
16
kono
parents: 14
diff changeset
135 {
kono
parents: 14
diff changeset
136 tree per_decl = DECL_FUNCTION_PERSONALITY (node->decl);
kono
parents: 14
diff changeset
137 cgraph_node *per_node = cgraph_node::get_create (per_decl);
kono
parents: 14
diff changeset
138
kono
parents: 14
diff changeset
139 node->create_reference (per_node, IPA_REF_ADDR);
kono
parents: 14
diff changeset
140 per_node->mark_address_taken ();
kono
parents: 14
diff changeset
141 }
14
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
142
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
143 i = fun->eh->region_tree;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
144 if (!i)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
145 return;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
146
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
147 while (1)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
148 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
149 switch (i->type)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
150 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
151 case ERT_CLEANUP:
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
152 case ERT_MUST_NOT_THROW:
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
153 break;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
154
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
155 case ERT_TRY:
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
156 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
157 eh_catch c;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
158 for (c = i->u.eh_try.first_catch; c; c = c->next_catch)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
159 record_type_list (node, c->type_list);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
160 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
161 break;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
162
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
163 case ERT_ALLOWED_EXCEPTIONS:
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
164 record_type_list (node, i->u.allowed.type_list);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
165 break;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
166 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
167 /* If there are sub-regions, process them. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
168 if (i->inner)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
169 i = i->inner;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
170 /* If there are peers, process them. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
171 else if (i->next_peer)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
172 i = i->next_peer;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
173 /* Otherwise, step back up the tree to the next peer. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
174 else
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
175 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
176 do
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
177 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
178 i = i->outer;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
179 if (i == NULL)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
180 return;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
181 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
182 while (i->next_peer == NULL);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
183 i = i->next_peer;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
184 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
185 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
186 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
187
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
188 /* Computes the frequency of the call statement so that it can be stored in
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
189 cgraph_edge. BB is the basic block of the call statement. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
190 int
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
191 compute_call_stmt_bb_frequency (tree decl, basic_block bb)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
192 {
16
kono
parents: 14
diff changeset
193 int entry_freq = ENTRY_BLOCK_PTR_FOR_FN
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
194 (DECL_STRUCT_FUNCTION (decl))->frequency;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
195 int freq = bb->frequency;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
196
16
kono
parents: 14
diff changeset
197 if (profile_status_for_fn (DECL_STRUCT_FUNCTION (decl)) == PROFILE_ABSENT)
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
198 return CGRAPH_FREQ_BASE;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
199
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
200 if (!entry_freq)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
201 entry_freq = 1, freq++;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
202
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 freq = freq * CGRAPH_FREQ_BASE / entry_freq;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
204 if (freq > CGRAPH_FREQ_MAX)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
205 freq = CGRAPH_FREQ_MAX;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
206
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
207 return freq;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
208 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
209
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
210 /* Mark address taken in STMT. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
211
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
212 static bool
16
kono
parents: 14
diff changeset
213 mark_address (gimple *stmt, tree addr, tree, void *data)
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
214 {
14
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
215 addr = get_base_address (addr);
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
216 if (TREE_CODE (addr) == FUNCTION_DECL)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
217 {
16
kono
parents: 14
diff changeset
218 cgraph_node *node = cgraph_node::get_create (addr);
kono
parents: 14
diff changeset
219 node->mark_address_taken ();
kono
parents: 14
diff changeset
220 ((symtab_node *)data)->create_reference (node, IPA_REF_ADDR, stmt);
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
221 }
16
kono
parents: 14
diff changeset
222 else if (addr && VAR_P (addr)
14
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
223 && (TREE_STATIC (addr) || DECL_EXTERNAL (addr)))
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
224 {
16
kono
parents: 14
diff changeset
225 varpool_node *vnode = varpool_node::get_create (addr);
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
226
16
kono
parents: 14
diff changeset
227 ((symtab_node *)data)->create_reference (vnode, IPA_REF_ADDR, stmt);
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
228 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
229
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
230 return false;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
231 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
232
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
233 /* Mark load of T. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
234
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
235 static bool
16
kono
parents: 14
diff changeset
236 mark_load (gimple *stmt, tree t, tree, void *data)
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
237 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
238 t = get_base_address (t);
14
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
239 if (t && TREE_CODE (t) == FUNCTION_DECL)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
240 {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
241 /* ??? This can happen on platforms with descriptors when these are
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
242 directly manipulated in the code. Pretend that it's an address. */
16
kono
parents: 14
diff changeset
243 cgraph_node *node = cgraph_node::get_create (t);
kono
parents: 14
diff changeset
244 node->mark_address_taken ();
kono
parents: 14
diff changeset
245 ((symtab_node *)data)->create_reference (node, IPA_REF_ADDR, stmt);
14
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
246 }
16
kono
parents: 14
diff changeset
247 else if (t && VAR_P (t) && (TREE_STATIC (t) || DECL_EXTERNAL (t)))
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
248 {
16
kono
parents: 14
diff changeset
249 varpool_node *vnode = varpool_node::get_create (t);
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
250
16
kono
parents: 14
diff changeset
251 ((symtab_node *)data)->create_reference (vnode, IPA_REF_LOAD, stmt);
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
252 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
253 return false;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
254 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
255
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
256 /* Mark store of T. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
257
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
258 static bool
16
kono
parents: 14
diff changeset
259 mark_store (gimple *stmt, tree t, tree, void *data)
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
260 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
261 t = get_base_address (t);
16
kono
parents: 14
diff changeset
262 if (t && VAR_P (t) && (TREE_STATIC (t) || DECL_EXTERNAL (t)))
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
263 {
16
kono
parents: 14
diff changeset
264 varpool_node *vnode = varpool_node::get_create (t);
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
265
16
kono
parents: 14
diff changeset
266 ((symtab_node *)data)->create_reference (vnode, IPA_REF_STORE, stmt);
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
267 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
268 return false;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
269 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
270
16
kono
parents: 14
diff changeset
271 /* Record all references from cgraph_node that are taken in statement STMT. */
kono
parents: 14
diff changeset
272
kono
parents: 14
diff changeset
273 void
kono
parents: 14
diff changeset
274 cgraph_node::record_stmt_references (gimple *stmt)
kono
parents: 14
diff changeset
275 {
kono
parents: 14
diff changeset
276 walk_stmt_load_store_addr_ops (stmt, this, mark_load, mark_store,
kono
parents: 14
diff changeset
277 mark_address);
kono
parents: 14
diff changeset
278 }
kono
parents: 14
diff changeset
279
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
280 /* Create cgraph edges for function calls.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
281 Also look for functions and variables having addresses taken. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
282
16
kono
parents: 14
diff changeset
283 namespace {
kono
parents: 14
diff changeset
284
kono
parents: 14
diff changeset
285 const pass_data pass_data_build_cgraph_edges =
kono
parents: 14
diff changeset
286 {
kono
parents: 14
diff changeset
287 GIMPLE_PASS, /* type */
kono
parents: 14
diff changeset
288 "*build_cgraph_edges", /* name */
kono
parents: 14
diff changeset
289 OPTGROUP_NONE, /* optinfo_flags */
kono
parents: 14
diff changeset
290 TV_NONE, /* tv_id */
kono
parents: 14
diff changeset
291 PROP_cfg, /* properties_required */
kono
parents: 14
diff changeset
292 0, /* properties_provided */
kono
parents: 14
diff changeset
293 0, /* properties_destroyed */
kono
parents: 14
diff changeset
294 0, /* todo_flags_start */
kono
parents: 14
diff changeset
295 0, /* todo_flags_finish */
kono
parents: 14
diff changeset
296 };
kono
parents: 14
diff changeset
297
kono
parents: 14
diff changeset
298 class pass_build_cgraph_edges : public gimple_opt_pass
kono
parents: 14
diff changeset
299 {
kono
parents: 14
diff changeset
300 public:
kono
parents: 14
diff changeset
301 pass_build_cgraph_edges (gcc::context *ctxt)
kono
parents: 14
diff changeset
302 : gimple_opt_pass (pass_data_build_cgraph_edges, ctxt)
kono
parents: 14
diff changeset
303 {}
kono
parents: 14
diff changeset
304
kono
parents: 14
diff changeset
305 /* opt_pass methods: */
kono
parents: 14
diff changeset
306 virtual unsigned int execute (function *);
kono
parents: 14
diff changeset
307
kono
parents: 14
diff changeset
308 }; // class pass_build_cgraph_edges
kono
parents: 14
diff changeset
309
kono
parents: 14
diff changeset
310 unsigned int
kono
parents: 14
diff changeset
311 pass_build_cgraph_edges::execute (function *fun)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
312 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
313 basic_block bb;
16
kono
parents: 14
diff changeset
314 cgraph_node *node = cgraph_node::get (current_function_decl);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
315 gimple_stmt_iterator gsi;
14
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
316 tree decl;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
317 unsigned ix;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
318
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
319 /* Create the callgraph edges and record the nodes referenced by the function.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
320 body. */
16
kono
parents: 14
diff changeset
321 FOR_EACH_BB_FN (bb, fun)
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
322 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
323 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
324 {
16
kono
parents: 14
diff changeset
325 gimple *stmt = gsi_stmt (gsi);
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
326 tree decl;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
327
16
kono
parents: 14
diff changeset
328 if (is_gimple_debug (stmt))
kono
parents: 14
diff changeset
329 continue;
kono
parents: 14
diff changeset
330
kono
parents: 14
diff changeset
331 if (gcall *call_stmt = dyn_cast <gcall *> (stmt))
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
332 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
333 int freq = compute_call_stmt_bb_frequency (current_function_decl,
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
334 bb);
16
kono
parents: 14
diff changeset
335 decl = gimple_call_fndecl (call_stmt);
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
336 if (decl)
16
kono
parents: 14
diff changeset
337 node->create_edge (cgraph_node::get_create (decl), call_stmt, bb->count, freq);
kono
parents: 14
diff changeset
338 else if (gimple_call_internal_p (call_stmt))
kono
parents: 14
diff changeset
339 ;
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
340 else
16
kono
parents: 14
diff changeset
341 node->create_indirect_edge (call_stmt,
kono
parents: 14
diff changeset
342 gimple_call_flags (call_stmt),
kono
parents: 14
diff changeset
343 bb->count, freq);
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
344 }
16
kono
parents: 14
diff changeset
345 node->record_stmt_references (stmt);
kono
parents: 14
diff changeset
346 if (gomp_parallel *omp_par_stmt = dyn_cast <gomp_parallel *> (stmt))
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
347 {
16
kono
parents: 14
diff changeset
348 tree fn = gimple_omp_parallel_child_fn (omp_par_stmt);
kono
parents: 14
diff changeset
349 node->create_reference (cgraph_node::get_create (fn),
kono
parents: 14
diff changeset
350 IPA_REF_ADDR, stmt);
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
351 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
352 if (gimple_code (stmt) == GIMPLE_OMP_TASK)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
353 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
354 tree fn = gimple_omp_task_child_fn (stmt);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
355 if (fn)
16
kono
parents: 14
diff changeset
356 node->create_reference (cgraph_node::get_create (fn),
kono
parents: 14
diff changeset
357 IPA_REF_ADDR, stmt);
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
358 fn = gimple_omp_task_copy_fn (stmt);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
359 if (fn)
16
kono
parents: 14
diff changeset
360 node->create_reference (cgraph_node::get_create (fn),
kono
parents: 14
diff changeset
361 IPA_REF_ADDR, stmt);
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
362 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
363 }
16
kono
parents: 14
diff changeset
364 for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
kono
parents: 14
diff changeset
365 node->record_stmt_references (gsi_stmt (gsi));
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
366 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
367
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
368 /* Look for initializers of constant variables and private statics. */
16
kono
parents: 14
diff changeset
369 FOR_EACH_LOCAL_DECL (fun, ix, decl)
kono
parents: 14
diff changeset
370 if (VAR_P (decl)
kono
parents: 14
diff changeset
371 && (TREE_STATIC (decl) && !DECL_EXTERNAL (decl))
kono
parents: 14
diff changeset
372 && !DECL_HAS_VALUE_EXPR_P (decl)
kono
parents: 14
diff changeset
373 && TREE_TYPE (decl) != error_mark_node)
kono
parents: 14
diff changeset
374 varpool_node::finalize_decl (decl);
kono
parents: 14
diff changeset
375 record_eh_tables (node, fun);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
376
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
377 return 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
378 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
379
16
kono
parents: 14
diff changeset
380 } // anon namespace
kono
parents: 14
diff changeset
381
kono
parents: 14
diff changeset
382 gimple_opt_pass *
kono
parents: 14
diff changeset
383 make_pass_build_cgraph_edges (gcc::context *ctxt)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
384 {
16
kono
parents: 14
diff changeset
385 return new pass_build_cgraph_edges (ctxt);
kono
parents: 14
diff changeset
386 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
387
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
388 /* Record references to functions and other variables present in the
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
389 initial value of DECL, a variable.
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
390 When ONLY_VARS is true, we mark needed only variables, not functions. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
391
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
392 void
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
393 record_references_in_initializer (tree decl, bool only_vars)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
394 {
16
kono
parents: 14
diff changeset
395 varpool_node *node = varpool_node::get_create (decl);
kono
parents: 14
diff changeset
396 hash_set<tree> visited_nodes;
kono
parents: 14
diff changeset
397 record_reference_ctx ctx = {false, NULL};
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
398
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
399 ctx.varpool_node = node;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
400 ctx.only_vars = only_vars;
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
401 walk_tree (&DECL_INITIAL (decl), record_reference,
16
kono
parents: 14
diff changeset
402 &ctx, &visited_nodes);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
403 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
404
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
405 /* Rebuild cgraph edges for current function node. This needs to be run after
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
406 passes that don't update the cgraph. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
407
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
408 unsigned int
16
kono
parents: 14
diff changeset
409 cgraph_edge::rebuild_edges (void)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
410 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
411 basic_block bb;
16
kono
parents: 14
diff changeset
412 cgraph_node *node = cgraph_node::get (current_function_decl);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
413 gimple_stmt_iterator gsi;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
414
16
kono
parents: 14
diff changeset
415 node->remove_callees ();
kono
parents: 14
diff changeset
416 node->remove_all_references ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
417
16
kono
parents: 14
diff changeset
418 node->count = ENTRY_BLOCK_PTR_FOR_FN (cfun)->count;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
419
16
kono
parents: 14
diff changeset
420 FOR_EACH_BB_FN (bb, cfun)
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
421 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
422 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
423 {
16
kono
parents: 14
diff changeset
424 gimple *stmt = gsi_stmt (gsi);
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
425 tree decl;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
426
16
kono
parents: 14
diff changeset
427 if (gcall *call_stmt = dyn_cast <gcall *> (stmt))
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
428 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
429 int freq = compute_call_stmt_bb_frequency (current_function_decl,
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
430 bb);
16
kono
parents: 14
diff changeset
431 decl = gimple_call_fndecl (call_stmt);
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
432 if (decl)
16
kono
parents: 14
diff changeset
433 node->create_edge (cgraph_node::get_create (decl), call_stmt,
kono
parents: 14
diff changeset
434 bb->count, freq);
kono
parents: 14
diff changeset
435 else if (gimple_call_internal_p (call_stmt))
kono
parents: 14
diff changeset
436 ;
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
437 else
16
kono
parents: 14
diff changeset
438 node->create_indirect_edge (call_stmt,
kono
parents: 14
diff changeset
439 gimple_call_flags (call_stmt),
kono
parents: 14
diff changeset
440 bb->count, freq);
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
441 }
16
kono
parents: 14
diff changeset
442 node->record_stmt_references (stmt);
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
443 }
16
kono
parents: 14
diff changeset
444 for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
kono
parents: 14
diff changeset
445 node->record_stmt_references (gsi_stmt (gsi));
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
446 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
447 record_eh_tables (node, cfun);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
448 gcc_assert (!node->global.inlined_to);
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
449
16
kono
parents: 14
diff changeset
450 if (node->instrumented_version
kono
parents: 14
diff changeset
451 && !node->instrumentation_clone)
kono
parents: 14
diff changeset
452 node->create_reference (node->instrumented_version, IPA_REF_CHKP, NULL);
kono
parents: 14
diff changeset
453
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
454 return 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
455 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
456
16
kono
parents: 14
diff changeset
457 /* Rebuild cgraph references for current function node. This needs to be run
kono
parents: 14
diff changeset
458 after passes that don't update the cgraph. */
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
459
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
460 void
16
kono
parents: 14
diff changeset
461 cgraph_edge::rebuild_references (void)
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
462 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
463 basic_block bb;
16
kono
parents: 14
diff changeset
464 cgraph_node *node = cgraph_node::get (current_function_decl);
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
465 gimple_stmt_iterator gsi;
16
kono
parents: 14
diff changeset
466 ipa_ref *ref = NULL;
kono
parents: 14
diff changeset
467 int i;
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
468
16
kono
parents: 14
diff changeset
469 /* Keep speculative references for further cgraph edge expansion. */
kono
parents: 14
diff changeset
470 for (i = 0; node->iterate_reference (i, ref);)
kono
parents: 14
diff changeset
471 if (!ref->speculative)
kono
parents: 14
diff changeset
472 ref->remove_reference ();
kono
parents: 14
diff changeset
473 else
kono
parents: 14
diff changeset
474 i++;
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
475
16
kono
parents: 14
diff changeset
476 FOR_EACH_BB_FN (bb, cfun)
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
477 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
478 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
16
kono
parents: 14
diff changeset
479 node->record_stmt_references (gsi_stmt (gsi));
kono
parents: 14
diff changeset
480 for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
kono
parents: 14
diff changeset
481 node->record_stmt_references (gsi_stmt (gsi));
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
482 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
483 record_eh_tables (node, cfun);
16
kono
parents: 14
diff changeset
484
kono
parents: 14
diff changeset
485 if (node->instrumented_version
kono
parents: 14
diff changeset
486 && !node->instrumentation_clone)
kono
parents: 14
diff changeset
487 node->create_reference (node->instrumented_version, IPA_REF_CHKP, NULL);
11
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
488 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
489
16
kono
parents: 14
diff changeset
490 namespace {
kono
parents: 14
diff changeset
491
kono
parents: 14
diff changeset
492 const pass_data pass_data_rebuild_cgraph_edges =
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
493 {
16
kono
parents: 14
diff changeset
494 GIMPLE_PASS, /* type */
kono
parents: 14
diff changeset
495 "*rebuild_cgraph_edges", /* name */
kono
parents: 14
diff changeset
496 OPTGROUP_NONE, /* optinfo_flags */
kono
parents: 14
diff changeset
497 TV_CGRAPH, /* tv_id */
kono
parents: 14
diff changeset
498 PROP_cfg, /* properties_required */
kono
parents: 14
diff changeset
499 0, /* properties_provided */
kono
parents: 14
diff changeset
500 0, /* properties_destroyed */
kono
parents: 14
diff changeset
501 0, /* todo_flags_start */
kono
parents: 14
diff changeset
502 0, /* todo_flags_finish */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
503 };
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
504
16
kono
parents: 14
diff changeset
505 class pass_rebuild_cgraph_edges : public gimple_opt_pass
kono
parents: 14
diff changeset
506 {
kono
parents: 14
diff changeset
507 public:
kono
parents: 14
diff changeset
508 pass_rebuild_cgraph_edges (gcc::context *ctxt)
kono
parents: 14
diff changeset
509 : gimple_opt_pass (pass_data_rebuild_cgraph_edges, ctxt)
kono
parents: 14
diff changeset
510 {}
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
511
16
kono
parents: 14
diff changeset
512 /* opt_pass methods: */
kono
parents: 14
diff changeset
513 opt_pass * clone () { return new pass_rebuild_cgraph_edges (m_ctxt); }
kono
parents: 14
diff changeset
514 virtual unsigned int execute (function *)
kono
parents: 14
diff changeset
515 {
kono
parents: 14
diff changeset
516 return cgraph_edge::rebuild_edges ();
kono
parents: 14
diff changeset
517 }
kono
parents: 14
diff changeset
518
kono
parents: 14
diff changeset
519 }; // class pass_rebuild_cgraph_edges
kono
parents: 14
diff changeset
520
kono
parents: 14
diff changeset
521 } // anon namespace
kono
parents: 14
diff changeset
522
kono
parents: 14
diff changeset
523 gimple_opt_pass *
kono
parents: 14
diff changeset
524 make_pass_rebuild_cgraph_edges (gcc::context *ctxt)
kono
parents: 14
diff changeset
525 {
kono
parents: 14
diff changeset
526 return new pass_rebuild_cgraph_edges (ctxt);
kono
parents: 14
diff changeset
527 }
kono
parents: 14
diff changeset
528
kono
parents: 14
diff changeset
529
kono
parents: 14
diff changeset
530 namespace {
kono
parents: 14
diff changeset
531
kono
parents: 14
diff changeset
532 const pass_data pass_data_remove_cgraph_callee_edges =
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
533 {
16
kono
parents: 14
diff changeset
534 GIMPLE_PASS, /* type */
kono
parents: 14
diff changeset
535 "*remove_cgraph_callee_edges", /* name */
kono
parents: 14
diff changeset
536 OPTGROUP_NONE, /* optinfo_flags */
kono
parents: 14
diff changeset
537 TV_NONE, /* tv_id */
kono
parents: 14
diff changeset
538 0, /* properties_required */
kono
parents: 14
diff changeset
539 0, /* properties_provided */
kono
parents: 14
diff changeset
540 0, /* properties_destroyed */
kono
parents: 14
diff changeset
541 0, /* todo_flags_start */
kono
parents: 14
diff changeset
542 0, /* todo_flags_finish */
kono
parents: 14
diff changeset
543 };
kono
parents: 14
diff changeset
544
kono
parents: 14
diff changeset
545 class pass_remove_cgraph_callee_edges : public gimple_opt_pass
kono
parents: 14
diff changeset
546 {
kono
parents: 14
diff changeset
547 public:
kono
parents: 14
diff changeset
548 pass_remove_cgraph_callee_edges (gcc::context *ctxt)
kono
parents: 14
diff changeset
549 : gimple_opt_pass (pass_data_remove_cgraph_callee_edges, ctxt)
kono
parents: 14
diff changeset
550 {}
kono
parents: 14
diff changeset
551
kono
parents: 14
diff changeset
552 /* opt_pass methods: */
kono
parents: 14
diff changeset
553 opt_pass * clone () {
kono
parents: 14
diff changeset
554 return new pass_remove_cgraph_callee_edges (m_ctxt);
kono
parents: 14
diff changeset
555 }
kono
parents: 14
diff changeset
556 virtual unsigned int execute (function *);
kono
parents: 14
diff changeset
557
kono
parents: 14
diff changeset
558 }; // class pass_remove_cgraph_callee_edges
kono
parents: 14
diff changeset
559
kono
parents: 14
diff changeset
560 unsigned int
kono
parents: 14
diff changeset
561 pass_remove_cgraph_callee_edges::execute (function *)
kono
parents: 14
diff changeset
562 {
kono
parents: 14
diff changeset
563 cgraph_node *node = cgraph_node::get (current_function_decl);
kono
parents: 14
diff changeset
564 node->remove_callees ();
kono
parents: 14
diff changeset
565 node->remove_all_references ();
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
566 return 0;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
567 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
568
16
kono
parents: 14
diff changeset
569 } // anon namespace
kono
parents: 14
diff changeset
570
kono
parents: 14
diff changeset
571 gimple_opt_pass *
kono
parents: 14
diff changeset
572 make_pass_remove_cgraph_callee_edges (gcc::context *ctxt)
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
573 {
16
kono
parents: 14
diff changeset
574 return new pass_remove_cgraph_callee_edges (ctxt);
kono
parents: 14
diff changeset
575 }