annotate gcc/ipa-reference.c @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
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 based analysis of static variables.
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
2 Copyright (C) 2004-2020 Free Software Foundation, Inc.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 Contributed by Kenneth Zadeck <zadeck@naturalbridge.com>
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 /* This file gathers information about how variables whose scope is
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
22 confined to the compilation unit are used.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
24 The transitive call site specific clobber effects are computed
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 for the variables whose scope is contained within this compilation
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 unit.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 First each function and static variable initialization is analyzed
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 to determine which local static variables are either read, written,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 or have their address taken. Any local static that has its address
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 taken is removed from consideration. Once the local read and
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 writes are determined, a transitive closure of this information is
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 performed over the call graph to determine the worst case set of
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 side effects of each call. In later parts of the compiler, these
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 local and global sets are examined to make the call clobbering less
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 traumatic, promote some statics to registers, and improve aliasing
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
37 information. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 #include "config.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 #include "system.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 #include "coretypes.h"
111
kono
parents: 67
diff changeset
42 #include "backend.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 #include "tree.h"
111
kono
parents: 67
diff changeset
44 #include "gimple.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 #include "tree-pass.h"
111
kono
parents: 67
diff changeset
46 #include "cgraph.h"
kono
parents: 67
diff changeset
47 #include "data-streamer.h"
kono
parents: 67
diff changeset
48 #include "calls.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 #include "ipa-utils.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 #include "ipa-reference.h"
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
51 #include "alloc-pool.h"
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
52 #include "symbol-summary.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 /* The static variables defined within the compilation unit that are
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
55 loaded or stored directly by function that owns this structure. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
57 struct ipa_reference_local_vars_info_d
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 bitmap statics_read;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 bitmap statics_written;
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
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 /* Statics that are read and written by some set of functions. The
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 local ones are based on the loads and stores local to the function.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 The global ones are based on the local info as well as the
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
66 transitive closure of the functions that are called. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 struct ipa_reference_global_vars_info_d
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 bitmap statics_read;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 bitmap statics_written;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
72 };
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
73
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
74 /* Information we save about every function after ipa-reference is completed. */
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
75
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
76 struct ipa_reference_optimization_summary_d
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
77 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
78 bitmap statics_read;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
79 bitmap statics_written;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
82 typedef ipa_reference_local_vars_info_d *ipa_reference_local_vars_info_t;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
83 typedef ipa_reference_global_vars_info_d *ipa_reference_global_vars_info_t;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
84 typedef ipa_reference_optimization_summary_d *
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
85 ipa_reference_optimization_summary_t;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
86
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
87 struct ipa_reference_vars_info_d
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 {
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
89 struct ipa_reference_local_vars_info_d local;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
90 struct ipa_reference_global_vars_info_d global;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 };
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 typedef struct ipa_reference_vars_info_d *ipa_reference_vars_info_t;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
94
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
95 /* This map contains all of the static variables that are
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
96 being considered by the compilation level alias analysis. */
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
97 typedef hash_map<tree, int> reference_vars_map_t;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
98 static reference_vars_map_t *ipa_reference_vars_map;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
99 static int ipa_reference_vars_uids;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
100 static vec<tree> *reference_vars_to_consider;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
101 varpool_node_hook_list *varpool_node_hooks;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
102
111
kono
parents: 67
diff changeset
103 /* Set of all interesting module statics. A bit is set for every module
kono
parents: 67
diff changeset
104 static we are considering. This is added to the local info when asm
kono
parents: 67
diff changeset
105 code is found that clobbers all memory. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 static bitmap all_module_statics;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
107 /* Zero bitmap. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
108 static bitmap no_module_statics;
111
kono
parents: 67
diff changeset
109 /* Set of all statics that should be ignored because they are touched by
kono
parents: 67
diff changeset
110 -fno-ipa-reference code. */
kono
parents: 67
diff changeset
111 static bitmap ignore_module_statics;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
112
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 /* Obstack holding bitmaps of local analysis (live from analysis to
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 propagation) */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 static bitmap_obstack local_info_obstack;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 /* Obstack holding global analysis live forever. */
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
117 static bitmap_obstack optimization_summary_obstack;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
118
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
119 class ipa_ref_var_info_summary_t: public fast_function_summary
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
120 <ipa_reference_vars_info_d *, va_heap>
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
121 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
122 public:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
123 ipa_ref_var_info_summary_t (symbol_table *symtab):
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
124 fast_function_summary <ipa_reference_vars_info_d *, va_heap> (symtab) {}
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
125 };
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
126
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
127 static ipa_ref_var_info_summary_t *ipa_ref_var_info_summaries = NULL;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
128
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
129 class ipa_ref_opt_summary_t: public fast_function_summary
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
130 <ipa_reference_optimization_summary_d *, va_heap>
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
131 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
132 public:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
133 ipa_ref_opt_summary_t (symbol_table *symtab):
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
134 fast_function_summary <ipa_reference_optimization_summary_d *, va_heap> (symtab) {}
111
kono
parents: 67
diff changeset
135
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
136 virtual void remove (cgraph_node *src_node,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
137 ipa_reference_optimization_summary_d *data);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
138 virtual void duplicate (cgraph_node *src_node, cgraph_node *dst_node,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
139 ipa_reference_optimization_summary_d *src_data,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
140 ipa_reference_optimization_summary_d *dst_data);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
141 };
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
142
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
143 static ipa_ref_opt_summary_t *ipa_ref_opt_sum_summaries = NULL;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
144
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
145 /* Return ID used by ipa-reference bitmaps. -1 if failed. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
146 int
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
147 ipa_reference_var_uid (tree t)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
148 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
149 if (!ipa_reference_vars_map)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
150 return -1;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
151 int *id = ipa_reference_vars_map->get
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
152 (symtab_node::get (t)->ultimate_alias_target (NULL)->decl);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
153 if (!id)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
154 return -1;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
155 return *id;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
156 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
157
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
158 /* Return ID used by ipa-reference bitmaps. Create new entry if
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
159 T is not in map. Set EXISTED accordinly */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
160 int
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
161 ipa_reference_var_get_or_insert_uid (tree t, bool *existed)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
162 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
163 int &id = ipa_reference_vars_map->get_or_insert
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
164 (symtab_node::get (t)->ultimate_alias_target (NULL)->decl, existed);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
165 if (!*existed)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
166 id = ipa_reference_vars_uids++;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
167 return id;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
168 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
169
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
170 /* Return the ipa_reference_vars structure starting from the cgraph NODE. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 static inline ipa_reference_vars_info_t
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
172 get_reference_vars_info (struct cgraph_node *node)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
173 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
174 if (ipa_ref_var_info_summaries == NULL)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
175 return NULL;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
176
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
177 ipa_reference_vars_info_t v = ipa_ref_var_info_summaries->get (node);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
178 return v == NULL ? NULL : v;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
179 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
180
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
181 /* Return the ipa_reference_vars structure starting from the cgraph NODE. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
182 static inline ipa_reference_optimization_summary_t
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
183 get_reference_optimization_summary (struct cgraph_node *node)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
184 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
185 if (ipa_ref_opt_sum_summaries == NULL)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
186 return NULL;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
187
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
188 ipa_reference_optimization_summary_t v
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
189 = ipa_ref_opt_sum_summaries->get (node);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
190
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
191 return v == NULL ? NULL : v;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
192 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
193
111
kono
parents: 67
diff changeset
194 /* Return a bitmap indexed by ipa_reference_var_uid for the static variables
kono
parents: 67
diff changeset
195 that are *not* read during the execution of the function FN. Returns
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
196 NULL if no data is available. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
197
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
198 bitmap
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
199 ipa_reference_get_read_global (struct cgraph_node *fn)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
200 {
111
kono
parents: 67
diff changeset
201 if (!opt_for_fn (current_function_decl, flag_ipa_reference))
kono
parents: 67
diff changeset
202 return NULL;
kono
parents: 67
diff changeset
203
kono
parents: 67
diff changeset
204 enum availability avail;
kono
parents: 67
diff changeset
205 struct cgraph_node *fn2 = fn->function_symbol (&avail);
kono
parents: 67
diff changeset
206 ipa_reference_optimization_summary_t info =
kono
parents: 67
diff changeset
207 get_reference_optimization_summary (fn2);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
208
111
kono
parents: 67
diff changeset
209 if (info
kono
parents: 67
diff changeset
210 && (avail >= AVAIL_AVAILABLE
kono
parents: 67
diff changeset
211 || (avail == AVAIL_INTERPOSABLE
kono
parents: 67
diff changeset
212 && flags_from_decl_or_type (fn->decl) & ECF_LEAF))
kono
parents: 67
diff changeset
213 && opt_for_fn (fn2->decl, flag_ipa_reference))
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
214 return info->statics_read;
111
kono
parents: 67
diff changeset
215 else if (avail == AVAIL_NOT_AVAILABLE
kono
parents: 67
diff changeset
216 && flags_from_decl_or_type (fn->decl) & ECF_LEAF)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
217 return no_module_statics;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
218 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
219 return NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
220 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
221
111
kono
parents: 67
diff changeset
222 /* Return a bitmap indexed by ipa_reference_var_uid for the static variables
kono
parents: 67
diff changeset
223 that are *not* written during the execution of the function FN. Note
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
224 that variables written may or may not be read during the function
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
225 call. Returns NULL if no data is available. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
226
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
227 bitmap
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
228 ipa_reference_get_written_global (struct cgraph_node *fn)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
229 {
111
kono
parents: 67
diff changeset
230 if (!opt_for_fn (current_function_decl, flag_ipa_reference))
kono
parents: 67
diff changeset
231 return NULL;
kono
parents: 67
diff changeset
232
kono
parents: 67
diff changeset
233 enum availability avail;
kono
parents: 67
diff changeset
234 struct cgraph_node *fn2 = fn->function_symbol (&avail);
kono
parents: 67
diff changeset
235 ipa_reference_optimization_summary_t info =
kono
parents: 67
diff changeset
236 get_reference_optimization_summary (fn2);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
237
111
kono
parents: 67
diff changeset
238 if (info
kono
parents: 67
diff changeset
239 && (avail >= AVAIL_AVAILABLE
kono
parents: 67
diff changeset
240 || (avail == AVAIL_INTERPOSABLE
kono
parents: 67
diff changeset
241 && flags_from_decl_or_type (fn->decl) & ECF_LEAF))
kono
parents: 67
diff changeset
242 && opt_for_fn (fn2->decl, flag_ipa_reference))
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
243 return info->statics_written;
111
kono
parents: 67
diff changeset
244 else if (avail == AVAIL_NOT_AVAILABLE
kono
parents: 67
diff changeset
245 && flags_from_decl_or_type (fn->decl) & ECF_LEAF)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
246 return no_module_statics;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
247 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
248 return NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
249 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
250
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
251
111
kono
parents: 67
diff changeset
252 /* Hepler for is_proper_for_analysis. */
kono
parents: 67
diff changeset
253 static bool
kono
parents: 67
diff changeset
254 is_improper (symtab_node *n, void *v ATTRIBUTE_UNUSED)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
255 {
111
kono
parents: 67
diff changeset
256 tree t = n->decl;
kono
parents: 67
diff changeset
257 /* If the variable has the "used" attribute, treat it as if it had a
kono
parents: 67
diff changeset
258 been touched by the devil. */
kono
parents: 67
diff changeset
259 if (DECL_PRESERVE_P (t))
kono
parents: 67
diff changeset
260 return true;
kono
parents: 67
diff changeset
261
kono
parents: 67
diff changeset
262 /* Do not want to do anything with volatile except mark any
kono
parents: 67
diff changeset
263 function that uses one to be not const or pure. */
kono
parents: 67
diff changeset
264 if (TREE_THIS_VOLATILE (t))
kono
parents: 67
diff changeset
265 return true;
kono
parents: 67
diff changeset
266
kono
parents: 67
diff changeset
267 /* We do not need to analyze readonly vars, we already know they do not
kono
parents: 67
diff changeset
268 alias. */
kono
parents: 67
diff changeset
269 if (TREE_READONLY (t))
kono
parents: 67
diff changeset
270 return true;
kono
parents: 67
diff changeset
271
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
272 /* We cannot track variables with address taken. */
111
kono
parents: 67
diff changeset
273 if (TREE_ADDRESSABLE (t))
kono
parents: 67
diff changeset
274 return true;
kono
parents: 67
diff changeset
275
kono
parents: 67
diff changeset
276 /* TODO: We could track public variables that are not addressable, but
kono
parents: 67
diff changeset
277 currently frontends don't give us those. */
kono
parents: 67
diff changeset
278 if (TREE_PUBLIC (t))
kono
parents: 67
diff changeset
279 return true;
kono
parents: 67
diff changeset
280
kono
parents: 67
diff changeset
281 return false;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
282 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
283
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
284 /* Return true if the variable T is the right kind of static variable to
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
285 perform compilation unit scope escape analysis. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
286
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
287 static inline bool
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
288 is_proper_for_analysis (tree t)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
289 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
290 int id = ipa_reference_var_uid (t);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
291
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
292 if (id != -1 && bitmap_bit_p (ignore_module_statics, id))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
293 return false;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
294
111
kono
parents: 67
diff changeset
295 if (symtab_node::get (t)
kono
parents: 67
diff changeset
296 ->call_for_symbol_and_aliases (is_improper, NULL, true))
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
297 return false;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
298
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
299 return true;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
300 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
301
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
302 /* Lookup the tree node for the static variable that has UID and
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
303 convert the name to a string for debugging. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
304
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
305 static const char *
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
306 get_static_name (int index)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
307 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
308 return fndecl_name ((*reference_vars_to_consider)[index]);
111
kono
parents: 67
diff changeset
309 }
kono
parents: 67
diff changeset
310
kono
parents: 67
diff changeset
311 /* Dump a set of static vars to FILE. */
kono
parents: 67
diff changeset
312 static void
kono
parents: 67
diff changeset
313 dump_static_vars_set_to_file (FILE *f, bitmap set)
kono
parents: 67
diff changeset
314 {
kono
parents: 67
diff changeset
315 unsigned int index;
kono
parents: 67
diff changeset
316 bitmap_iterator bi;
kono
parents: 67
diff changeset
317 if (set == NULL)
kono
parents: 67
diff changeset
318 return;
kono
parents: 67
diff changeset
319 else if (set == all_module_statics)
kono
parents: 67
diff changeset
320 fprintf (f, "ALL");
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
321 else if (set == no_module_statics)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
322 fprintf (f, "NO");
111
kono
parents: 67
diff changeset
323 else
kono
parents: 67
diff changeset
324 EXECUTE_IF_SET_IN_BITMAP (set, 0, index, bi)
kono
parents: 67
diff changeset
325 {
kono
parents: 67
diff changeset
326 fprintf (f, "%s ", get_static_name (index));
kono
parents: 67
diff changeset
327 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
328 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
329
111
kono
parents: 67
diff changeset
330 /* Compute X |= Y, taking into account the possibility that
kono
parents: 67
diff changeset
331 either X or Y is already the maximum set.
kono
parents: 67
diff changeset
332 Return true if X is the maximum set after taking the union with Y. */
kono
parents: 67
diff changeset
333
kono
parents: 67
diff changeset
334 static bool
kono
parents: 67
diff changeset
335 union_static_var_sets (bitmap &x, bitmap y)
kono
parents: 67
diff changeset
336 {
kono
parents: 67
diff changeset
337 if (x != all_module_statics)
kono
parents: 67
diff changeset
338 {
kono
parents: 67
diff changeset
339 if (y == all_module_statics)
kono
parents: 67
diff changeset
340 {
kono
parents: 67
diff changeset
341 BITMAP_FREE (x);
kono
parents: 67
diff changeset
342 x = all_module_statics;
kono
parents: 67
diff changeset
343 }
kono
parents: 67
diff changeset
344 else if (bitmap_ior_into (x, y))
kono
parents: 67
diff changeset
345 {
kono
parents: 67
diff changeset
346 /* The union may have reduced X to the maximum set.
kono
parents: 67
diff changeset
347 In that case, we want to make that visible explicitly.
kono
parents: 67
diff changeset
348 Even though bitmap_equal_p can be very expensive, it
kono
parents: 67
diff changeset
349 turns out to be an overall win to check this here for
kono
parents: 67
diff changeset
350 an LTO bootstrap of GCC itself. Liberally extrapoliate
kono
parents: 67
diff changeset
351 that result to be applicable to all cases. */
kono
parents: 67
diff changeset
352 if (bitmap_equal_p (x, all_module_statics))
kono
parents: 67
diff changeset
353 {
kono
parents: 67
diff changeset
354 BITMAP_FREE (x);
kono
parents: 67
diff changeset
355 x = all_module_statics;
kono
parents: 67
diff changeset
356 }
kono
parents: 67
diff changeset
357 }
kono
parents: 67
diff changeset
358 }
kono
parents: 67
diff changeset
359 return x == all_module_statics;
kono
parents: 67
diff changeset
360 }
kono
parents: 67
diff changeset
361
kono
parents: 67
diff changeset
362 /* Return a copy of SET on the bitmap obstack containing SET.
kono
parents: 67
diff changeset
363 But if SET is NULL or the maximum set, return that instead. */
kono
parents: 67
diff changeset
364
kono
parents: 67
diff changeset
365 static bitmap
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
366 copy_static_var_set (bitmap set, bool for_propagation)
111
kono
parents: 67
diff changeset
367 {
kono
parents: 67
diff changeset
368 if (set == NULL || set == all_module_statics)
kono
parents: 67
diff changeset
369 return set;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
370 if (!for_propagation && set == no_module_statics)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
371 return set;
111
kono
parents: 67
diff changeset
372 bitmap_obstack *o = set->obstack;
kono
parents: 67
diff changeset
373 gcc_checking_assert (o);
kono
parents: 67
diff changeset
374 bitmap copy = BITMAP_ALLOC (o);
kono
parents: 67
diff changeset
375 bitmap_copy (copy, set);
kono
parents: 67
diff changeset
376 return copy;
kono
parents: 67
diff changeset
377 }
kono
parents: 67
diff changeset
378
kono
parents: 67
diff changeset
379 /* Compute the union all of the statics read and written by every callee of X
kono
parents: 67
diff changeset
380 into X_GLOBAL->statics_read and X_GLOBAL->statics_written. X_GLOBAL is
kono
parents: 67
diff changeset
381 actually the set representing the cycle containing X. If the read and
kono
parents: 67
diff changeset
382 written sets of X_GLOBAL has been reduced to the maximum set, we don't
kono
parents: 67
diff changeset
383 have to look at the remaining callees. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
384
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
385 static void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
386 propagate_bits (ipa_reference_global_vars_info_t x_global, struct cgraph_node *x)
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 struct cgraph_edge *e;
111
kono
parents: 67
diff changeset
389 bool read_all = x_global->statics_read == all_module_statics;
kono
parents: 67
diff changeset
390 bool write_all = x_global->statics_written == all_module_statics;
kono
parents: 67
diff changeset
391 for (e = x->callees;
kono
parents: 67
diff changeset
392 e && !(read_all && write_all);
kono
parents: 67
diff changeset
393 e = e->next_callee)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
394 {
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
395 enum availability avail;
111
kono
parents: 67
diff changeset
396 struct cgraph_node *y = e->callee->function_symbol (&avail);
kono
parents: 67
diff changeset
397 if (!y)
kono
parents: 67
diff changeset
398 continue;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
399
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
400 /* Only look into nodes we can propagate something. */
111
kono
parents: 67
diff changeset
401 int flags = flags_from_decl_or_type (y->decl);
kono
parents: 67
diff changeset
402 if (opt_for_fn (y->decl, flag_ipa_reference)
kono
parents: 67
diff changeset
403 && (avail > AVAIL_INTERPOSABLE
kono
parents: 67
diff changeset
404 || (avail == AVAIL_INTERPOSABLE && (flags & ECF_LEAF))))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
405 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
406 if (get_reference_vars_info (y))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
407 {
111
kono
parents: 67
diff changeset
408 ipa_reference_vars_info_t y_info = get_reference_vars_info (y);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
409 ipa_reference_global_vars_info_t y_global = &y_info->global;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
410
111
kono
parents: 67
diff changeset
411 /* Calls in the current cycle do not have their global set
kono
parents: 67
diff changeset
412 computed yet (but everything else does because we're
kono
parents: 67
diff changeset
413 visiting nodes in topological order). */
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
414 if (!y_global->statics_read)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
415 continue;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
416
111
kono
parents: 67
diff changeset
417 /* If the function is const, it reads no memory even if it
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
418 seems so to local analysis. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
419 if (flags & ECF_CONST)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
420 continue;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
421
111
kono
parents: 67
diff changeset
422 union_static_var_sets (x_global->statics_read,
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
423 y_global->statics_read);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
424
111
kono
parents: 67
diff changeset
425 /* If the function is pure, it has no stores even if it
kono
parents: 67
diff changeset
426 seems so to local analysis. If we cannot return from
kono
parents: 67
diff changeset
427 the function, we can safely ignore the call. */
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
428 if ((flags & ECF_PURE)
111
kono
parents: 67
diff changeset
429 || e->cannot_lead_to_return_p ())
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
430 continue;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
431
111
kono
parents: 67
diff changeset
432 union_static_var_sets (x_global->statics_written,
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
433 y_global->statics_written);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
434 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
435 else
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
436 gcc_unreachable ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
437 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
438 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
439 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
440
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
441 /* Delete NODE from map. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
442
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
443 static void
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
444 varpool_removal_hook (varpool_node *node, void *)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
445 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
446 ipa_reference_vars_map->remove (node->decl);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
447 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
448
111
kono
parents: 67
diff changeset
449 static bool ipa_init_p = false;
kono
parents: 67
diff changeset
450
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
451 /* The init routine for analyzing global static variable usage. See
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
452 comments at top for description. */
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
453 static void
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
454 ipa_init (void)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
455 {
111
kono
parents: 67
diff changeset
456 if (ipa_init_p)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
457 return;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
458
111
kono
parents: 67
diff changeset
459 ipa_init_p = true;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
460
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
461 vec_alloc (reference_vars_to_consider, 10);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
462
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
463
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
464 if (ipa_ref_opt_sum_summaries != NULL)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
465 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
466 delete ipa_ref_opt_sum_summaries;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
467 ipa_ref_opt_sum_summaries = NULL;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
468 delete ipa_reference_vars_map;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
469 }
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
470 ipa_reference_vars_map = new reference_vars_map_t(257);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
471 varpool_node_hooks
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
472 = symtab->add_varpool_removal_hook (varpool_removal_hook, NULL);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
473 ipa_reference_vars_uids = 0;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
474
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
475 bitmap_obstack_initialize (&local_info_obstack);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
476 bitmap_obstack_initialize (&optimization_summary_obstack);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
477 all_module_statics = BITMAP_ALLOC (&optimization_summary_obstack);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
478 no_module_statics = BITMAP_ALLOC (&optimization_summary_obstack);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
479 ignore_module_statics = BITMAP_ALLOC (&optimization_summary_obstack);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
480
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
481 if (ipa_ref_var_info_summaries == NULL)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
482 ipa_ref_var_info_summaries = new ipa_ref_var_info_summary_t (symtab);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
483 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
484
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
485
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
486 /* Set up the persistent info for FN. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
487
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
488 static ipa_reference_local_vars_info_t
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
489 init_function_info (struct cgraph_node *fn)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
490 {
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
491 ipa_reference_vars_info_t info
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
492 = ipa_ref_var_info_summaries->get_create (fn);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
493
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
494 info->local.statics_read = BITMAP_ALLOC (&local_info_obstack);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
495 info->local.statics_written = BITMAP_ALLOC (&local_info_obstack);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
496 info->global.statics_read = NULL;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
497
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
498 return &info->local;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
499 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
500
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
501
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
502 /* This is the main routine for finding the reference patterns for
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
503 global variables within a function FN. */
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
504
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
505 static void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
506 analyze_function (struct cgraph_node *fn)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
507 {
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
508 ipa_reference_local_vars_info_t local;
111
kono
parents: 67
diff changeset
509 struct ipa_ref *ref = NULL;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
510 int i;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
511 tree var;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
512
111
kono
parents: 67
diff changeset
513 if (!opt_for_fn (fn->decl, flag_ipa_reference))
kono
parents: 67
diff changeset
514 return;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
515 local = init_function_info (fn);
111
kono
parents: 67
diff changeset
516 for (i = 0; fn->iterate_reference (i, ref); i++)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
517 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
518 int id;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
519 bool existed;
111
kono
parents: 67
diff changeset
520 if (!is_a <varpool_node *> (ref->referred))
kono
parents: 67
diff changeset
521 continue;
kono
parents: 67
diff changeset
522 var = ref->referred->decl;
kono
parents: 67
diff changeset
523 if (!is_proper_for_analysis (var))
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
524 continue;
111
kono
parents: 67
diff changeset
525 /* This is a variable we care about. Check if we have seen it
kono
parents: 67
diff changeset
526 before, and if not add it the set of variables we care about. */
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
527 id = ipa_reference_var_get_or_insert_uid (var, &existed);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
528 if (!existed)
111
kono
parents: 67
diff changeset
529 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
530 bitmap_set_bit (all_module_statics, id);
111
kono
parents: 67
diff changeset
531 if (dump_file)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
532 reference_vars_to_consider->safe_push (var);
111
kono
parents: 67
diff changeset
533 }
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
534 switch (ref->use)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
535 {
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
536 case IPA_REF_LOAD:
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
537 bitmap_set_bit (local->statics_read, id);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
538 break;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
539 case IPA_REF_STORE:
111
kono
parents: 67
diff changeset
540 if (ref->cannot_lead_to_return ())
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
541 break;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
542 bitmap_set_bit (local->statics_written, id);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
543 break;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
544 case IPA_REF_ADDR:
111
kono
parents: 67
diff changeset
545 break;
kono
parents: 67
diff changeset
546 default:
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
547 gcc_unreachable ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
548 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
549 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
550
111
kono
parents: 67
diff changeset
551 if (fn->cannot_return_p ())
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
552 bitmap_clear (local->statics_written);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
553 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
554
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
555
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
556 /* Called when new clone is inserted to callgraph late. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
557
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
558 void
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
559 ipa_ref_opt_summary_t::duplicate (cgraph_node *, cgraph_node *,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
560 ipa_reference_optimization_summary_d *ginfo,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
561 ipa_reference_optimization_summary_d
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
562 *dst_ginfo)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
563 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
564 dst_ginfo->statics_read =
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
565 copy_static_var_set (ginfo->statics_read, false);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
566 dst_ginfo->statics_written =
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
567 copy_static_var_set (ginfo->statics_written, false);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
568 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
569
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
570 /* Called when node is removed. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
571
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
572 void
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
573 ipa_ref_opt_summary_t::remove (cgraph_node *,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
574 ipa_reference_optimization_summary_d *ginfo)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
575 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
576 if (ginfo->statics_read
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
577 && ginfo->statics_read != all_module_statics
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
578 && ginfo->statics_read != no_module_statics)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
579 BITMAP_FREE (ginfo->statics_read);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
580
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
581 if (ginfo->statics_written
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
582 && ginfo->statics_written != all_module_statics
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
583 && ginfo->statics_written != no_module_statics)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
584 BITMAP_FREE (ginfo->statics_written);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
585 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
586
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
587 /* Analyze each function in the cgraph to see which global or statics
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
588 are read or written. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
589
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
590 static void
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
591 generate_summary (void)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
592 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
593 struct cgraph_node *node;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
594 unsigned int index;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
595 bitmap_iterator bi;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
596
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
597 ipa_init ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
598
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
599 /* Process all of the functions next. */
111
kono
parents: 67
diff changeset
600 FOR_EACH_DEFINED_FUNCTION (node)
kono
parents: 67
diff changeset
601 if (!node->alias && !opt_for_fn (node->decl, flag_ipa_reference))
kono
parents: 67
diff changeset
602 {
kono
parents: 67
diff changeset
603 struct ipa_ref *ref = NULL;
kono
parents: 67
diff changeset
604 int i;
kono
parents: 67
diff changeset
605 tree var;
kono
parents: 67
diff changeset
606 for (i = 0; node->iterate_reference (i, ref); i++)
kono
parents: 67
diff changeset
607 {
kono
parents: 67
diff changeset
608 if (!is_a <varpool_node *> (ref->referred))
kono
parents: 67
diff changeset
609 continue;
kono
parents: 67
diff changeset
610 var = ref->referred->decl;
kono
parents: 67
diff changeset
611 if (!is_proper_for_analysis (var))
kono
parents: 67
diff changeset
612 continue;
kono
parents: 67
diff changeset
613 bitmap_set_bit (ignore_module_statics, ipa_reference_var_uid (var));
kono
parents: 67
diff changeset
614 }
kono
parents: 67
diff changeset
615 }
kono
parents: 67
diff changeset
616 FOR_EACH_DEFINED_FUNCTION (node)
kono
parents: 67
diff changeset
617 analyze_function (node);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
618
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
619 if (dump_file)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
620 EXECUTE_IF_SET_IN_BITMAP (all_module_statics, 0, index, bi)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
621 {
111
kono
parents: 67
diff changeset
622 fprintf (dump_file, "\nPromotable global:%s (uid=%u)\n",
kono
parents: 67
diff changeset
623 get_static_name (index), index);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
624 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
625
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
626 if (dump_file)
111
kono
parents: 67
diff changeset
627 FOR_EACH_DEFINED_FUNCTION (node)
kono
parents: 67
diff changeset
628 if (node->get_availability () >= AVAIL_INTERPOSABLE
kono
parents: 67
diff changeset
629 && opt_for_fn (node->decl, flag_ipa_reference))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
630 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
631 ipa_reference_local_vars_info_t l;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
632 unsigned int index;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
633 bitmap_iterator bi;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
634
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
635 l = &get_reference_vars_info (node)->local;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
636 fprintf (dump_file,
111
kono
parents: 67
diff changeset
637 "\nFunction name:%s:", node->dump_name ());
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
638 fprintf (dump_file, "\n locals read: ");
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
639 if (l->statics_read)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
640 EXECUTE_IF_SET_IN_BITMAP (l->statics_read,
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
641 0, index, bi)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
642 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
643 fprintf (dump_file, "%s ",
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
644 get_static_name (index));
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
645 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
646 fprintf (dump_file, "\n locals written: ");
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
647 if (l->statics_written)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
648 EXECUTE_IF_SET_IN_BITMAP (l->statics_written,
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
649 0, index, bi)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
650 {
111
kono
parents: 67
diff changeset
651 fprintf (dump_file, "%s ", get_static_name (index));
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
652 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
653 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
654 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
655
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
656 /* Set READ_ALL/WRITE_ALL based on decl flags of NODE. */
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
657
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
658 static void
111
kono
parents: 67
diff changeset
659 read_write_all_from_decl (struct cgraph_node *node,
kono
parents: 67
diff changeset
660 bool &read_all, bool &write_all)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
661 {
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
662 tree decl = node->decl;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
663 int flags = flags_from_decl_or_type (decl);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
664 if ((flags & ECF_LEAF)
111
kono
parents: 67
diff changeset
665 && node->get_availability () < AVAIL_INTERPOSABLE)
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
666 ;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
667 else if (flags & ECF_CONST)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
668 ;
111
kono
parents: 67
diff changeset
669 else if ((flags & ECF_PURE) || node->cannot_return_p ())
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
670 {
111
kono
parents: 67
diff changeset
671 read_all = true;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
672 if (dump_file && (dump_flags & TDF_DETAILS))
111
kono
parents: 67
diff changeset
673 fprintf (dump_file, " %s -> read all\n", node->dump_name ());
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
674 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
675 else
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
676 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
677 /* TODO: To be able to produce sane results, we should also handle
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
678 common builtins, in particular throw. */
111
kono
parents: 67
diff changeset
679 read_all = true;
kono
parents: 67
diff changeset
680 write_all = true;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
681 if (dump_file && (dump_flags & TDF_DETAILS))
111
kono
parents: 67
diff changeset
682 fprintf (dump_file, " %s -> read all, write all\n",
kono
parents: 67
diff changeset
683 node->dump_name ());
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
684 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
685 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
686
111
kono
parents: 67
diff changeset
687 /* Set READ_ALL/WRITE_ALL based on decl flags of NODE or any member
kono
parents: 67
diff changeset
688 in the cycle of NODE. */
kono
parents: 67
diff changeset
689
kono
parents: 67
diff changeset
690 static void
kono
parents: 67
diff changeset
691 get_read_write_all_from_node (struct cgraph_node *node,
kono
parents: 67
diff changeset
692 bool &read_all, bool &write_all)
kono
parents: 67
diff changeset
693 {
kono
parents: 67
diff changeset
694 struct cgraph_edge *e, *ie;
kono
parents: 67
diff changeset
695
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
696 /* When function is overwritable, we cannot assume anything. */
111
kono
parents: 67
diff changeset
697 if (node->get_availability () <= AVAIL_INTERPOSABLE
kono
parents: 67
diff changeset
698 || (node->analyzed && !opt_for_fn (node->decl, flag_ipa_reference)))
kono
parents: 67
diff changeset
699 read_write_all_from_decl (node, read_all, write_all);
kono
parents: 67
diff changeset
700
kono
parents: 67
diff changeset
701 for (e = node->callees;
kono
parents: 67
diff changeset
702 e && !(read_all && write_all);
kono
parents: 67
diff changeset
703 e = e->next_callee)
kono
parents: 67
diff changeset
704 {
kono
parents: 67
diff changeset
705 enum availability avail;
kono
parents: 67
diff changeset
706 struct cgraph_node *callee = e->callee->function_symbol (&avail);
kono
parents: 67
diff changeset
707 gcc_checking_assert (callee);
kono
parents: 67
diff changeset
708 if (avail <= AVAIL_INTERPOSABLE
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
709 || (callee->analyzed && !opt_for_fn (callee->decl,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
710 flag_ipa_reference)))
111
kono
parents: 67
diff changeset
711 read_write_all_from_decl (callee, read_all, write_all);
kono
parents: 67
diff changeset
712 }
kono
parents: 67
diff changeset
713
kono
parents: 67
diff changeset
714 for (ie = node->indirect_calls;
kono
parents: 67
diff changeset
715 ie && !(read_all && write_all);
kono
parents: 67
diff changeset
716 ie = ie->next_callee)
kono
parents: 67
diff changeset
717 if (!(ie->indirect_info->ecf_flags & ECF_CONST))
kono
parents: 67
diff changeset
718 {
kono
parents: 67
diff changeset
719 read_all = true;
kono
parents: 67
diff changeset
720 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents: 67
diff changeset
721 fprintf (dump_file, " indirect call -> read all\n");
kono
parents: 67
diff changeset
722 if (!ie->cannot_lead_to_return_p ()
kono
parents: 67
diff changeset
723 && !(ie->indirect_info->ecf_flags & ECF_PURE))
kono
parents: 67
diff changeset
724 {
kono
parents: 67
diff changeset
725 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents: 67
diff changeset
726 fprintf (dump_file, " indirect call -> write all\n");
kono
parents: 67
diff changeset
727 write_all = true;
kono
parents: 67
diff changeset
728 }
kono
parents: 67
diff changeset
729 }
kono
parents: 67
diff changeset
730 }
kono
parents: 67
diff changeset
731
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
732 /* Skip edges from and to nodes without ipa_reference enabled.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
733 Ignore not available symbols. This leave
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
734 them out of strongly connected components and makes them easy to skip in the
111
kono
parents: 67
diff changeset
735 propagation loop bellow. */
kono
parents: 67
diff changeset
736
kono
parents: 67
diff changeset
737 static bool
kono
parents: 67
diff changeset
738 ignore_edge_p (cgraph_edge *e)
kono
parents: 67
diff changeset
739 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
740 enum availability avail;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
741 cgraph_node *ultimate_target
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
742 = e->callee->function_or_virtual_thunk_symbol (&avail, e->caller);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
743
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
744 return (avail < AVAIL_INTERPOSABLE
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
745 || (avail == AVAIL_INTERPOSABLE
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
746 && !(flags_from_decl_or_type (e->callee->decl) & ECF_LEAF))
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
747 || !opt_for_fn (e->caller->decl, flag_ipa_reference)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
748 || !opt_for_fn (ultimate_target->decl, flag_ipa_reference));
111
kono
parents: 67
diff changeset
749 }
kono
parents: 67
diff changeset
750
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
751 /* Produce the global information by preforming a transitive closure
111
kono
parents: 67
diff changeset
752 on the local information that was produced by ipa_analyze_function. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
753
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
754 static unsigned int
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
755 propagate (void)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
756 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
757 struct cgraph_node *node;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
758 struct cgraph_node **order =
111
kono
parents: 67
diff changeset
759 XCNEWVEC (struct cgraph_node *, symtab->cgraph_count);
kono
parents: 67
diff changeset
760 int order_pos;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
761 int i;
111
kono
parents: 67
diff changeset
762 bool remove_p;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
763
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
764 if (dump_file)
111
kono
parents: 67
diff changeset
765 cgraph_node::dump_cgraph (dump_file);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
766
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
767 remove_p = ipa_discover_variable_flags ();
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
768 generate_summary ();
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
769
111
kono
parents: 67
diff changeset
770 /* Propagate the local information through the call graph to produce
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
771 the global information. All the nodes within a cycle will have
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
772 the same info so we collapse cycles first. Then we can do the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
773 propagation in one pass from the leaves to the roots. */
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
774 order_pos = ipa_reduced_postorder (order, true, ignore_edge_p);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
775 if (dump_file)
111
kono
parents: 67
diff changeset
776 ipa_print_order (dump_file, "reduced", order, order_pos);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
777
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
778 for (i = 0; i < order_pos; i++ )
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
779 {
111
kono
parents: 67
diff changeset
780 unsigned x;
kono
parents: 67
diff changeset
781 struct cgraph_node *w;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
782 ipa_reference_vars_info_t node_info;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
783 ipa_reference_global_vars_info_t node_g;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
784 ipa_reference_local_vars_info_t node_l;
111
kono
parents: 67
diff changeset
785 bool read_all = false;
kono
parents: 67
diff changeset
786 bool write_all = false;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
787
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
788 node = order[i];
111
kono
parents: 67
diff changeset
789 if (node->alias || !opt_for_fn (node->decl, flag_ipa_reference))
kono
parents: 67
diff changeset
790 continue;
kono
parents: 67
diff changeset
791
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
792 node_info = get_reference_vars_info (node);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
793 gcc_assert (node_info);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
794 node_l = &node_info->local;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
795 node_g = &node_info->global;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
796
111
kono
parents: 67
diff changeset
797 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents: 67
diff changeset
798 fprintf (dump_file, "Starting cycle with %s\n", node->dump_name ());
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
799
111
kono
parents: 67
diff changeset
800 vec<cgraph_node *> cycle_nodes = ipa_get_nodes_in_cycle (node);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
801
111
kono
parents: 67
diff changeset
802 /* If any node in a cycle is read_all or write_all, they all are. */
kono
parents: 67
diff changeset
803 FOR_EACH_VEC_ELT (cycle_nodes, x, w)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
804 {
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
805 if (dump_file && (dump_flags & TDF_DETAILS))
111
kono
parents: 67
diff changeset
806 fprintf (dump_file, " Visiting %s\n", w->dump_asm_name ());
kono
parents: 67
diff changeset
807 get_read_write_all_from_node (w, read_all, write_all);
kono
parents: 67
diff changeset
808 if (read_all && write_all)
kono
parents: 67
diff changeset
809 break;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
810 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
811
111
kono
parents: 67
diff changeset
812 /* Initialized the bitmaps global sets for the reduced node. */
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
813 if (read_all)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
814 node_g->statics_read = all_module_statics;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
815 else
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
816 node_g->statics_read = copy_static_var_set (node_l->statics_read, true);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
817 if (write_all)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
818 node_g->statics_written = all_module_statics;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
819 else
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
820 node_g->statics_written
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
821 = copy_static_var_set (node_l->statics_written, true);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
822
111
kono
parents: 67
diff changeset
823 /* Merge the sets of this cycle with all sets of callees reached
kono
parents: 67
diff changeset
824 from this cycle. */
kono
parents: 67
diff changeset
825 FOR_EACH_VEC_ELT (cycle_nodes, x, w)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
826 {
111
kono
parents: 67
diff changeset
827 if (read_all && write_all)
kono
parents: 67
diff changeset
828 break;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
829
111
kono
parents: 67
diff changeset
830 if (w != node)
kono
parents: 67
diff changeset
831 {
kono
parents: 67
diff changeset
832 ipa_reference_vars_info_t w_ri = get_reference_vars_info (w);
kono
parents: 67
diff changeset
833 ipa_reference_local_vars_info_t w_l = &w_ri->local;
kono
parents: 67
diff changeset
834 int flags = flags_from_decl_or_type (w->decl);
kono
parents: 67
diff changeset
835
kono
parents: 67
diff changeset
836 if (!(flags & ECF_CONST))
kono
parents: 67
diff changeset
837 read_all = union_static_var_sets (node_g->statics_read,
kono
parents: 67
diff changeset
838 w_l->statics_read);
kono
parents: 67
diff changeset
839 if (!(flags & ECF_PURE)
kono
parents: 67
diff changeset
840 && !w->cannot_return_p ())
kono
parents: 67
diff changeset
841 write_all = union_static_var_sets (node_g->statics_written,
kono
parents: 67
diff changeset
842 w_l->statics_written);
kono
parents: 67
diff changeset
843 }
kono
parents: 67
diff changeset
844
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
845 propagate_bits (node_g, w);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
846 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
847
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
848 /* All nodes within a cycle have the same global info bitmaps. */
111
kono
parents: 67
diff changeset
849 FOR_EACH_VEC_ELT (cycle_nodes, x, w)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
850 {
111
kono
parents: 67
diff changeset
851 ipa_reference_vars_info_t w_ri = get_reference_vars_info (w);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
852 w_ri->global = *node_g;
111
kono
parents: 67
diff changeset
853 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
854
111
kono
parents: 67
diff changeset
855 cycle_nodes.release ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
856 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
857
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
858 if (dump_file)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
859 {
111
kono
parents: 67
diff changeset
860 for (i = 0; i < order_pos; i++)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
861 {
111
kono
parents: 67
diff changeset
862 unsigned x;
kono
parents: 67
diff changeset
863 struct cgraph_node *w;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
864
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
865 node = order[i];
111
kono
parents: 67
diff changeset
866 if (node->alias || !opt_for_fn (node->decl, flag_ipa_reference))
kono
parents: 67
diff changeset
867 continue;
kono
parents: 67
diff changeset
868
kono
parents: 67
diff changeset
869 fprintf (dump_file, "\nFunction name:%s:", node->dump_asm_name ());
kono
parents: 67
diff changeset
870
kono
parents: 67
diff changeset
871 ipa_reference_vars_info_t node_info = get_reference_vars_info (node);
kono
parents: 67
diff changeset
872 ipa_reference_global_vars_info_t node_g = &node_info->global;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
873
111
kono
parents: 67
diff changeset
874 vec<cgraph_node *> cycle_nodes = ipa_get_nodes_in_cycle (node);
kono
parents: 67
diff changeset
875 FOR_EACH_VEC_ELT (cycle_nodes, x, w)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
876 {
111
kono
parents: 67
diff changeset
877 ipa_reference_vars_info_t w_ri = get_reference_vars_info (w);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
878 ipa_reference_local_vars_info_t w_l = &w_ri->local;
111
kono
parents: 67
diff changeset
879 if (w != node)
kono
parents: 67
diff changeset
880 fprintf (dump_file, "\n next cycle: %s ", w->dump_asm_name ());
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
881 fprintf (dump_file, "\n locals read: ");
111
kono
parents: 67
diff changeset
882 dump_static_vars_set_to_file (dump_file, w_l->statics_read);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
883 fprintf (dump_file, "\n locals written: ");
111
kono
parents: 67
diff changeset
884 dump_static_vars_set_to_file (dump_file, w_l->statics_written);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
885 }
111
kono
parents: 67
diff changeset
886 cycle_nodes.release ();
kono
parents: 67
diff changeset
887
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
888 fprintf (dump_file, "\n globals read: ");
111
kono
parents: 67
diff changeset
889 dump_static_vars_set_to_file (dump_file, node_g->statics_read);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
890 fprintf (dump_file, "\n globals written: ");
111
kono
parents: 67
diff changeset
891 dump_static_vars_set_to_file (dump_file, node_g->statics_written);
kono
parents: 67
diff changeset
892 fprintf (dump_file, "\n");
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
893 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
894 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
895
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
896 if (ipa_ref_opt_sum_summaries == NULL)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
897 ipa_ref_opt_sum_summaries = new ipa_ref_opt_summary_t (symtab);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
898
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
899 /* Cleanup. */
111
kono
parents: 67
diff changeset
900 FOR_EACH_DEFINED_FUNCTION (node)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
901 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
902 ipa_reference_vars_info_t node_info;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
903 ipa_reference_global_vars_info_t node_g;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
904
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
905 /* No need to produce summaries for inline clones. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
906 if (node->inlined_to)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
907 continue;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
908
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
909 node_info = get_reference_vars_info (node);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
910 if (!node->alias && opt_for_fn (node->decl, flag_ipa_reference))
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
911 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
912 node_g = &node_info->global;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
913 bool read_all =
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
914 (node_g->statics_read == all_module_statics
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
915 || bitmap_equal_p (node_g->statics_read, all_module_statics));
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
916 bool written_all =
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
917 (node_g->statics_written == all_module_statics
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
918 || bitmap_equal_p (node_g->statics_written,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
919 all_module_statics));
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
920
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
921 /* There is no need to produce summary if we collected nothing
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
922 useful. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
923 if (read_all && written_all)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
924 continue;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
925
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
926 ipa_reference_optimization_summary_d *opt
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
927 = ipa_ref_opt_sum_summaries->get_create (node);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
928
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
929 /* Create the complimentary sets. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
930
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
931 if (bitmap_empty_p (node_g->statics_read))
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
932 opt->statics_read = no_module_statics;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
933 else if (read_all)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
934 opt->statics_read = all_module_statics;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
935 else
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
936 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
937 opt->statics_read
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
938 = BITMAP_ALLOC (&optimization_summary_obstack);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
939 bitmap_copy (opt->statics_read, node_g->statics_read);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
940 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
941
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
942 if (bitmap_empty_p (node_g->statics_written))
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
943 opt->statics_written = no_module_statics;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
944 else if (written_all)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
945 opt->statics_written = all_module_statics;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
946 else
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
947 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
948 opt->statics_written
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
949 = BITMAP_ALLOC (&optimization_summary_obstack);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
950 bitmap_copy (opt->statics_written, node_g->statics_written);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
951 }
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
952 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
953 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
954
111
kono
parents: 67
diff changeset
955 ipa_free_postorder_info ();
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
956 free (order);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
957
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
958 bitmap_obstack_release (&local_info_obstack);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
959
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
960 if (ipa_ref_var_info_summaries != NULL)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
961 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
962 delete ipa_ref_var_info_summaries;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
963 ipa_ref_var_info_summaries = NULL;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
964 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
965
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
966 if (dump_file)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
967 vec_free (reference_vars_to_consider);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
968 reference_vars_to_consider = NULL;
111
kono
parents: 67
diff changeset
969 return remove_p ? TODO_remove_functions : 0;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
970 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
971
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
972 /* Return true if we need to write summary of NODE. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
973
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
974 static bool
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
975 write_node_summary_p (struct cgraph_node *node,
111
kono
parents: 67
diff changeset
976 lto_symtab_encoder_t encoder,
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
977 bitmap ltrans_statics)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
978 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
979 ipa_reference_optimization_summary_t info;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
980
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
981 /* See if we have (non-empty) info. */
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
982 if (!node->definition || node->inlined_to)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
983 return false;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
984 info = get_reference_optimization_summary (node);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
985 if (!info)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
986 return false;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
987
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
988 /* See if we want to encode it.
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
989 Encode also referenced functions since constant folding might turn it into
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
990 a direct call.
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
991
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
992 In future we might also want to include summaries of functions references
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
993 by initializers of constant variables references in current unit. */
111
kono
parents: 67
diff changeset
994 if (!reachable_from_this_partition_p (node, encoder)
kono
parents: 67
diff changeset
995 && !referenced_from_this_partition_p (node, encoder))
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
996 return false;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
997
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
998 /* See if the info has non-empty intersections with vars we want to
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
999 encode. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1000 bitmap_iterator bi;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1001 unsigned int i;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1002 EXECUTE_IF_AND_COMPL_IN_BITMAP (ltrans_statics, info->statics_read, 0,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1003 i, bi)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1004 return true;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1005 EXECUTE_IF_AND_COMPL_IN_BITMAP (ltrans_statics, info->statics_written, 0,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1006 i, bi)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1007 return true;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1008 return false;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1009 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1010
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1011 /* Stream out BITS&LTRANS_STATICS as list of decls to OB.
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1012 LTRANS_STATICS_BITCOUNT specify number of bits in LTRANS_STATICS
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1013 or -1. When it is positive, just output -1 when
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1014 BITS&LTRANS_STATICS == BITS&LTRANS_STATICS. */
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1015
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1016 static void
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1017 stream_out_bitmap (struct lto_simple_output_block *ob,
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1018 bitmap bits, bitmap ltrans_statics,
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1019 int ltrans_statics_bitcount)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1020 {
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1021 int count = 0;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1022 unsigned int index;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1023 bitmap_iterator bi;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1024 if (bits == all_module_statics)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1025 {
111
kono
parents: 67
diff changeset
1026 streamer_write_hwi_stream (ob->main_stream, -1);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1027 return;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1028 }
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1029 EXECUTE_IF_AND_IN_BITMAP (bits, ltrans_statics, 0, index, bi)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1030 count ++;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1031 if (count == ltrans_statics_bitcount)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1032 {
111
kono
parents: 67
diff changeset
1033 streamer_write_hwi_stream (ob->main_stream, -1);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1034 return;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1035 }
111
kono
parents: 67
diff changeset
1036 streamer_write_hwi_stream (ob->main_stream, count);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1037 if (!count)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1038 return;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1039 EXECUTE_IF_AND_IN_BITMAP (bits, ltrans_statics, 0, index, bi)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1040 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1041 tree decl = (*reference_vars_to_consider) [index];
111
kono
parents: 67
diff changeset
1042 lto_output_var_decl_index (ob->decl_state, ob->main_stream, decl);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1043 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1044 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1045
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1046 /* Serialize the ipa info for lto. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1047
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1048 static void
111
kono
parents: 67
diff changeset
1049 ipa_reference_write_optimization_summary (void)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1050 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1051 struct lto_simple_output_block *ob
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1052 = lto_create_simple_output_block (LTO_section_ipa_reference);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1053 unsigned int count = 0;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1054 int ltrans_statics_bitcount = 0;
111
kono
parents: 67
diff changeset
1055 lto_symtab_encoder_t encoder = ob->decl_state->symtab_node_encoder;
kono
parents: 67
diff changeset
1056 auto_bitmap ltrans_statics;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1057 int i;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1058
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1059 vec_alloc (reference_vars_to_consider, ipa_reference_vars_uids);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1060 reference_vars_to_consider->safe_grow (ipa_reference_vars_uids);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1061
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1062 /* See what variables we are interested in. */
111
kono
parents: 67
diff changeset
1063 for (i = 0; i < lto_symtab_encoder_size (encoder); i++)
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1064 {
111
kono
parents: 67
diff changeset
1065 symtab_node *snode = lto_symtab_encoder_deref (encoder, i);
kono
parents: 67
diff changeset
1066 varpool_node *vnode = dyn_cast <varpool_node *> (snode);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1067 int id;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1068
111
kono
parents: 67
diff changeset
1069 if (vnode
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1070 && (id = ipa_reference_var_uid (vnode->decl)) != -1
111
kono
parents: 67
diff changeset
1071 && referenced_from_this_partition_p (vnode, encoder))
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1072 {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1073 tree decl = vnode->decl;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1074 bitmap_set_bit (ltrans_statics, id);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1075 (*reference_vars_to_consider)[id] = decl;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1076 ltrans_statics_bitcount ++;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1077 }
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1078 }
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1079
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1080
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1081 if (ltrans_statics_bitcount)
111
kono
parents: 67
diff changeset
1082 for (i = 0; i < lto_symtab_encoder_size (encoder); i++)
kono
parents: 67
diff changeset
1083 {
kono
parents: 67
diff changeset
1084 symtab_node *snode = lto_symtab_encoder_deref (encoder, i);
kono
parents: 67
diff changeset
1085 cgraph_node *cnode = dyn_cast <cgraph_node *> (snode);
kono
parents: 67
diff changeset
1086 if (cnode && write_node_summary_p (cnode, encoder, ltrans_statics))
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1087 count++;
111
kono
parents: 67
diff changeset
1088 }
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1089
111
kono
parents: 67
diff changeset
1090 streamer_write_uhwi_stream (ob->main_stream, count);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1091 if (count)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1092 stream_out_bitmap (ob, ltrans_statics, ltrans_statics,
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1093 -1);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1094
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1095 /* Process all of the functions. */
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1096 if (ltrans_statics_bitcount)
111
kono
parents: 67
diff changeset
1097 for (i = 0; i < lto_symtab_encoder_size (encoder); i++)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1098 {
111
kono
parents: 67
diff changeset
1099 symtab_node *snode = lto_symtab_encoder_deref (encoder, i);
kono
parents: 67
diff changeset
1100 cgraph_node *cnode = dyn_cast <cgraph_node *> (snode);
kono
parents: 67
diff changeset
1101 if (cnode && write_node_summary_p (cnode, encoder, ltrans_statics))
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1102 {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1103 ipa_reference_optimization_summary_t info;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1104 int node_ref;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1105
111
kono
parents: 67
diff changeset
1106 info = get_reference_optimization_summary (cnode);
kono
parents: 67
diff changeset
1107 node_ref = lto_symtab_encoder_encode (encoder, snode);
kono
parents: 67
diff changeset
1108 streamer_write_uhwi_stream (ob->main_stream, node_ref);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1109
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1110 stream_out_bitmap (ob, info->statics_read, ltrans_statics,
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1111 ltrans_statics_bitcount);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1112 stream_out_bitmap (ob, info->statics_written, ltrans_statics,
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1113 ltrans_statics_bitcount);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1114 }
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1115 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1116 lto_destroy_simple_output_block (ob);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1117 delete reference_vars_to_consider;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1118 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1119
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1120 /* Deserialize the ipa info for lto. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1121
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1122 static void
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1123 ipa_reference_read_optimization_summary (void)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1124 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1125 struct lto_file_decl_data ** file_data_vec
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1126 = lto_get_file_decl_data ();
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1127 struct lto_file_decl_data * file_data;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1128 unsigned int j = 0;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1129 bitmap_obstack_initialize (&optimization_summary_obstack);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1130
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1131 gcc_checking_assert (ipa_ref_opt_sum_summaries == NULL);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1132 ipa_ref_opt_sum_summaries = new ipa_ref_opt_summary_t (symtab);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1133 ipa_reference_vars_map = new reference_vars_map_t(257);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1134 varpool_node_hooks
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1135 = symtab->add_varpool_removal_hook (varpool_removal_hook, NULL);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1136 ipa_reference_vars_uids = 0;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1137
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1138 all_module_statics = BITMAP_ALLOC (&optimization_summary_obstack);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1139 no_module_statics = BITMAP_ALLOC (&optimization_summary_obstack);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1140
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1141 while ((file_data = file_data_vec[j++]))
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1142 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1143 const char *data;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1144 size_t len;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1145 class lto_input_block *ib
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1146 = lto_create_simple_input_block (file_data,
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1147 LTO_section_ipa_reference,
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1148 &data, &len);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1149 if (ib)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1150 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1151 unsigned int i;
111
kono
parents: 67
diff changeset
1152 unsigned int f_count = streamer_read_uhwi (ib);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1153 int b_count;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1154 if (!f_count)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1155 continue;
111
kono
parents: 67
diff changeset
1156 b_count = streamer_read_hwi (ib);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1157 if (dump_file)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1158 fprintf (dump_file, "all module statics:");
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1159 for (i = 0; i < (unsigned int)b_count; i++)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1160 {
111
kono
parents: 67
diff changeset
1161 unsigned int var_index = streamer_read_uhwi (ib);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1162 tree v_decl = lto_file_decl_data_get_var_decl (file_data,
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1163 var_index);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1164 bool existed;
111
kono
parents: 67
diff changeset
1165 bitmap_set_bit (all_module_statics,
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1166 ipa_reference_var_get_or_insert_uid
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1167 (v_decl, &existed));
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1168 gcc_checking_assert (!existed);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1169 if (dump_file)
111
kono
parents: 67
diff changeset
1170 fprintf (dump_file, " %s", fndecl_name (v_decl));
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1171 }
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1172
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1173 for (i = 0; i < f_count; i++)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1174 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1175 unsigned int j, index;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1176 struct cgraph_node *node;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1177 int v_count;
111
kono
parents: 67
diff changeset
1178 lto_symtab_encoder_t encoder;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1179
111
kono
parents: 67
diff changeset
1180 index = streamer_read_uhwi (ib);
kono
parents: 67
diff changeset
1181 encoder = file_data->symtab_node_encoder;
kono
parents: 67
diff changeset
1182 node = dyn_cast<cgraph_node *> (lto_symtab_encoder_deref
kono
parents: 67
diff changeset
1183 (encoder, index));
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1184
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1185 ipa_reference_optimization_summary_d *info
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1186 = ipa_ref_opt_sum_summaries->get_create (node);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1187
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1188 if (dump_file)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1189 fprintf (dump_file,
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1190 "\nFunction name:%s:\n static read:",
111
kono
parents: 67
diff changeset
1191 node->dump_asm_name ());
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1192
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1193 /* Set the statics read. */
111
kono
parents: 67
diff changeset
1194 v_count = streamer_read_hwi (ib);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1195 if (v_count == -1)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1196 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1197 info->statics_read = all_module_statics;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1198 if (dump_file)
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1199 fprintf (dump_file, " all module statics");
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1200 }
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1201 else if (v_count == 0)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1202 info->statics_read = no_module_statics;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1203 else
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1204 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1205 info->statics_read = BITMAP_ALLOC
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1206 (&optimization_summary_obstack);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1207 for (j = 0; j < (unsigned int)v_count; j++)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1208 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1209 unsigned int var_index = streamer_read_uhwi (ib);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1210 tree v_decl = lto_file_decl_data_get_var_decl (file_data,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1211 var_index);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1212 bitmap_set_bit (info->statics_read,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1213 ipa_reference_var_uid (v_decl));
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1214 if (dump_file)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1215 fprintf (dump_file, " %s", fndecl_name (v_decl));
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1216 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1217 }
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1218
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1219 if (dump_file)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1220 fprintf (dump_file,
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1221 "\n static written:");
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1222 /* Set the statics written. */
111
kono
parents: 67
diff changeset
1223 v_count = streamer_read_hwi (ib);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1224 if (v_count == -1)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1225 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1226 info->statics_written = all_module_statics;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1227 if (dump_file)
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1228 fprintf (dump_file, " all module statics");
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1229 }
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1230 else if (v_count == 0)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1231 info->statics_written = no_module_statics;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1232 else
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1233 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1234 info->statics_written = BITMAP_ALLOC
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1235 (&optimization_summary_obstack);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1236 for (j = 0; j < (unsigned int)v_count; j++)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1237 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1238 unsigned int var_index = streamer_read_uhwi (ib);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1239 tree v_decl = lto_file_decl_data_get_var_decl (file_data,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1240 var_index);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1241 bitmap_set_bit (info->statics_written,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1242 ipa_reference_var_uid (v_decl));
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1243 if (dump_file)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1244 fprintf (dump_file, " %s", fndecl_name (v_decl));
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1245 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1246 }
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1247 if (dump_file)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1248 fprintf (dump_file, "\n");
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1249 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1250
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1251 lto_destroy_simple_input_block (file_data,
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1252 LTO_section_ipa_reference,
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1253 ib, data, len);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1254 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1255 else
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1256 /* Fatal error here. We do not want to support compiling ltrans units
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1257 with different version of compiler or different flags than
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1258 the WPA unit, so this should never happen. */
111
kono
parents: 67
diff changeset
1259 fatal_error (input_location,
kono
parents: 67
diff changeset
1260 "ipa reference summary is missing in ltrans unit");
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1261 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
1262 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1263
111
kono
parents: 67
diff changeset
1264 namespace {
kono
parents: 67
diff changeset
1265
kono
parents: 67
diff changeset
1266 const pass_data pass_data_ipa_reference =
kono
parents: 67
diff changeset
1267 {
kono
parents: 67
diff changeset
1268 IPA_PASS, /* type */
kono
parents: 67
diff changeset
1269 "static-var", /* name */
kono
parents: 67
diff changeset
1270 OPTGROUP_NONE, /* optinfo_flags */
kono
parents: 67
diff changeset
1271 TV_IPA_REFERENCE, /* tv_id */
kono
parents: 67
diff changeset
1272 0, /* properties_required */
kono
parents: 67
diff changeset
1273 0, /* properties_provided */
kono
parents: 67
diff changeset
1274 0, /* properties_destroyed */
kono
parents: 67
diff changeset
1275 0, /* todo_flags_start */
kono
parents: 67
diff changeset
1276 0, /* todo_flags_finish */
kono
parents: 67
diff changeset
1277 };
kono
parents: 67
diff changeset
1278
kono
parents: 67
diff changeset
1279 class pass_ipa_reference : public ipa_opt_pass_d
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1280 {
111
kono
parents: 67
diff changeset
1281 public:
kono
parents: 67
diff changeset
1282 pass_ipa_reference (gcc::context *ctxt)
kono
parents: 67
diff changeset
1283 : ipa_opt_pass_d (pass_data_ipa_reference, ctxt,
kono
parents: 67
diff changeset
1284 NULL, /* generate_summary */
kono
parents: 67
diff changeset
1285 NULL, /* write_summary */
kono
parents: 67
diff changeset
1286 NULL, /* read_summary */
kono
parents: 67
diff changeset
1287 ipa_reference_write_optimization_summary, /*
kono
parents: 67
diff changeset
1288 write_optimization_summary */
kono
parents: 67
diff changeset
1289 ipa_reference_read_optimization_summary, /*
kono
parents: 67
diff changeset
1290 read_optimization_summary */
kono
parents: 67
diff changeset
1291 NULL, /* stmt_fixup */
kono
parents: 67
diff changeset
1292 0, /* function_transform_todo_flags_start */
kono
parents: 67
diff changeset
1293 NULL, /* function_transform */
kono
parents: 67
diff changeset
1294 NULL) /* variable_transform */
kono
parents: 67
diff changeset
1295 {}
kono
parents: 67
diff changeset
1296
kono
parents: 67
diff changeset
1297 /* opt_pass methods: */
kono
parents: 67
diff changeset
1298 virtual bool gate (function *)
kono
parents: 67
diff changeset
1299 {
kono
parents: 67
diff changeset
1300 return ((in_lto_p || flag_ipa_reference)
kono
parents: 67
diff changeset
1301 /* Don't bother doing anything if the program has errors. */
kono
parents: 67
diff changeset
1302 && !seen_error ());
kono
parents: 67
diff changeset
1303 }
kono
parents: 67
diff changeset
1304
kono
parents: 67
diff changeset
1305 virtual unsigned int execute (function *) { return propagate (); }
kono
parents: 67
diff changeset
1306
kono
parents: 67
diff changeset
1307 }; // class pass_ipa_reference
kono
parents: 67
diff changeset
1308
kono
parents: 67
diff changeset
1309 } // anon namespace
kono
parents: 67
diff changeset
1310
kono
parents: 67
diff changeset
1311 ipa_opt_pass_d *
kono
parents: 67
diff changeset
1312 make_pass_ipa_reference (gcc::context *ctxt)
kono
parents: 67
diff changeset
1313 {
kono
parents: 67
diff changeset
1314 return new pass_ipa_reference (ctxt);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1315 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1316
111
kono
parents: 67
diff changeset
1317 /* Reset all state within ipa-reference.c so that we can rerun the compiler
kono
parents: 67
diff changeset
1318 within the same process. For use by toplev::finalize. */
kono
parents: 67
diff changeset
1319
kono
parents: 67
diff changeset
1320 void
kono
parents: 67
diff changeset
1321 ipa_reference_c_finalize (void)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1322 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1323 if (ipa_ref_opt_sum_summaries != NULL)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1324 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1325 delete ipa_ref_opt_sum_summaries;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1326 ipa_ref_opt_sum_summaries = NULL;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1327 delete ipa_reference_vars_map;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1328 ipa_reference_vars_map = NULL;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1329 symtab->remove_varpool_removal_hook (varpool_node_hooks);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1330 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1331
111
kono
parents: 67
diff changeset
1332 if (ipa_init_p)
kono
parents: 67
diff changeset
1333 {
kono
parents: 67
diff changeset
1334 bitmap_obstack_release (&optimization_summary_obstack);
kono
parents: 67
diff changeset
1335 ipa_init_p = false;
kono
parents: 67
diff changeset
1336 }
kono
parents: 67
diff changeset
1337 }