annotate gcc/tree-streamer.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
111
kono
parents:
diff changeset
1 /* Miscellaneous utilities for tree streaming. Things that are used
kono
parents:
diff changeset
2 in both input and output are here.
kono
parents:
diff changeset
3
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
4 Copyright (C) 2011-2020 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
5 Contributed by Diego Novillo <dnovillo@google.com>
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 This file is part of GCC.
kono
parents:
diff changeset
8
kono
parents:
diff changeset
9 GCC is free software; you can redistribute it and/or modify it under
kono
parents:
diff changeset
10 the terms of the GNU General Public License as published by the Free
kono
parents:
diff changeset
11 Software Foundation; either version 3, or (at your option) any later
kono
parents:
diff changeset
12 version.
kono
parents:
diff changeset
13
kono
parents:
diff changeset
14 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
kono
parents:
diff changeset
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
kono
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
kono
parents:
diff changeset
17 for more details.
kono
parents:
diff changeset
18
kono
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
20 along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
21 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23 #include "config.h"
kono
parents:
diff changeset
24 #include "system.h"
kono
parents:
diff changeset
25 #include "coretypes.h"
kono
parents:
diff changeset
26 #include "backend.h"
kono
parents:
diff changeset
27 #include "tree.h"
kono
parents:
diff changeset
28 #include "gimple.h"
kono
parents:
diff changeset
29 #include "tree-streamer.h"
kono
parents:
diff changeset
30 #include "cgraph.h"
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 /* Table indexed by machine_mode, used for 2 different purposes.
kono
parents:
diff changeset
33 During streaming out we record there non-zero value for all modes
kono
parents:
diff changeset
34 that were streamed out.
kono
parents:
diff changeset
35 During streaming in, we translate the on the disk mode using this
kono
parents:
diff changeset
36 table. For normal LTO it is set to identity, for ACCEL_COMPILER
kono
parents:
diff changeset
37 depending on the mode_table content. */
kono
parents:
diff changeset
38 unsigned char streamer_mode_table[1 << 8];
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 /* Check that all the TS_* structures handled by the streamer_write_* and
kono
parents:
diff changeset
41 streamer_read_* routines are exactly ALL the structures defined in
kono
parents:
diff changeset
42 treestruct.def. */
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 void
kono
parents:
diff changeset
45 streamer_check_handled_ts_structures (void)
kono
parents:
diff changeset
46 {
kono
parents:
diff changeset
47 bool handled_p[LAST_TS_ENUM];
kono
parents:
diff changeset
48 unsigned i;
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 memset (&handled_p, 0, sizeof (handled_p));
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 /* These are the TS_* structures that are either handled or
kono
parents:
diff changeset
53 explicitly ignored by the streamer routines. */
kono
parents:
diff changeset
54 handled_p[TS_BASE] = true;
kono
parents:
diff changeset
55 handled_p[TS_TYPED] = true;
kono
parents:
diff changeset
56 handled_p[TS_COMMON] = true;
kono
parents:
diff changeset
57 handled_p[TS_INT_CST] = true;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
58 handled_p[TS_POLY_INT_CST] = true;
111
kono
parents:
diff changeset
59 handled_p[TS_REAL_CST] = true;
kono
parents:
diff changeset
60 handled_p[TS_FIXED_CST] = true;
kono
parents:
diff changeset
61 handled_p[TS_VECTOR] = true;
kono
parents:
diff changeset
62 handled_p[TS_STRING] = true;
kono
parents:
diff changeset
63 handled_p[TS_COMPLEX] = true;
kono
parents:
diff changeset
64 handled_p[TS_IDENTIFIER] = true;
kono
parents:
diff changeset
65 handled_p[TS_DECL_MINIMAL] = true;
kono
parents:
diff changeset
66 handled_p[TS_DECL_COMMON] = true;
kono
parents:
diff changeset
67 handled_p[TS_DECL_WRTL] = true;
kono
parents:
diff changeset
68 handled_p[TS_DECL_NON_COMMON] = true;
kono
parents:
diff changeset
69 handled_p[TS_DECL_WITH_VIS] = true;
kono
parents:
diff changeset
70 handled_p[TS_FIELD_DECL] = true;
kono
parents:
diff changeset
71 handled_p[TS_VAR_DECL] = true;
kono
parents:
diff changeset
72 handled_p[TS_PARM_DECL] = true;
kono
parents:
diff changeset
73 handled_p[TS_LABEL_DECL] = true;
kono
parents:
diff changeset
74 handled_p[TS_RESULT_DECL] = true;
kono
parents:
diff changeset
75 handled_p[TS_CONST_DECL] = true;
kono
parents:
diff changeset
76 handled_p[TS_TYPE_DECL] = true;
kono
parents:
diff changeset
77 handled_p[TS_FUNCTION_DECL] = true;
kono
parents:
diff changeset
78 handled_p[TS_TYPE_COMMON] = true;
kono
parents:
diff changeset
79 handled_p[TS_TYPE_WITH_LANG_SPECIFIC] = true;
kono
parents:
diff changeset
80 handled_p[TS_TYPE_NON_COMMON] = true;
kono
parents:
diff changeset
81 handled_p[TS_LIST] = true;
kono
parents:
diff changeset
82 handled_p[TS_VEC] = true;
kono
parents:
diff changeset
83 handled_p[TS_EXP] = true;
kono
parents:
diff changeset
84 handled_p[TS_SSA_NAME] = true;
kono
parents:
diff changeset
85 handled_p[TS_BLOCK] = true;
kono
parents:
diff changeset
86 handled_p[TS_BINFO] = true;
kono
parents:
diff changeset
87 handled_p[TS_STATEMENT_LIST] = true;
kono
parents:
diff changeset
88 handled_p[TS_CONSTRUCTOR] = true;
kono
parents:
diff changeset
89 handled_p[TS_OMP_CLAUSE] = true;
kono
parents:
diff changeset
90 handled_p[TS_OPTIMIZATION] = true;
kono
parents:
diff changeset
91 handled_p[TS_TARGET_OPTION] = true;
kono
parents:
diff changeset
92 handled_p[TS_TRANSLATION_UNIT_DECL] = true;
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 /* Anything not marked above will trigger the following assertion.
kono
parents:
diff changeset
95 If this assertion triggers, it means that there is a new TS_*
kono
parents:
diff changeset
96 structure that should be handled by the streamer. */
kono
parents:
diff changeset
97 for (i = 0; i < LAST_TS_ENUM; i++)
kono
parents:
diff changeset
98 gcc_assert (handled_p[i]);
kono
parents:
diff changeset
99 }
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 /* Helper for streamer_tree_cache_insert_1. Add T to CACHE->NODES at
kono
parents:
diff changeset
103 slot IX. */
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105 static void
kono
parents:
diff changeset
106 streamer_tree_cache_add_to_node_array (struct streamer_tree_cache_d *cache,
kono
parents:
diff changeset
107 unsigned ix, tree t, hashval_t hash)
kono
parents:
diff changeset
108 {
kono
parents:
diff changeset
109 /* We're either replacing an old element or appending consecutively. */
kono
parents:
diff changeset
110 if (cache->nodes.exists ())
kono
parents:
diff changeset
111 {
kono
parents:
diff changeset
112 if (cache->nodes.length () == ix)
kono
parents:
diff changeset
113 cache->nodes.safe_push (t);
kono
parents:
diff changeset
114 else
kono
parents:
diff changeset
115 cache->nodes[ix] = t;
kono
parents:
diff changeset
116 }
kono
parents:
diff changeset
117 if (cache->hashes.exists ())
kono
parents:
diff changeset
118 {
kono
parents:
diff changeset
119 if (cache->hashes.length () == ix)
kono
parents:
diff changeset
120 cache->hashes.safe_push (hash);
kono
parents:
diff changeset
121 else
kono
parents:
diff changeset
122 cache->hashes[ix] = hash;
kono
parents:
diff changeset
123 }
kono
parents:
diff changeset
124 }
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127 /* Helper for streamer_tree_cache_insert and streamer_tree_cache_insert_at.
kono
parents:
diff changeset
128 CACHE, T, and IX_P are as in streamer_tree_cache_insert.
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 If INSERT_AT_NEXT_SLOT_P is true, T is inserted at the next available
kono
parents:
diff changeset
131 slot in the cache. Otherwise, T is inserted at the position indicated
kono
parents:
diff changeset
132 in *IX_P.
kono
parents:
diff changeset
133
kono
parents:
diff changeset
134 If T already existed in CACHE, return true. Otherwise,
kono
parents:
diff changeset
135 return false. */
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137 static bool
kono
parents:
diff changeset
138 streamer_tree_cache_insert_1 (struct streamer_tree_cache_d *cache,
kono
parents:
diff changeset
139 tree t, hashval_t hash, unsigned *ix_p,
kono
parents:
diff changeset
140 bool insert_at_next_slot_p)
kono
parents:
diff changeset
141 {
kono
parents:
diff changeset
142 bool existed_p;
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144 gcc_assert (t);
kono
parents:
diff changeset
145
kono
parents:
diff changeset
146 unsigned int &ix = cache->node_map->get_or_insert (t, &existed_p);
kono
parents:
diff changeset
147 if (!existed_p)
kono
parents:
diff changeset
148 {
kono
parents:
diff changeset
149 /* Determine the next slot to use in the cache. */
kono
parents:
diff changeset
150 if (insert_at_next_slot_p)
kono
parents:
diff changeset
151 ix = cache->next_idx++;
kono
parents:
diff changeset
152 else
kono
parents:
diff changeset
153 ix = *ix_p;
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 streamer_tree_cache_add_to_node_array (cache, ix, t, hash);
kono
parents:
diff changeset
156 }
kono
parents:
diff changeset
157 else
kono
parents:
diff changeset
158 {
kono
parents:
diff changeset
159 if (!insert_at_next_slot_p && ix != *ix_p)
kono
parents:
diff changeset
160 {
kono
parents:
diff changeset
161 /* If the caller wants to insert T at a specific slot
kono
parents:
diff changeset
162 location, and ENTRY->TO does not match *IX_P, add T to
kono
parents:
diff changeset
163 the requested location slot. */
kono
parents:
diff changeset
164 ix = *ix_p;
kono
parents:
diff changeset
165 streamer_tree_cache_add_to_node_array (cache, ix, t, hash);
kono
parents:
diff changeset
166 }
kono
parents:
diff changeset
167 }
kono
parents:
diff changeset
168
kono
parents:
diff changeset
169 if (ix_p)
kono
parents:
diff changeset
170 *ix_p = ix;
kono
parents:
diff changeset
171
kono
parents:
diff changeset
172 return existed_p;
kono
parents:
diff changeset
173 }
kono
parents:
diff changeset
174
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 /* Insert tree node T in CACHE. If T already existed in the cache
kono
parents:
diff changeset
177 return true. Otherwise, return false.
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179 If IX_P is non-null, update it with the index into the cache where
kono
parents:
diff changeset
180 T has been stored. */
kono
parents:
diff changeset
181
kono
parents:
diff changeset
182 bool
kono
parents:
diff changeset
183 streamer_tree_cache_insert (struct streamer_tree_cache_d *cache, tree t,
kono
parents:
diff changeset
184 hashval_t hash, unsigned *ix_p)
kono
parents:
diff changeset
185 {
kono
parents:
diff changeset
186 return streamer_tree_cache_insert_1 (cache, t, hash, ix_p, true);
kono
parents:
diff changeset
187 }
kono
parents:
diff changeset
188
kono
parents:
diff changeset
189
kono
parents:
diff changeset
190 /* Replace the tree node with T in CACHE at slot IX. */
kono
parents:
diff changeset
191
kono
parents:
diff changeset
192 void
kono
parents:
diff changeset
193 streamer_tree_cache_replace_tree (struct streamer_tree_cache_d *cache,
kono
parents:
diff changeset
194 tree t, unsigned ix)
kono
parents:
diff changeset
195 {
kono
parents:
diff changeset
196 hashval_t hash = 0;
kono
parents:
diff changeset
197 if (cache->hashes.exists ())
kono
parents:
diff changeset
198 hash = streamer_tree_cache_get_hash (cache, ix);
kono
parents:
diff changeset
199 if (!cache->node_map)
kono
parents:
diff changeset
200 streamer_tree_cache_add_to_node_array (cache, ix, t, hash);
kono
parents:
diff changeset
201 else
kono
parents:
diff changeset
202 streamer_tree_cache_insert_1 (cache, t, hash, &ix, false);
kono
parents:
diff changeset
203 }
kono
parents:
diff changeset
204
kono
parents:
diff changeset
205
kono
parents:
diff changeset
206 /* Appends tree node T to CACHE, even if T already existed in it. */
kono
parents:
diff changeset
207
kono
parents:
diff changeset
208 void
kono
parents:
diff changeset
209 streamer_tree_cache_append (struct streamer_tree_cache_d *cache,
kono
parents:
diff changeset
210 tree t, hashval_t hash)
kono
parents:
diff changeset
211 {
kono
parents:
diff changeset
212 unsigned ix = cache->next_idx++;
kono
parents:
diff changeset
213 if (!cache->node_map)
kono
parents:
diff changeset
214 streamer_tree_cache_add_to_node_array (cache, ix, t, hash);
kono
parents:
diff changeset
215 else
kono
parents:
diff changeset
216 streamer_tree_cache_insert_1 (cache, t, hash, &ix, false);
kono
parents:
diff changeset
217 }
kono
parents:
diff changeset
218
kono
parents:
diff changeset
219 /* Return true if tree node T exists in CACHE, otherwise false. If IX_P is
kono
parents:
diff changeset
220 not NULL, write to *IX_P the index into the cache where T is stored
kono
parents:
diff changeset
221 ((unsigned)-1 if T is not found). */
kono
parents:
diff changeset
222
kono
parents:
diff changeset
223 bool
kono
parents:
diff changeset
224 streamer_tree_cache_lookup (struct streamer_tree_cache_d *cache, tree t,
kono
parents:
diff changeset
225 unsigned *ix_p)
kono
parents:
diff changeset
226 {
kono
parents:
diff changeset
227 unsigned *slot;
kono
parents:
diff changeset
228 bool retval;
kono
parents:
diff changeset
229 unsigned ix;
kono
parents:
diff changeset
230
kono
parents:
diff changeset
231 gcc_assert (t);
kono
parents:
diff changeset
232
kono
parents:
diff changeset
233 slot = cache->node_map->get (t);
kono
parents:
diff changeset
234 if (slot == NULL)
kono
parents:
diff changeset
235 {
kono
parents:
diff changeset
236 retval = false;
kono
parents:
diff changeset
237 ix = -1;
kono
parents:
diff changeset
238 }
kono
parents:
diff changeset
239 else
kono
parents:
diff changeset
240 {
kono
parents:
diff changeset
241 retval = true;
kono
parents:
diff changeset
242 ix = *slot;
kono
parents:
diff changeset
243 }
kono
parents:
diff changeset
244
kono
parents:
diff changeset
245 if (ix_p)
kono
parents:
diff changeset
246 *ix_p = ix;
kono
parents:
diff changeset
247
kono
parents:
diff changeset
248 return retval;
kono
parents:
diff changeset
249 }
kono
parents:
diff changeset
250
kono
parents:
diff changeset
251
kono
parents:
diff changeset
252 /* Verify that NODE is in CACHE. */
kono
parents:
diff changeset
253
kono
parents:
diff changeset
254 static void
kono
parents:
diff changeset
255 verify_common_node_recorded (struct streamer_tree_cache_d *cache, tree node)
kono
parents:
diff changeset
256 {
kono
parents:
diff changeset
257 /* Restrict this to flag_checking only because in general violating it is
kono
parents:
diff changeset
258 harmless plus we never know what happens on all targets/frontend/flag(!)
kono
parents:
diff changeset
259 combinations. */
kono
parents:
diff changeset
260 if (!flag_checking)
kono
parents:
diff changeset
261 return;
kono
parents:
diff changeset
262
kono
parents:
diff changeset
263 if (cache->node_map)
kono
parents:
diff changeset
264 gcc_assert (streamer_tree_cache_lookup (cache, node, NULL));
kono
parents:
diff changeset
265 else
kono
parents:
diff changeset
266 {
kono
parents:
diff changeset
267 bool found = false;
kono
parents:
diff changeset
268 gcc_assert (cache->nodes.exists ());
kono
parents:
diff changeset
269 /* Linear search... */
kono
parents:
diff changeset
270 for (unsigned i = 0; !found && i < cache->nodes.length (); ++i)
kono
parents:
diff changeset
271 if (cache->nodes[i] == node)
kono
parents:
diff changeset
272 found = true;
kono
parents:
diff changeset
273 gcc_assert (found);
kono
parents:
diff changeset
274 }
kono
parents:
diff changeset
275 }
kono
parents:
diff changeset
276
kono
parents:
diff changeset
277
kono
parents:
diff changeset
278 /* Record NODE in CACHE. */
kono
parents:
diff changeset
279
kono
parents:
diff changeset
280 static void
kono
parents:
diff changeset
281 record_common_node (struct streamer_tree_cache_d *cache, tree node)
kono
parents:
diff changeset
282 {
kono
parents:
diff changeset
283 /* If we recursively end up at nodes we do not want to preload simply don't.
kono
parents:
diff changeset
284 ??? We'd want to verify that this doesn't happen, or alternatively
kono
parents:
diff changeset
285 do not recurse at all. */
kono
parents:
diff changeset
286 if (node == char_type_node)
kono
parents:
diff changeset
287 return;
kono
parents:
diff changeset
288
kono
parents:
diff changeset
289 gcc_checking_assert (node != boolean_type_node
kono
parents:
diff changeset
290 && node != boolean_true_node
kono
parents:
diff changeset
291 && node != boolean_false_node);
kono
parents:
diff changeset
292
kono
parents:
diff changeset
293 /* We have to make sure to fill exactly the same number of
kono
parents:
diff changeset
294 elements for all frontends. That can include NULL trees.
kono
parents:
diff changeset
295 As our hash table can't deal with zero entries we'll simply stream
kono
parents:
diff changeset
296 a random other tree. A NULL tree never will be looked up so it
kono
parents:
diff changeset
297 doesn't matter which tree we replace it with, just to be sure
kono
parents:
diff changeset
298 use error_mark_node. */
kono
parents:
diff changeset
299 if (!node)
kono
parents:
diff changeset
300 node = error_mark_node;
kono
parents:
diff changeset
301
kono
parents:
diff changeset
302 /* ??? FIXME, devise a better hash value. But the hash needs to be equal
kono
parents:
diff changeset
303 for all frontend and lto1 invocations. So just use the position
kono
parents:
diff changeset
304 in the cache as hash value. */
kono
parents:
diff changeset
305 streamer_tree_cache_append (cache, node, cache->nodes.length ());
kono
parents:
diff changeset
306
kono
parents:
diff changeset
307 switch (TREE_CODE (node))
kono
parents:
diff changeset
308 {
kono
parents:
diff changeset
309 case ERROR_MARK:
kono
parents:
diff changeset
310 case FIELD_DECL:
kono
parents:
diff changeset
311 case FIXED_POINT_TYPE:
kono
parents:
diff changeset
312 case IDENTIFIER_NODE:
kono
parents:
diff changeset
313 case INTEGER_CST:
kono
parents:
diff changeset
314 case INTEGER_TYPE:
kono
parents:
diff changeset
315 case REAL_TYPE:
kono
parents:
diff changeset
316 case TREE_LIST:
kono
parents:
diff changeset
317 case VOID_CST:
kono
parents:
diff changeset
318 case VOID_TYPE:
kono
parents:
diff changeset
319 /* No recursive trees. */
kono
parents:
diff changeset
320 break;
kono
parents:
diff changeset
321 case ARRAY_TYPE:
kono
parents:
diff changeset
322 case POINTER_TYPE:
kono
parents:
diff changeset
323 case REFERENCE_TYPE:
kono
parents:
diff changeset
324 record_common_node (cache, TREE_TYPE (node));
kono
parents:
diff changeset
325 break;
kono
parents:
diff changeset
326 case COMPLEX_TYPE:
kono
parents:
diff changeset
327 /* Verify that a complex type's component type (node_type) has been
kono
parents:
diff changeset
328 handled already (and we thus don't need to recurse here). */
kono
parents:
diff changeset
329 verify_common_node_recorded (cache, TREE_TYPE (node));
kono
parents:
diff changeset
330 break;
kono
parents:
diff changeset
331 case RECORD_TYPE:
kono
parents:
diff changeset
332 /* The FIELD_DECLs of structures should be shared, so that every
kono
parents:
diff changeset
333 COMPONENT_REF uses the same tree node when referencing a field.
kono
parents:
diff changeset
334 Pointer equality between FIELD_DECLs is used by the alias
kono
parents:
diff changeset
335 machinery to compute overlapping component references (see
kono
parents:
diff changeset
336 nonoverlapping_component_refs_p and
kono
parents:
diff changeset
337 nonoverlapping_component_refs_of_decl_p). */
kono
parents:
diff changeset
338 for (tree f = TYPE_FIELDS (node); f; f = TREE_CHAIN (f))
kono
parents:
diff changeset
339 record_common_node (cache, f);
kono
parents:
diff changeset
340 break;
kono
parents:
diff changeset
341 default:
kono
parents:
diff changeset
342 /* Unexpected tree code. */
kono
parents:
diff changeset
343 gcc_unreachable ();
kono
parents:
diff changeset
344 }
kono
parents:
diff changeset
345 }
kono
parents:
diff changeset
346
kono
parents:
diff changeset
347
kono
parents:
diff changeset
348 /* Preload common nodes into CACHE and make sure they are merged
kono
parents:
diff changeset
349 properly according to the gimple type table. */
kono
parents:
diff changeset
350
kono
parents:
diff changeset
351 static void
kono
parents:
diff changeset
352 preload_common_nodes (struct streamer_tree_cache_d *cache)
kono
parents:
diff changeset
353 {
kono
parents:
diff changeset
354 unsigned i;
kono
parents:
diff changeset
355
kono
parents:
diff changeset
356 for (i = 0; i < itk_none; i++)
kono
parents:
diff changeset
357 /* Skip itk_char. char_type_node is dependent on -f[un]signed-char. */
kono
parents:
diff changeset
358 if (i != itk_char)
kono
parents:
diff changeset
359 record_common_node (cache, integer_types[i]);
kono
parents:
diff changeset
360
kono
parents:
diff changeset
361 for (i = 0; i < stk_type_kind_last; i++)
kono
parents:
diff changeset
362 record_common_node (cache, sizetype_tab[i]);
kono
parents:
diff changeset
363
kono
parents:
diff changeset
364 for (i = 0; i < TI_MAX; i++)
kono
parents:
diff changeset
365 /* Skip boolean type and constants, they are frontend dependent. */
kono
parents:
diff changeset
366 if (i != TI_BOOLEAN_TYPE
kono
parents:
diff changeset
367 && i != TI_BOOLEAN_FALSE
kono
parents:
diff changeset
368 && i != TI_BOOLEAN_TRUE
kono
parents:
diff changeset
369 /* MAIN_IDENTIFIER is not always initialized by Fortran FE. */
kono
parents:
diff changeset
370 && i != TI_MAIN_IDENTIFIER
kono
parents:
diff changeset
371 /* PID_TYPE is initialized only by C family front-ends. */
kono
parents:
diff changeset
372 && i != TI_PID_TYPE
kono
parents:
diff changeset
373 /* Skip optimization and target option nodes; they depend on flags. */
kono
parents:
diff changeset
374 && i != TI_OPTIMIZATION_DEFAULT
kono
parents:
diff changeset
375 && i != TI_OPTIMIZATION_CURRENT
kono
parents:
diff changeset
376 && i != TI_TARGET_OPTION_DEFAULT
kono
parents:
diff changeset
377 && i != TI_TARGET_OPTION_CURRENT
kono
parents:
diff changeset
378 && i != TI_CURRENT_TARGET_PRAGMA
kono
parents:
diff changeset
379 && i != TI_CURRENT_OPTIMIZE_PRAGMA
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
380 /* SCEV state shouldn't reach the IL. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
381 && i != TI_CHREC_DONT_KNOW
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
382 && i != TI_CHREC_KNOWN
111
kono
parents:
diff changeset
383 /* Skip va_list* related nodes if offloading. For native LTO
kono
parents:
diff changeset
384 we want them to be merged for the stdarg pass, for offloading
kono
parents:
diff changeset
385 they might not be identical between host and offloading target. */
kono
parents:
diff changeset
386 && (!lto_stream_offload_p
kono
parents:
diff changeset
387 || (i != TI_VA_LIST_TYPE
kono
parents:
diff changeset
388 && i != TI_VA_LIST_GPR_COUNTER_FIELD
kono
parents:
diff changeset
389 && i != TI_VA_LIST_FPR_COUNTER_FIELD)))
kono
parents:
diff changeset
390 record_common_node (cache, global_trees[i]);
kono
parents:
diff changeset
391 }
kono
parents:
diff changeset
392
kono
parents:
diff changeset
393
kono
parents:
diff changeset
394 /* Create a cache of pickled nodes. */
kono
parents:
diff changeset
395
kono
parents:
diff changeset
396 struct streamer_tree_cache_d *
kono
parents:
diff changeset
397 streamer_tree_cache_create (bool with_hashes, bool with_map, bool with_vec)
kono
parents:
diff changeset
398 {
kono
parents:
diff changeset
399 struct streamer_tree_cache_d *cache;
kono
parents:
diff changeset
400
kono
parents:
diff changeset
401 cache = XCNEW (struct streamer_tree_cache_d);
kono
parents:
diff changeset
402
kono
parents:
diff changeset
403 if (with_map)
kono
parents:
diff changeset
404 cache->node_map = new hash_map<tree, unsigned> (251);
kono
parents:
diff changeset
405 cache->next_idx = 0;
kono
parents:
diff changeset
406 if (with_vec)
kono
parents:
diff changeset
407 cache->nodes.create (165);
kono
parents:
diff changeset
408 if (with_hashes)
kono
parents:
diff changeset
409 cache->hashes.create (165);
kono
parents:
diff changeset
410
kono
parents:
diff changeset
411 /* Load all the well-known tree nodes that are always created by
kono
parents:
diff changeset
412 the compiler on startup. This prevents writing them out
kono
parents:
diff changeset
413 unnecessarily. */
kono
parents:
diff changeset
414 preload_common_nodes (cache);
kono
parents:
diff changeset
415
kono
parents:
diff changeset
416 return cache;
kono
parents:
diff changeset
417 }
kono
parents:
diff changeset
418
kono
parents:
diff changeset
419
kono
parents:
diff changeset
420 /* Delete the streamer cache C. */
kono
parents:
diff changeset
421
kono
parents:
diff changeset
422 void
kono
parents:
diff changeset
423 streamer_tree_cache_delete (struct streamer_tree_cache_d *c)
kono
parents:
diff changeset
424 {
kono
parents:
diff changeset
425 if (c == NULL)
kono
parents:
diff changeset
426 return;
kono
parents:
diff changeset
427
kono
parents:
diff changeset
428 delete c->node_map;
kono
parents:
diff changeset
429 c->node_map = NULL;
kono
parents:
diff changeset
430 c->nodes.release ();
kono
parents:
diff changeset
431 c->hashes.release ();
kono
parents:
diff changeset
432 free (c);
kono
parents:
diff changeset
433 }