Branch data Line data Source code
1 : : /* Write the GIMPLE representation to a file stream.
2 : :
3 : : Copyright (C) 2009-2026 Free Software Foundation, Inc.
4 : : Contributed by Kenneth Zadeck <zadeck@naturalbridge.com>
5 : : Re-implemented by Diego Novillo <dnovillo@google.com>
6 : :
7 : : This file is part of GCC.
8 : :
9 : : GCC is free software; you can redistribute it and/or modify it under
10 : : the terms of the GNU General Public License as published by the Free
11 : : Software Foundation; either version 3, or (at your option) any later
12 : : version.
13 : :
14 : : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15 : : WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 : : FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 : : for more details.
18 : :
19 : : You should have received a copy of the GNU General Public License
20 : : along with GCC; see the file COPYING3. If not see
21 : : <http://www.gnu.org/licenses/>. */
22 : :
23 : : #include "config.h"
24 : : #include "system.h"
25 : : #include "coretypes.h"
26 : : #include "backend.h"
27 : : #include "target.h"
28 : : #include "rtl.h"
29 : : #include "tree.h"
30 : : #include "gimple.h"
31 : : #include "tree-pass.h"
32 : : #include "ssa.h"
33 : : #include "gimple-streamer.h"
34 : : #include "alias.h"
35 : : #include "stor-layout.h"
36 : : #include "gimple-iterator.h"
37 : : #include "except.h"
38 : : #include "lto-symtab.h"
39 : : #include "cgraph.h"
40 : : #include "cfgloop.h"
41 : : #include "builtins.h"
42 : : #include "gomp-constants.h"
43 : : #include "debug.h"
44 : : #include "omp-offload.h"
45 : : #include "print-tree.h"
46 : : #include "tree-dfa.h"
47 : : #include "file-prefix-map.h" /* remap_debug_filename() */
48 : : #include "output.h"
49 : : #include "ipa-utils.h"
50 : : #include "toplev.h"
51 : :
52 : :
53 : : static void lto_write_tree (struct output_block*, tree, bool);
54 : :
55 : : /* Clear the line info stored in DATA_IN. */
56 : :
57 : : static void
58 : 314295 : clear_line_info (struct output_block *ob)
59 : : {
60 : 314295 : ob->current_file = NULL;
61 : 314295 : ob->current_line = 0;
62 : 314295 : ob->current_col = 0;
63 : 314295 : ob->current_sysp = false;
64 : 314295 : ob->reset_locus = true;
65 : 314295 : ob->emit_pwd = true;
66 : : /* Initialize to something that will never appear as block,
67 : : so that the first location with block in a function etc.
68 : : always streams a change_block bit and the first block. */
69 : 314295 : ob->current_block = void_node;
70 : 314295 : ob->current_discr = UINT_MAX;
71 : 0 : }
72 : :
73 : :
74 : : /* Create the output block and return it. SECTION_TYPE is
75 : : LTO_section_function_body or LTO_static_initializer. */
76 : :
77 : : struct output_block *
78 : 314295 : create_output_block (enum lto_section_type section_type)
79 : : {
80 : 314295 : struct output_block *ob = XCNEW (struct output_block);
81 : 314295 : if (streamer_dump_file)
82 : 40 : fprintf (streamer_dump_file, "Creating output block for %s\n",
83 : 40 : lto_section_name[section_type]);
84 : :
85 : 314295 : ob->section_type = section_type;
86 : 314295 : ob->decl_state = lto_get_out_decl_state ();
87 : : /* Only global decl stream in non-wpa will ever be considered by tree
88 : : merging. */
89 : 314295 : if (!flag_wpa && section_type == LTO_section_decls)
90 : 23047 : ob->local_trees = new (hash_set <tree>);
91 : 314295 : ob->main_stream = XCNEW (struct lto_output_stream);
92 : 314295 : ob->string_stream = XCNEW (struct lto_output_stream);
93 : 314295 : ob->writer_cache = streamer_tree_cache_create (!flag_wpa, true, false);
94 : :
95 : 314295 : if (section_type == LTO_section_function_body)
96 : 118127 : ob->cfg_stream = XCNEW (struct lto_output_stream);
97 : :
98 : 314295 : clear_line_info (ob);
99 : :
100 : 314295 : ob->string_hash_table = new hash_table<string_slot_hasher> (37);
101 : 314295 : gcc_obstack_init (&ob->obstack);
102 : :
103 : 314295 : return ob;
104 : : }
105 : :
106 : :
107 : : /* Destroy the output block OB. */
108 : :
109 : : void
110 : 314295 : destroy_output_block (struct output_block *ob)
111 : : {
112 : 314295 : enum lto_section_type section_type = ob->section_type;
113 : :
114 : 314295 : delete ob->string_hash_table;
115 : 314295 : ob->string_hash_table = NULL;
116 : 337342 : delete ob->local_trees;
117 : :
118 : 314295 : free (ob->main_stream);
119 : 314295 : free (ob->string_stream);
120 : 314295 : if (section_type == LTO_section_function_body)
121 : 118127 : free (ob->cfg_stream);
122 : :
123 : 314295 : streamer_tree_cache_delete (ob->writer_cache);
124 : 314295 : obstack_free (&ob->obstack, NULL);
125 : :
126 : 314295 : free (ob);
127 : 314295 : }
128 : :
129 : :
130 : : /* Wrapper around variably_modified_type_p avoiding type modification
131 : : during WPA streaming. */
132 : :
133 : : bool
134 : 14259927 : lto_variably_modified_type_p (tree type)
135 : : {
136 : 14259927 : return (in_lto_p
137 : 14259927 : ? TYPE_LANG_FLAG_0 (TYPE_MAIN_VARIANT (type))
138 : 13961222 : : variably_modified_type_p (type, NULL_TREE));
139 : : }
140 : :
141 : :
142 : : /* Return true if tree node T is written to various tables. For these
143 : : nodes, we sometimes want to write their phyiscal representation
144 : : (via lto_output_tree), and sometimes we need to emit an index
145 : : reference into a table (via lto_output_tree_ref). */
146 : :
147 : : static bool
148 : 35619207 : tree_is_indexable (tree t)
149 : : {
150 : : /* Parameters and return values of functions of variably modified types
151 : : must go to global stream, because they may be used in the type
152 : : definition. */
153 : 34520257 : if ((TREE_CODE (t) == PARM_DECL || TREE_CODE (t) == RESULT_DECL)
154 : 35947005 : && DECL_CONTEXT (t))
155 : 1426748 : return lto_variably_modified_type_p (TREE_TYPE (DECL_CONTEXT (t)));
156 : : /* IMPORTED_DECL is put into BLOCK and thus it never can be shared.
157 : : We should no longer need to stream it. */
158 : 34192459 : else if (TREE_CODE (t) == IMPORTED_DECL)
159 : 0 : gcc_unreachable ();
160 : 34192459 : else if (TREE_CODE (t) == LABEL_DECL)
161 : 81282 : return FORCED_LABEL (t) || DECL_NONLOCAL (t);
162 : 1649014 : else if (((VAR_P (t) && !TREE_STATIC (t))
163 : : || TREE_CODE (t) == TYPE_DECL
164 : : || TREE_CODE (t) == CONST_DECL
165 : : || TREE_CODE (t) == NAMELIST_DECL)
166 : 34984058 : && decl_function_context (t))
167 : : return false;
168 : 33248017 : else if (TREE_CODE (t) == DEBUG_EXPR_DECL)
169 : : return false;
170 : : /* Variably modified types need to be streamed alongside function
171 : : bodies because they can refer to local entities. Together with
172 : : them we have to localize their members as well.
173 : : ??? In theory that includes non-FIELD_DECLs as well. */
174 : 33246117 : else if (TYPE_P (t)
175 : 33246117 : && lto_variably_modified_type_p (t))
176 : : return false;
177 : 33234784 : else if (TREE_CODE (t) == FIELD_DECL
178 : 33234784 : && lto_variably_modified_type_p (DECL_CONTEXT (t)))
179 : : return false;
180 : : else
181 : 53916496 : return (IS_TYPE_OR_DECL_P (t) || TREE_CODE (t) == SSA_NAME);
182 : : }
183 : :
184 : :
185 : : /* Output info about new location into bitpack BP.
186 : : After outputting bitpack, lto_output_location_data has
187 : : to be done to output actual data. */
188 : :
189 : : static void
190 : 6765651 : lto_output_location_1 (struct output_block *ob, struct bitpack_d *bp,
191 : : location_t orig_loc, bool block_p)
192 : : {
193 : 6765651 : location_t loc = LOCATION_LOCUS (orig_loc);
194 : :
195 : 6765651 : if (loc >= RESERVED_LOCATION_COUNT)
196 : : {
197 : 4361605 : expanded_location xloc = expand_location (loc);
198 : 4361605 : unsigned discr = get_discriminator_from_loc (orig_loc);
199 : :
200 : 4361605 : if (ob->reset_locus)
201 : : {
202 : 138673 : if (xloc.file == NULL)
203 : 0 : ob->current_file = "";
204 : 138673 : if (xloc.line == 0)
205 : 0 : ob->current_line = 1;
206 : 138673 : if (xloc.column == 0)
207 : 4 : ob->current_col = 1;
208 : 138673 : ob->reset_locus = false;
209 : : }
210 : :
211 : : /* As RESERVED_LOCATION_COUNT is 2, we can use the spare value of
212 : : 3 without wasting additional bits to signalize file change.
213 : : If RESERVED_LOCATION_COUNT changes, reconsider this. */
214 : 4361605 : gcc_checking_assert (RESERVED_LOCATION_COUNT == 2);
215 : 4361605 : bp_pack_int_in_range (bp, 0, RESERVED_LOCATION_COUNT + 1,
216 : : RESERVED_LOCATION_COUNT
217 : 4361605 : + (ob->current_file != xloc.file));
218 : :
219 : 4361605 : bp_pack_value (bp, ob->current_line != xloc.line, 1);
220 : 4361605 : bp_pack_value (bp, ob->current_col != xloc.column, 1);
221 : 4361605 : bp_pack_value (bp, ob->current_discr != discr, 1);
222 : :
223 : 4361605 : if (ob->current_file != xloc.file)
224 : : {
225 : 215651 : bool stream_pwd = false;
226 : 215651 : const char *remapped = remap_debug_filename (xloc.file);
227 : 215651 : if (ob->emit_pwd && remapped && !IS_ABSOLUTE_PATH (remapped))
228 : : {
229 : 5935 : stream_pwd = true;
230 : 5935 : ob->emit_pwd = false;
231 : : }
232 : 215651 : bp_pack_value (bp, stream_pwd, 1);
233 : 215651 : if (stream_pwd)
234 : 5935 : bp_pack_string (ob, bp, get_src_pwd (), true);
235 : 215651 : bp_pack_string (ob, bp, remapped, true);
236 : 215651 : bp_pack_value (bp, xloc.sysp, 1);
237 : : }
238 : 4361605 : ob->current_file = xloc.file;
239 : 4361605 : ob->current_sysp = xloc.sysp;
240 : :
241 : 4361605 : if (ob->current_line != xloc.line)
242 : 1411048 : bp_pack_var_len_unsigned (bp, xloc.line);
243 : 4361605 : ob->current_line = xloc.line;
244 : :
245 : 4361605 : if (ob->current_col != xloc.column)
246 : 1692895 : bp_pack_var_len_unsigned (bp, xloc.column);
247 : 4361605 : ob->current_col = xloc.column;
248 : :
249 : 4361605 : if (ob->current_discr != discr)
250 : 1314235 : bp_pack_var_len_unsigned (bp, discr);
251 : 4361605 : ob->current_discr = discr;
252 : : }
253 : : else
254 : 2404046 : bp_pack_int_in_range (bp, 0, RESERVED_LOCATION_COUNT + 1, loc);
255 : :
256 : 6765651 : if (block_p)
257 : : {
258 : 2954652 : tree block = LOCATION_BLOCK (orig_loc);
259 : 2954652 : bp_pack_value (bp, ob->current_block != block, 1);
260 : 2954652 : streamer_write_bitpack (bp);
261 : 2954652 : if (ob->current_block != block)
262 : 746563 : lto_output_tree (ob, block, true, true);
263 : 2954652 : ob->current_block = block;
264 : : }
265 : 6765651 : }
266 : :
267 : : /* Output info about new location into bitpack BP.
268 : : After outputting bitpack, lto_output_location_data has
269 : : to be done to output actual data. */
270 : :
271 : : void
272 : 3810999 : lto_output_location (struct output_block *ob, struct bitpack_d *bp,
273 : : location_t loc)
274 : : {
275 : 3810999 : lto_output_location_1 (ob, bp, loc, false);
276 : 3810999 : }
277 : :
278 : : /* Output info about new location into bitpack BP.
279 : : After outputting bitpack, lto_output_location_data has
280 : : to be done to output actual data. Like lto_output_location, but
281 : : additionally output LOCATION_BLOCK info too and write the BP bitpack. */
282 : :
283 : : void
284 : 2954652 : lto_output_location_and_block (struct output_block *ob, struct bitpack_d *bp,
285 : : location_t loc)
286 : : {
287 : 2954652 : lto_output_location_1 (ob, bp, loc, true);
288 : 2954652 : }
289 : :
290 : :
291 : : /* Lookup NAME in ENCODER. If NAME is not found, create a new entry in
292 : : ENCODER for NAME with the next available index of ENCODER, then
293 : : print the index to OBS.
294 : : Return the index. */
295 : :
296 : :
297 : : static unsigned
298 : 7944853 : lto_get_index (struct lto_tree_ref_encoder *encoder, tree t)
299 : : {
300 : 7944853 : bool existed_p;
301 : :
302 : 7944853 : unsigned int &index
303 : 7944853 : = encoder->tree_hash_table->get_or_insert (t, &existed_p);
304 : 7944853 : if (!existed_p)
305 : : {
306 : 2175386 : index = encoder->trees.length ();
307 : 2175386 : if (streamer_dump_file)
308 : : {
309 : 176 : print_node_brief (streamer_dump_file, " Encoding indexable ",
310 : : t, 4);
311 : 176 : fprintf (streamer_dump_file, " as %i \n", index);
312 : : }
313 : 2175386 : encoder->trees.safe_push (t);
314 : : }
315 : :
316 : 7944853 : return index;
317 : : }
318 : :
319 : :
320 : : /* If EXPR is an indexable tree node, output a reference to it to
321 : : output block OB. Otherwise, output the physical representation of
322 : : EXPR to OB. */
323 : :
324 : : static void
325 : 9434453 : lto_indexable_tree_ref (struct output_block *ob, tree expr,
326 : : enum LTO_tags *tag, unsigned *index)
327 : : {
328 : 9434453 : gcc_checking_assert (tree_is_indexable (expr));
329 : :
330 : 9434453 : if (TREE_CODE (expr) == SSA_NAME)
331 : : {
332 : 2197195 : *tag = LTO_ssa_name_ref;
333 : 2197195 : *index = SSA_NAME_VERSION (expr);
334 : : }
335 : : else
336 : : {
337 : 7237258 : *tag = LTO_global_stream_ref;
338 : 7237258 : *index = lto_get_index (&ob->decl_state->streams[LTO_DECL_STREAM], expr);
339 : : }
340 : 9434453 : }
341 : :
342 : :
343 : : /* Output a static or extern var DECL to OBS. */
344 : :
345 : : void
346 : 288659 : lto_output_var_decl_ref (struct lto_out_decl_state *decl_state,
347 : : struct lto_output_stream * obs, tree decl)
348 : : {
349 : 288659 : gcc_checking_assert (VAR_P (decl));
350 : 288659 : streamer_write_uhwi_stream
351 : 288659 : (obs, lto_get_index (&decl_state->streams[LTO_DECL_STREAM],
352 : : decl));
353 : 288659 : }
354 : :
355 : :
356 : : /* Output a static or extern var DECL to OBS. */
357 : :
358 : : void
359 : 418936 : lto_output_fn_decl_ref (struct lto_out_decl_state *decl_state,
360 : : struct lto_output_stream * obs, tree decl)
361 : : {
362 : 418936 : gcc_checking_assert (TREE_CODE (decl) == FUNCTION_DECL);
363 : 418936 : streamer_write_uhwi_stream
364 : 418936 : (obs, lto_get_index (&decl_state->streams[LTO_DECL_STREAM], decl));
365 : 418936 : }
366 : :
367 : : /* Return true if EXPR is a tree node that can be written to disk. */
368 : :
369 : : static inline bool
370 : 7034024 : lto_is_streamable (tree expr)
371 : : {
372 : 7034024 : enum tree_code code = TREE_CODE (expr);
373 : :
374 : : /* Notice that we reject SSA_NAMEs as well. We only emit the SSA
375 : : name version in lto_output_tree_ref (see output_ssa_names). */
376 : 7034024 : return !is_lang_specific (expr)
377 : 7034024 : && code != SSA_NAME
378 : 7034024 : && code != LANG_TYPE
379 : : && code != MODIFY_EXPR
380 : 7034024 : && code != INIT_EXPR
381 : 7034024 : && code != TARGET_EXPR
382 : 7034024 : && code != BIND_EXPR
383 : 7034024 : && code != WITH_CLEANUP_EXPR
384 : 7034024 : && code != STATEMENT_LIST
385 : 7034024 : && (code == CASE_LABEL_EXPR
386 : 7034024 : || code == DECL_EXPR
387 : 7026149 : || code == ASM_EXPR
388 : 7026109 : || TREE_CODE_CLASS (code) != tcc_statement);
389 : : }
390 : :
391 : : /* Very rough estimate of streaming size of the initializer. If we ignored
392 : : presence of strings, we could simply just count number of non-indexable
393 : : tree nodes and number of references to indexable nodes. Strings however
394 : : may be very large and we do not want to dump them int othe global stream.
395 : :
396 : : Count the size of initializer until the size in DATA is positive. */
397 : :
398 : : static tree
399 : 100658 : subtract_estimated_size (tree *tp, int *ws, void *data)
400 : : {
401 : 100658 : long *sum = (long *)data;
402 : 100658 : if (tree_is_indexable (*tp))
403 : : {
404 : : /* Indexable tree is one reference to global stream.
405 : : Guess it may be about 4 bytes. */
406 : 1560 : *sum -= 4;
407 : 1560 : *ws = 0;
408 : : }
409 : : /* String table entry + base of tree node needs to be streamed. */
410 : 100658 : if (TREE_CODE (*tp) == STRING_CST)
411 : 7671 : *sum -= TREE_STRING_LENGTH (*tp) + 8;
412 : : else
413 : : {
414 : : /* Identifiers are also variable length but should not appear
415 : : naked in constructor. */
416 : 92987 : gcc_checking_assert (TREE_CODE (*tp) != IDENTIFIER_NODE);
417 : : /* We do not really make attempt to work out size of pickled tree, as
418 : : it is very variable. Make it bigger than the reference. */
419 : 92987 : *sum -= 16;
420 : : }
421 : 100658 : if (*sum < 0)
422 : 32908 : return *tp;
423 : : return NULL_TREE;
424 : : }
425 : :
426 : :
427 : : /* For EXPR lookup and return what we want to stream to OB as DECL_INITIAL. */
428 : :
429 : : static tree
430 : 2417383 : get_symbol_initial_value (lto_symtab_encoder_t encoder, tree expr)
431 : : {
432 : 2417383 : gcc_checking_assert (DECL_P (expr)
433 : : && TREE_CODE (expr) != FUNCTION_DECL
434 : : && TREE_CODE (expr) != TRANSLATION_UNIT_DECL);
435 : :
436 : : /* Handle DECL_INITIAL for symbols. */
437 : 2417383 : tree initial = DECL_INITIAL (expr);
438 : 2417383 : if (VAR_P (expr)
439 : 1203557 : && (TREE_STATIC (expr) || DECL_EXTERNAL (expr))
440 : 858707 : && !DECL_IN_CONSTANT_POOL (expr)
441 : 3275958 : && initial)
442 : : {
443 : 85230 : varpool_node *vnode;
444 : : /* Extra section needs about 30 bytes; do not produce it for simple
445 : : scalar values. */
446 : 85230 : if (!(vnode = varpool_node::get (expr))
447 : 85230 : || !lto_symtab_encoder_encode_initializer_p (encoder, vnode))
448 : 3231 : initial = error_mark_node;
449 : 85230 : if (initial != error_mark_node)
450 : : {
451 : 68623 : long max_size = 30;
452 : 68623 : if (walk_tree (&initial, subtract_estimated_size, (void *)&max_size,
453 : : NULL))
454 : 32908 : initial = error_mark_node;
455 : : }
456 : : }
457 : :
458 : 2417383 : return initial;
459 : : }
460 : :
461 : :
462 : : /* Output reference to tree T to the stream.
463 : : Assume that T is already in encoder cache.
464 : : This is used to stream tree bodies where we know the DFS walk arranged
465 : : everything to cache. Must be matched with stream_read_tree_ref. */
466 : :
467 : : void
468 : 31838735 : stream_write_tree_ref (struct output_block *ob, tree t)
469 : : {
470 : 31838735 : if (!t)
471 : 12137946 : streamer_write_zero (ob);
472 : : else
473 : : {
474 : 19700789 : unsigned int ix;
475 : 19700789 : bool existed_p = streamer_tree_cache_lookup (ob->writer_cache, t, &ix);
476 : 19700789 : if (existed_p)
477 : 15270822 : streamer_write_hwi (ob, ix + 1);
478 : : else
479 : : {
480 : 4429967 : enum LTO_tags tag;
481 : 4429967 : unsigned ix;
482 : 4429967 : int id = 0;
483 : :
484 : 4429967 : lto_indexable_tree_ref (ob, t, &tag, &ix);
485 : 4429967 : if (tag == LTO_ssa_name_ref)
486 : : id = 1;
487 : : else
488 : 4225449 : gcc_checking_assert (tag == LTO_global_stream_ref);
489 : 4429967 : streamer_write_hwi (ob, -(int)(ix * 2 + id + 1));
490 : : }
491 : : }
492 : 31838735 : }
493 : :
494 : :
495 : :
496 : : /* Write a physical representation of tree node EXPR to output block
497 : : OB. If REF_P is true, the leaves of EXPR are emitted as references
498 : : via lto_output_tree_ref. IX is the index into the streamer cache
499 : : where EXPR is stored. */
500 : :
501 : : static void
502 : 7034024 : lto_write_tree_1 (struct output_block *ob, tree expr, bool ref_p)
503 : : {
504 : 7034024 : if (streamer_dump_file)
505 : : {
506 : 416 : print_node_brief (streamer_dump_file, " Streaming body of ",
507 : : expr, 4);
508 : 416 : fprintf (streamer_dump_file, " to %s\n",
509 : 416 : lto_section_name[ob->section_type]);
510 : : }
511 : :
512 : : /* Pack all the non-pointer fields in EXPR into a bitpack and write
513 : : the resulting bitpack. */
514 : 7034024 : streamer_write_tree_bitfields (ob, expr);
515 : :
516 : : /* Write all the pointer fields in EXPR. */
517 : 7034024 : streamer_write_tree_body (ob, expr);
518 : :
519 : : /* Write any LTO-specific data to OB. */
520 : 7034024 : if (DECL_P (expr)
521 : 1526567 : && TREE_CODE (expr) != FUNCTION_DECL
522 : 1096157 : && TREE_CODE (expr) != TRANSLATION_UNIT_DECL)
523 : : {
524 : : /* Handle DECL_INITIAL for symbols. */
525 : 1064389 : tree initial = get_symbol_initial_value
526 : 1064389 : (ob->decl_state->symtab_node_encoder, expr);
527 : 1064389 : stream_write_tree (ob, initial, ref_p);
528 : : }
529 : :
530 : : /* Stream references to early generated DIEs. Keep in sync with the
531 : : trees handled in dwarf2out_die_ref_for_decl. */
532 : 7034024 : if ((DECL_P (expr)
533 : : && TREE_CODE (expr) != FIELD_DECL
534 : : && TREE_CODE (expr) != DEBUG_EXPR_DECL
535 : : && TREE_CODE (expr) != TYPE_DECL)
536 : 5644607 : || TREE_CODE (expr) == BLOCK)
537 : : {
538 : 1733056 : const char *sym;
539 : 1733056 : unsigned HOST_WIDE_INT off;
540 : 1733056 : if (debug_info_level > DINFO_LEVEL_NONE
541 : 1733056 : && debug_hooks->die_ref_for_decl (expr, &sym, &off))
542 : : {
543 : 48939 : streamer_write_string (ob, ob->main_stream, sym, true);
544 : 48939 : streamer_write_uhwi (ob, off);
545 : : }
546 : : else
547 : 1684117 : streamer_write_string (ob, ob->main_stream, NULL, true);
548 : : }
549 : 7034024 : }
550 : :
551 : : /* Write a physical representation of tree node EXPR to output block
552 : : OB. If REF_P is true, the leaves of EXPR are emitted as references
553 : : via lto_output_tree_ref. IX is the index into the streamer cache
554 : : where EXPR is stored. */
555 : :
556 : : static void
557 : 6762242 : lto_write_tree (struct output_block *ob, tree expr, bool ref_p)
558 : : {
559 : 6762242 : if (!lto_is_streamable (expr))
560 : 0 : internal_error ("tree code %qs is not supported in LTO streams",
561 : 0 : get_tree_code_name (TREE_CODE (expr)));
562 : :
563 : : /* Write the header, containing everything needed to materialize
564 : : EXPR on the reading side. */
565 : 6762242 : streamer_write_tree_header (ob, expr);
566 : :
567 : 6762242 : lto_write_tree_1 (ob, expr, ref_p);
568 : 6762242 : }
569 : :
570 : : /* Emit the physical representation of tree node EXPR to output block OB,
571 : : If THIS_REF_P is true, the leaves of EXPR are emitted as references via
572 : : lto_output_tree_ref. REF_P is used for streaming siblings of EXPR. */
573 : :
574 : : static void
575 : 7813928 : lto_output_tree_1 (struct output_block *ob, tree expr, hashval_t hash,
576 : : bool ref_p, bool this_ref_p)
577 : : {
578 : 7813928 : unsigned ix;
579 : :
580 : 7813928 : gcc_checking_assert (expr != NULL_TREE
581 : : && !(this_ref_p && tree_is_indexable (expr)));
582 : :
583 : 7813928 : bool exists_p = streamer_tree_cache_insert (ob->writer_cache,
584 : : expr, hash, &ix);
585 : 7813928 : gcc_assert (!exists_p);
586 : 7813928 : if (TREE_CODE (expr) == INTEGER_CST
587 : 7813928 : && !TREE_OVERFLOW (expr))
588 : : {
589 : : /* Shared INTEGER_CST nodes are special because they need their
590 : : original type to be materialized by the reader (to implement
591 : : TYPE_CACHED_VALUES). */
592 : 1051686 : streamer_write_integer_cst (ob, expr);
593 : : }
594 : : else
595 : : {
596 : : /* This is the first time we see EXPR, write its fields
597 : : to OB. */
598 : 6762242 : lto_write_tree (ob, expr, ref_p);
599 : : }
600 : 7813928 : }
601 : :
602 : : class DFS
603 : : {
604 : : public:
605 : : DFS (struct output_block *ob, tree expr, bool ref_p, bool this_ref_p,
606 : : bool single_p);
607 : : ~DFS ();
608 : :
609 : : struct scc_entry
610 : : {
611 : : tree t;
612 : : hashval_t hash;
613 : : };
614 : : auto_vec<scc_entry,32> sccstack;
615 : :
616 : : private:
617 : : struct sccs
618 : : {
619 : : unsigned int dfsnum;
620 : : unsigned int low;
621 : : };
622 : : struct worklist
623 : : {
624 : : tree expr;
625 : : sccs *from_state;
626 : : sccs *cstate;
627 : : bool ref_p;
628 : : bool this_ref_p;
629 : : };
630 : : /* Maximum index of scc stack containing a local tree. */
631 : : int max_local_entry;
632 : :
633 : : static int scc_entry_compare (const void *, const void *);
634 : :
635 : : void DFS_write_tree_body (struct output_block *ob,
636 : : tree expr, sccs *expr_state, bool ref_p);
637 : :
638 : : void DFS_write_tree (struct output_block *ob, sccs *from_state,
639 : : tree expr, bool ref_p, bool this_ref_p);
640 : :
641 : : hashval_t
642 : : hash_scc (struct output_block *ob, unsigned first, unsigned size,
643 : : bool ref_p, bool this_ref_p);
644 : :
645 : : hash_map<tree, sccs *> sccstate;
646 : : auto_vec<worklist, 32> worklist_vec;
647 : : struct obstack sccstate_obstack;
648 : : };
649 : :
650 : : /* Return true if type can not be merged with structurally same tree in
651 : : other translation unit. During stream out this information is propagated
652 : : to all trees referring to T and they are not streamed with additional
653 : : information needed by the tree merging in lto-common.cc (in particular,
654 : : scc hash codes are not streamed).
655 : :
656 : : TRANSLATION_UNIT_DECL is handled specially since references to it does
657 : : not make other trees local as well. */
658 : :
659 : : static bool
660 : 2846813 : local_tree_p (tree t)
661 : : {
662 : 2846813 : switch (TREE_CODE (t))
663 : : {
664 : : case LABEL_DECL:
665 : : return true;
666 : 1600 : case NAMESPACE_DECL:
667 : 1600 : return !DECL_NAME (t);
668 : 616836 : case VAR_DECL:
669 : 616836 : case FUNCTION_DECL:
670 : 616836 : return !TREE_PUBLIC (t) && !DECL_EXTERNAL (t);
671 : 73366 : case RECORD_TYPE:
672 : 73366 : case UNION_TYPE:
673 : 73366 : case ENUMERAL_TYPE:
674 : : /* Anonymous namespace types are local.
675 : : Only work hard for main variants;
676 : : variant types will inherit locality. */
677 : 73366 : return TYPE_MAIN_VARIANT (t) == t
678 : 58734 : && odr_type_p (t) && type_with_linkage_p (t)
679 : 93020 : && type_in_anonymous_namespace_p (t);
680 : : default:
681 : : return false;
682 : : }
683 : : }
684 : :
685 : : /* Emit the physical representation of tree node EXPR to output block OB,
686 : : using depth-first search on the subgraph. If THIS_REF_P is true, the
687 : : leaves of EXPR are emitted as references via lto_output_tree_ref.
688 : : REF_P is used for streaming siblings of EXPR. If SINGLE_P is true,
689 : : this is for a rewalk of a single leaf SCC. */
690 : :
691 : 2976387 : DFS::DFS (struct output_block *ob, tree expr, bool ref_p, bool this_ref_p,
692 : 2976387 : bool single_p)
693 : : {
694 : 2976387 : unsigned int next_dfs_num = 1;
695 : :
696 : 2976387 : max_local_entry = -1;
697 : 2976387 : gcc_obstack_init (&sccstate_obstack);
698 : 2976387 : DFS_write_tree (ob, NULL, expr, ref_p, this_ref_p);
699 : 21598224 : while (!worklist_vec.is_empty ())
700 : : {
701 : 17696014 : worklist &w = worklist_vec.last ();
702 : 17696014 : expr = w.expr;
703 : 17696014 : sccs *from_state = w.from_state;
704 : 17696014 : sccs *cstate = w.cstate;
705 : 17696014 : ref_p = w.ref_p;
706 : 17696014 : this_ref_p = w.this_ref_p;
707 : 17696014 : if (cstate == NULL)
708 : : {
709 : 9599414 : sccs **slot = &sccstate.get_or_insert (expr);
710 : 9599414 : cstate = *slot;
711 : 9599414 : if (cstate)
712 : : {
713 : 1502814 : gcc_checking_assert (from_state);
714 : 1502814 : if (cstate->dfsnum < from_state->dfsnum)
715 : 189899 : from_state->low = MIN (cstate->dfsnum, from_state->low);
716 : 1502814 : worklist_vec.pop ();
717 : 1502814 : continue;
718 : : }
719 : :
720 : 8096600 : scc_entry e = { expr, 0 };
721 : : /* Not yet visited. DFS recurse and push it onto the stack. */
722 : 8096600 : *slot = cstate = XOBNEW (&sccstate_obstack, struct sccs);
723 : 8096600 : if (ob->local_trees && local_tree_p (expr))
724 : 85072 : max_local_entry = sccstack.length ();
725 : 8096600 : sccstack.safe_push (e);
726 : 8096600 : cstate->dfsnum = next_dfs_num++;
727 : 8096600 : cstate->low = cstate->dfsnum;
728 : 8096600 : w.cstate = cstate;
729 : :
730 : 8096600 : if (TREE_CODE (expr) == INTEGER_CST
731 : 8096600 : && !TREE_OVERFLOW (expr))
732 : 1094832 : DFS_write_tree (ob, cstate, TREE_TYPE (expr), ref_p, ref_p);
733 : : else
734 : : {
735 : 7001768 : DFS_write_tree_body (ob, expr, cstate, ref_p);
736 : :
737 : : /* Walk any LTO-specific edges. */
738 : 7001768 : if (DECL_P (expr)
739 : 1530251 : && TREE_CODE (expr) != FUNCTION_DECL
740 : 1099841 : && TREE_CODE (expr) != TRANSLATION_UNIT_DECL)
741 : : {
742 : : /* Handle DECL_INITIAL for symbols. */
743 : 1068073 : tree initial
744 : 1068073 : = get_symbol_initial_value (ob->decl_state->symtab_node_encoder,
745 : : expr);
746 : 1068073 : DFS_write_tree (ob, cstate, initial, ref_p, ref_p);
747 : : }
748 : : }
749 : 8096600 : continue;
750 : 8096600 : }
751 : :
752 : : /* See if we found an SCC. */
753 : 8096600 : if (cstate->low == cstate->dfsnum)
754 : : {
755 : 7895082 : unsigned first, size;
756 : 7895082 : tree x;
757 : :
758 : : /* If we are re-walking a single leaf SCC just pop it,
759 : : let earlier worklist item access the sccstack. */
760 : 7895082 : if (single_p)
761 : : {
762 : 343 : worklist_vec.pop ();
763 : 343 : continue;
764 : : }
765 : :
766 : : /* Pop the SCC and compute its size. */
767 : 15789478 : first = sccstack.length ();
768 : 8085710 : do
769 : : {
770 : 8085710 : x = sccstack[--first].t;
771 : : }
772 : 8085710 : while (x != expr);
773 : 7894739 : size = sccstack.length () - first;
774 : :
775 : : /* No need to compute hashes for LTRANS units, we don't perform
776 : : any merging there. */
777 : 7894739 : hashval_t scc_hash = 0;
778 : 7894739 : unsigned scc_entry_len = 0;
779 : 21040945 : bool local_to_unit = !ob->local_trees
780 : 7894739 : || max_local_entry >= (int)first;
781 : :
782 : : /* Remember that trees are local so info gets propagated to other
783 : : SCCs. */
784 : 5251467 : if (local_to_unit && ob->local_trees)
785 : : {
786 : 94254 : for (unsigned i = 0; i < size; ++i)
787 : 48531 : ob->local_trees->add (sccstack[first + i].t);
788 : : }
789 : :
790 : : /* As a special case do not stream TRANSLATION_UNIT_DECL as shared
791 : : tree. We can not mark it local because references to it does not
792 : : make other trees local (all global decls reffer to it via
793 : : CONTEXT). */
794 : 7894739 : if (size == 1
795 : 7894739 : && TREE_CODE (sccstack[first].t) == TRANSLATION_UNIT_DECL)
796 : : local_to_unit = true;
797 : :
798 : 7862971 : if (!local_to_unit)
799 : : {
800 : 2620445 : scc_hash = hash_scc (ob, first, size, ref_p, this_ref_p);
801 : :
802 : : /* Put the entries with the least number of collisions first. */
803 : 2620445 : unsigned entry_start = 0;
804 : 2620445 : scc_entry_len = size + 1;
805 : 5385010 : for (unsigned i = 0; i < size;)
806 : : {
807 : 2764565 : unsigned from = i;
808 : 2764565 : for (i = i + 1; i < size
809 : 2764565 : && (sccstack[first + i].hash
810 : 144120 : == sccstack[first + from].hash); ++i)
811 : : ;
812 : 2764565 : if (i - from < scc_entry_len)
813 : : {
814 : 2620445 : scc_entry_len = i - from;
815 : 2620445 : entry_start = from;
816 : : }
817 : : }
818 : 5240890 : for (unsigned i = 0; i < scc_entry_len; ++i)
819 : 2620445 : std::swap (sccstack[first + i],
820 : 2620445 : sccstack[first + entry_start + i]);
821 : :
822 : : /* We already sorted SCC deterministically in hash_scc. */
823 : :
824 : : /* Check that we have only one SCC.
825 : : Naturally we may have conflicts if hash function is not
826 : : strong enough. Lets see how far this gets. */
827 : 2620445 : gcc_checking_assert (scc_entry_len == 1);
828 : : }
829 : :
830 : 7894739 : worklist_vec.pop ();
831 : :
832 : 7894739 : unsigned int prev_size = ob->main_stream->total_size;
833 : :
834 : : /* Only global decl sections are considered by tree merging. */
835 : 7894739 : if (ob->section_type != LTO_section_decls)
836 : : {
837 : : /* If this is the original tree we stream and it forms SCC
838 : : by itself then we do not need to stream SCC at all. */
839 : 4489835 : if (worklist_vec.is_empty () && first == 0 && size == 1)
840 : : return;
841 : 2439271 : if (streamer_dump_file)
842 : : {
843 : 140 : fprintf (streamer_dump_file,
844 : : " Start of LTO_trees of size %i\n", size);
845 : : }
846 : 2439271 : streamer_write_record_start (ob, LTO_trees);
847 : 2439271 : streamer_write_uhwi (ob, size);
848 : : }
849 : : /* Write LTO_tree_scc if tree merging is going to be performed. */
850 : 3404904 : else if (!local_to_unit
851 : : /* These are special since sharing is not done by tree
852 : : merging machinery. We can not special case them earlier
853 : : because we still need to compute hash for further sharing
854 : : of trees referring to them. */
855 : 3404904 : && (size != 1
856 : 2554742 : || (TREE_CODE (sccstack[first].t) != IDENTIFIER_NODE
857 : 1684498 : && (TREE_CODE (sccstack[first].t) != INTEGER_CST
858 : 152530 : || TREE_OVERFLOW (sccstack[first].t)))))
859 : :
860 : : {
861 : 1597673 : gcc_checking_assert (ob->section_type == LTO_section_decls);
862 : 1597673 : if (streamer_dump_file)
863 : : {
864 : 172 : fprintf (streamer_dump_file,
865 : : " Start of LTO_tree_scc of size %i\n", size);
866 : : }
867 : 1597673 : streamer_write_record_start (ob, LTO_tree_scc);
868 : : /* In wast majority of cases scc_entry_len is 1 and size is small
869 : : integer. Use extra bit of size to stream info about
870 : : exceptions. */
871 : 1597673 : streamer_write_uhwi (ob, size * 2 + (scc_entry_len != 1));
872 : 1597673 : if (scc_entry_len != 1)
873 : 0 : streamer_write_uhwi (ob, scc_entry_len);
874 : 1597673 : streamer_write_uhwi (ob, scc_hash);
875 : : }
876 : : /* Non-trivial SCCs must be packed to trees blocks so forward
877 : : references work correctly. */
878 : 1807231 : else if (size != 1)
879 : : {
880 : 14974 : if (streamer_dump_file)
881 : : {
882 : 0 : fprintf (streamer_dump_file,
883 : : " Start of LTO_trees of size %i\n", size);
884 : : }
885 : 14974 : streamer_write_record_start (ob, LTO_trees);
886 : 14974 : streamer_write_uhwi (ob, size);
887 : : }
888 : 1792257 : else if (streamer_dump_file)
889 : : {
890 : 108 : fprintf (streamer_dump_file, " Streaming single tree\n");
891 : : }
892 : :
893 : : /* Write size-1 SCCs without wrapping them inside SCC bundles.
894 : : All INTEGER_CSTs need to be handled this way as we need
895 : : their type to materialize them. Also builtins are handled
896 : : this way. */
897 : 5844175 : if (size == 1)
898 : 5763364 : lto_output_tree_1 (ob, expr, scc_hash, ref_p, this_ref_p);
899 : : else
900 : : {
901 : :
902 : : /* Write all headers and populate the streamer cache. */
903 : 352593 : for (unsigned i = 0; i < size; ++i)
904 : : {
905 : 271782 : hashval_t hash = sccstack[first+i].hash;
906 : 271782 : tree t = sccstack[first+i].t;
907 : 271782 : bool exists_p = streamer_tree_cache_insert (ob->writer_cache,
908 : : t, hash, NULL);
909 : 271782 : gcc_assert (!exists_p);
910 : :
911 : 271782 : if (!lto_is_streamable (t))
912 : 0 : internal_error ("tree code %qs is not supported "
913 : : "in LTO streams",
914 : 0 : get_tree_code_name (TREE_CODE (t)));
915 : :
916 : : /* Write the header, containing everything needed to
917 : : materialize EXPR on the reading side. */
918 : 271782 : streamer_write_tree_header (ob, t);
919 : : }
920 : :
921 : : /* Write the bitpacks and tree references. */
922 : 352593 : for (unsigned i = 0; i < size; ++i)
923 : 271782 : lto_write_tree_1 (ob, sccstack[first+i].t, ref_p);
924 : : }
925 : 5844175 : if (streamer_dump_file)
926 : 420 : fprintf (streamer_dump_file, " %u bytes\n",
927 : 420 : ob->main_stream->total_size - prev_size);
928 : :
929 : : /* Finally truncate the vector. */
930 : 5844175 : sccstack.truncate (first);
931 : 5844175 : if ((int)first <= max_local_entry)
932 : 45723 : max_local_entry = first - 1;
933 : :
934 : 5844175 : if (from_state)
935 : 4918695 : from_state->low = MIN (from_state->low, cstate->low);
936 : 5844175 : continue;
937 : 5844175 : }
938 : :
939 : 201518 : gcc_checking_assert (from_state);
940 : 201518 : from_state->low = MIN (from_state->low, cstate->low);
941 : 201518 : if (cstate->dfsnum < from_state->dfsnum)
942 : 0 : from_state->low = MIN (cstate->dfsnum, from_state->low);
943 : 201518 : worklist_vec.pop ();
944 : : }
945 : : }
946 : :
947 : 2976387 : DFS::~DFS ()
948 : : {
949 : 2976387 : obstack_free (&sccstate_obstack, NULL);
950 : 2976387 : }
951 : :
952 : : /* Handle the tree EXPR in the DFS walk with SCC state EXPR_STATE and
953 : : DFS recurse for all tree edges originating from it. */
954 : :
955 : : void
956 : 7001768 : DFS::DFS_write_tree_body (struct output_block *ob,
957 : : tree expr, sccs *expr_state, bool ref_p)
958 : : {
959 : : #define DFS_follow_tree_edge(DEST) \
960 : : DFS_write_tree (ob, expr_state, DEST, ref_p, ref_p)
961 : :
962 : 7001768 : enum tree_code code;
963 : :
964 : 7001768 : code = TREE_CODE (expr);
965 : :
966 : 7001768 : if (CODE_CONTAINS_STRUCT (code, TS_TYPED))
967 : : {
968 : 6596131 : if (TREE_CODE (expr) != IDENTIFIER_NODE)
969 : 5116658 : DFS_follow_tree_edge (TREE_TYPE (expr));
970 : : }
971 : :
972 : 7001768 : if (CODE_CONTAINS_STRUCT (code, TS_VECTOR))
973 : : {
974 : 5760 : unsigned int count = vector_cst_encoded_nelts (expr);
975 : 23878 : for (unsigned int i = 0; i < count; ++i)
976 : 18118 : DFS_follow_tree_edge (VECTOR_CST_ENCODED_ELT (expr, i));
977 : : }
978 : :
979 : 7001768 : if (CODE_CONTAINS_STRUCT (code, TS_POLY_INT_CST))
980 : 0 : for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
981 : 0 : DFS_follow_tree_edge (POLY_INT_CST_COEFF (expr, i));
982 : :
983 : 7001768 : if (CODE_CONTAINS_STRUCT (code, TS_COMPLEX))
984 : : {
985 : 8007 : DFS_follow_tree_edge (TREE_REALPART (expr));
986 : 8007 : DFS_follow_tree_edge (TREE_IMAGPART (expr));
987 : : }
988 : :
989 : 7001768 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_MINIMAL))
990 : : {
991 : : /* Drop names that were created for anonymous entities. */
992 : 1530251 : if (DECL_NAME (expr)
993 : 1346920 : && TREE_CODE (DECL_NAME (expr)) == IDENTIFIER_NODE
994 : 2877171 : && IDENTIFIER_ANON_P (DECL_NAME (expr)))
995 : : ;
996 : : else
997 : 1529654 : DFS_follow_tree_edge (DECL_NAME (expr));
998 : 1530251 : if (TREE_CODE (expr) != TRANSLATION_UNIT_DECL
999 : 1530251 : && ! DECL_CONTEXT (expr))
1000 : 15146 : DFS_follow_tree_edge ((*all_translation_units)[0]);
1001 : : else
1002 : 1515105 : DFS_follow_tree_edge (DECL_CONTEXT (expr));
1003 : : }
1004 : :
1005 : 7001768 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
1006 : : {
1007 : 1530251 : DFS_follow_tree_edge (DECL_SIZE (expr));
1008 : 1530251 : DFS_follow_tree_edge (DECL_SIZE_UNIT (expr));
1009 : :
1010 : : /* Note, DECL_INITIAL is not handled here. Since DECL_INITIAL needs
1011 : : special handling in LTO, it must be handled by streamer hooks. */
1012 : :
1013 : 1530251 : DFS_follow_tree_edge (DECL_ATTRIBUTES (expr));
1014 : :
1015 : : /* We use DECL_ABSTRACT_ORIGIN == error_mark_node to mark
1016 : : declarations which should be eliminated by decl merging. Be sure none
1017 : : leaks to this point. */
1018 : 1530251 : gcc_assert (DECL_ABSTRACT_ORIGIN (expr) != error_mark_node);
1019 : 1530251 : DFS_follow_tree_edge (DECL_ABSTRACT_ORIGIN (expr));
1020 : :
1021 : 1530251 : if ((VAR_P (expr)
1022 : 1530251 : || TREE_CODE (expr) == PARM_DECL)
1023 : 1530251 : && DECL_HAS_VALUE_EXPR_P (expr))
1024 : 6526 : DFS_follow_tree_edge (DECL_VALUE_EXPR (expr));
1025 : 1530251 : if (VAR_P (expr)
1026 : 1530251 : && DECL_HAS_DEBUG_EXPR_P (expr))
1027 : 1502 : DFS_follow_tree_edge (DECL_DEBUG_EXPR (expr));
1028 : : }
1029 : :
1030 : 7001768 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS))
1031 : : {
1032 : : /* Make sure we don't inadvertently set the assembler name. */
1033 : 919291 : if (DECL_ASSEMBLER_NAME_SET_P (expr))
1034 : 743582 : DFS_follow_tree_edge (DECL_ASSEMBLER_NAME (expr));
1035 : : }
1036 : :
1037 : 7001768 : if (CODE_CONTAINS_STRUCT (code, TS_FIELD_DECL))
1038 : : {
1039 : 112955 : DFS_follow_tree_edge (DECL_FIELD_OFFSET (expr));
1040 : 112955 : DFS_follow_tree_edge (DECL_BIT_FIELD_TYPE (expr));
1041 : 112955 : DFS_follow_tree_edge (DECL_BIT_FIELD_REPRESENTATIVE (expr));
1042 : 112955 : DFS_follow_tree_edge (DECL_FIELD_BIT_OFFSET (expr));
1043 : 112955 : gcc_checking_assert (!DECL_FCONTEXT (expr));
1044 : : }
1045 : :
1046 : 7001768 : if (CODE_CONTAINS_STRUCT (code, TS_FUNCTION_DECL))
1047 : : {
1048 : 430410 : gcc_checking_assert (DECL_VINDEX (expr) == NULL);
1049 : 430410 : DFS_follow_tree_edge (DECL_FUNCTION_PERSONALITY (expr));
1050 : 430410 : DFS_follow_tree_edge (DECL_FUNCTION_SPECIFIC_TARGET (expr));
1051 : 430410 : DFS_follow_tree_edge (DECL_FUNCTION_SPECIFIC_OPTIMIZATION (expr));
1052 : : }
1053 : :
1054 : 7001768 : if (CODE_CONTAINS_STRUCT (code, TS_TYPE_COMMON))
1055 : : {
1056 : 644222 : DFS_follow_tree_edge (TYPE_SIZE (expr));
1057 : 644222 : DFS_follow_tree_edge (TYPE_SIZE_UNIT (expr));
1058 : 644222 : DFS_follow_tree_edge (TYPE_ATTRIBUTES (expr));
1059 : 644222 : DFS_follow_tree_edge (TYPE_NAME (expr));
1060 : : /* Do not follow TYPE_POINTER_TO or TYPE_REFERENCE_TO. They will be
1061 : : reconstructed during fixup. */
1062 : : /* Do not follow TYPE_NEXT_VARIANT, we reconstruct the variant lists
1063 : : during fixup. */
1064 : 644222 : DFS_follow_tree_edge (TYPE_MAIN_VARIANT (expr));
1065 : 644222 : DFS_follow_tree_edge (TYPE_CONTEXT (expr));
1066 : : /* TYPE_CANONICAL is re-computed during type merging, so no need
1067 : : to follow it here. */
1068 : : /* Do not stream TYPE_STUB_DECL; it is not needed by LTO but currently
1069 : : it cannot be freed by free_lang_data without triggering ICEs in
1070 : : langhooks. */
1071 : : }
1072 : :
1073 : 7001768 : if (CODE_CONTAINS_STRUCT (code, TS_TYPE_NON_COMMON))
1074 : : {
1075 : 644222 : if (TREE_CODE (expr) == ARRAY_TYPE)
1076 : 45443 : DFS_follow_tree_edge (TYPE_DOMAIN (expr));
1077 : 598779 : else if (RECORD_OR_UNION_TYPE_P (expr))
1078 : 243076 : for (tree t = TYPE_FIELDS (expr); t; t = TREE_CHAIN (t))
1079 : 149557 : DFS_follow_tree_edge (t);
1080 : 505260 : else if (FUNC_OR_METHOD_TYPE_P (expr))
1081 : 169754 : DFS_follow_tree_edge (TYPE_ARG_TYPES (expr));
1082 : :
1083 : 644222 : if (!POINTER_TYPE_P (expr))
1084 : 388679 : DFS_follow_tree_edge (TYPE_MIN_VALUE_RAW (expr));
1085 : 644222 : DFS_follow_tree_edge (TYPE_MAX_VALUE_RAW (expr));
1086 : : }
1087 : :
1088 : 7001768 : if (CODE_CONTAINS_STRUCT (code, TS_LIST))
1089 : : {
1090 : 668955 : DFS_follow_tree_edge (TREE_PURPOSE (expr));
1091 : 668955 : DFS_follow_tree_edge (TREE_VALUE (expr));
1092 : 668955 : DFS_follow_tree_edge (TREE_CHAIN (expr));
1093 : : }
1094 : :
1095 : 7001768 : if (CODE_CONTAINS_STRUCT (code, TS_VEC))
1096 : : {
1097 : 10 : for (int i = 0; i < TREE_VEC_LENGTH (expr); i++)
1098 : 8 : DFS_follow_tree_edge (TREE_VEC_ELT (expr, i));
1099 : : }
1100 : :
1101 : 7001768 : if (CODE_CONTAINS_STRUCT (code, TS_EXP))
1102 : : {
1103 : 4178197 : for (int i = 0; i < TREE_OPERAND_LENGTH (expr); i++)
1104 : 2455052 : DFS_follow_tree_edge (TREE_OPERAND (expr, i));
1105 : 1723145 : DFS_follow_tree_edge (TREE_BLOCK (expr));
1106 : : }
1107 : :
1108 : 7001768 : if (CODE_CONTAINS_STRUCT (code, TS_BLOCK))
1109 : : {
1110 : 486669 : for (tree t = BLOCK_VARS (expr); t; t = TREE_CHAIN (t))
1111 : : {
1112 : : /* We would have to stream externals in the block chain as
1113 : : non-references but we should have dropped them in
1114 : : free-lang-data. */
1115 : 143030 : gcc_assert (!VAR_OR_FUNCTION_DECL_P (t) || !DECL_EXTERNAL (t));
1116 : 143030 : DFS_follow_tree_edge (t);
1117 : : }
1118 : :
1119 : 343639 : DFS_follow_tree_edge (BLOCK_SUPERCONTEXT (expr));
1120 : 343639 : DFS_follow_tree_edge (BLOCK_ABSTRACT_ORIGIN (expr));
1121 : :
1122 : : /* Do not follow BLOCK_NONLOCALIZED_VARS. We cannot handle debug
1123 : : information for early inlined BLOCKs so drop it on the floor instead
1124 : : of ICEing in dwarf2out.cc. */
1125 : :
1126 : : /* BLOCK_FRAGMENT_ORIGIN and BLOCK_FRAGMENT_CHAIN is not live at LTO
1127 : : streaming time. */
1128 : :
1129 : : /* Do not output BLOCK_SUBBLOCKS. Instead on streaming-in this
1130 : : list is re-constructed from BLOCK_SUPERCONTEXT. */
1131 : : }
1132 : :
1133 : 7001768 : if (CODE_CONTAINS_STRUCT (code, TS_BINFO))
1134 : : {
1135 : : unsigned i;
1136 : : tree t;
1137 : :
1138 : : /* Note that the number of BINFO slots has already been emitted in
1139 : : EXPR's header (see streamer_write_tree_header) because this length
1140 : : is needed to build the empty BINFO node on the reader side. */
1141 : 20266 : FOR_EACH_VEC_ELT (*BINFO_BASE_BINFOS (expr), i, t)
1142 : 10780 : DFS_follow_tree_edge (t);
1143 : 9486 : DFS_follow_tree_edge (BINFO_OFFSET (expr));
1144 : 9486 : DFS_follow_tree_edge (BINFO_VTABLE (expr));
1145 : :
1146 : : /* Do not walk BINFO_INHERITANCE_CHAIN, BINFO_SUBVTT_INDEX,
1147 : : BINFO_BASE_ACCESSES and BINFO_VPTR_INDEX; these are used
1148 : : by C++ FE only. */
1149 : : }
1150 : :
1151 : 7001768 : if (CODE_CONTAINS_STRUCT (code, TS_CONSTRUCTOR))
1152 : : {
1153 : : unsigned i;
1154 : : tree index, value;
1155 : :
1156 : 767570 : FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (expr), i, index, value)
1157 : : {
1158 : 530514 : DFS_follow_tree_edge (index);
1159 : 530514 : DFS_follow_tree_edge (value);
1160 : : }
1161 : : }
1162 : :
1163 : 7001768 : if (code == RAW_DATA_CST)
1164 : 21 : DFS_follow_tree_edge (RAW_DATA_OWNER (expr));
1165 : :
1166 : 7001768 : if (code == OMP_CLAUSE)
1167 : : {
1168 : : int i;
1169 : 494 : for (i = 0; i < omp_clause_num_ops[OMP_CLAUSE_CODE (expr)]; i++)
1170 : 280 : DFS_follow_tree_edge (OMP_CLAUSE_OPERAND (expr, i));
1171 : 214 : DFS_follow_tree_edge (OMP_CLAUSE_CHAIN (expr));
1172 : : }
1173 : :
1174 : : #undef DFS_follow_tree_edge
1175 : 7001768 : }
1176 : :
1177 : : /* Return a hash value for the tree T.
1178 : : CACHE holds hash values of trees outside current SCC. MAP, if non-NULL,
1179 : : may hold hash values if trees inside current SCC. */
1180 : :
1181 : : static hashval_t
1182 : 2764565 : hash_tree (struct streamer_tree_cache_d *cache, hash_map<tree, hashval_t> *map, tree t)
1183 : : {
1184 : 2764565 : inchash::hash hstate;
1185 : :
1186 : : #define visit(SIBLING) \
1187 : : do { \
1188 : : unsigned ix; \
1189 : : if (!SIBLING) \
1190 : : hstate.add_int (0); \
1191 : : else if (streamer_tree_cache_lookup (cache, SIBLING, &ix)) \
1192 : : hstate.add_int (streamer_tree_cache_get_hash (cache, ix)); \
1193 : : else if (map) \
1194 : : hstate.add_int (*map->get (SIBLING)); \
1195 : : else \
1196 : : hstate.add_int (1); \
1197 : : } while (0)
1198 : :
1199 : : /* Hash TS_BASE. */
1200 : 2764565 : enum tree_code code = TREE_CODE (t);
1201 : 2764565 : hstate.add_int (code);
1202 : 2764565 : if (!TYPE_P (t))
1203 : : {
1204 : 2316099 : hstate.add_flag (TREE_SIDE_EFFECTS (t));
1205 : 2316099 : hstate.add_flag (TREE_CONSTANT (t));
1206 : 2316099 : hstate.add_flag (TREE_READONLY (t));
1207 : 2316099 : hstate.add_flag (TREE_PUBLIC (t));
1208 : : }
1209 : 2764565 : hstate.add_flag (TREE_ADDRESSABLE (t));
1210 : 2764565 : hstate.add_flag (TREE_THIS_VOLATILE (t));
1211 : 2764565 : if (DECL_P (t))
1212 : 680237 : hstate.add_flag (DECL_UNSIGNED (t));
1213 : 2084328 : else if (TYPE_P (t))
1214 : 448466 : hstate.add_flag (TYPE_UNSIGNED (t));
1215 : 2764565 : if (TYPE_P (t))
1216 : 448466 : hstate.add_flag (TYPE_ARTIFICIAL (t));
1217 : : else
1218 : 2316099 : hstate.add_flag (TREE_NO_WARNING (t));
1219 : 2764565 : hstate.add_flag (TREE_NOTHROW (t));
1220 : 2764565 : hstate.add_flag (TREE_STATIC (t));
1221 : 2764565 : hstate.add_flag (TREE_PROTECTED (t));
1222 : 2764565 : hstate.add_flag (TREE_DEPRECATED (t));
1223 : 2764565 : if (code != TREE_BINFO)
1224 : 2758272 : hstate.add_flag (TREE_PRIVATE (t));
1225 : 2764565 : if (TYPE_P (t))
1226 : : {
1227 : 448466 : hstate.add_flag (AGGREGATE_TYPE_P (t)
1228 : 448466 : ? TYPE_REVERSE_STORAGE_ORDER (t) : TYPE_SATURATING (t));
1229 : 448466 : hstate.add_flag (TYPE_ADDR_SPACE (t));
1230 : : }
1231 : 2316099 : else if (code == SSA_NAME)
1232 : 0 : hstate.add_flag (SSA_NAME_IS_DEFAULT_DEF (t));
1233 : 2764565 : hstate.commit_flag ();
1234 : :
1235 : 2764565 : if (CODE_CONTAINS_STRUCT (code, TS_INT_CST))
1236 : 182460 : hstate.add_wide_int (wi::to_widest (t));
1237 : :
1238 : 2764565 : if (CODE_CONTAINS_STRUCT (code, TS_REAL_CST))
1239 : : {
1240 : 1714 : REAL_VALUE_TYPE r = TREE_REAL_CST (t);
1241 : 1714 : hstate.add_flag (r.cl);
1242 : 1714 : hstate.add_flag (r.sign);
1243 : 1714 : hstate.add_flag (r.signalling);
1244 : 1714 : hstate.add_flag (r.canonical);
1245 : 1714 : hstate.commit_flag ();
1246 : 1714 : hstate.add_int (r.uexp);
1247 : 1714 : hstate.add (r.sig, sizeof (r.sig));
1248 : : }
1249 : :
1250 : 2764565 : if (CODE_CONTAINS_STRUCT (code, TS_FIXED_CST))
1251 : : {
1252 : 0 : FIXED_VALUE_TYPE f = TREE_FIXED_CST (t);
1253 : 0 : hstate.add_int (f.mode);
1254 : 0 : hstate.add_int (f.data.low);
1255 : 0 : hstate.add_int (f.data.high);
1256 : : }
1257 : :
1258 : 2764565 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
1259 : : {
1260 : : /* Similar to TYPE_MODE, avoid streaming out host-specific DECL_MODE
1261 : : for aggregate type with offloading enabled, and while streaming-in
1262 : : recompute appropriate DECL_MODE for accelerator. */
1263 : 680237 : if (lto_stream_offload_p
1264 : 0 : && (VAR_P (t)
1265 : 0 : || TREE_CODE (t) == PARM_DECL
1266 : 0 : || TREE_CODE (t) == FIELD_DECL)
1267 : 680237 : && AGGREGATE_TYPE_P (TREE_TYPE (t)))
1268 : 0 : hstate.add_hwi (VOIDmode);
1269 : : else
1270 : 680237 : hstate.add_hwi (DECL_MODE (t));
1271 : 680237 : hstate.add_flag (DECL_NONLOCAL (t));
1272 : 680237 : hstate.add_flag (DECL_VIRTUAL_P (t));
1273 : 680237 : hstate.add_flag (DECL_IGNORED_P (t));
1274 : 680237 : hstate.add_flag (DECL_ABSTRACT_P (t));
1275 : 680237 : hstate.add_flag (DECL_ARTIFICIAL (t));
1276 : 680237 : hstate.add_flag (DECL_USER_ALIGN (t));
1277 : 680237 : hstate.add_flag (DECL_PRESERVE_P (t));
1278 : 680237 : hstate.add_flag (DECL_EXTERNAL (t));
1279 : 680237 : hstate.add_flag (DECL_NOT_GIMPLE_REG_P (t));
1280 : 680237 : hstate.commit_flag ();
1281 : 680237 : hstate.add_int (DECL_ALIGN (t));
1282 : 680237 : if (code == LABEL_DECL)
1283 : : {
1284 : 0 : hstate.add_int (EH_LANDING_PAD_NR (t));
1285 : 0 : hstate.add_int (LABEL_DECL_UID (t));
1286 : : }
1287 : 680237 : else if (code == FIELD_DECL)
1288 : : {
1289 : 81211 : hstate.add_flag (DECL_PACKED (t));
1290 : 81211 : hstate.add_flag (DECL_NONADDRESSABLE_P (t));
1291 : 81211 : hstate.add_flag (DECL_PADDING_P (t));
1292 : 81211 : if (DECL_BIT_FIELD (t))
1293 : 4908 : hstate.add_flag (DECL_FIELD_CXX_ZERO_WIDTH_BIT_FIELD (t));
1294 : : else
1295 : 156373 : hstate.add_flag (DECL_FIELD_ABI_IGNORED (t));
1296 : 81211 : hstate.add_int (DECL_OFFSET_ALIGN (t));
1297 : : }
1298 : 599026 : else if (code == VAR_DECL)
1299 : : {
1300 : 234675 : hstate.add_flag (DECL_HAS_DEBUG_EXPR_P (t));
1301 : 234675 : hstate.add_flag (DECL_NONLOCAL_FRAME (t));
1302 : : }
1303 : 680237 : if (code == RESULT_DECL
1304 : 680237 : || code == PARM_DECL
1305 : : || code == VAR_DECL)
1306 : : {
1307 : 234687 : hstate.add_flag (DECL_BY_REFERENCE (t));
1308 : 234687 : if (code == VAR_DECL
1309 : 234687 : || code == PARM_DECL)
1310 : 234687 : hstate.add_flag (DECL_HAS_VALUE_EXPR_P (t));
1311 : : }
1312 : 680237 : hstate.commit_flag ();
1313 : : }
1314 : :
1315 : 2764565 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_WRTL))
1316 : 599022 : hstate.add_int (DECL_REGISTER (t));
1317 : :
1318 : 2764565 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS))
1319 : : {
1320 : 599010 : hstate.add_flag (DECL_COMMON (t));
1321 : 599010 : hstate.add_flag (DECL_DLLIMPORT_P (t));
1322 : 599010 : hstate.add_flag (DECL_WEAK (t));
1323 : 599010 : hstate.add_flag (DECL_SEEN_IN_BIND_EXPR_P (t));
1324 : 599010 : hstate.add_flag (DECL_COMDAT (t));
1325 : 599010 : hstate.add_flag (DECL_VISIBILITY_SPECIFIED (t));
1326 : 599010 : hstate.add_int (DECL_VISIBILITY (t));
1327 : 599010 : if (code == VAR_DECL)
1328 : : {
1329 : : /* DECL_IN_TEXT_SECTION is set during final asm output only. */
1330 : 234675 : hstate.add_flag (DECL_HARD_REGISTER (t));
1331 : 234675 : hstate.add_flag (DECL_IN_CONSTANT_POOL (t));
1332 : : }
1333 : 599010 : if (TREE_CODE (t) == FUNCTION_DECL)
1334 : : {
1335 : 342331 : hstate.add_flag (DECL_FINAL_P (t));
1336 : 342331 : hstate.add_flag (DECL_CXX_CONSTRUCTOR_P (t));
1337 : 342331 : hstate.add_flag (DECL_CXX_DESTRUCTOR_P (t));
1338 : : }
1339 : 599010 : hstate.commit_flag ();
1340 : : }
1341 : :
1342 : 2764565 : if (CODE_CONTAINS_STRUCT (code, TS_FUNCTION_DECL))
1343 : : {
1344 : 342331 : hstate.add_int (DECL_BUILT_IN_CLASS (t));
1345 : 342331 : hstate.add_flag (DECL_STATIC_CONSTRUCTOR (t));
1346 : 342331 : hstate.add_flag (DECL_STATIC_DESTRUCTOR (t));
1347 : 342331 : hstate.add_int ((unsigned)FUNCTION_DECL_DECL_TYPE (t));
1348 : 342331 : hstate.add_flag (DECL_UNINLINABLE (t));
1349 : 342331 : hstate.add_flag (DECL_POSSIBLY_INLINED (t));
1350 : 342331 : hstate.add_flag (DECL_IS_NOVOPS (t));
1351 : 342331 : hstate.add_flag (DECL_IS_RETURNS_TWICE (t));
1352 : 342331 : hstate.add_flag (DECL_IS_MALLOC (t));
1353 : 342331 : hstate.add_flag (DECL_DECLARED_INLINE_P (t));
1354 : 342331 : hstate.add_flag (DECL_STATIC_CHAIN (t));
1355 : 342331 : hstate.add_flag (DECL_NO_INLINE_WARNING_P (t));
1356 : 342331 : hstate.add_flag (DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (t));
1357 : 342331 : hstate.add_flag (DECL_NO_LIMIT_STACK (t));
1358 : 342331 : hstate.add_flag (DECL_DISREGARD_INLINE_LIMITS (t));
1359 : 342331 : hstate.add_flag (DECL_PURE_P (t));
1360 : 342331 : hstate.add_flag (DECL_LOOPING_CONST_OR_PURE_P (t));
1361 : 342331 : hstate.commit_flag ();
1362 : 342331 : if (DECL_BUILT_IN_CLASS (t) != NOT_BUILT_IN)
1363 : 21779 : hstate.add_int (DECL_UNCHECKED_FUNCTION_CODE (t));
1364 : : }
1365 : :
1366 : 2764565 : if (CODE_CONTAINS_STRUCT (code, TS_TYPE_COMMON))
1367 : : {
1368 : : /* For offloading, avoid streaming out TYPE_MODE for aggregate type since
1369 : : it may be host-specific. For eg, aarch64 uses OImode for ARRAY_TYPE
1370 : : whose size is 256-bits, which is not representable on accelerator.
1371 : : Instead stream out VOIDmode, and while streaming-in, recompute
1372 : : appropriate TYPE_MODE for accelerator. */
1373 : 448466 : if (lto_stream_offload_p
1374 : 0 : && (AGGREGATE_TYPE_P (t) || VECTOR_TYPE_P (t)))
1375 : 0 : hstate.add_hwi (VOIDmode);
1376 : : /* for VECTOR_TYPE, TYPE_MODE reevaluates the mode using target_flags
1377 : : not necessary valid in a global context.
1378 : : Use the raw value previously set by layout_type. */
1379 : : else
1380 : 448466 : hstate.add_hwi (TYPE_MODE_RAW (t));
1381 : : /* TYPE_NO_FORCE_BLK is private to stor-layout and need
1382 : : no streaming. */
1383 : 448466 : hstate.add_flag (TYPE_PACKED (t));
1384 : 448466 : hstate.add_flag (TYPE_RESTRICT (t));
1385 : 448466 : hstate.add_flag (TYPE_USER_ALIGN (t));
1386 : 448466 : hstate.add_flag (TYPE_READONLY (t));
1387 : 448466 : if (RECORD_OR_UNION_TYPE_P (t))
1388 : : {
1389 : 70670 : hstate.add_flag (TYPE_TRANSPARENT_AGGR (t));
1390 : 70670 : hstate.add_flag (TYPE_FINAL_P (t));
1391 : 70670 : hstate.add_flag (TYPE_CXX_ODR_P (t));
1392 : : }
1393 : 377796 : else if (code == ARRAY_TYPE)
1394 : 28688 : hstate.add_flag (TYPE_NONALIASED_COMPONENT (t));
1395 : 448466 : if (code == ARRAY_TYPE || code == INTEGER_TYPE)
1396 : 72656 : hstate.add_flag (TYPE_STRING_FLAG (t));
1397 : 448466 : if (AGGREGATE_TYPE_P (t))
1398 : 99358 : hstate.add_flag (TYPE_TYPELESS_STORAGE (t));
1399 : 448466 : hstate.commit_flag ();
1400 : 448466 : hstate.add_int (TYPE_PRECISION_RAW (t));
1401 : 448466 : hstate.add_int (TYPE_ALIGN (t));
1402 : 448466 : if (!lto_stream_offload_p)
1403 : 448466 : hstate.add_int (TYPE_EMPTY_P (t));
1404 : : }
1405 : :
1406 : 2764565 : if (CODE_CONTAINS_STRUCT (code, TS_TRANSLATION_UNIT_DECL))
1407 : 0 : hstate.add (TRANSLATION_UNIT_LANGUAGE (t),
1408 : 0 : strlen (TRANSLATION_UNIT_LANGUAGE (t)));
1409 : :
1410 : 2764565 : if (CODE_CONTAINS_STRUCT (code, TS_TARGET_OPTION)
1411 : : /* We don't stream these when passing things to a different target. */
1412 : 22540 : && !lto_stream_offload_p)
1413 : 22540 : hstate.add_hwi (cl_target_option_hash (TREE_TARGET_OPTION (t)));
1414 : :
1415 : 2764565 : if (CODE_CONTAINS_STRUCT (code, TS_OPTIMIZATION))
1416 : 22752 : hstate.add_hwi (cl_optimization_hash (TREE_OPTIMIZATION (t)));
1417 : :
1418 : 2764565 : if (CODE_CONTAINS_STRUCT (code, TS_IDENTIFIER))
1419 : 870244 : hstate.merge_hash (IDENTIFIER_HASH_VALUE (t));
1420 : :
1421 : 2764565 : if (CODE_CONTAINS_STRUCT (code, TS_STRING))
1422 : 4206 : hstate.add (TREE_STRING_POINTER (t), TREE_STRING_LENGTH (t));
1423 : :
1424 : 2764565 : if (CODE_CONTAINS_STRUCT (code, TS_TYPED))
1425 : : {
1426 : 2719273 : if (code != IDENTIFIER_NODE)
1427 : 1849029 : visit (TREE_TYPE (t));
1428 : : }
1429 : :
1430 : 2764565 : if (CODE_CONTAINS_STRUCT (code, TS_VECTOR))
1431 : : {
1432 : 0 : unsigned int count = vector_cst_encoded_nelts (t);
1433 : 0 : for (unsigned int i = 0; i < count; ++i)
1434 : 0 : visit (VECTOR_CST_ENCODED_ELT (t, i));
1435 : : }
1436 : :
1437 : 2764565 : if (CODE_CONTAINS_STRUCT (code, TS_POLY_INT_CST))
1438 : 0 : for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
1439 : 0 : visit (POLY_INT_CST_COEFF (t, i));
1440 : :
1441 : 2764565 : if (CODE_CONTAINS_STRUCT (code, TS_COMPLEX))
1442 : : {
1443 : 0 : visit (TREE_REALPART (t));
1444 : 0 : visit (TREE_IMAGPART (t));
1445 : : }
1446 : :
1447 : 2764565 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_MINIMAL))
1448 : : {
1449 : : /* Drop names that were created for anonymous entities. */
1450 : 680237 : if (DECL_NAME (t)
1451 : 663052 : && TREE_CODE (DECL_NAME (t)) == IDENTIFIER_NODE
1452 : 1343289 : && IDENTIFIER_ANON_P (DECL_NAME (t)))
1453 : : ;
1454 : : else
1455 : 679894 : visit (DECL_NAME (t));
1456 : 680237 : if (DECL_FILE_SCOPE_P (t))
1457 : : ;
1458 : : else
1459 : 109532 : visit (DECL_CONTEXT (t));
1460 : : }
1461 : :
1462 : 2764565 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
1463 : : {
1464 : 680237 : visit (DECL_SIZE (t));
1465 : 680237 : visit (DECL_SIZE_UNIT (t));
1466 : 680237 : visit (DECL_ATTRIBUTES (t));
1467 : 680237 : if ((code == VAR_DECL
1468 : 680237 : || code == PARM_DECL)
1469 : 680237 : && DECL_HAS_VALUE_EXPR_P (t))
1470 : 20 : visit (DECL_VALUE_EXPR (t));
1471 : 680237 : if (code == VAR_DECL
1472 : 914912 : && DECL_HAS_DEBUG_EXPR_P (t))
1473 : 0 : visit (DECL_DEBUG_EXPR (t));
1474 : : /* ??? Hash DECL_INITIAL as streamed. Needs the output-block to
1475 : : be able to call get_symbol_initial_value. */
1476 : : }
1477 : :
1478 : 2764565 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS))
1479 : : {
1480 : 599010 : if (DECL_ASSEMBLER_NAME_SET_P (t))
1481 : 596683 : visit (DECL_ASSEMBLER_NAME (t));
1482 : : }
1483 : :
1484 : 2764565 : if (CODE_CONTAINS_STRUCT (code, TS_FIELD_DECL))
1485 : : {
1486 : 81211 : visit (DECL_FIELD_OFFSET (t));
1487 : 81211 : visit (DECL_BIT_FIELD_TYPE (t));
1488 : 81211 : visit (DECL_BIT_FIELD_REPRESENTATIVE (t));
1489 : 81211 : visit (DECL_FIELD_BIT_OFFSET (t));
1490 : : }
1491 : :
1492 : 2764565 : if (CODE_CONTAINS_STRUCT (code, TS_FUNCTION_DECL))
1493 : : {
1494 : 342331 : visit (DECL_FUNCTION_PERSONALITY (t));
1495 : 342331 : visit (DECL_FUNCTION_SPECIFIC_TARGET (t));
1496 : 342331 : visit (DECL_FUNCTION_SPECIFIC_OPTIMIZATION (t));
1497 : : }
1498 : :
1499 : 2764565 : if (CODE_CONTAINS_STRUCT (code, TS_TYPE_COMMON))
1500 : : {
1501 : 448466 : visit (TYPE_SIZE (t));
1502 : 448466 : visit (TYPE_SIZE_UNIT (t));
1503 : 448466 : visit (TYPE_ATTRIBUTES (t));
1504 : 448466 : visit (TYPE_NAME (t));
1505 : 448466 : visit (TYPE_MAIN_VARIANT (t));
1506 : 448466 : if (TYPE_FILE_SCOPE_P (t))
1507 : : ;
1508 : : else
1509 : 15249 : visit (TYPE_CONTEXT (t));
1510 : : }
1511 : :
1512 : 2764565 : if (CODE_CONTAINS_STRUCT (code, TS_TYPE_NON_COMMON))
1513 : : {
1514 : 448466 : if (code == ARRAY_TYPE)
1515 : 28688 : visit (TYPE_DOMAIN (t));
1516 : 419778 : else if (RECORD_OR_UNION_TYPE_P (t))
1517 : 175149 : for (tree f = TYPE_FIELDS (t); f; f = TREE_CHAIN (f))
1518 : 104479 : visit (f);
1519 : 349108 : else if (code == FUNCTION_TYPE
1520 : 349108 : || code == METHOD_TYPE)
1521 : 110614 : visit (TYPE_ARG_TYPES (t));
1522 : 448466 : if (!POINTER_TYPE_P (t))
1523 : 263412 : visit (TYPE_MIN_VALUE_RAW (t));
1524 : 448466 : visit (TYPE_MAX_VALUE_RAW (t));
1525 : : }
1526 : :
1527 : 2764565 : if (CODE_CONTAINS_STRUCT (code, TS_LIST))
1528 : : {
1529 : 517609 : visit (TREE_PURPOSE (t));
1530 : 517609 : visit (TREE_VALUE (t));
1531 : 517609 : visit (TREE_CHAIN (t));
1532 : : }
1533 : :
1534 : 2764565 : if (CODE_CONTAINS_STRUCT (code, TS_VEC))
1535 : 0 : for (int i = 0; i < TREE_VEC_LENGTH (t); ++i)
1536 : 0 : visit (TREE_VEC_ELT (t, i));
1537 : :
1538 : 2764565 : if (CODE_CONTAINS_STRUCT (code, TS_EXP))
1539 : : {
1540 : 7517 : hstate.add_hwi (TREE_OPERAND_LENGTH (t));
1541 : 18838 : for (int i = 0; i < TREE_OPERAND_LENGTH (t); ++i)
1542 : 11321 : visit (TREE_OPERAND (t, i));
1543 : : }
1544 : :
1545 : 2764565 : if (CODE_CONTAINS_STRUCT (code, TS_BINFO))
1546 : : {
1547 : : unsigned i;
1548 : : tree b;
1549 : 12680 : FOR_EACH_VEC_ELT (*BINFO_BASE_BINFOS (t), i, b)
1550 : 6387 : visit (b);
1551 : 6293 : visit (BINFO_OFFSET (t));
1552 : 6293 : visit (BINFO_VTABLE (t));
1553 : : /* Do not walk BINFO_INHERITANCE_CHAIN, BINFO_SUBVTT_INDEX
1554 : : BINFO_BASE_ACCESSES and BINFO_VPTR_INDEX; these are used
1555 : : by C++ FE only. */
1556 : : }
1557 : :
1558 : 2764565 : if (CODE_CONTAINS_STRUCT (code, TS_CONSTRUCTOR))
1559 : : {
1560 : 387 : unsigned i;
1561 : 387 : tree index, value;
1562 : 590 : hstate.add_hwi (CONSTRUCTOR_NELTS (t));
1563 : 1729 : FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (t), i, index, value)
1564 : : {
1565 : 1342 : visit (index);
1566 : 1342 : visit (value);
1567 : : }
1568 : : }
1569 : :
1570 : 2764565 : if (code == OMP_CLAUSE)
1571 : : {
1572 : 134 : int i;
1573 : 134 : HOST_WIDE_INT val;
1574 : :
1575 : 134 : hstate.add_hwi (OMP_CLAUSE_CODE (t));
1576 : 134 : switch (OMP_CLAUSE_CODE (t))
1577 : : {
1578 : 0 : case OMP_CLAUSE_DEFAULT:
1579 : 0 : val = OMP_CLAUSE_DEFAULT_KIND (t);
1580 : 0 : break;
1581 : 0 : case OMP_CLAUSE_SCHEDULE:
1582 : 0 : val = OMP_CLAUSE_SCHEDULE_KIND (t);
1583 : 0 : break;
1584 : 0 : case OMP_CLAUSE_DEPEND:
1585 : 0 : val = OMP_CLAUSE_DEPEND_KIND (t);
1586 : 0 : break;
1587 : 0 : case OMP_CLAUSE_DOACROSS:
1588 : 0 : val = OMP_CLAUSE_DOACROSS_KIND (t);
1589 : 0 : break;
1590 : 0 : case OMP_CLAUSE_MAP:
1591 : 0 : val = OMP_CLAUSE_MAP_KIND (t);
1592 : 0 : break;
1593 : 0 : case OMP_CLAUSE_PROC_BIND:
1594 : 0 : val = OMP_CLAUSE_PROC_BIND_KIND (t);
1595 : 0 : break;
1596 : 0 : case OMP_CLAUSE_REDUCTION:
1597 : 0 : case OMP_CLAUSE_TASK_REDUCTION:
1598 : 0 : case OMP_CLAUSE_IN_REDUCTION:
1599 : 0 : val = OMP_CLAUSE_REDUCTION_CODE (t);
1600 : 0 : break;
1601 : : default:
1602 : : val = 0;
1603 : : break;
1604 : : }
1605 : 134 : hstate.add_hwi (val);
1606 : 302 : for (i = 0; i < omp_clause_num_ops[OMP_CLAUSE_CODE (t)]; i++)
1607 : 168 : visit (OMP_CLAUSE_OPERAND (t, i));
1608 : 134 : visit (OMP_CLAUSE_CHAIN (t));
1609 : : }
1610 : :
1611 : 2764565 : return hstate.end ();
1612 : :
1613 : : #undef visit
1614 : : }
1615 : :
1616 : : /* Compare two SCC entries by their hash value for qsorting them. */
1617 : :
1618 : : int
1619 : 1549016 : DFS::scc_entry_compare (const void *p1_, const void *p2_)
1620 : : {
1621 : 1549016 : const scc_entry *p1 = (const scc_entry *) p1_;
1622 : 1549016 : const scc_entry *p2 = (const scc_entry *) p2_;
1623 : 1549016 : if (p1->hash < p2->hash)
1624 : : return -1;
1625 : 699601 : else if (p1->hash > p2->hash)
1626 : 678172 : return 1;
1627 : : return 0;
1628 : : }
1629 : :
1630 : : /* Return a hash value for the SCC on the SCC stack from FIRST with SIZE.
1631 : : THIS_REF_P and REF_P are as passed to lto_output_tree for FIRST. */
1632 : :
1633 : : hashval_t
1634 : 2620445 : DFS::hash_scc (struct output_block *ob, unsigned first, unsigned size,
1635 : : bool ref_p, bool this_ref_p)
1636 : : {
1637 : 2620445 : unsigned int last_classes = 0, iterations = 0;
1638 : :
1639 : : /* Compute hash values for the SCC members. */
1640 : 5385010 : for (unsigned i = 0; i < size; ++i)
1641 : 2764565 : sccstack[first+i].hash
1642 : 5529130 : = hash_tree (ob->writer_cache, NULL, sccstack[first+i].t);
1643 : :
1644 : 2620445 : if (size == 1)
1645 : 2554742 : return sccstack[first].hash;
1646 : :
1647 : : /* We aim to get unique hash for every tree within SCC and compute hash value
1648 : : of the whole SCC by combining all values together in a stable (entry-point
1649 : : independent) order. This guarantees that the same SCC regions within
1650 : : different translation units will get the same hash values and therefore
1651 : : will be merged at WPA time.
1652 : :
1653 : : Often the hashes are already unique. In that case we compute the SCC hash
1654 : : by combining individual hash values in an increasing order.
1655 : :
1656 : : If there are duplicates, we seek at least one tree with unique hash (and
1657 : : pick one with minimal hash and this property). Then we obtain a stable
1658 : : order by DFS walk starting from this unique tree and then use the index
1659 : : within this order to make individual hash values unique.
1660 : :
1661 : : If there is no tree with unique hash, we iteratively propagate the hash
1662 : : values across the internal edges of SCC. This usually quickly leads
1663 : : to unique hashes. Consider, for example, an SCC containing two pointers
1664 : : that are identical except for the types they point to and assume that
1665 : : these types are also part of the SCC. The propagation will add the
1666 : : points-to type information into their hash values. */
1667 : 65703 : do
1668 : : {
1669 : : /* Sort the SCC so we can easily check for uniqueness. */
1670 : 65703 : qsort (&sccstack[first], size, sizeof (scc_entry), scc_entry_compare);
1671 : :
1672 : 65703 : unsigned int classes = 1;
1673 : 65703 : int firstunique = -1;
1674 : :
1675 : : /* Find the tree with lowest unique hash (if it exists) and compute
1676 : : the number of equivalence classes. */
1677 : 65703 : if (sccstack[first].hash != sccstack[first+1].hash)
1678 : 65700 : firstunique = 0;
1679 : 209823 : for (unsigned i = 1; i < size; ++i)
1680 : 144120 : if (sccstack[first+i-1].hash != sccstack[first+i].hash)
1681 : : {
1682 : 142157 : classes++;
1683 : 142157 : if (firstunique == -1
1684 : 142157 : && (i == size - 1
1685 : 3 : || sccstack[first+i+1].hash != sccstack[first+i].hash))
1686 : 3 : firstunique = i;
1687 : : }
1688 : :
1689 : : /* If we found a tree with unique hash, stop the iteration. */
1690 : 65703 : if (firstunique != -1
1691 : : /* Also terminate if we run out of iterations or if the number of
1692 : : equivalence classes is no longer increasing.
1693 : : For example a cyclic list of trees that are all equivalent will
1694 : : never have unique entry point; we however do not build such SCCs
1695 : : in our IL. */
1696 : 65703 : || classes <= last_classes || iterations > 16)
1697 : : {
1698 : 65703 : hashval_t scc_hash;
1699 : :
1700 : : /* If some hashes are not unique (CLASSES != SIZE), use the DFS walk
1701 : : starting from FIRSTUNIQUE to obtain a stable order. */
1702 : 65703 : if (classes != size && firstunique != -1)
1703 : : {
1704 : 343 : hash_map <tree, hashval_t> map(size*2);
1705 : :
1706 : : /* Store hash values into a map, so we can associate them with
1707 : : the reordered SCC. */
1708 : 11233 : for (unsigned i = 0; i < size; ++i)
1709 : 10890 : map.put (sccstack[first+i].t, sccstack[first+i].hash);
1710 : :
1711 : 686 : DFS again (ob, sccstack[first+firstunique].t, ref_p, this_ref_p,
1712 : 343 : true);
1713 : 686 : gcc_assert (again.sccstack.length () == size);
1714 : :
1715 : 343 : memcpy (sccstack.address () + first,
1716 : 343 : again.sccstack.address (),
1717 : : sizeof (scc_entry) * size);
1718 : :
1719 : : /* Update hash values of individual members by hashing in the
1720 : : index within the stable order. This ensures uniqueness.
1721 : : Also compute the SCC hash by mixing in all hash values in
1722 : : the stable order we obtained. */
1723 : 343 : sccstack[first].hash = *map.get (sccstack[first].t);
1724 : 343 : scc_hash = sccstack[first].hash;
1725 : 10890 : for (unsigned i = 1; i < size; ++i)
1726 : : {
1727 : 31641 : sccstack[first+i].hash
1728 : 10547 : = iterative_hash_hashval_t (i,
1729 : 10547 : *map.get (sccstack[first+i].t));
1730 : 10547 : scc_hash
1731 : 10547 : = iterative_hash_hashval_t (scc_hash,
1732 : 10547 : sccstack[first+i].hash);
1733 : : }
1734 : 343 : }
1735 : : /* If we got a unique hash value for each tree, then sort already
1736 : : ensured entry-point independent order. Only compute the final
1737 : : SCC hash.
1738 : :
1739 : : If we failed to find the unique entry point, we go by the same
1740 : : route. We will eventually introduce unwanted hash conflicts. */
1741 : : else
1742 : : {
1743 : : scc_hash = sccstack[first].hash;
1744 : 198933 : for (unsigned i = 1; i < size; ++i)
1745 : 133573 : scc_hash
1746 : 133573 : = iterative_hash_hashval_t (scc_hash, sccstack[first+i].hash);
1747 : :
1748 : : /* We cannot 100% guarantee that the hash won't conflict so as
1749 : : to make it impossible to find a unique hash. This however
1750 : : should be an extremely rare case. ICE for now so possible
1751 : : issues are found and evaluated. */
1752 : 65360 : gcc_checking_assert (classes == size);
1753 : : }
1754 : :
1755 : : /* To avoid conflicts across SCCs, iteratively hash the whole SCC
1756 : : hash into the hash of each element. */
1757 : 275526 : for (unsigned i = 0; i < size; ++i)
1758 : 419646 : sccstack[first+i].hash
1759 : 209823 : = iterative_hash_hashval_t (sccstack[first+i].hash, scc_hash);
1760 : 65703 : return scc_hash;
1761 : : }
1762 : :
1763 : 0 : last_classes = classes;
1764 : 0 : iterations++;
1765 : :
1766 : : /* We failed to identify the entry point; propagate hash values across
1767 : : the edges. */
1768 : 0 : hash_map <tree, hashval_t> map(size*2);
1769 : :
1770 : 0 : for (unsigned i = 0; i < size; ++i)
1771 : 0 : map.put (sccstack[first+i].t, sccstack[first+i].hash);
1772 : :
1773 : 0 : for (unsigned i = 0; i < size; i++)
1774 : 0 : sccstack[first+i].hash
1775 : 0 : = hash_tree (ob->writer_cache, &map, sccstack[first+i].t);
1776 : 0 : }
1777 : : while (true);
1778 : : }
1779 : :
1780 : : /* DFS walk EXPR and stream SCCs of tree bodies if they are not
1781 : : already in the streamer cache. Main routine called for
1782 : : each visit of EXPR. */
1783 : :
1784 : : void
1785 : 35335311 : DFS::DFS_write_tree (struct output_block *ob, sccs *from_state,
1786 : : tree expr, bool ref_p, bool this_ref_p)
1787 : : {
1788 : : /* Handle special cases. */
1789 : 35335311 : if (expr == NULL_TREE)
1790 : 25735897 : return;
1791 : :
1792 : : /* Do not DFS walk into indexable trees. */
1793 : 23092609 : if (this_ref_p && tree_is_indexable (expr))
1794 : : return;
1795 : :
1796 : : /* Check if we already streamed EXPR. */
1797 : 16836237 : if (streamer_tree_cache_lookup (ob->writer_cache, expr, NULL))
1798 : : {
1799 : : /* Reference to a local tree makes entry also local. We always process
1800 : : top of stack entry, so set max to number of entries in stack - 1. */
1801 : 7236823 : if (ob->local_trees
1802 : 7236823 : && ob->local_trees->contains (expr))
1803 : 17070 : max_local_entry = sccstack.length () - 1;
1804 : 7236823 : return;
1805 : : }
1806 : :
1807 : 9599414 : worklist w;
1808 : 9599414 : w.expr = expr;
1809 : 9599414 : w.from_state = from_state;
1810 : 9599414 : w.cstate = NULL;
1811 : 9599414 : w.ref_p = ref_p;
1812 : 9599414 : w.this_ref_p = this_ref_p;
1813 : 9599414 : worklist_vec.safe_push (w);
1814 : : }
1815 : :
1816 : :
1817 : : /* Emit the physical representation of tree node EXPR to output block OB.
1818 : : If THIS_REF_P is true, the leaves of EXPR are emitted as references via
1819 : : lto_output_tree_ref. REF_P is used for streaming siblings of EXPR. */
1820 : :
1821 : : void
1822 : 12735942 : lto_output_tree (struct output_block *ob, tree expr,
1823 : : bool ref_p, bool this_ref_p)
1824 : : {
1825 : 12735942 : unsigned ix;
1826 : 12735942 : bool existed_p;
1827 : 12735942 : unsigned int size = ob->main_stream->total_size;
1828 : : /* This is the first time we see EXPR, write all reachable
1829 : : trees to OB. */
1830 : 12735942 : static bool in_dfs_walk;
1831 : :
1832 : 12735942 : if (expr == NULL_TREE)
1833 : : {
1834 : 2858690 : streamer_write_record_start (ob, LTO_null);
1835 : 10721866 : return;
1836 : : }
1837 : :
1838 : 9877252 : if (this_ref_p && tree_is_indexable (expr))
1839 : : {
1840 : 5004486 : enum LTO_tags tag;
1841 : 5004486 : unsigned ix;
1842 : :
1843 : 5004486 : lto_indexable_tree_ref (ob, expr, &tag, &ix);
1844 : 5004486 : streamer_write_record_start (ob, tag);
1845 : 5004486 : streamer_write_uhwi (ob, ix);
1846 : 5004486 : return;
1847 : : }
1848 : :
1849 : 4872766 : existed_p = streamer_tree_cache_lookup (ob->writer_cache, expr, &ix);
1850 : 4872766 : if (existed_p)
1851 : : {
1852 : 1896722 : if (streamer_dump_file)
1853 : : {
1854 : 88 : if (in_dfs_walk)
1855 : 8 : print_node_brief (streamer_dump_file, " Streaming ref to ",
1856 : : expr, 4);
1857 : : else
1858 : 80 : print_node_brief (streamer_dump_file, " Streaming ref to ",
1859 : : expr, 4);
1860 : 88 : fprintf (streamer_dump_file, "\n");
1861 : : }
1862 : : /* If a node has already been streamed out, make sure that
1863 : : we don't write it more than once. Otherwise, the reader
1864 : : will instantiate two different nodes for the same object. */
1865 : 1896722 : streamer_write_record_start (ob, LTO_tree_pickle_reference);
1866 : 1896722 : streamer_write_uhwi (ob, ix);
1867 : 1896722 : lto_stats.num_pickle_refs_output++;
1868 : : }
1869 : : else
1870 : : {
1871 : : /* Protect against recursion which means disconnect between
1872 : : what tree edges we walk in the DFS walk and what edges
1873 : : we stream out. */
1874 : 2976044 : gcc_assert (!in_dfs_walk);
1875 : :
1876 : 2976044 : if (streamer_dump_file)
1877 : : {
1878 : 168 : print_node_brief (streamer_dump_file, " Streaming tree ",
1879 : : expr, 4);
1880 : 168 : fprintf (streamer_dump_file, "\n");
1881 : : }
1882 : :
1883 : : /* Start the DFS walk. */
1884 : : /* Save ob state ... */
1885 : : /* let's see ... */
1886 : 2976044 : in_dfs_walk = true;
1887 : 2976044 : DFS (ob, expr, ref_p, this_ref_p, false);
1888 : :
1889 : : /* Finally append a reference to the tree we were writing. */
1890 : 2976044 : existed_p = streamer_tree_cache_lookup (ob->writer_cache, expr, &ix);
1891 : :
1892 : : /* DFS walk above possibly skipped streaming EXPR itself to let us inline
1893 : : it. */
1894 : 2976044 : if (!existed_p)
1895 : 2050564 : lto_output_tree_1 (ob, expr, 0, ref_p, this_ref_p);
1896 : 925480 : else if (this_ref_p)
1897 : : {
1898 : 10 : if (streamer_dump_file)
1899 : : {
1900 : 0 : print_node_brief (streamer_dump_file,
1901 : : " Streaming final ref to ",
1902 : : expr, 4);
1903 : 0 : fprintf (streamer_dump_file, "\n");
1904 : : }
1905 : 10 : streamer_write_record_start (ob, LTO_tree_pickle_reference);
1906 : 10 : streamer_write_uhwi (ob, ix);
1907 : : }
1908 : 2976044 : in_dfs_walk = false;
1909 : 2976044 : lto_stats.num_pickle_refs_output++;
1910 : : }
1911 : 4872766 : if (streamer_dump_file && !in_dfs_walk)
1912 : 248 : fprintf (streamer_dump_file, " %u bytes\n",
1913 : 248 : ob->main_stream->total_size - size);
1914 : : }
1915 : :
1916 : :
1917 : : /* Output to OB a list of try/catch handlers starting with FIRST. */
1918 : :
1919 : : static void
1920 : 309 : output_eh_try_list (struct output_block *ob, eh_catch first)
1921 : : {
1922 : 309 : eh_catch n;
1923 : :
1924 : 706 : for (n = first; n; n = n->next_catch)
1925 : : {
1926 : 397 : streamer_write_record_start (ob, LTO_eh_catch);
1927 : 397 : stream_write_tree (ob, n->type_list, true);
1928 : 397 : stream_write_tree (ob, n->filter_list, true);
1929 : 397 : stream_write_tree (ob, n->label, true);
1930 : : }
1931 : :
1932 : 309 : streamer_write_record_start (ob, LTO_null);
1933 : 309 : }
1934 : :
1935 : :
1936 : : /* Output EH region R in function FN to OB. CURR_RN is the slot index
1937 : : that is being emitted in FN->EH->REGION_ARRAY. This is used to
1938 : : detect EH region sharing. */
1939 : :
1940 : : static void
1941 : 18147 : output_eh_region (struct output_block *ob, eh_region r)
1942 : : {
1943 : 18147 : enum LTO_tags tag;
1944 : :
1945 : 18147 : if (r == NULL)
1946 : : {
1947 : 7555 : streamer_write_record_start (ob, LTO_null);
1948 : 7555 : return;
1949 : : }
1950 : :
1951 : 10592 : if (r->type == ERT_CLEANUP)
1952 : : tag = LTO_ert_cleanup;
1953 : : else if (r->type == ERT_TRY)
1954 : : tag = LTO_ert_try;
1955 : : else if (r->type == ERT_ALLOWED_EXCEPTIONS)
1956 : : tag = LTO_ert_allowed_exceptions;
1957 : : else if (r->type == ERT_MUST_NOT_THROW)
1958 : : tag = LTO_ert_must_not_throw;
1959 : : else
1960 : 0 : gcc_unreachable ();
1961 : :
1962 : 10592 : streamer_write_record_start (ob, tag);
1963 : 10592 : streamer_write_hwi (ob, r->index);
1964 : :
1965 : 10592 : if (r->outer)
1966 : 3149 : streamer_write_hwi (ob, r->outer->index);
1967 : : else
1968 : 7443 : streamer_write_zero (ob);
1969 : :
1970 : 10592 : if (r->inner)
1971 : 1865 : streamer_write_hwi (ob, r->inner->index);
1972 : : else
1973 : 8727 : streamer_write_zero (ob);
1974 : :
1975 : 10592 : if (r->next_peer)
1976 : 4463 : streamer_write_hwi (ob, r->next_peer->index);
1977 : : else
1978 : 6129 : streamer_write_zero (ob);
1979 : :
1980 : 10592 : if (r->type == ERT_TRY)
1981 : : {
1982 : 309 : output_eh_try_list (ob, r->u.eh_try.first_catch);
1983 : : }
1984 : 10283 : else if (r->type == ERT_ALLOWED_EXCEPTIONS)
1985 : : {
1986 : 324 : stream_write_tree (ob, r->u.allowed.type_list, true);
1987 : 324 : stream_write_tree (ob, r->u.allowed.label, true);
1988 : 324 : streamer_write_uhwi (ob, r->u.allowed.filter);
1989 : : }
1990 : 9959 : else if (r->type == ERT_MUST_NOT_THROW)
1991 : : {
1992 : 5309 : stream_write_tree (ob, r->u.must_not_throw.failure_decl, true);
1993 : 5309 : bitpack_d bp = bitpack_create (ob->main_stream);
1994 : 5309 : stream_output_location (ob, &bp, r->u.must_not_throw.failure_loc);
1995 : 5309 : streamer_write_bitpack (&bp);
1996 : : }
1997 : :
1998 : 10592 : if (r->landing_pads)
1999 : 3179 : streamer_write_hwi (ob, r->landing_pads->index);
2000 : : else
2001 : 7413 : streamer_write_zero (ob);
2002 : : }
2003 : :
2004 : :
2005 : : /* Output landing pad LP to OB. */
2006 : :
2007 : : static void
2008 : 8344 : output_eh_lp (struct output_block *ob, eh_landing_pad lp)
2009 : : {
2010 : 8344 : if (lp == NULL)
2011 : : {
2012 : 5117 : streamer_write_record_start (ob, LTO_null);
2013 : 5117 : return;
2014 : : }
2015 : :
2016 : 3227 : streamer_write_record_start (ob, LTO_eh_landing_pad);
2017 : 3227 : streamer_write_hwi (ob, lp->index);
2018 : 3227 : if (lp->next_lp)
2019 : 48 : streamer_write_hwi (ob, lp->next_lp->index);
2020 : : else
2021 : 3179 : streamer_write_zero (ob);
2022 : :
2023 : 3227 : if (lp->region)
2024 : 3227 : streamer_write_hwi (ob, lp->region->index);
2025 : : else
2026 : 0 : streamer_write_zero (ob);
2027 : :
2028 : 3227 : stream_write_tree (ob, lp->post_landing_pad, true);
2029 : : }
2030 : :
2031 : :
2032 : : /* Output the existing eh_table to OB. */
2033 : :
2034 : : static void
2035 : 107045 : output_eh_regions (struct output_block *ob, struct function *fn)
2036 : : {
2037 : 107045 : if (fn->eh && fn->eh->region_tree)
2038 : : {
2039 : 4264 : unsigned i;
2040 : 4264 : eh_region eh;
2041 : 4264 : eh_landing_pad lp;
2042 : 4264 : tree ttype;
2043 : :
2044 : 4264 : streamer_write_record_start (ob, LTO_eh_table);
2045 : :
2046 : : /* Emit the index of the root of the EH region tree. */
2047 : 4264 : streamer_write_hwi (ob, fn->eh->region_tree->index);
2048 : :
2049 : : /* Emit all the EH regions in the region array. */
2050 : 4264 : streamer_write_hwi (ob, vec_safe_length (fn->eh->region_array));
2051 : 26675 : FOR_EACH_VEC_SAFE_ELT (fn->eh->region_array, i, eh)
2052 : 18147 : output_eh_region (ob, eh);
2053 : :
2054 : : /* Emit all landing pads. */
2055 : 4264 : streamer_write_hwi (ob, vec_safe_length (fn->eh->lp_array));
2056 : 16872 : FOR_EACH_VEC_SAFE_ELT (fn->eh->lp_array, i, lp)
2057 : 8344 : output_eh_lp (ob, lp);
2058 : :
2059 : : /* Emit all the runtime type data. */
2060 : 4264 : streamer_write_hwi (ob, vec_safe_length (fn->eh->ttype_data));
2061 : 8528 : FOR_EACH_VEC_SAFE_ELT (fn->eh->ttype_data, i, ttype)
2062 : 0 : stream_write_tree (ob, ttype, true);
2063 : :
2064 : : /* Emit the table of action chains. */
2065 : 4264 : if (targetm.arm_eabi_unwinder)
2066 : : {
2067 : 0 : tree t;
2068 : 0 : streamer_write_hwi (ob, vec_safe_length (fn->eh->ehspec_data.arm_eabi));
2069 : 0 : FOR_EACH_VEC_SAFE_ELT (fn->eh->ehspec_data.arm_eabi, i, t)
2070 : 0 : stream_write_tree (ob, t, true);
2071 : : }
2072 : : else
2073 : : {
2074 : 4264 : uchar c;
2075 : 4264 : streamer_write_hwi (ob, vec_safe_length (fn->eh->ehspec_data.other));
2076 : 8528 : FOR_EACH_VEC_SAFE_ELT (fn->eh->ehspec_data.other, i, c)
2077 : 0 : streamer_write_char_stream (ob->main_stream, c);
2078 : : }
2079 : : }
2080 : :
2081 : : /* The LTO_null either terminates the record or indicates that there
2082 : : are no eh_records at all. */
2083 : 107045 : streamer_write_record_start (ob, LTO_null);
2084 : 107045 : }
2085 : :
2086 : :
2087 : : /* Output all of the active ssa names to the ssa_names stream. */
2088 : :
2089 : : static void
2090 : 107045 : output_ssa_names (struct output_block *ob, struct function *fn)
2091 : : {
2092 : 107045 : unsigned int i, len;
2093 : :
2094 : 107045 : len = vec_safe_length (SSANAMES (fn));
2095 : 107045 : streamer_write_uhwi (ob, len);
2096 : :
2097 : 1721769 : for (i = 1; i < len; i++)
2098 : : {
2099 : 1614724 : tree ptr = (*SSANAMES (fn))[i];
2100 : :
2101 : 2216724 : if (ptr == NULL_TREE
2102 : 1608509 : || SSA_NAME_IN_FREE_LIST (ptr)
2103 : 1608509 : || virtual_operand_p (ptr)
2104 : : /* Simply skip unreleased SSA names. */
2105 : 2630340 : || (! SSA_NAME_IS_DEFAULT_DEF (ptr)
2106 : 910077 : && (! SSA_NAME_DEF_STMT (ptr)
2107 : 910077 : || ! gimple_bb (SSA_NAME_DEF_STMT (ptr)))))
2108 : 602000 : continue;
2109 : :
2110 : 1012724 : streamer_write_uhwi (ob, i);
2111 : 1012724 : streamer_write_char_stream (ob->main_stream,
2112 : 1012724 : SSA_NAME_IS_DEFAULT_DEF (ptr));
2113 : 1012724 : if (SSA_NAME_VAR (ptr))
2114 : 294629 : stream_write_tree (ob, SSA_NAME_VAR (ptr), true);
2115 : : else
2116 : : /* ??? This drops SSA_NAME_IDENTIFIER on the floor. */
2117 : 718095 : stream_write_tree (ob, TREE_TYPE (ptr), true);
2118 : : }
2119 : :
2120 : 107045 : streamer_write_zero (ob);
2121 : 107045 : }
2122 : :
2123 : :
2124 : :
2125 : : /* Output the cfg. */
2126 : :
2127 : : static void
2128 : 107045 : output_cfg (struct output_block *ob, struct function *fn)
2129 : : {
2130 : 107045 : struct lto_output_stream *tmp_stream = ob->main_stream;
2131 : 107045 : basic_block bb;
2132 : :
2133 : 107045 : ob->main_stream = ob->cfg_stream;
2134 : :
2135 : 107045 : streamer_write_enum (ob->main_stream, profile_status_d, PROFILE_LAST,
2136 : : profile_status_for_fn (fn));
2137 : :
2138 : : /* Output the number of the highest basic block. */
2139 : 107045 : streamer_write_uhwi (ob, last_basic_block_for_fn (fn));
2140 : :
2141 : 1016391 : FOR_ALL_BB_FN (bb, fn)
2142 : : {
2143 : 909346 : edge_iterator ei;
2144 : 909346 : edge e;
2145 : :
2146 : 909346 : streamer_write_hwi (ob, bb->index);
2147 : :
2148 : : /* Output the successors and the edge flags. */
2149 : 1709001 : streamer_write_uhwi (ob, EDGE_COUNT (bb->succs));
2150 : 1944324 : FOR_EACH_EDGE (e, ei, bb->succs)
2151 : : {
2152 : 1034978 : bitpack_d bp = bitpack_create (ob->main_stream);
2153 : 1034978 : bp_pack_var_len_unsigned (&bp, e->dest->index);
2154 : 1034978 : bp_pack_var_len_unsigned (&bp, e->flags);
2155 : 1034978 : stream_output_location_and_block (ob, &bp, e->goto_locus);
2156 : 1034978 : e->probability.stream_out (ob);
2157 : : }
2158 : : }
2159 : :
2160 : 107045 : streamer_write_hwi (ob, -1);
2161 : :
2162 : 107045 : bb = ENTRY_BLOCK_PTR_FOR_FN (fn);
2163 : 909346 : while (bb->next_bb)
2164 : : {
2165 : 802301 : streamer_write_hwi (ob, bb->next_bb->index);
2166 : 802301 : bb = bb->next_bb;
2167 : : }
2168 : :
2169 : 107045 : streamer_write_hwi (ob, -1);
2170 : :
2171 : : /* Output the number of loops. */
2172 : 107045 : streamer_write_uhwi (ob, number_of_loops (fn));
2173 : :
2174 : : /* Output each loop, skipping the tree root which has number zero. */
2175 : 361794 : for (unsigned i = 1; i < number_of_loops (fn); ++i)
2176 : : {
2177 : 73852 : class loop *loop = get_loop (fn, i);
2178 : :
2179 : : /* Write the index of the loop header. That's enough to rebuild
2180 : : the loop tree on the reader side. Stream -1 for an unused
2181 : : loop entry. */
2182 : 73852 : if (!loop)
2183 : : {
2184 : 25283 : streamer_write_hwi (ob, -1);
2185 : 25283 : continue;
2186 : : }
2187 : : else
2188 : 48569 : streamer_write_hwi (ob, loop->header->index);
2189 : :
2190 : : /* Write everything copy_loop_info copies. */
2191 : 48569 : streamer_write_enum (ob->main_stream,
2192 : : loop_estimation, EST_LAST, loop->estimate_state);
2193 : 48569 : streamer_write_hwi (ob, loop->any_upper_bound);
2194 : 48569 : if (loop->any_upper_bound)
2195 : : {
2196 : 39731 : widest_int w = widest_int::from (loop->nb_iterations_upper_bound,
2197 : 39731 : SIGNED);
2198 : 39731 : streamer_write_widest_int (ob, w);
2199 : 39731 : }
2200 : 48569 : streamer_write_hwi (ob, loop->any_likely_upper_bound);
2201 : 48569 : if (loop->any_likely_upper_bound)
2202 : : {
2203 : 39733 : widest_int w
2204 : 39733 : = widest_int::from (loop->nb_iterations_likely_upper_bound,
2205 : 39733 : SIGNED);
2206 : 39733 : streamer_write_widest_int (ob, w);
2207 : 39733 : }
2208 : 48569 : streamer_write_hwi (ob, loop->any_estimate);
2209 : 48569 : if (loop->any_estimate)
2210 : : {
2211 : 32977 : widest_int w = widest_int::from (loop->nb_iterations_estimate,
2212 : 32977 : SIGNED);
2213 : 32977 : streamer_write_widest_int (ob, w);
2214 : 32977 : }
2215 : :
2216 : : /* Write OMP SIMD related info. */
2217 : 48569 : streamer_write_hwi (ob, loop->safelen);
2218 : 48569 : streamer_write_hwi (ob, loop->unroll);
2219 : 48569 : streamer_write_hwi (ob, loop->owned_clique);
2220 : 48569 : streamer_write_hwi (ob, loop->dont_vectorize);
2221 : 48569 : streamer_write_hwi (ob, loop->force_vectorize);
2222 : 48569 : streamer_write_hwi (ob, loop->finite_p);
2223 : 48569 : stream_write_tree (ob, loop->simduid, true);
2224 : : }
2225 : :
2226 : 107045 : ob->main_stream = tmp_stream;
2227 : 107045 : }
2228 : :
2229 : : /* Create the header in the file using OB. If the section type is for
2230 : : a function, set FN to the decl for that function. */
2231 : :
2232 : : void
2233 : 251533 : produce_symbol_asm (struct output_block *ob, tree fn, int output_order)
2234 : : {
2235 : 251533 : enum lto_section_type section_type = ob->section_type;
2236 : 251533 : struct lto_function_header header;
2237 : 251533 : char *section_name;
2238 : :
2239 : 251533 : if (section_type == LTO_section_function_body)
2240 : : {
2241 : 118127 : const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fn));
2242 : 118127 : section_name = lto_get_section_name (section_type, name,
2243 : : output_order, NULL);
2244 : : }
2245 : : else
2246 : 133406 : section_name = lto_get_section_name (section_type, NULL, 0, NULL);
2247 : :
2248 : 251533 : lto_begin_section (section_name, !flag_wpa);
2249 : 251533 : free (section_name);
2250 : :
2251 : : /* The entire header is stream computed here. */
2252 : 251533 : memset (&header, 0, sizeof (struct lto_function_header));
2253 : :
2254 : 251533 : if (section_type == LTO_section_function_body)
2255 : 118127 : header.cfg_size = ob->cfg_stream->total_size;
2256 : 251533 : header.main_size = ob->main_stream->total_size;
2257 : 251533 : header.string_size = ob->string_stream->total_size;
2258 : 251533 : lto_write_data (&header, sizeof header);
2259 : :
2260 : : /* Put all of the gimple and the string table out the asm file as a
2261 : : block of text. */
2262 : 251533 : if (section_type == LTO_section_function_body)
2263 : 118127 : lto_write_stream (ob->cfg_stream);
2264 : 251533 : lto_write_stream (ob->main_stream);
2265 : 251533 : lto_write_stream (ob->string_stream);
2266 : :
2267 : 251533 : lto_end_section ();
2268 : 251533 : }
2269 : :
2270 : : /* Wrapper for unused arguments. */
2271 : :
2272 : : void
2273 : 133406 : produce_asm (struct output_block *ob)
2274 : : {
2275 : 133406 : produce_symbol_asm (ob, NULL, -1);
2276 : 133406 : }
2277 : :
2278 : :
2279 : : /* Output the base body of struct function FN using output block OB. */
2280 : :
2281 : : static void
2282 : 107045 : output_struct_function_base (struct output_block *ob, struct function *fn)
2283 : : {
2284 : 107045 : struct bitpack_d bp;
2285 : 107045 : unsigned i;
2286 : 107045 : tree t;
2287 : :
2288 : : /* Output the static chain and non-local goto save area. */
2289 : 107045 : stream_write_tree (ob, fn->static_chain_decl, true);
2290 : 107045 : stream_write_tree (ob, fn->nonlocal_goto_save_area, true);
2291 : :
2292 : : /* Output all the local variables in the function. */
2293 : 107045 : streamer_write_hwi (ob, vec_safe_length (fn->local_decls));
2294 : 378259 : FOR_EACH_VEC_SAFE_ELT (fn->local_decls, i, t)
2295 : 164169 : stream_write_tree (ob, t, true);
2296 : :
2297 : : /* Output current IL state of the function. */
2298 : 107045 : streamer_write_uhwi (ob, fn->curr_properties);
2299 : :
2300 : : /* Write all the attributes for FN. */
2301 : 107045 : bp = bitpack_create (ob->main_stream);
2302 : 107045 : bp_pack_value (&bp, fn->is_thunk, 1);
2303 : 107045 : bp_pack_value (&bp, fn->has_local_explicit_reg_vars, 1);
2304 : 107045 : bp_pack_value (&bp, fn->returns_pcc_struct, 1);
2305 : 107045 : bp_pack_value (&bp, fn->returns_struct, 1);
2306 : 107045 : bp_pack_value (&bp, fn->can_throw_non_call_exceptions, 1);
2307 : 107045 : bp_pack_value (&bp, fn->can_delete_dead_exceptions, 1);
2308 : 107045 : bp_pack_value (&bp, fn->always_inline_functions_inlined, 1);
2309 : 107045 : bp_pack_value (&bp, fn->after_inlining, 1);
2310 : 107045 : bp_pack_value (&bp, fn->stdarg, 1);
2311 : 107045 : bp_pack_value (&bp, fn->has_nonlocal_label, 1);
2312 : 107045 : bp_pack_value (&bp, fn->has_forced_label_in_static, 1);
2313 : 107045 : bp_pack_value (&bp, fn->calls_alloca, 1);
2314 : 107045 : bp_pack_value (&bp, fn->calls_setjmp, 1);
2315 : 107045 : bp_pack_value (&bp, fn->calls_eh_return, 1);
2316 : 107045 : bp_pack_value (&bp, fn->has_force_vectorize_loops, 1);
2317 : 107045 : bp_pack_value (&bp, fn->has_simduid_loops, 1);
2318 : 107045 : bp_pack_value (&bp, fn->has_musttail, 1);
2319 : 107045 : bp_pack_value (&bp, fn->has_unroll, 1);
2320 : 107045 : bp_pack_value (&bp, fn->assume_function, 1);
2321 : 107045 : bp_pack_value (&bp, fn->va_list_fpr_size, 8);
2322 : 107045 : bp_pack_value (&bp, fn->va_list_gpr_size, 8);
2323 : 107045 : bp_pack_value (&bp, fn->last_clique, sizeof (short) * 8);
2324 : :
2325 : : /* Output the function start and end loci. */
2326 : 107045 : stream_output_location (ob, &bp, fn->function_start_locus);
2327 : 107045 : stream_output_location (ob, &bp, fn->function_end_locus);
2328 : :
2329 : : /* Save the instance discriminator if present. */
2330 : 107045 : int *instance_number_p = NULL;
2331 : 107045 : if (decl_to_instance_map)
2332 : 0 : instance_number_p = decl_to_instance_map->get (fn->decl);
2333 : 107045 : bp_pack_value (&bp, !!instance_number_p, 1);
2334 : 107045 : if (instance_number_p)
2335 : 0 : bp_pack_value (&bp, *instance_number_p, sizeof (int) * CHAR_BIT);
2336 : :
2337 : 107045 : streamer_write_bitpack (&bp);
2338 : 107045 : }
2339 : :
2340 : :
2341 : : /* Collect all leaf BLOCKs beyond ROOT into LEAFS. */
2342 : :
2343 : : static void
2344 : 242243 : collect_block_tree_leafs (tree root, vec<tree> &leafs)
2345 : : {
2346 : 451808 : for (root = BLOCK_SUBBLOCKS (root); root; root = BLOCK_CHAIN (root))
2347 : 209565 : if (! BLOCK_SUBBLOCKS (root))
2348 : 74367 : leafs.safe_push (root);
2349 : : else
2350 : 135198 : collect_block_tree_leafs (root, leafs);
2351 : 242243 : }
2352 : :
2353 : : /* This performs function body modifications that are needed for streaming
2354 : : to work. */
2355 : :
2356 : : void
2357 : 107035 : lto_prepare_function_for_streaming (struct cgraph_node *node)
2358 : : {
2359 : 107035 : struct function *fn = DECL_STRUCT_FUNCTION (node->decl);
2360 : 107035 : basic_block bb;
2361 : :
2362 : 214070 : if (number_of_loops (fn))
2363 : : {
2364 : 107035 : push_cfun (fn);
2365 : 107035 : loop_optimizer_init (AVOID_CFG_MODIFICATIONS);
2366 : 107035 : loop_optimizer_finalize ();
2367 : 107035 : pop_cfun ();
2368 : : }
2369 : : /* We will renumber the statements. The code that does this uses
2370 : : the same ordering that we use for serializing them so we can use
2371 : : the same code on the other end and not have to write out the
2372 : : statement numbers. We do not assign UIDs to PHIs here because
2373 : : virtual PHIs get re-computed on-the-fly which would make numbers
2374 : : inconsistent. */
2375 : 107035 : set_gimple_stmt_max_uid (fn, 0);
2376 : 1016351 : FOR_ALL_BB_FN (bb, fn)
2377 : : {
2378 : 1065917 : for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
2379 : 156601 : gsi_next (&gsi))
2380 : : {
2381 : 156601 : gphi *stmt = gsi.phi ();
2382 : :
2383 : : /* Virtual PHIs are not going to be streamed. */
2384 : 313202 : if (!virtual_operand_p (gimple_phi_result (stmt)))
2385 : 90608 : gimple_set_uid (stmt, inc_gimple_stmt_max_uid (fn));
2386 : : }
2387 : 3499206 : for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
2388 : 1680574 : gsi_next (&gsi))
2389 : : {
2390 : 1680574 : gimple *stmt = gsi_stmt (gsi);
2391 : 1680574 : gimple_set_uid (stmt, inc_gimple_stmt_max_uid (fn));
2392 : : }
2393 : : }
2394 : : /* To avoid keeping duplicate gimple IDs in the statements, renumber
2395 : : virtual phis now. */
2396 : 1016351 : FOR_ALL_BB_FN (bb, fn)
2397 : : {
2398 : 1065917 : for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
2399 : 156601 : gsi_next (&gsi))
2400 : : {
2401 : 156601 : gphi *stmt = gsi.phi ();
2402 : 379195 : if (virtual_operand_p (gimple_phi_result (stmt)))
2403 : 65993 : gimple_set_uid (stmt, inc_gimple_stmt_max_uid (fn));
2404 : : }
2405 : : }
2406 : :
2407 : 107035 : }
2408 : :
2409 : : /* Emit the chain of tree nodes starting at T. OB is the output block
2410 : : to write to. REF_P is true if chain elements should be emitted
2411 : : as references. */
2412 : :
2413 : : static void
2414 : 107192 : streamer_write_chain (struct output_block *ob, tree t, bool ref_p)
2415 : : {
2416 : 425348 : while (t)
2417 : : {
2418 : : /* We avoid outputting external vars or functions by reference
2419 : : to the global decls section as we do not want to have them
2420 : : enter decl merging. We should not need to do this anymore because
2421 : : free_lang_data removes them from block scopes. */
2422 : 318156 : gcc_assert (!VAR_OR_FUNCTION_DECL_P (t) || !DECL_EXTERNAL (t));
2423 : 318156 : stream_write_tree (ob, t, ref_p);
2424 : :
2425 : 318156 : t = TREE_CHAIN (t);
2426 : : }
2427 : :
2428 : : /* Write a sentinel to terminate the chain. */
2429 : 107192 : stream_write_tree (ob, NULL_TREE, ref_p);
2430 : 107192 : }
2431 : :
2432 : : /* Output the body of function NODE->DECL. */
2433 : :
2434 : : static void
2435 : 107192 : output_function (struct cgraph_node *node, int output_order)
2436 : : {
2437 : 107192 : tree function;
2438 : 107192 : struct function *fn;
2439 : 107192 : basic_block bb;
2440 : 107192 : struct output_block *ob;
2441 : :
2442 : 107192 : if (streamer_dump_file)
2443 : 8 : fprintf (streamer_dump_file, "\nStreaming body of %s\n",
2444 : : node->dump_name ());
2445 : :
2446 : 107192 : function = node->decl;
2447 : 107192 : fn = DECL_STRUCT_FUNCTION (function);
2448 : 107192 : ob = create_output_block (LTO_section_function_body);
2449 : :
2450 : 107192 : ob->symbol = node;
2451 : :
2452 : 107192 : gcc_assert (current_function_decl == NULL_TREE && cfun == NULL);
2453 : :
2454 : : /* Make string 0 be a NULL string. */
2455 : 107192 : streamer_write_char_stream (ob->string_stream, 0);
2456 : :
2457 : 107192 : streamer_write_record_start (ob, LTO_function);
2458 : :
2459 : : /* Output decls for parameters and args. */
2460 : 107192 : stream_write_tree (ob, DECL_RESULT (function), true);
2461 : 107192 : streamer_write_chain (ob, DECL_ARGUMENTS (function), true);
2462 : :
2463 : : /* Output debug args if available. */
2464 : 107192 : vec<tree, va_gc> **debugargs = decl_debug_args_lookup (function);
2465 : 107192 : if (! debugargs)
2466 : 107163 : streamer_write_uhwi (ob, 0);
2467 : : else
2468 : : {
2469 : 29 : streamer_write_uhwi (ob, (*debugargs)->length ());
2470 : 103 : for (unsigned i = 0; i < (*debugargs)->length (); ++i)
2471 : 74 : stream_write_tree (ob, (**debugargs)[i], true);
2472 : : }
2473 : :
2474 : : /* Output DECL_INITIAL for the function, which contains the tree of
2475 : : lexical scopes. */
2476 : 107192 : stream_write_tree (ob, DECL_INITIAL (function), true);
2477 : : /* As we do not recurse into BLOCK_SUBBLOCKS but only BLOCK_SUPERCONTEXT
2478 : : collect block tree leafs and stream those. */
2479 : 107192 : auto_vec<tree> block_tree_leafs;
2480 : 107192 : if (DECL_INITIAL (function) && DECL_INITIAL (function) != error_mark_node)
2481 : 107045 : collect_block_tree_leafs (DECL_INITIAL (function), block_tree_leafs);
2482 : 107192 : streamer_write_uhwi (ob, block_tree_leafs.length ());
2483 : 181559 : for (unsigned i = 0; i < block_tree_leafs.length (); ++i)
2484 : 74367 : stream_write_tree (ob, block_tree_leafs[i], true);
2485 : :
2486 : : /* We also stream abstract functions where we stream only stuff needed for
2487 : : debug info. */
2488 : 107192 : if (gimple_has_body_p (function))
2489 : : {
2490 : 107045 : streamer_write_uhwi (ob, 1);
2491 : 107045 : output_struct_function_base (ob, fn);
2492 : :
2493 : 107045 : output_cfg (ob, fn);
2494 : :
2495 : : /* Output all the SSA names used in the function. */
2496 : 107045 : output_ssa_names (ob, fn);
2497 : :
2498 : : /* Output any exception handling regions. */
2499 : 107045 : output_eh_regions (ob, fn);
2500 : :
2501 : : /* Output the code for the function. */
2502 : 1016391 : FOR_ALL_BB_FN (bb, fn)
2503 : 909346 : output_bb (ob, bb, fn);
2504 : :
2505 : : /* The terminator for this function. */
2506 : 107045 : streamer_write_record_start (ob, LTO_null);
2507 : : }
2508 : : else
2509 : 147 : streamer_write_uhwi (ob, 0);
2510 : :
2511 : : /* Create a section to hold the pickled output of this function. */
2512 : 107192 : produce_symbol_asm (ob, function, output_order);
2513 : :
2514 : 107192 : destroy_output_block (ob);
2515 : 107192 : if (streamer_dump_file)
2516 : 8 : fprintf (streamer_dump_file, "Finished streaming %s\n",
2517 : : node->dump_name ());
2518 : 107192 : }
2519 : :
2520 : : /* Output the body of function NODE->DECL. */
2521 : :
2522 : : static void
2523 : 10935 : output_constructor (struct varpool_node *node, int output_order)
2524 : : {
2525 : 10935 : tree var = node->decl;
2526 : 10935 : struct output_block *ob;
2527 : :
2528 : 10935 : if (streamer_dump_file)
2529 : 4 : fprintf (streamer_dump_file, "\nStreaming constructor of %s\n",
2530 : : node->dump_name ());
2531 : :
2532 : 10935 : timevar_push (TV_IPA_LTO_CTORS_OUT);
2533 : 10935 : ob = create_output_block (LTO_section_function_body);
2534 : :
2535 : 10935 : ob->symbol = node;
2536 : :
2537 : : /* Make string 0 be a NULL string. */
2538 : 10935 : streamer_write_char_stream (ob->string_stream, 0);
2539 : :
2540 : : /* Output DECL_INITIAL for the function, which contains the tree of
2541 : : lexical scopes. */
2542 : 10935 : stream_write_tree (ob, DECL_INITIAL (var), true);
2543 : :
2544 : : /* Create a section to hold the pickled output of this function. */
2545 : 10935 : produce_symbol_asm (ob, var, output_order);
2546 : :
2547 : 10935 : destroy_output_block (ob);
2548 : 10935 : if (streamer_dump_file)
2549 : 4 : fprintf (streamer_dump_file, "Finished streaming %s\n",
2550 : : node->dump_name ());
2551 : 10935 : timevar_pop (TV_IPA_LTO_CTORS_OUT);
2552 : 10935 : }
2553 : :
2554 : :
2555 : : /* Emit toplevel asms. */
2556 : :
2557 : : void
2558 : 31324 : lto_output_toplevel_asms (lto_symtab_encoder_t encoder)
2559 : : {
2560 : 31324 : struct output_block *ob;
2561 : 31324 : char *section_name;
2562 : 31324 : struct lto_simple_header_with_strings header;
2563 : :
2564 : 31324 : unsigned asm_count = 0;
2565 : 1471001 : for (int i = 0; i < lto_symtab_encoder_size (encoder); i++)
2566 : 1408590 : if (is_a <asm_node*> (lto_symtab_encoder_deref (encoder, i)))
2567 : 156 : asm_count++;
2568 : :
2569 : 31324 : if (!asm_count)
2570 : 31210 : return;
2571 : :
2572 : 114 : ob = create_output_block (LTO_section_asm);
2573 : :
2574 : : /* Stream the length. */
2575 : 114 : streamer_write_uhwi (ob, asm_count);
2576 : 26046 : for (int i = 0; i < lto_symtab_encoder_size (encoder); i++)
2577 : : {
2578 : 12909 : toplevel_node *tnode = lto_symtab_encoder_deref (encoder, i);
2579 : 12909 : asm_node *anode = dyn_cast <asm_node*> (tnode);
2580 : 12909 : if (!anode)
2581 : 12753 : continue;
2582 : :
2583 : 156 : int output_order = *encoder->order_remap->get (anode->order);
2584 : 156 : stream_write_tree (ob, anode->asm_str, true);
2585 : 156 : streamer_write_hwi (ob, output_order);
2586 : : }
2587 : :
2588 : 114 : section_name = lto_get_section_name (LTO_section_asm, NULL, 0, NULL);
2589 : 114 : lto_begin_section (section_name, !flag_wpa);
2590 : 114 : free (section_name);
2591 : :
2592 : : /* The entire header stream is computed here. */
2593 : 114 : memset (&header, 0, sizeof (header));
2594 : :
2595 : 114 : header.main_size = ob->main_stream->total_size;
2596 : 114 : header.string_size = ob->string_stream->total_size;
2597 : 114 : lto_write_data (&header, sizeof header);
2598 : :
2599 : : /* Put all of the gimple and the string table out the asm file as a
2600 : : block of text. */
2601 : 114 : lto_write_stream (ob->main_stream);
2602 : 114 : lto_write_stream (ob->string_stream);
2603 : :
2604 : 114 : lto_end_section ();
2605 : :
2606 : 114 : destroy_output_block (ob);
2607 : : }
2608 : :
2609 : :
2610 : : /* Copy the function body or variable constructor of NODE without deserializing. */
2611 : :
2612 : : static void
2613 : 33863 : copy_function_or_variable (struct symtab_node *node, int output_order)
2614 : : {
2615 : 33863 : tree function = node->decl;
2616 : 33863 : struct lto_file_decl_data *file_data = node->lto_file_data;
2617 : 33863 : const char *data;
2618 : 33863 : size_t len;
2619 : 33863 : const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (function));
2620 : 33863 : char *section_name =
2621 : 33863 : lto_get_section_name (LTO_section_function_body, name, output_order, NULL);
2622 : 33863 : size_t i, j;
2623 : 33863 : struct lto_in_decl_state *in_state;
2624 : 33863 : struct lto_out_decl_state *out_state = lto_get_out_decl_state ();
2625 : :
2626 : 33863 : if (streamer_dump_file)
2627 : 0 : fprintf (streamer_dump_file, "Copying section for %s\n", name);
2628 : 33863 : lto_begin_section (section_name, false);
2629 : 33863 : free (section_name);
2630 : :
2631 : : /* We may have renamed the declaration, e.g., a static function. */
2632 : 33863 : name = lto_get_decl_name_mapping (file_data, name);
2633 : :
2634 : 67726 : data = lto_get_raw_section_data (file_data, LTO_section_function_body,
2635 : 33863 : name, node->order - file_data->order_base,
2636 : : &len);
2637 : 33863 : gcc_assert (data);
2638 : :
2639 : : /* Do a bit copy of the function body. */
2640 : 33863 : lto_write_raw_data (data, len);
2641 : :
2642 : : /* Copy decls. */
2643 : 33863 : in_state =
2644 : 33863 : lto_get_function_in_decl_state (node->lto_file_data, function);
2645 : 33863 : out_state->compressed = in_state->compressed;
2646 : 33863 : gcc_assert (in_state);
2647 : :
2648 : 67726 : for (i = 0; i < LTO_N_DECL_STREAMS; i++)
2649 : : {
2650 : 33863 : size_t n = vec_safe_length (in_state->streams[i]);
2651 : 33863 : vec<tree, va_gc> *trees = in_state->streams[i];
2652 : 33863 : struct lto_tree_ref_encoder *encoder = &(out_state->streams[i]);
2653 : :
2654 : : /* The out state must have the same indices and the in state.
2655 : : So just copy the vector. All the encoders in the in state
2656 : : must be empty where we reach here. */
2657 : 33863 : gcc_assert (lto_tree_ref_encoder_size (encoder) == 0);
2658 : 33863 : encoder->trees.reserve_exact (n);
2659 : 515274 : for (j = 0; j < n; j++)
2660 : 447548 : encoder->trees.safe_push ((*trees)[j]);
2661 : : }
2662 : :
2663 : 33863 : lto_free_raw_section_data (file_data, LTO_section_function_body, name,
2664 : : data, len);
2665 : 33863 : lto_end_section ();
2666 : 33863 : }
2667 : :
2668 : : /* Wrap symbol references in *TP inside a type-preserving MEM_REF. */
2669 : :
2670 : : static tree
2671 : 790878 : wrap_refs (tree *tp, int *ws, void *)
2672 : : {
2673 : 790878 : tree t = *tp;
2674 : 790878 : if (handled_component_p (t)
2675 : 176 : && VAR_P (TREE_OPERAND (t, 0))
2676 : 120 : && TREE_PUBLIC (TREE_OPERAND (t, 0)))
2677 : : {
2678 : 81 : tree decl = TREE_OPERAND (t, 0);
2679 : 81 : tree ptrtype = build_pointer_type (TREE_TYPE (decl));
2680 : 81 : TREE_OPERAND (t, 0) = build2 (MEM_REF, TREE_TYPE (decl),
2681 : : build1 (ADDR_EXPR, ptrtype, decl),
2682 : : build_int_cst (ptrtype, 0));
2683 : 81 : TREE_THIS_VOLATILE (TREE_OPERAND (t, 0)) = TREE_THIS_VOLATILE (decl);
2684 : 81 : *ws = 0;
2685 : : }
2686 : 790797 : else if (TREE_CODE (t) == CONSTRUCTOR)
2687 : : ;
2688 : 573323 : else if (!EXPR_P (t))
2689 : 333655 : *ws = 0;
2690 : 790878 : return NULL_TREE;
2691 : : }
2692 : :
2693 : : /* Remove functions that are no longer used from offload_funcs, and mark the
2694 : : remaining ones with DECL_PRESERVE_P. */
2695 : :
2696 : : static void
2697 : 31324 : prune_offload_funcs (void)
2698 : : {
2699 : 31324 : if (!offload_funcs)
2700 : 31324 : return;
2701 : :
2702 : 0 : unsigned ix, ix2;
2703 : 0 : tree *elem_ptr;
2704 : 0 : VEC_ORDERED_REMOVE_IF (*offload_funcs, ix, ix2, elem_ptr,
2705 : : cgraph_node::get (*elem_ptr) == NULL);
2706 : :
2707 : : tree fn_decl;
2708 : 0 : FOR_EACH_VEC_ELT (*offload_funcs, ix, fn_decl)
2709 : 0 : DECL_PRESERVE_P (fn_decl) = 1;
2710 : : }
2711 : :
2712 : : /* Produce LTO section that contains global information
2713 : : about LTO bytecode. */
2714 : :
2715 : : static void
2716 : 31324 : produce_lto_section ()
2717 : : {
2718 : : /* Stream LTO meta section. */
2719 : 31324 : output_block *ob = create_output_block (LTO_section_lto);
2720 : :
2721 : 31324 : char * section_name = lto_get_section_name (LTO_section_lto, NULL, 0, NULL);
2722 : 31324 : lto_begin_section (section_name, false);
2723 : 31324 : free (section_name);
2724 : :
2725 : : #ifdef HAVE_ZSTD_H
2726 : 31324 : lto_compression compression = ZSTD;
2727 : : #else
2728 : : lto_compression compression = ZLIB;
2729 : : #endif
2730 : :
2731 : 31324 : bool slim_object = flag_generate_lto && !flag_fat_lto_objects;
2732 : 31324 : lto_section s
2733 : 31324 : = { LTO_major_version, LTO_minor_version, slim_object, 0, 0 };
2734 : 31324 : s.set_compression (compression);
2735 : 31324 : lto_write_data (&s, sizeof s);
2736 : 31324 : lto_end_section ();
2737 : 31324 : destroy_output_block (ob);
2738 : 31324 : }
2739 : :
2740 : : /* Compare symbols to get them sorted by filename (to optimize streaming) */
2741 : :
2742 : : static int
2743 : 3345051 : cmp_symbol_files (const void *pn1, const void *pn2, void *id_map_)
2744 : : {
2745 : 3345051 : const symtab_node *n1 = *(const symtab_node * const *)pn1;
2746 : 3345051 : const symtab_node *n2 = *(const symtab_node * const *)pn2;
2747 : 3345051 : hash_map<lto_file_decl_data *, int> *id_map
2748 : : = (hash_map<lto_file_decl_data *, int> *)id_map_;
2749 : :
2750 : 3345051 : int file_order1 = n1->lto_file_data ? n1->lto_file_data->order : -1;
2751 : 3345051 : int file_order2 = n2->lto_file_data ? n2->lto_file_data->order : -1;
2752 : :
2753 : : /* Order files same way as they appeared in the command line to reduce
2754 : : seeking while copying sections. */
2755 : 3345051 : if (file_order1 != file_order2)
2756 : 321 : return file_order1 - file_order2;
2757 : :
2758 : : /* Order within static library. */
2759 : 3344730 : if (n1->lto_file_data && n1->lto_file_data->id != n2->lto_file_data->id)
2760 : 9507 : return *id_map->get (n1->lto_file_data) - *id_map->get (n2->lto_file_data);
2761 : :
2762 : : /* And finaly order by the definition order. */
2763 : 3335223 : return n1->order - n2->order;
2764 : : }
2765 : :
2766 : : /* Compare ints, callback for qsort. */
2767 : :
2768 : : static int
2769 : 31788490 : cmp_int (const void *a, const void *b)
2770 : : {
2771 : 31788490 : int ia = *(int const*) a;
2772 : 31788490 : int ib = *(int const*) b;
2773 : 31788490 : return ia - ib;
2774 : : }
2775 : :
2776 : : /* Create order mapping independent on symbols outside of the partition.
2777 : : Results in stable order values for incremental LTO.
2778 : :
2779 : : Remapping is not done in place, because symbols can be used
2780 : : by multiple partitions. */
2781 : :
2782 : : static void
2783 : 31324 : create_order_remap (lto_symtab_encoder_t encoder)
2784 : : {
2785 : 31324 : auto_vec<int> orders;
2786 : 31324 : unsigned i;
2787 : 31324 : encoder->order_remap = new hash_map<int_hash<int, -1, -2>, int>;
2788 : 31324 : unsigned n_nodes = lto_symtab_encoder_size (encoder);
2789 : :
2790 : 735619 : for (i = 0; i < n_nodes; i++)
2791 : 704295 : orders.safe_push (lto_symtab_encoder_deref (encoder, i)->order);
2792 : :
2793 : 31324 : orders.qsort (cmp_int);
2794 : 31324 : int ord = 0;
2795 : 31324 : int last_order = -1;
2796 : 735619 : for (i = 0; i < orders.length (); i++)
2797 : : {
2798 : 704295 : int order = orders[i];
2799 : 704295 : if (order != last_order)
2800 : : {
2801 : 681317 : last_order = order;
2802 : 681317 : encoder->order_remap->put (order, ord);
2803 : 681317 : ord++;
2804 : : }
2805 : : }
2806 : 31324 : }
2807 : :
2808 : : /* Main entry point from the pass manager. */
2809 : :
2810 : : void
2811 : 31324 : lto_output (void)
2812 : : {
2813 : 31324 : struct lto_out_decl_state *decl_state;
2814 : 31324 : bitmap output = NULL;
2815 : 31324 : bitmap_obstack output_obstack;
2816 : 31324 : unsigned int i, n_nodes;
2817 : 31324 : lto_symtab_encoder_t encoder = lto_get_out_decl_state ()->symtab_node_encoder;
2818 : 31324 : auto_vec<symtab_node *> symbols_to_copy;
2819 : :
2820 : 31324 : create_order_remap (encoder);
2821 : :
2822 : 31324 : prune_offload_funcs ();
2823 : :
2824 : 31324 : if (flag_checking)
2825 : : {
2826 : 31318 : bitmap_obstack_initialize (&output_obstack);
2827 : 31318 : output = BITMAP_ALLOC (&output_obstack);
2828 : : }
2829 : :
2830 : : /* Initialize the streamer. */
2831 : 31324 : lto_streamer_init ();
2832 : :
2833 : 31324 : produce_lto_section ();
2834 : :
2835 : 31324 : n_nodes = lto_symtab_encoder_size (encoder);
2836 : : /* Prepare vector of functions to output and then sort it to optimize
2837 : : section copying. */
2838 : 735619 : for (i = 0; i < n_nodes; i++)
2839 : : {
2840 : 704295 : toplevel_node *tnode = lto_symtab_encoder_deref (encoder, i);
2841 : 704295 : symtab_node *node = dyn_cast <symtab_node *> (tnode);
2842 : 704139 : if (!node || node->alias)
2843 : 12885 : continue;
2844 : :
2845 : 691410 : if (cgraph_node *node = dyn_cast <cgraph_node *> (tnode))
2846 : : {
2847 : 406489 : if (lto_symtab_encoder_encode_body_p (encoder, node)
2848 : 406489 : && !node->clone_of)
2849 : 136597 : symbols_to_copy.safe_push (node);
2850 : : }
2851 : 989216 : else if (varpool_node *node = dyn_cast <varpool_node *> (tnode))
2852 : : {
2853 : : /* Wrap symbol references inside the ctor in a type
2854 : : preserving MEM_REF. */
2855 : 284921 : tree ctor = DECL_INITIAL (node->decl);
2856 : 284921 : if (ctor && !in_lto_p)
2857 : 19229 : walk_tree (&ctor, wrap_refs, NULL, NULL);
2858 : 284921 : if (get_symbol_initial_value (encoder, node->decl) == error_mark_node
2859 : 284921 : && lto_symtab_encoder_encode_initializer_p (encoder, node))
2860 : 15393 : symbols_to_copy.safe_push (node);
2861 : : }
2862 : : }
2863 : : /* Map the section hash to an order it appears in symbols_to_copy
2864 : : since we want to sort same ID symbols next to each other but need
2865 : : to avoid making overall order depend on the actual hash value. */
2866 : 31324 : int order = 0;
2867 : 31324 : hash_map<lto_file_decl_data *, int> id_map;
2868 : 183314 : for (i = 0; i < symbols_to_copy.length (); ++i)
2869 : : {
2870 : 151990 : symtab_node *snode = symbols_to_copy[i];
2871 : 151990 : if (snode->lto_file_data)
2872 : : {
2873 : 39440 : bool existed_p = false;
2874 : 39440 : int &ord = id_map.get_or_insert (snode->lto_file_data, &existed_p);
2875 : 39440 : if (!existed_p)
2876 : 8748 : ord = order++;
2877 : : }
2878 : : }
2879 : 31324 : symbols_to_copy.sort (cmp_symbol_files, (void *)&id_map);
2880 : 183314 : for (i = 0; i < symbols_to_copy.length (); i++)
2881 : : {
2882 : 151990 : symtab_node *snode = symbols_to_copy[i];
2883 : 151990 : cgraph_node *cnode;
2884 : 151990 : varpool_node *vnode;
2885 : :
2886 : 151990 : int output_order = *encoder->order_remap->get (snode->order);
2887 : :
2888 : 151990 : if (flag_checking)
2889 : 151988 : gcc_assert (bitmap_set_bit (output, DECL_UID (snode->decl)));
2890 : :
2891 : 151990 : decl_state = lto_new_out_decl_state ();
2892 : 151990 : lto_push_out_decl_state (decl_state);
2893 : :
2894 : 151990 : if ((cnode = dyn_cast <cgraph_node *> (snode))
2895 : 136597 : && (gimple_has_body_p (cnode->decl)
2896 : 29552 : || (!flag_wpa
2897 : 285 : && flag_incremental_link != INCREMENTAL_LINK_LTO)
2898 : : /* Thunks have no body but they may be synthetized
2899 : : at WPA time. */
2900 : 29406 : || DECL_ARGUMENTS (cnode->decl)))
2901 : 107192 : output_function (cnode, output_order);
2902 : 44798 : else if ((vnode = dyn_cast <varpool_node *> (snode))
2903 : 15393 : && (DECL_INITIAL (vnode->decl) != error_mark_node
2904 : 4458 : || (!flag_wpa
2905 : 42 : && flag_incremental_link != INCREMENTAL_LINK_LTO)))
2906 : 10935 : output_constructor (vnode, output_order);
2907 : : else
2908 : 33863 : copy_function_or_variable (snode, output_order);
2909 : 151990 : gcc_assert (lto_get_out_decl_state () == decl_state);
2910 : 151990 : lto_pop_out_decl_state ();
2911 : 151990 : lto_record_function_out_decl_state (snode->decl, decl_state);
2912 : : }
2913 : :
2914 : : /* Emit the callgraph after emitting function bodies. This needs to
2915 : : be done now to make sure that all the statements in every function
2916 : : have been renumbered so that edges can be associated with call
2917 : : statements using the statement UIDs. */
2918 : 31324 : output_symtab ();
2919 : :
2920 : 31324 : if (lto_get_out_decl_state ()->output_offload_tables_p)
2921 : 7904 : output_offload_tables ();
2922 : :
2923 : 31324 : if (flag_checking)
2924 : : {
2925 : 31318 : BITMAP_FREE (output);
2926 : 31318 : bitmap_obstack_release (&output_obstack);
2927 : : }
2928 : 31324 : }
2929 : :
2930 : : /* Write each node in encoded by ENCODER to OB, as well as those reachable
2931 : : from it and required for correct representation of its semantics.
2932 : : Each node in ENCODER must be a global declaration or a type. A node
2933 : : is written only once, even if it appears multiple times in the
2934 : : vector. Certain transitively-reachable nodes, such as those
2935 : : representing expressions, may be duplicated, but such nodes
2936 : : must not appear in ENCODER itself. */
2937 : :
2938 : : static void
2939 : 183314 : write_global_stream (struct output_block *ob,
2940 : : struct lto_tree_ref_encoder *encoder)
2941 : : {
2942 : 183314 : tree t;
2943 : 183314 : size_t index;
2944 : 183314 : const size_t size = lto_tree_ref_encoder_size (encoder);
2945 : :
2946 : 2806248 : for (index = 0; index < size; index++)
2947 : : {
2948 : 2622934 : t = lto_tree_ref_encoder_get_tree (encoder, index);
2949 : 2622934 : if (streamer_dump_file)
2950 : : {
2951 : 176 : fprintf (streamer_dump_file, " %i:", (int)index);
2952 : 176 : print_node_brief (streamer_dump_file, "", t, 4);
2953 : 176 : fprintf (streamer_dump_file, "\n");
2954 : : }
2955 : 2622934 : if (!streamer_tree_cache_lookup (ob->writer_cache, t, NULL))
2956 : 925470 : stream_write_tree (ob, t, false);
2957 : : }
2958 : 183314 : }
2959 : :
2960 : :
2961 : : /* Write a sequence of indices into the globals vector corresponding
2962 : : to the trees in ENCODER. These are used by the reader to map the
2963 : : indices used to refer to global entities within function bodies to
2964 : : their referents. */
2965 : :
2966 : : static void
2967 : 183314 : write_global_references (struct output_block *ob,
2968 : : struct lto_tree_ref_encoder *encoder)
2969 : : {
2970 : 183314 : tree t;
2971 : 183314 : uint32_t index;
2972 : 183314 : const uint32_t size = lto_tree_ref_encoder_size (encoder);
2973 : :
2974 : : /* Write size and slot indexes as 32-bit unsigned numbers. */
2975 : 183314 : uint32_t *data = XNEWVEC (uint32_t, size + 1);
2976 : 183314 : data[0] = size;
2977 : :
2978 : 2806248 : for (index = 0; index < size; index++)
2979 : : {
2980 : 2622934 : unsigned slot_num;
2981 : :
2982 : 2622934 : t = lto_tree_ref_encoder_get_tree (encoder, index);
2983 : 2622934 : streamer_tree_cache_lookup (ob->writer_cache, t, &slot_num);
2984 : 2622934 : gcc_assert (slot_num != (unsigned)-1);
2985 : 2622934 : data[index + 1] = slot_num;
2986 : : }
2987 : :
2988 : 183314 : lto_write_data (data, sizeof (int32_t) * (size + 1));
2989 : 183314 : free (data);
2990 : 183314 : }
2991 : :
2992 : :
2993 : : /* Write all the streams in an lto_out_decl_state STATE using
2994 : : output block OB and output stream OUT_STREAM. */
2995 : :
2996 : : void
2997 : 183314 : lto_output_decl_state_streams (struct output_block *ob,
2998 : : struct lto_out_decl_state *state)
2999 : : {
3000 : 183314 : int i;
3001 : :
3002 : 366628 : for (i = 0; i < LTO_N_DECL_STREAMS; i++)
3003 : 183314 : write_global_stream (ob, &state->streams[i]);
3004 : 183314 : }
3005 : :
3006 : :
3007 : : /* Write all the references in an lto_out_decl_state STATE using
3008 : : output block OB and output stream OUT_STREAM. */
3009 : :
3010 : : void
3011 : 183314 : lto_output_decl_state_refs (struct output_block *ob,
3012 : : struct lto_out_decl_state *state)
3013 : : {
3014 : 183314 : unsigned i;
3015 : 183314 : unsigned ref;
3016 : 183314 : tree decl;
3017 : :
3018 : : /* Write reference to FUNCTION_DECL. If there is not function,
3019 : : write reference to void_type_node. */
3020 : 183314 : decl = (state->fn_decl) ? state->fn_decl : void_type_node;
3021 : 183314 : streamer_tree_cache_lookup (ob->writer_cache, decl, &ref);
3022 : 183314 : gcc_assert (ref != (unsigned)-1);
3023 : 183314 : ref = ref * 2 + (state->compressed ? 1 : 0);
3024 : 183314 : lto_write_data (&ref, sizeof (uint32_t));
3025 : :
3026 : 549942 : for (i = 0; i < LTO_N_DECL_STREAMS; i++)
3027 : 183314 : write_global_references (ob, &state->streams[i]);
3028 : 183314 : }
3029 : :
3030 : :
3031 : : /* Return the written size of STATE. */
3032 : :
3033 : : static size_t
3034 : 183314 : lto_out_decl_state_written_size (struct lto_out_decl_state *state)
3035 : : {
3036 : 183314 : int i;
3037 : 183314 : size_t size;
3038 : :
3039 : 183314 : size = sizeof (int32_t); /* fn_ref. */
3040 : 0 : for (i = 0; i < LTO_N_DECL_STREAMS; i++)
3041 : : {
3042 : 183314 : size += sizeof (int32_t); /* vector size. */
3043 : 0 : size += (lto_tree_ref_encoder_size (&state->streams[i])
3044 : 0 : * sizeof (int32_t));
3045 : : }
3046 : 183314 : return size;
3047 : : }
3048 : :
3049 : :
3050 : : /* Write symbol T into STREAM in CACHE. SEEN specifies symbols we wrote
3051 : : so far. */
3052 : :
3053 : : static void
3054 : 542338 : write_symbol (struct streamer_tree_cache_d *cache,
3055 : : tree t, hash_set<const char *> *seen, bool alias)
3056 : : {
3057 : 542338 : const char *name;
3058 : 542338 : enum gcc_plugin_symbol_kind kind;
3059 : 542338 : enum gcc_plugin_symbol_visibility visibility = GCCPV_DEFAULT;
3060 : 542338 : unsigned slot_num;
3061 : 542338 : uint64_t size;
3062 : 542338 : const char *comdat;
3063 : 542338 : unsigned char c;
3064 : :
3065 : 542338 : gcc_assert (VAR_OR_FUNCTION_DECL_P (t));
3066 : :
3067 : 542338 : name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (t));
3068 : :
3069 : : /* This behaves like assemble_name_raw in varasm.cc, performing the
3070 : : same name manipulations that ASM_OUTPUT_LABELREF does. */
3071 : 542338 : name = IDENTIFIER_POINTER ((*targetm.asm_out.mangle_assembler_name) (name));
3072 : :
3073 : 542338 : if (seen->add (name))
3074 : 769 : return;
3075 : :
3076 : 541569 : streamer_tree_cache_lookup (cache, t, &slot_num);
3077 : 541569 : gcc_assert (slot_num != (unsigned)-1);
3078 : :
3079 : 541569 : if (DECL_EXTERNAL (t))
3080 : : {
3081 : 215046 : if (DECL_WEAK (t))
3082 : : kind = GCCPK_WEAKUNDEF;
3083 : : else
3084 : 215015 : kind = GCCPK_UNDEF;
3085 : : }
3086 : : else
3087 : : {
3088 : 326523 : if (DECL_WEAK (t))
3089 : : kind = GCCPK_WEAKDEF;
3090 : 314653 : else if (DECL_COMMON (t))
3091 : : kind = GCCPK_COMMON;
3092 : : else
3093 : 314592 : kind = GCCPK_DEF;
3094 : :
3095 : : /* When something is defined, it should have node attached. */
3096 : 326523 : gcc_assert (alias || !VAR_P (t) || varpool_node::get (t)->definition);
3097 : 326523 : gcc_assert (alias || TREE_CODE (t) != FUNCTION_DECL
3098 : : || (cgraph_node::get (t)
3099 : : && cgraph_node::get (t)->definition));
3100 : : }
3101 : :
3102 : : /* Imitate what default_elf_asm_output_external do.
3103 : : When symbol is external, we need to output it with DEFAULT visibility
3104 : : when compiling with -fvisibility=default, while with HIDDEN visibility
3105 : : when symbol has attribute (visibility("hidden")) specified.
3106 : : targetm.binds_local_p check DECL_VISIBILITY_SPECIFIED and gets this
3107 : : right. */
3108 : :
3109 : 541569 : if (DECL_EXTERNAL (t)
3110 : 541569 : && !targetm.binds_local_p (t))
3111 : : visibility = GCCPV_DEFAULT;
3112 : : else
3113 : 326576 : switch (DECL_VISIBILITY (t))
3114 : : {
3115 : : case VISIBILITY_DEFAULT:
3116 : : visibility = GCCPV_DEFAULT;
3117 : : break;
3118 : : case VISIBILITY_PROTECTED:
3119 : 541569 : visibility = GCCPV_PROTECTED;
3120 : : break;
3121 : : case VISIBILITY_HIDDEN:
3122 : : visibility = GCCPV_HIDDEN;
3123 : : break;
3124 : : case VISIBILITY_INTERNAL:
3125 : : visibility = GCCPV_INTERNAL;
3126 : : break;
3127 : : }
3128 : :
3129 : 541569 : if (kind == GCCPK_COMMON
3130 : 61 : && DECL_SIZE_UNIT (t)
3131 : 541630 : && TREE_CODE (DECL_SIZE_UNIT (t)) == INTEGER_CST)
3132 : 61 : size = TREE_INT_CST_LOW (DECL_SIZE_UNIT (t));
3133 : : else
3134 : 541508 : size = 0;
3135 : :
3136 : 541569 : if (DECL_ONE_ONLY (t))
3137 : 11826 : comdat = IDENTIFIER_POINTER (decl_comdat_group_id (t));
3138 : : else
3139 : : comdat = "";
3140 : :
3141 : 541569 : lto_write_data (name, strlen (name) + 1);
3142 : 541569 : lto_write_data (comdat, strlen (comdat) + 1);
3143 : 541569 : c = (unsigned char) kind;
3144 : 541569 : lto_write_data (&c, 1);
3145 : 541569 : c = (unsigned char) visibility;
3146 : 541569 : lto_write_data (&c, 1);
3147 : 541569 : lto_write_data (&size, 8);
3148 : 541569 : lto_write_data (&slot_num, 4);
3149 : : }
3150 : :
3151 : : /* Write extension information for symbols (symbol type, section flags). */
3152 : :
3153 : : static void
3154 : 542338 : write_symbol_extension_info (tree t)
3155 : : {
3156 : 542338 : unsigned char c;
3157 : 542338 : c = ((unsigned char) TREE_CODE (t) == VAR_DECL
3158 : : ? GCCST_VARIABLE : GCCST_FUNCTION);
3159 : 542338 : lto_write_data (&c, 1);
3160 : 542338 : unsigned char section_kind = 0;
3161 : 542338 : if (VAR_P (t))
3162 : : {
3163 : 233606 : section *s = get_variable_section (t, false);
3164 : 233606 : if (s->common.flags & SECTION_BSS)
3165 : 223715 : section_kind |= GCCSSK_BSS;
3166 : : }
3167 : 542338 : lto_write_data (§ion_kind, 1);
3168 : 542338 : }
3169 : :
3170 : : /* Write an IL symbol table to OB.
3171 : : SET and VSET are cgraph/varpool node sets we are outputting. */
3172 : :
3173 : : static unsigned int
3174 : 23047 : produce_symtab (struct output_block *ob)
3175 : : {
3176 : 23047 : unsigned int streamed_symbols = 0;
3177 : 23047 : struct streamer_tree_cache_d *cache = ob->writer_cache;
3178 : 23047 : char *section_name = lto_get_section_name (LTO_section_symtab, NULL, 0, NULL);
3179 : 23047 : lto_symtab_encoder_t encoder = ob->decl_state->symtab_node_encoder;
3180 : 23047 : lto_symtab_encoder_iterator lsei;
3181 : :
3182 : 23047 : lto_begin_section (section_name, false);
3183 : 23047 : free (section_name);
3184 : :
3185 : 23047 : hash_set<const char *> seen;
3186 : :
3187 : : /* Write the symbol table.
3188 : : First write everything defined and then all declarations.
3189 : : This is necessary to handle cases where we have duplicated symbols. */
3190 : 23047 : for (lsei = lsei_start (encoder);
3191 : 620346 : !lsei_end_p (lsei); lsei_next (&lsei))
3192 : : {
3193 : 597299 : toplevel_node *tnode = lsei_node (lsei);
3194 : 597299 : symtab_node *node = dyn_cast<symtab_node*> (tnode);
3195 : 597299 : if (!node)
3196 : 84 : continue;
3197 : :
3198 : 597215 : if (DECL_EXTERNAL (node->decl) || !node->output_to_lto_symbol_table_p ())
3199 : 270692 : continue;
3200 : 326523 : write_symbol (cache, node->decl, &seen, false);
3201 : 326523 : ++streamed_symbols;
3202 : : }
3203 : 620346 : for (lsei = lsei_start (encoder);
3204 : 620346 : !lsei_end_p (lsei); lsei_next (&lsei))
3205 : : {
3206 : 597299 : toplevel_node *tnode = lsei_node (lsei);
3207 : 597299 : symtab_node *node = dyn_cast<symtab_node*> (tnode);
3208 : 597299 : if (!node)
3209 : 84 : continue;
3210 : :
3211 : 597215 : if (!DECL_EXTERNAL (node->decl) || !node->output_to_lto_symbol_table_p ())
3212 : 381400 : continue;
3213 : 215815 : write_symbol (cache, node->decl, &seen, false);
3214 : 215815 : ++streamed_symbols;
3215 : : }
3216 : :
3217 : 23047 : lto_end_section ();
3218 : :
3219 : 23047 : return streamed_symbols;
3220 : 23047 : }
3221 : :
3222 : : /* Symtab extension version. */
3223 : : #define LTO_SYMTAB_EXTENSION_VERSION 1
3224 : :
3225 : : /* Write an IL symbol table extension to OB.
3226 : : SET and VSET are cgraph/varpool node sets we are outputting. */
3227 : :
3228 : : static void
3229 : 23047 : produce_symtab_extension (struct output_block *ob,
3230 : : unsigned int previous_streamed_symbols)
3231 : : {
3232 : 23047 : unsigned int streamed_symbols = 0;
3233 : 23047 : char *section_name = lto_get_section_name (LTO_section_symtab_extension,
3234 : : NULL, 0, NULL);
3235 : 23047 : lto_symtab_encoder_t encoder = ob->decl_state->symtab_node_encoder;
3236 : 23047 : lto_symtab_encoder_iterator lsei;
3237 : :
3238 : 23047 : lto_begin_section (section_name, false);
3239 : 23047 : free (section_name);
3240 : :
3241 : 23047 : unsigned char version = LTO_SYMTAB_EXTENSION_VERSION;
3242 : 23047 : lto_write_data (&version, 1);
3243 : :
3244 : : /* Write the symbol table.
3245 : : First write everything defined and then all declarations.
3246 : : This is necessary to handle cases where we have duplicated symbols. */
3247 : 23047 : for (lsei = lsei_start (encoder);
3248 : 620346 : !lsei_end_p (lsei); lsei_next (&lsei))
3249 : : {
3250 : 597299 : toplevel_node *tnode = lsei_node (lsei);
3251 : 597299 : symtab_node *node = dyn_cast<symtab_node*> (tnode);
3252 : 597299 : if (!node)
3253 : 84 : continue;
3254 : :
3255 : 597215 : if (DECL_EXTERNAL (node->decl) || !node->output_to_lto_symbol_table_p ())
3256 : 270692 : continue;
3257 : 326523 : write_symbol_extension_info (node->decl);
3258 : 326523 : ++streamed_symbols;
3259 : : }
3260 : 620346 : for (lsei = lsei_start (encoder);
3261 : 620346 : !lsei_end_p (lsei); lsei_next (&lsei))
3262 : : {
3263 : 597299 : toplevel_node *tnode = lsei_node (lsei);
3264 : 597299 : symtab_node *node = dyn_cast<symtab_node*> (tnode);
3265 : 597299 : if (!node)
3266 : 84 : continue;
3267 : :
3268 : 597215 : if (!DECL_EXTERNAL (node->decl) || !node->output_to_lto_symbol_table_p ())
3269 : 381400 : continue;
3270 : 215815 : write_symbol_extension_info (node->decl);
3271 : 215815 : ++streamed_symbols;
3272 : : }
3273 : :
3274 : 23047 : gcc_assert (previous_streamed_symbols == streamed_symbols);
3275 : 23047 : lto_end_section ();
3276 : 23047 : }
3277 : :
3278 : :
3279 : : /* Init the streamer_mode_table for output, where we collect info on what
3280 : : machine_mode values have been streamed. */
3281 : : void
3282 : 31324 : lto_output_init_mode_table (void)
3283 : : {
3284 : 31324 : memset (streamer_mode_table, '\0', MAX_MACHINE_MODE);
3285 : 31324 : }
3286 : :
3287 : :
3288 : : /* Write the mode table. */
3289 : : static void
3290 : 0 : lto_write_mode_table (void)
3291 : : {
3292 : 0 : struct output_block *ob;
3293 : 0 : ob = create_output_block (LTO_section_mode_table);
3294 : 0 : bitpack_d bp = bitpack_create (ob->main_stream);
3295 : :
3296 : 0 : if (lto_stream_offload_p)
3297 : 0 : bp_pack_value (&bp, NUM_POLY_INT_COEFFS, MAX_NUM_POLY_INT_COEFFS_BITS);
3298 : :
3299 : : /* Ensure that for GET_MODE_INNER (m) != m we have
3300 : : also the inner mode marked. */
3301 : 0 : for (int i = 0; i < (int) MAX_MACHINE_MODE; i++)
3302 : 0 : if (streamer_mode_table[i])
3303 : : {
3304 : 0 : machine_mode m = (machine_mode) i;
3305 : 0 : machine_mode inner_m = GET_MODE_INNER (m);
3306 : 0 : if (inner_m != m)
3307 : 0 : streamer_mode_table[(int) inner_m] = 1;
3308 : : }
3309 : :
3310 : : /* Pack the mode_bits value within 5 bits (up to 31) in the beginning. */
3311 : 0 : unsigned mode_bits = ceil_log2 (MAX_MACHINE_MODE);
3312 : 0 : bp_pack_value (&bp, mode_bits, 5);
3313 : :
3314 : : /* First stream modes that have GET_MODE_INNER (m) == m,
3315 : : so that we can refer to them afterwards. */
3316 : 0 : for (int pass = 0; pass < 2; pass++)
3317 : 0 : for (int i = 0; i < (int) MAX_MACHINE_MODE; i++)
3318 : 0 : if (streamer_mode_table[i] && i != (int) VOIDmode && i != (int) BLKmode)
3319 : : {
3320 : 0 : machine_mode m = (machine_mode) i;
3321 : 0 : if ((GET_MODE_INNER (m) == m) ^ (pass == 0))
3322 : 0 : continue;
3323 : 0 : bp_pack_value (&bp, m, mode_bits);
3324 : 0 : bp_pack_enum (&bp, mode_class, MAX_MODE_CLASS, GET_MODE_CLASS (m));
3325 : 0 : bp_pack_poly_value (&bp, GET_MODE_SIZE (m), 16);
3326 : 0 : bp_pack_poly_value (&bp, GET_MODE_PRECISION (m), 16);
3327 : 0 : bp_pack_value (&bp, GET_MODE_INNER (m), mode_bits);
3328 : 0 : bp_pack_poly_value (&bp, GET_MODE_NUNITS (m), 16);
3329 : 0 : switch (GET_MODE_CLASS (m))
3330 : : {
3331 : 0 : case MODE_FRACT:
3332 : 0 : case MODE_UFRACT:
3333 : 0 : case MODE_ACCUM:
3334 : 0 : case MODE_UACCUM:
3335 : 0 : bp_pack_value (&bp, GET_MODE_IBIT (m), 8);
3336 : 0 : bp_pack_value (&bp, GET_MODE_FBIT (m), 8);
3337 : 0 : break;
3338 : 0 : case MODE_FLOAT:
3339 : 0 : case MODE_DECIMAL_FLOAT:
3340 : 0 : bp_pack_string (ob, &bp, REAL_MODE_FORMAT (m)->name, true);
3341 : 0 : break;
3342 : : default:
3343 : : break;
3344 : : }
3345 : 0 : bp_pack_string (ob, &bp, GET_MODE_NAME (m), true);
3346 : : }
3347 : 0 : bp_pack_value (&bp, VOIDmode, mode_bits);
3348 : :
3349 : 0 : streamer_write_bitpack (&bp);
3350 : :
3351 : 0 : char *section_name
3352 : 0 : = lto_get_section_name (LTO_section_mode_table, NULL, 0, NULL);
3353 : 0 : lto_begin_section (section_name, !flag_wpa);
3354 : 0 : free (section_name);
3355 : :
3356 : : /* The entire header stream is computed here. */
3357 : 0 : struct lto_simple_header_with_strings header;
3358 : 0 : memset (&header, 0, sizeof (header));
3359 : :
3360 : 0 : header.main_size = ob->main_stream->total_size;
3361 : 0 : header.string_size = ob->string_stream->total_size;
3362 : 0 : lto_write_data (&header, sizeof header);
3363 : :
3364 : : /* Put all of the gimple and the string table out the asm file as a
3365 : : block of text. */
3366 : 0 : lto_write_stream (ob->main_stream);
3367 : 0 : lto_write_stream (ob->string_stream);
3368 : :
3369 : 0 : lto_end_section ();
3370 : 0 : destroy_output_block (ob);
3371 : 0 : }
3372 : :
3373 : :
3374 : : /* This pass is run after all of the functions are serialized and all
3375 : : of the IPA passes have written their serialized forms. This pass
3376 : : causes the vector of all of the global decls and types used from
3377 : : this file to be written in to a section that can then be read in to
3378 : : recover these on other side. */
3379 : :
3380 : : void
3381 : 31324 : produce_asm_for_decls (void)
3382 : : {
3383 : 31324 : struct lto_out_decl_state *out_state;
3384 : 31324 : struct lto_out_decl_state *fn_out_state;
3385 : 31324 : struct lto_decl_header header;
3386 : 31324 : char *section_name;
3387 : 31324 : struct output_block *ob;
3388 : 31324 : unsigned idx, num_fns;
3389 : 31324 : size_t decl_state_size;
3390 : 31324 : int32_t num_decl_states;
3391 : :
3392 : 31324 : ob = create_output_block (LTO_section_decls);
3393 : :
3394 : 31324 : memset (&header, 0, sizeof (struct lto_decl_header));
3395 : :
3396 : 31324 : section_name = lto_get_section_name (LTO_section_decls, NULL, 0, NULL);
3397 : 31324 : lto_begin_section (section_name, !flag_wpa);
3398 : 31324 : free (section_name);
3399 : :
3400 : : /* Make string 0 be a NULL string. */
3401 : 31324 : streamer_write_char_stream (ob->string_stream, 0);
3402 : :
3403 : 31324 : gcc_assert (!alias_pairs);
3404 : :
3405 : : /* Get rid of the global decl state hash tables to save some memory. */
3406 : 31324 : out_state = lto_get_out_decl_state ();
3407 : 93972 : for (int i = 0; i < LTO_N_DECL_STREAMS; i++)
3408 : 31324 : if (out_state->streams[i].tree_hash_table)
3409 : : {
3410 : 31324 : delete out_state->streams[i].tree_hash_table;
3411 : 31324 : out_state->streams[i].tree_hash_table = NULL;
3412 : : }
3413 : :
3414 : : /* Write the global symbols. */
3415 : 31324 : if (streamer_dump_file)
3416 : 4 : fprintf (streamer_dump_file, "Outputting global stream\n");
3417 : 31324 : lto_output_decl_state_streams (ob, out_state);
3418 : 31324 : num_fns = lto_function_decl_states.length ();
3419 : 183314 : for (idx = 0; idx < num_fns; idx++)
3420 : : {
3421 : 151990 : fn_out_state =
3422 : 151990 : lto_function_decl_states[idx];
3423 : 151990 : if (streamer_dump_file)
3424 : 24 : fprintf (streamer_dump_file, "Outputting stream for %s\n",
3425 : 12 : IDENTIFIER_POINTER
3426 : : (DECL_ASSEMBLER_NAME (fn_out_state->fn_decl)));
3427 : 151990 : lto_output_decl_state_streams (ob, fn_out_state);
3428 : : }
3429 : :
3430 : : /* Currently not used. This field would allow us to preallocate
3431 : : the globals vector, so that it need not be resized as it is extended. */
3432 : 31324 : header.num_nodes = -1;
3433 : :
3434 : : /* Compute the total size of all decl out states. */
3435 : 31324 : decl_state_size = sizeof (int32_t);
3436 : 31324 : decl_state_size += lto_out_decl_state_written_size (out_state);
3437 : 183314 : for (idx = 0; idx < num_fns; idx++)
3438 : : {
3439 : 151990 : fn_out_state =
3440 : 151990 : lto_function_decl_states[idx];
3441 : 303303 : decl_state_size += lto_out_decl_state_written_size (fn_out_state);
3442 : : }
3443 : 31324 : header.decl_state_size = decl_state_size;
3444 : :
3445 : 31324 : header.main_size = ob->main_stream->total_size;
3446 : 31324 : header.string_size = ob->string_stream->total_size;
3447 : :
3448 : 31324 : lto_write_data (&header, sizeof header);
3449 : :
3450 : : /* Write the main out-decl state, followed by out-decl states of
3451 : : functions. */
3452 : 31324 : num_decl_states = num_fns + 1;
3453 : 31324 : lto_write_data (&num_decl_states, sizeof (num_decl_states));
3454 : 31324 : lto_output_decl_state_refs (ob, out_state);
3455 : 214638 : for (idx = 0; idx < num_fns; idx++)
3456 : : {
3457 : 151990 : fn_out_state = lto_function_decl_states[idx];
3458 : 151990 : lto_output_decl_state_refs (ob, fn_out_state);
3459 : : }
3460 : :
3461 : 31324 : lto_write_stream (ob->main_stream);
3462 : 31324 : lto_write_stream (ob->string_stream);
3463 : :
3464 : 31324 : lto_end_section ();
3465 : :
3466 : : /* Write the symbol table. It is used by linker to determine dependencies
3467 : : and thus we can skip it for WPA. */
3468 : 31324 : if (!flag_wpa)
3469 : : {
3470 : 23047 : unsigned int streamed_symbols = produce_symtab (ob);
3471 : 23047 : produce_symtab_extension (ob, streamed_symbols);
3472 : : }
3473 : :
3474 : : /* Write command line opts. */
3475 : 31324 : lto_write_options ();
3476 : :
3477 : : /* Deallocate memory and clean up. */
3478 : 214638 : for (idx = 0; idx < num_fns; idx++)
3479 : : {
3480 : 151990 : fn_out_state =
3481 : 151990 : lto_function_decl_states[idx];
3482 : 151990 : lto_delete_out_decl_state (fn_out_state);
3483 : : }
3484 : 31324 : lto_symtab_encoder_delete (ob->decl_state->symtab_node_encoder);
3485 : 31324 : lto_function_decl_states.release ();
3486 : 31324 : destroy_output_block (ob);
3487 : 31324 : if (lto_stream_offload_p)
3488 : 0 : lto_write_mode_table ();
3489 : 31324 : }
|