tree.c (free_lang_data_in_binfo): Do not free BINFO_OFFSET and BINFO_VPTR_FIELD.
[gcc.git] / gcc / lto-streamer-out.c
1 /* Write the GIMPLE representation to a file stream.
2
3 Copyright 2009 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 "tm.h"
27 #include "toplev.h"
28 #include "tree.h"
29 #include "expr.h"
30 #include "flags.h"
31 #include "params.h"
32 #include "input.h"
33 #include "varray.h"
34 #include "hashtab.h"
35 #include "basic-block.h"
36 #include "tree-flow.h"
37 #include "tree-pass.h"
38 #include "cgraph.h"
39 #include "function.h"
40 #include "ggc.h"
41 #include "diagnostic.h"
42 #include "except.h"
43 #include "vec.h"
44 #include "lto-symtab.h"
45 #include "lto-streamer.h"
46
47
48 struct string_slot
49 {
50 const char *s;
51 int len;
52 unsigned int slot_num;
53 };
54
55
56 /* Returns a hash code for P. */
57
58 static hashval_t
59 hash_string_slot_node (const void *p)
60 {
61 const struct string_slot *ds = (const struct string_slot *) p;
62 return (hashval_t) htab_hash_string (ds->s);
63 }
64
65
66 /* Returns nonzero if P1 and P2 are equal. */
67
68 static int
69 eq_string_slot_node (const void *p1, const void *p2)
70 {
71 const struct string_slot *ds1 = (const struct string_slot *) p1;
72 const struct string_slot *ds2 = (const struct string_slot *) p2;
73
74 if (ds1->len == ds2->len)
75 {
76 int i;
77 for (i = 0; i < ds1->len; i++)
78 if (ds1->s[i] != ds2->s[i])
79 return 0;
80 return 1;
81 }
82
83 return 0;
84 }
85
86
87 /* Free the string slot pointed-to by P. */
88
89 static void
90 string_slot_free (void *p)
91 {
92 struct string_slot *slot = (struct string_slot *) p;
93 free (CONST_CAST (void *, (const void *) slot->s));
94 free (slot);
95 }
96
97
98 /* Clear the line info stored in DATA_IN. */
99
100 static void
101 clear_line_info (struct output_block *ob)
102 {
103 ob->current_file = NULL;
104 ob->current_line = 0;
105 ob->current_col = 0;
106 }
107
108
109 /* Create the output block and return it. SECTION_TYPE is
110 LTO_section_function_body or LTO_static_initializer. */
111
112 struct output_block *
113 create_output_block (enum lto_section_type section_type)
114 {
115 struct output_block *ob = XCNEW (struct output_block);
116
117 ob->section_type = section_type;
118 ob->decl_state = lto_get_out_decl_state ();
119 ob->main_stream = XCNEW (struct lto_output_stream);
120 ob->string_stream = XCNEW (struct lto_output_stream);
121 ob->writer_cache = lto_streamer_cache_create ();
122
123 if (section_type == LTO_section_function_body)
124 ob->cfg_stream = XCNEW (struct lto_output_stream);
125
126 clear_line_info (ob);
127
128 ob->string_hash_table = htab_create (37, hash_string_slot_node,
129 eq_string_slot_node, string_slot_free);
130
131 return ob;
132 }
133
134
135 /* Destroy the output block OB. */
136
137 void
138 destroy_output_block (struct output_block *ob)
139 {
140 enum lto_section_type section_type = ob->section_type;
141
142 htab_delete (ob->string_hash_table);
143
144 free (ob->main_stream);
145 free (ob->string_stream);
146 if (section_type == LTO_section_function_body)
147 free (ob->cfg_stream);
148
149 lto_streamer_cache_delete (ob->writer_cache);
150
151 free (ob);
152 }
153
154
155 /* Output bitpack BP to output stream S. */
156
157 void
158 lto_output_bitpack (struct lto_output_stream *s, struct bitpack_d *bp)
159 {
160 unsigned i;
161 bitpack_word_t v;
162
163 lto_output_uleb128_stream (s, VEC_length (bitpack_word_t, bp->values));
164 for (i = 0; VEC_iterate (bitpack_word_t, bp->values, i, v); i++)
165 lto_output_uleb128_stream (s, v);
166 }
167
168
169 /* Output STRING of LEN characters to the string
170 table in OB. The string might or might not include a trailing '\0'.
171 Then put the index onto the INDEX_STREAM. */
172
173 static void
174 output_string_with_length (struct output_block *ob,
175 struct lto_output_stream *index_stream,
176 const char *s,
177 unsigned int len)
178 {
179 struct string_slot **slot;
180 struct string_slot s_slot;
181 char *string = (char *) xmalloc (len + 1);
182 memcpy (string, s, len);
183 string[len] = '\0';
184
185 s_slot.s = string;
186 s_slot.len = len;
187 s_slot.slot_num = 0;
188
189 slot = (struct string_slot **) htab_find_slot (ob->string_hash_table,
190 &s_slot, INSERT);
191 if (*slot == NULL)
192 {
193 struct lto_output_stream *string_stream = ob->string_stream;
194 unsigned int start = string_stream->total_size;
195 struct string_slot *new_slot
196 = (struct string_slot *) xmalloc (sizeof (struct string_slot));
197 unsigned int i;
198
199 new_slot->s = string;
200 new_slot->len = len;
201 new_slot->slot_num = start;
202 *slot = new_slot;
203 lto_output_uleb128_stream (index_stream, start);
204 lto_output_uleb128_stream (string_stream, len);
205 for (i = 0; i < len; i++)
206 lto_output_1_stream (string_stream, string[i]);
207 }
208 else
209 {
210 struct string_slot *old_slot = (struct string_slot *)*slot;
211 lto_output_uleb128_stream (index_stream, old_slot->slot_num);
212 free (string);
213 }
214 }
215
216 /* Output the '\0' terminated STRING to the string
217 table in OB. Then put the index onto the INDEX_STREAM. */
218
219 static void
220 output_string (struct output_block *ob,
221 struct lto_output_stream *index_stream,
222 const char *string)
223 {
224 if (string)
225 {
226 lto_output_uleb128_stream (index_stream, 0);
227 output_string_with_length (ob, index_stream, string, strlen (string) + 1);
228 }
229 else
230 lto_output_uleb128_stream (index_stream, 1);
231 }
232
233
234 /* Output the STRING constant to the string
235 table in OB. Then put the index onto the INDEX_STREAM. */
236
237 static void
238 output_string_cst (struct output_block *ob,
239 struct lto_output_stream *index_stream,
240 tree string)
241 {
242 if (string)
243 {
244 lto_output_uleb128_stream (index_stream, 0);
245 output_string_with_length (ob, index_stream,
246 TREE_STRING_POINTER (string),
247 TREE_STRING_LENGTH (string));
248 }
249 else
250 lto_output_uleb128_stream (index_stream, 1);
251 }
252
253
254 /* Output the identifier ID to the string
255 table in OB. Then put the index onto the INDEX_STREAM. */
256
257 static void
258 output_identifier (struct output_block *ob,
259 struct lto_output_stream *index_stream,
260 tree id)
261 {
262 if (id)
263 {
264 lto_output_uleb128_stream (index_stream, 0);
265 output_string_with_length (ob, index_stream,
266 IDENTIFIER_POINTER (id),
267 IDENTIFIER_LENGTH (id));
268 }
269 else
270 lto_output_uleb128_stream (index_stream, 1);
271 }
272
273 /* Write a zero to the output stream. */
274
275 static void
276 output_zero (struct output_block *ob)
277 {
278 lto_output_1_stream (ob->main_stream, 0);
279 }
280
281
282 /* Output an unsigned LEB128 quantity to OB->main_stream. */
283
284 static void
285 output_uleb128 (struct output_block *ob, unsigned HOST_WIDE_INT work)
286 {
287 lto_output_uleb128_stream (ob->main_stream, work);
288 }
289
290
291 /* Output a signed LEB128 quantity to OB->main_stream. */
292
293 static void
294 output_sleb128 (struct output_block *ob, HOST_WIDE_INT work)
295 {
296 lto_output_sleb128_stream (ob->main_stream, work);
297 }
298
299
300 /* Output the start of a record with TAG to output block OB. */
301
302 static void
303 output_record_start (struct output_block *ob, enum LTO_tags tag)
304 {
305 /* Make sure TAG fits inside an unsigned int. */
306 gcc_assert (tag == (enum LTO_tags) (unsigned) tag);
307 output_uleb128 (ob, tag);
308 }
309
310
311 /* Look up NODE in the type table and write the index for it to OB. */
312
313 static void
314 output_type_ref (struct output_block *ob, tree node)
315 {
316 output_record_start (ob, LTO_type_ref);
317 lto_output_type_ref_index (ob->decl_state, ob->main_stream, node);
318 }
319
320
321 /* Pack all the non-pointer fields of the TS_BASE structure of
322 expression EXPR into bitpack BP. */
323
324 static void
325 pack_ts_base_value_fields (struct bitpack_d *bp, tree expr)
326 {
327 bp_pack_value (bp, TREE_CODE (expr), 16);
328 if (!TYPE_P (expr))
329 {
330 bp_pack_value (bp, TREE_SIDE_EFFECTS (expr), 1);
331 bp_pack_value (bp, TREE_CONSTANT (expr), 1);
332 bp_pack_value (bp, TREE_READONLY (expr), 1);
333
334 /* TREE_PUBLIC is used on types to indicate that the type
335 has a TYPE_CACHED_VALUES vector. This is not streamed out,
336 so we skip it here. */
337 bp_pack_value (bp, TREE_PUBLIC (expr), 1);
338 }
339 bp_pack_value (bp, TREE_ADDRESSABLE (expr), 1);
340 bp_pack_value (bp, TREE_THIS_VOLATILE (expr), 1);
341 if (DECL_P (expr))
342 bp_pack_value (bp, DECL_UNSIGNED (expr), 1);
343 else if (TYPE_P (expr))
344 bp_pack_value (bp, TYPE_UNSIGNED (expr), 1);
345 /* We write debug info two times, do not confuse the second one. */
346 bp_pack_value (bp, TYPE_P (expr) ? 0 : TREE_ASM_WRITTEN (expr), 1);
347 bp_pack_value (bp, TREE_NO_WARNING (expr), 1);
348 bp_pack_value (bp, TREE_USED (expr), 1);
349 bp_pack_value (bp, TREE_NOTHROW (expr), 1);
350 bp_pack_value (bp, TREE_STATIC (expr), 1);
351 bp_pack_value (bp, TREE_PRIVATE (expr), 1);
352 bp_pack_value (bp, TREE_PROTECTED (expr), 1);
353 bp_pack_value (bp, TREE_DEPRECATED (expr), 1);
354 if (TYPE_P (expr))
355 bp_pack_value (bp, TYPE_SATURATING (expr), 1);
356 if (TREE_CODE (expr) == SSA_NAME)
357 bp_pack_value (bp, SSA_NAME_IS_DEFAULT_DEF (expr), 1);
358 }
359
360
361 /* Pack all the non-pointer fields of the TS_REAL_CST structure of
362 expression EXPR into bitpack BP. */
363
364 static void
365 pack_ts_real_cst_value_fields (struct bitpack_d *bp, tree expr)
366 {
367 unsigned i;
368 REAL_VALUE_TYPE r;
369
370 r = TREE_REAL_CST (expr);
371 bp_pack_value (bp, r.cl, 2);
372 bp_pack_value (bp, r.decimal, 1);
373 bp_pack_value (bp, r.sign, 1);
374 bp_pack_value (bp, r.signalling, 1);
375 bp_pack_value (bp, r.canonical, 1);
376 bp_pack_value (bp, r.uexp, EXP_BITS);
377 for (i = 0; i < SIGSZ; i++)
378 bp_pack_value (bp, r.sig[i], HOST_BITS_PER_LONG);
379 }
380
381
382 /* Pack all the non-pointer fields of the TS_FIXED_CST structure of
383 expression EXPR into bitpack BP. */
384
385 static void
386 pack_ts_fixed_cst_value_fields (struct bitpack_d *bp, tree expr)
387 {
388 struct fixed_value fv = TREE_FIXED_CST (expr);
389 bp_pack_value (bp, fv.data.low, HOST_BITS_PER_WIDE_INT);
390 bp_pack_value (bp, fv.data.high, HOST_BITS_PER_WIDE_INT);
391 }
392
393
394 /* Pack all the non-pointer fields of the TS_DECL_COMMON structure
395 of expression EXPR into bitpack BP. */
396
397 static void
398 pack_ts_decl_common_value_fields (struct bitpack_d *bp, tree expr)
399 {
400 bp_pack_value (bp, DECL_MODE (expr), 8);
401 bp_pack_value (bp, DECL_NONLOCAL (expr), 1);
402 bp_pack_value (bp, DECL_VIRTUAL_P (expr), 1);
403 bp_pack_value (bp, DECL_IGNORED_P (expr), 1);
404 bp_pack_value (bp, DECL_ABSTRACT (expr), 1);
405 bp_pack_value (bp, DECL_ARTIFICIAL (expr), 1);
406 bp_pack_value (bp, DECL_USER_ALIGN (expr), 1);
407 bp_pack_value (bp, DECL_PRESERVE_P (expr), 1);
408 bp_pack_value (bp, DECL_DEBUG_EXPR_IS_FROM (expr), 1);
409 bp_pack_value (bp, DECL_EXTERNAL (expr), 1);
410 bp_pack_value (bp, DECL_GIMPLE_REG_P (expr), 1);
411 bp_pack_value (bp, DECL_ALIGN (expr), HOST_BITS_PER_INT);
412
413 if (TREE_CODE (expr) == LABEL_DECL)
414 {
415 /* Note that we do not write LABEL_DECL_UID. The reader will
416 always assume an initial value of -1 so that the
417 label_to_block_map is recreated by gimple_set_bb. */
418 bp_pack_value (bp, DECL_ERROR_ISSUED (expr), 1);
419 bp_pack_value (bp, EH_LANDING_PAD_NR (expr), HOST_BITS_PER_INT);
420 }
421
422 if (TREE_CODE (expr) == FIELD_DECL)
423 {
424 bp_pack_value (bp, DECL_PACKED (expr), 1);
425 bp_pack_value (bp, DECL_NONADDRESSABLE_P (expr), 1);
426 bp_pack_value (bp, DECL_OFFSET_ALIGN (expr), 8);
427 }
428
429 if (TREE_CODE (expr) == RESULT_DECL
430 || TREE_CODE (expr) == PARM_DECL
431 || TREE_CODE (expr) == VAR_DECL)
432 {
433 bp_pack_value (bp, DECL_BY_REFERENCE (expr), 1);
434 if (TREE_CODE (expr) == VAR_DECL
435 || TREE_CODE (expr) == PARM_DECL)
436 bp_pack_value (bp, DECL_HAS_VALUE_EXPR_P (expr), 1);
437 bp_pack_value (bp, DECL_RESTRICTED_P (expr), 1);
438 }
439 }
440
441
442 /* Pack all the non-pointer fields of the TS_DECL_WRTL structure
443 of expression EXPR into bitpack BP. */
444
445 static void
446 pack_ts_decl_wrtl_value_fields (struct bitpack_d *bp, tree expr)
447 {
448 bp_pack_value (bp, DECL_REGISTER (expr), 1);
449 }
450
451
452 /* Pack all the non-pointer fields of the TS_DECL_WITH_VIS structure
453 of expression EXPR into bitpack BP. */
454
455 static void
456 pack_ts_decl_with_vis_value_fields (struct bitpack_d *bp, tree expr)
457 {
458 bp_pack_value (bp, DECL_DEFER_OUTPUT (expr), 1);
459 bp_pack_value (bp, DECL_COMMON (expr), 1);
460 bp_pack_value (bp, DECL_DLLIMPORT_P (expr), 1);
461 bp_pack_value (bp, DECL_WEAK (expr), 1);
462 bp_pack_value (bp, DECL_SEEN_IN_BIND_EXPR_P (expr), 1);
463 bp_pack_value (bp, DECL_COMDAT (expr), 1);
464 bp_pack_value (bp, DECL_VISIBILITY (expr), 2);
465 bp_pack_value (bp, DECL_VISIBILITY_SPECIFIED (expr), 1);
466
467 if (TREE_CODE (expr) == VAR_DECL)
468 {
469 bp_pack_value (bp, DECL_HARD_REGISTER (expr), 1);
470 bp_pack_value (bp, DECL_IN_TEXT_SECTION (expr), 1);
471 bp_pack_value (bp, DECL_TLS_MODEL (expr), 3);
472 }
473
474 if (VAR_OR_FUNCTION_DECL_P (expr))
475 bp_pack_value (bp, DECL_INIT_PRIORITY (expr), HOST_BITS_PER_SHORT);
476 }
477
478
479 /* Pack all the non-pointer fields of the TS_FUNCTION_DECL structure
480 of expression EXPR into bitpack BP. */
481
482 static void
483 pack_ts_function_decl_value_fields (struct bitpack_d *bp, tree expr)
484 {
485 /* For normal/md builtins we only write the class and code, so they
486 should never be handled here. */
487 gcc_assert (!lto_stream_as_builtin_p (expr));
488
489 bp_pack_value (bp, DECL_FUNCTION_CODE (expr), 11);
490 bp_pack_value (bp, DECL_BUILT_IN_CLASS (expr), 2);
491 bp_pack_value (bp, DECL_STATIC_CONSTRUCTOR (expr), 1);
492 bp_pack_value (bp, DECL_STATIC_DESTRUCTOR (expr), 1);
493 bp_pack_value (bp, DECL_UNINLINABLE (expr), 1);
494 bp_pack_value (bp, DECL_POSSIBLY_INLINED (expr), 1);
495 bp_pack_value (bp, DECL_IS_NOVOPS (expr), 1);
496 bp_pack_value (bp, DECL_IS_RETURNS_TWICE (expr), 1);
497 bp_pack_value (bp, DECL_IS_MALLOC (expr), 1);
498 bp_pack_value (bp, DECL_IS_OPERATOR_NEW (expr), 1);
499 bp_pack_value (bp, DECL_DECLARED_INLINE_P (expr), 1);
500 bp_pack_value (bp, DECL_STATIC_CHAIN (expr), 1);
501 bp_pack_value (bp, DECL_NO_INLINE_WARNING_P (expr), 1);
502 bp_pack_value (bp, DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (expr), 1);
503 bp_pack_value (bp, DECL_NO_LIMIT_STACK (expr), 1);
504 bp_pack_value (bp, DECL_DISREGARD_INLINE_LIMITS (expr), 1);
505 bp_pack_value (bp, DECL_PURE_P (expr), 1);
506 bp_pack_value (bp, DECL_LOOPING_CONST_OR_PURE_P (expr), 1);
507 }
508
509
510 /* Pack all the non-pointer fields of the TS_TYPE structure
511 of expression EXPR into bitpack BP. */
512
513 static void
514 pack_ts_type_value_fields (struct bitpack_d *bp, tree expr)
515 {
516 bp_pack_value (bp, TYPE_PRECISION (expr), 9);
517 bp_pack_value (bp, TYPE_MODE (expr), 7);
518 bp_pack_value (bp, TYPE_STRING_FLAG (expr), 1);
519 bp_pack_value (bp, TYPE_NO_FORCE_BLK (expr), 1);
520 bp_pack_value (bp, TYPE_NEEDS_CONSTRUCTING(expr), 1);
521 if (TREE_CODE (expr) == UNION_TYPE)
522 bp_pack_value (bp, TYPE_TRANSPARENT_UNION (expr), 1);
523 bp_pack_value (bp, TYPE_PACKED (expr), 1);
524 bp_pack_value (bp, TYPE_RESTRICT (expr), 1);
525 bp_pack_value (bp, TYPE_CONTAINS_PLACEHOLDER_INTERNAL (expr), 2);
526 bp_pack_value (bp, TYPE_USER_ALIGN (expr), 1);
527 bp_pack_value (bp, TYPE_READONLY (expr), 1);
528 bp_pack_value (bp, TYPE_ALIGN (expr), HOST_BITS_PER_INT);
529 bp_pack_value (bp, TYPE_ALIAS_SET (expr) == 0 ? 0 : -1, HOST_BITS_PER_INT);
530 }
531
532
533 /* Pack all the non-pointer fields of the TS_BLOCK structure
534 of expression EXPR into bitpack BP. */
535
536 static void
537 pack_ts_block_value_fields (struct bitpack_d *bp, tree expr)
538 {
539 bp_pack_value (bp, BLOCK_ABSTRACT (expr), 1);
540 bp_pack_value (bp, BLOCK_NUMBER (expr), 31);
541 }
542
543
544 /* Pack all the non-pointer fields in EXPR into a bit pack. */
545
546 static struct bitpack_d *
547 pack_value_fields (tree expr)
548 {
549 enum tree_code code;
550 struct bitpack_d *bp;
551
552 code = TREE_CODE (expr);
553 bp = bitpack_create ();
554
555 /* Note that all these functions are highly sensitive to changes in
556 the types and sizes of each of the fields being packed. */
557 pack_ts_base_value_fields (bp, expr);
558
559 if (CODE_CONTAINS_STRUCT (code, TS_REAL_CST))
560 pack_ts_real_cst_value_fields (bp, expr);
561
562 if (CODE_CONTAINS_STRUCT (code, TS_FIXED_CST))
563 pack_ts_fixed_cst_value_fields (bp, expr);
564
565 if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
566 pack_ts_decl_common_value_fields (bp, expr);
567
568 if (CODE_CONTAINS_STRUCT (code, TS_DECL_WRTL))
569 pack_ts_decl_wrtl_value_fields (bp, expr);
570
571 if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS))
572 pack_ts_decl_with_vis_value_fields (bp, expr);
573
574 if (CODE_CONTAINS_STRUCT (code, TS_FUNCTION_DECL))
575 pack_ts_function_decl_value_fields (bp, expr);
576
577 if (CODE_CONTAINS_STRUCT (code, TS_TYPE))
578 pack_ts_type_value_fields (bp, expr);
579
580 if (CODE_CONTAINS_STRUCT (code, TS_BLOCK))
581 pack_ts_block_value_fields (bp, expr);
582
583 if (CODE_CONTAINS_STRUCT (code, TS_SSA_NAME))
584 {
585 /* We only stream the version number of SSA names. */
586 gcc_unreachable ();
587 }
588
589 if (CODE_CONTAINS_STRUCT (code, TS_STATEMENT_LIST))
590 {
591 /* This is only used by GENERIC. */
592 gcc_unreachable ();
593 }
594
595 if (CODE_CONTAINS_STRUCT (code, TS_OMP_CLAUSE))
596 {
597 /* This is only used by High GIMPLE. */
598 gcc_unreachable ();
599 }
600
601 return bp;
602 }
603
604
605 /* Emit location LOC to output block OB. */
606
607 static void
608 lto_output_location (struct output_block *ob, location_t loc)
609 {
610 expanded_location xloc;
611
612 if (loc == UNKNOWN_LOCATION)
613 {
614 output_string (ob, ob->main_stream, NULL);
615 return;
616 }
617
618 xloc = expand_location (loc);
619
620 output_string (ob, ob->main_stream, xloc.file);
621 output_sleb128 (ob, xloc.line);
622 output_sleb128 (ob, xloc.column);
623 output_sleb128 (ob, xloc.sysp);
624
625 ob->current_file = xloc.file;
626 ob->current_line = xloc.line;
627 ob->current_col = xloc.column;
628 }
629
630
631 /* Return true if tree node T is written to various tables. For these
632 nodes, we sometimes want to write their phyiscal representation
633 (via lto_output_tree), and sometimes we need to emit an index
634 reference into a table (via lto_output_tree_ref). */
635
636 static bool
637 tree_is_indexable (tree t)
638 {
639 if (TREE_CODE (t) == PARM_DECL)
640 return false;
641 else if (TREE_CODE (t) == VAR_DECL && decl_function_context (t))
642 return false;
643 else
644 return (TYPE_P (t) || DECL_P (t) || TREE_CODE (t) == SSA_NAME);
645 }
646
647
648 /* If EXPR is an indexable tree node, output a reference to it to
649 output block OB. Otherwise, output the physical representation of
650 EXPR to OB. */
651
652 static void
653 lto_output_tree_ref (struct output_block *ob, tree expr)
654 {
655 enum tree_code code;
656
657 if (expr == NULL_TREE)
658 {
659 output_zero (ob);
660 return;
661 }
662
663 if (!tree_is_indexable (expr))
664 {
665 /* Even though we are emitting the physical representation of
666 EXPR, its leaves must be emitted as references. */
667 lto_output_tree (ob, expr, true);
668 return;
669 }
670
671 if (TYPE_P (expr))
672 {
673 output_type_ref (ob, expr);
674 return;
675 }
676
677 code = TREE_CODE (expr);
678 switch (code)
679 {
680 case SSA_NAME:
681 output_record_start (ob, LTO_ssa_name_ref);
682 output_uleb128 (ob, SSA_NAME_VERSION (expr));
683 break;
684
685 case FIELD_DECL:
686 output_record_start (ob, LTO_field_decl_ref);
687 lto_output_field_decl_index (ob->decl_state, ob->main_stream, expr);
688 break;
689
690 case FUNCTION_DECL:
691 output_record_start (ob, LTO_function_decl_ref);
692 lto_output_fn_decl_index (ob->decl_state, ob->main_stream, expr);
693 break;
694
695 case VAR_DECL:
696 case DEBUG_EXPR_DECL:
697 gcc_assert (decl_function_context (expr) == NULL);
698 output_record_start (ob, LTO_global_decl_ref);
699 lto_output_var_decl_index (ob->decl_state, ob->main_stream, expr);
700 break;
701
702 case CONST_DECL:
703 output_record_start (ob, LTO_const_decl_ref);
704 lto_output_var_decl_index (ob->decl_state, ob->main_stream, expr);
705 break;
706
707 case IMPORTED_DECL:
708 gcc_assert (decl_function_context (expr) == NULL);
709 output_record_start (ob, LTO_imported_decl_ref);
710 lto_output_var_decl_index (ob->decl_state, ob->main_stream, expr);
711 break;
712
713 case TYPE_DECL:
714 output_record_start (ob, LTO_type_decl_ref);
715 lto_output_type_decl_index (ob->decl_state, ob->main_stream, expr);
716 break;
717
718 case NAMESPACE_DECL:
719 output_record_start (ob, LTO_namespace_decl_ref);
720 lto_output_namespace_decl_index (ob->decl_state, ob->main_stream, expr);
721 break;
722
723 case LABEL_DECL:
724 output_record_start (ob, LTO_label_decl_ref);
725 lto_output_var_decl_index (ob->decl_state, ob->main_stream, expr);
726 break;
727
728 case RESULT_DECL:
729 output_record_start (ob, LTO_result_decl_ref);
730 lto_output_var_decl_index (ob->decl_state, ob->main_stream, expr);
731 break;
732
733 default:
734 /* No other node is indexable, so it should have been handled
735 by lto_output_tree. */
736 gcc_unreachable ();
737 }
738 }
739
740
741 /* If REF_P is true, emit a reference to EXPR in output block OB,
742 otherwise emit the physical representation of EXPR in OB. */
743
744 static inline void
745 lto_output_tree_or_ref (struct output_block *ob, tree expr, bool ref_p)
746 {
747 if (ref_p)
748 lto_output_tree_ref (ob, expr);
749 else
750 lto_output_tree (ob, expr, false);
751 }
752
753
754 /* Emit the chain of tree nodes starting at T. OB is the output block
755 to write to. REF_P is true if chain elements should be emitted
756 as references. */
757
758 static void
759 lto_output_chain (struct output_block *ob, tree t, bool ref_p)
760 {
761 int i, count;
762
763 count = list_length (t);
764 output_sleb128 (ob, count);
765 for (i = 0; i < count; i++)
766 {
767 tree saved_chain;
768
769 /* Clear TREE_CHAIN to avoid blindly recursing into the rest
770 of the list. */
771 saved_chain = TREE_CHAIN (t);
772 TREE_CHAIN (t) = NULL_TREE;
773
774 lto_output_tree_or_ref (ob, t, ref_p);
775
776 TREE_CHAIN (t) = saved_chain;
777 t = TREE_CHAIN (t);
778 }
779 }
780
781
782 /* Write all pointer fields in the TS_COMMON structure of EXPR to output
783 block OB. If REF_P is true, write a reference to EXPR's pointer
784 fields. */
785
786 static void
787 lto_output_ts_common_tree_pointers (struct output_block *ob, tree expr,
788 bool ref_p)
789 {
790 lto_output_tree_or_ref (ob, TREE_TYPE (expr), ref_p);
791 }
792
793
794 /* Write all pointer fields in the TS_VECTOR structure of EXPR to output
795 block OB. If REF_P is true, write a reference to EXPR's pointer
796 fields. */
797
798 static void
799 lto_output_ts_vector_tree_pointers (struct output_block *ob, tree expr,
800 bool ref_p)
801 {
802 lto_output_chain (ob, TREE_VECTOR_CST_ELTS (expr), ref_p);
803 }
804
805
806 /* Write all pointer fields in the TS_COMPLEX structure of EXPR to output
807 block OB. If REF_P is true, write a reference to EXPR's pointer
808 fields. */
809
810 static void
811 lto_output_ts_complex_tree_pointers (struct output_block *ob, tree expr,
812 bool ref_p)
813 {
814 lto_output_tree_or_ref (ob, TREE_REALPART (expr), ref_p);
815 lto_output_tree_or_ref (ob, TREE_IMAGPART (expr), ref_p);
816 }
817
818
819 /* Write all pointer fields in the TS_DECL_MINIMAL structure of EXPR
820 to output block OB. If REF_P is true, write a reference to EXPR's
821 pointer fields. */
822
823 static void
824 lto_output_ts_decl_minimal_tree_pointers (struct output_block *ob, tree expr,
825 bool ref_p)
826 {
827 lto_output_tree_or_ref (ob, DECL_NAME (expr), ref_p);
828 lto_output_tree_or_ref (ob, DECL_CONTEXT (expr), ref_p);
829 lto_output_location (ob, DECL_SOURCE_LOCATION (expr));
830 }
831
832
833 /* Write all pointer fields in the TS_DECL_COMMON structure of EXPR to
834 output block OB. If REF_P is true, write a reference to EXPR's
835 pointer fields. */
836
837 static void
838 lto_output_ts_decl_common_tree_pointers (struct output_block *ob, tree expr,
839 bool ref_p)
840 {
841 lto_output_tree_or_ref (ob, DECL_SIZE (expr), ref_p);
842 lto_output_tree_or_ref (ob, DECL_SIZE_UNIT (expr), ref_p);
843
844 if (TREE_CODE (expr) != FUNCTION_DECL)
845 lto_output_tree_or_ref (ob, DECL_INITIAL (expr), ref_p);
846
847 lto_output_tree_or_ref (ob, DECL_ATTRIBUTES (expr), ref_p);
848 lto_output_tree_or_ref (ob, DECL_ABSTRACT_ORIGIN (expr), ref_p);
849
850 if (TREE_CODE (expr) == PARM_DECL)
851 lto_output_chain (ob, TREE_CHAIN (expr), ref_p);
852
853 if ((TREE_CODE (expr) == VAR_DECL
854 || TREE_CODE (expr) == PARM_DECL)
855 && DECL_HAS_VALUE_EXPR_P (expr))
856 lto_output_tree_or_ref (ob, DECL_VALUE_EXPR (expr), ref_p);
857 }
858
859
860 /* Write all pointer fields in the TS_DECL_NON_COMMON structure of
861 EXPR to output block OB. If REF_P is true, write a reference to EXPR's
862 pointer fields. */
863
864 static void
865 lto_output_ts_decl_non_common_tree_pointers (struct output_block *ob,
866 tree expr, bool ref_p)
867 {
868 if (TREE_CODE (expr) == FUNCTION_DECL)
869 {
870 /* DECL_SAVED_TREE holds the GENERIC representation for DECL.
871 At this point, it should not exist. Either because it was
872 converted to gimple or because DECL didn't have a GENERIC
873 representation in this TU. */
874 gcc_assert (DECL_SAVED_TREE (expr) == NULL_TREE);
875 lto_output_tree_or_ref (ob, DECL_ARGUMENTS (expr), ref_p);
876 lto_output_tree_or_ref (ob, DECL_RESULT (expr), ref_p);
877 }
878 lto_output_tree_or_ref (ob, DECL_VINDEX (expr), ref_p);
879 }
880
881
882 /* Write all pointer fields in the TS_DECL_WITH_VIS structure of EXPR
883 to output block OB. If REF_P is true, write a reference to EXPR's
884 pointer fields. */
885
886 static void
887 lto_output_ts_decl_with_vis_tree_pointers (struct output_block *ob, tree expr,
888 bool ref_p)
889 {
890 /* Make sure we don't inadvertently set the assembler name. */
891 if (DECL_ASSEMBLER_NAME_SET_P (expr))
892 lto_output_tree_or_ref (ob, DECL_ASSEMBLER_NAME (expr), ref_p);
893 else
894 output_zero (ob);
895
896 lto_output_tree_or_ref (ob, DECL_SECTION_NAME (expr), ref_p);
897 lto_output_tree_or_ref (ob, DECL_COMDAT_GROUP (expr), ref_p);
898 }
899
900
901 /* Write all pointer fields in the TS_FIELD_DECL structure of EXPR to
902 output block OB. If REF_P is true, write a reference to EXPR's
903 pointer fields. */
904
905 static void
906 lto_output_ts_field_decl_tree_pointers (struct output_block *ob, tree expr,
907 bool ref_p)
908 {
909 lto_output_tree_or_ref (ob, DECL_FIELD_OFFSET (expr), ref_p);
910 lto_output_tree_or_ref (ob, DECL_BIT_FIELD_TYPE (expr), ref_p);
911 lto_output_tree_or_ref (ob, DECL_QUALIFIER (expr), ref_p);
912 lto_output_tree_or_ref (ob, DECL_FIELD_BIT_OFFSET (expr), ref_p);
913 lto_output_tree_or_ref (ob, DECL_FCONTEXT (expr), ref_p);
914 lto_output_chain (ob, TREE_CHAIN (expr), ref_p);
915 }
916
917
918 /* Write all pointer fields in the TS_FUNCTION_DECL structure of EXPR
919 to output block OB. If REF_P is true, write a reference to EXPR's
920 pointer fields. */
921
922 static void
923 lto_output_ts_function_decl_tree_pointers (struct output_block *ob, tree expr,
924 bool ref_p)
925 {
926 /* DECL_STRUCT_FUNCTION is handled by lto_output_function. FIXME lto,
927 maybe it should be handled here? */
928 lto_output_tree_or_ref (ob, DECL_FUNCTION_PERSONALITY (expr), ref_p);
929 lto_output_tree_or_ref (ob, DECL_FUNCTION_SPECIFIC_TARGET (expr), ref_p);
930 lto_output_tree_or_ref (ob, DECL_FUNCTION_SPECIFIC_OPTIMIZATION (expr),
931 ref_p);
932 }
933
934
935 /* Write all pointer fields in the TS_TYPE structure of EXPR to output
936 block OB. If REF_P is true, write a reference to EXPR's pointer
937 fields. */
938
939 static void
940 lto_output_ts_type_tree_pointers (struct output_block *ob, tree expr,
941 bool ref_p)
942 {
943 if (TREE_CODE (expr) == ENUMERAL_TYPE)
944 lto_output_tree_or_ref (ob, TYPE_VALUES (expr), ref_p);
945 else if (TREE_CODE (expr) == ARRAY_TYPE)
946 lto_output_tree_or_ref (ob, TYPE_DOMAIN (expr), ref_p);
947 else if (TREE_CODE (expr) == RECORD_TYPE || TREE_CODE (expr) == UNION_TYPE)
948 lto_output_tree_or_ref (ob, TYPE_FIELDS (expr), ref_p);
949 else if (TREE_CODE (expr) == FUNCTION_TYPE || TREE_CODE (expr) == METHOD_TYPE)
950 lto_output_tree_or_ref (ob, TYPE_ARG_TYPES (expr), ref_p);
951 else if (TREE_CODE (expr) == VECTOR_TYPE)
952 lto_output_tree_or_ref (ob, TYPE_DEBUG_REPRESENTATION_TYPE (expr), ref_p);
953
954 lto_output_tree_or_ref (ob, TYPE_SIZE (expr), ref_p);
955 lto_output_tree_or_ref (ob, TYPE_SIZE_UNIT (expr), ref_p);
956 lto_output_tree_or_ref (ob, TYPE_ATTRIBUTES (expr), ref_p);
957 lto_output_tree_or_ref (ob, TYPE_NAME (expr), ref_p);
958 /* Do not stream TYPE_POINTER_TO or TYPE_REFERENCE_TO nor
959 TYPE_NEXT_PTR_TO or TYPE_NEXT_REF_TO. */
960 if (!POINTER_TYPE_P (expr))
961 lto_output_tree_or_ref (ob, TYPE_MINVAL (expr), ref_p);
962 lto_output_tree_or_ref (ob, TYPE_MAXVAL (expr), ref_p);
963 lto_output_tree_or_ref (ob, TYPE_MAIN_VARIANT (expr), ref_p);
964 /* Do not stream TYPE_NEXT_VARIANT, we reconstruct the variant lists
965 during fixup. */
966 if (TREE_CODE (expr) == RECORD_TYPE || TREE_CODE (expr) == UNION_TYPE)
967 lto_output_tree_or_ref (ob, TYPE_BINFO (expr), ref_p);
968 lto_output_tree_or_ref (ob, TYPE_CONTEXT (expr), ref_p);
969 lto_output_tree_or_ref (ob, TYPE_CANONICAL (expr), ref_p);
970 lto_output_tree_or_ref (ob, TYPE_STUB_DECL (expr), ref_p);
971 }
972
973
974 /* Write all pointer fields in the TS_LIST structure of EXPR to output
975 block OB. If REF_P is true, write a reference to EXPR's pointer
976 fields. */
977
978 static void
979 lto_output_ts_list_tree_pointers (struct output_block *ob, tree expr,
980 bool ref_p)
981 {
982 lto_output_tree_or_ref (ob, TREE_PURPOSE (expr), ref_p);
983 lto_output_tree_or_ref (ob, TREE_VALUE (expr), ref_p);
984 lto_output_chain (ob, TREE_CHAIN (expr), ref_p);
985 }
986
987
988 /* Write all pointer fields in the TS_VEC structure of EXPR to output
989 block OB. If REF_P is true, write a reference to EXPR's pointer
990 fields. */
991
992 static void
993 lto_output_ts_vec_tree_pointers (struct output_block *ob, tree expr, bool ref_p)
994 {
995 int i;
996
997 /* Note that the number of slots for EXPR has already been emitted
998 in EXPR's header (see lto_output_tree_header). */
999 for (i = 0; i < TREE_VEC_LENGTH (expr); i++)
1000 lto_output_tree_or_ref (ob, TREE_VEC_ELT (expr, i), ref_p);
1001 }
1002
1003
1004 /* Write all pointer fields in the TS_EXP structure of EXPR to output
1005 block OB. If REF_P is true, write a reference to EXPR's pointer
1006 fields. */
1007
1008 static void
1009 lto_output_ts_exp_tree_pointers (struct output_block *ob, tree expr, bool ref_p)
1010 {
1011 int i;
1012
1013 output_sleb128 (ob, TREE_OPERAND_LENGTH (expr));
1014 for (i = 0; i < TREE_OPERAND_LENGTH (expr); i++)
1015 lto_output_tree_or_ref (ob, TREE_OPERAND (expr, i), ref_p);
1016 lto_output_location (ob, EXPR_LOCATION (expr));
1017 lto_output_tree_or_ref (ob, TREE_BLOCK (expr), ref_p);
1018 }
1019
1020
1021 /* Write all pointer fields in the TS_BLOCK structure of EXPR to output
1022 block OB. If REF_P is true, write a reference to EXPR's pointer
1023 fields. */
1024
1025 static void
1026 lto_output_ts_block_tree_pointers (struct output_block *ob, tree expr,
1027 bool ref_p)
1028 {
1029 unsigned i;
1030 tree t;
1031
1032 lto_output_location (ob, BLOCK_SOURCE_LOCATION (expr));
1033 lto_output_chain (ob, BLOCK_VARS (expr), ref_p);
1034
1035 output_uleb128 (ob, VEC_length (tree, BLOCK_NONLOCALIZED_VARS (expr)));
1036 for (i = 0; VEC_iterate (tree, BLOCK_NONLOCALIZED_VARS (expr), i, t); i++)
1037 lto_output_tree_or_ref (ob, t, ref_p);
1038
1039 lto_output_tree_or_ref (ob, BLOCK_SUPERCONTEXT (expr), ref_p);
1040 lto_output_tree_or_ref (ob, BLOCK_ABSTRACT_ORIGIN (expr), ref_p);
1041 lto_output_tree_or_ref (ob, BLOCK_FRAGMENT_ORIGIN (expr), ref_p);
1042 lto_output_tree_or_ref (ob, BLOCK_FRAGMENT_CHAIN (expr), ref_p);
1043 lto_output_chain (ob, BLOCK_SUBBLOCKS (expr), ref_p);
1044 }
1045
1046
1047 /* Write all pointer fields in the TS_BINFO structure of EXPR to output
1048 block OB. If REF_P is true, write a reference to EXPR's pointer
1049 fields. */
1050
1051 static void
1052 lto_output_ts_binfo_tree_pointers (struct output_block *ob, tree expr,
1053 bool ref_p)
1054 {
1055 unsigned i;
1056 tree t;
1057
1058 /* Note that the number of BINFO slots has already been emitted in
1059 EXPR's header (see lto_output_tree_header) because this length
1060 is needed to build the empty BINFO node on the reader side. */
1061 for (i = 0; VEC_iterate (tree, BINFO_BASE_BINFOS (expr), i, t); i++)
1062 lto_output_tree_or_ref (ob, t, ref_p);
1063 output_zero (ob);
1064
1065 lto_output_tree_or_ref (ob, BINFO_OFFSET (expr), ref_p);
1066 lto_output_tree_or_ref (ob, BINFO_VTABLE (expr), ref_p);
1067 lto_output_tree_or_ref (ob, BINFO_VIRTUALS (expr), ref_p);
1068 lto_output_tree_or_ref (ob, BINFO_VPTR_FIELD (expr), ref_p);
1069
1070 output_uleb128 (ob, VEC_length (tree, BINFO_BASE_ACCESSES (expr)));
1071 for (i = 0; VEC_iterate (tree, BINFO_BASE_ACCESSES (expr), i, t); i++)
1072 lto_output_tree_or_ref (ob, t, ref_p);
1073
1074 lto_output_tree_or_ref (ob, BINFO_INHERITANCE_CHAIN (expr), ref_p);
1075 lto_output_tree_or_ref (ob, BINFO_SUBVTT_INDEX (expr), ref_p);
1076 lto_output_tree_or_ref (ob, BINFO_VPTR_INDEX (expr), ref_p);
1077 }
1078
1079
1080 /* Write all pointer fields in the TS_CONSTRUCTOR structure of EXPR to
1081 output block OB. If REF_P is true, write a reference to EXPR's
1082 pointer fields. */
1083
1084 static void
1085 lto_output_ts_constructor_tree_pointers (struct output_block *ob, tree expr,
1086 bool ref_p)
1087 {
1088 unsigned i;
1089 tree index, value;
1090
1091 output_uleb128 (ob, CONSTRUCTOR_NELTS (expr));
1092 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (expr), i, index, value)
1093 {
1094 lto_output_tree_or_ref (ob, index, ref_p);
1095 lto_output_tree_or_ref (ob, value, ref_p);
1096 }
1097 }
1098
1099
1100 /* Helper for lto_output_tree. Write all pointer fields in EXPR to output
1101 block OB. If REF_P is true, the leaves of EXPR are emitted as
1102 references. */
1103
1104 static void
1105 lto_output_tree_pointers (struct output_block *ob, tree expr, bool ref_p)
1106 {
1107 enum tree_code code;
1108
1109 code = TREE_CODE (expr);
1110
1111 if (CODE_CONTAINS_STRUCT (code, TS_COMMON))
1112 lto_output_ts_common_tree_pointers (ob, expr, ref_p);
1113
1114 if (CODE_CONTAINS_STRUCT (code, TS_VECTOR))
1115 lto_output_ts_vector_tree_pointers (ob, expr, ref_p);
1116
1117 if (CODE_CONTAINS_STRUCT (code, TS_COMPLEX))
1118 lto_output_ts_complex_tree_pointers (ob, expr, ref_p);
1119
1120 if (CODE_CONTAINS_STRUCT (code, TS_DECL_MINIMAL))
1121 lto_output_ts_decl_minimal_tree_pointers (ob, expr, ref_p);
1122
1123 if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
1124 lto_output_ts_decl_common_tree_pointers (ob, expr, ref_p);
1125
1126 if (CODE_CONTAINS_STRUCT (code, TS_DECL_NON_COMMON))
1127 lto_output_ts_decl_non_common_tree_pointers (ob, expr, ref_p);
1128
1129 if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS))
1130 lto_output_ts_decl_with_vis_tree_pointers (ob, expr, ref_p);
1131
1132 if (CODE_CONTAINS_STRUCT (code, TS_FIELD_DECL))
1133 lto_output_ts_field_decl_tree_pointers (ob, expr, ref_p);
1134
1135 if (CODE_CONTAINS_STRUCT (code, TS_FUNCTION_DECL))
1136 lto_output_ts_function_decl_tree_pointers (ob, expr, ref_p);
1137
1138 if (CODE_CONTAINS_STRUCT (code, TS_TYPE))
1139 lto_output_ts_type_tree_pointers (ob, expr, ref_p);
1140
1141 if (CODE_CONTAINS_STRUCT (code, TS_LIST))
1142 lto_output_ts_list_tree_pointers (ob, expr, ref_p);
1143
1144 if (CODE_CONTAINS_STRUCT (code, TS_VEC))
1145 lto_output_ts_vec_tree_pointers (ob, expr, ref_p);
1146
1147 if (CODE_CONTAINS_STRUCT (code, TS_EXP))
1148 lto_output_ts_exp_tree_pointers (ob, expr, ref_p);
1149
1150 if (CODE_CONTAINS_STRUCT (code, TS_SSA_NAME))
1151 {
1152 /* We only stream the version number of SSA names. */
1153 gcc_unreachable ();
1154 }
1155
1156 if (CODE_CONTAINS_STRUCT (code, TS_BLOCK))
1157 lto_output_ts_block_tree_pointers (ob, expr, ref_p);
1158
1159 if (CODE_CONTAINS_STRUCT (code, TS_BINFO))
1160 lto_output_ts_binfo_tree_pointers (ob, expr, ref_p);
1161
1162 if (CODE_CONTAINS_STRUCT (code, TS_CONSTRUCTOR))
1163 lto_output_ts_constructor_tree_pointers (ob, expr, ref_p);
1164
1165 if (CODE_CONTAINS_STRUCT (code, TS_STATEMENT_LIST))
1166 {
1167 /* This should only appear in GENERIC. */
1168 gcc_unreachable ();
1169 }
1170
1171 if (CODE_CONTAINS_STRUCT (code, TS_OMP_CLAUSE))
1172 {
1173 /* This should only appear in High GIMPLE. */
1174 gcc_unreachable ();
1175 }
1176
1177 if (CODE_CONTAINS_STRUCT (code, TS_OPTIMIZATION))
1178 sorry ("gimple bytecode streams do not support the optimization attribute");
1179
1180 if (CODE_CONTAINS_STRUCT (code, TS_TARGET_OPTION))
1181 sorry ("gimple bytecode streams do not support the target attribute");
1182 }
1183
1184
1185 /* Emit header information for tree EXPR to output block OB. The header
1186 contains everything needed to instantiate an empty skeleton for
1187 EXPR on the reading side. IX is the index into the streamer cache
1188 where EXPR is stored. REF_P is as in lto_output_tree. */
1189
1190 static void
1191 lto_output_tree_header (struct output_block *ob, tree expr, int ix)
1192 {
1193 enum LTO_tags tag;
1194 enum tree_code code;
1195
1196 /* We should not see any non-GIMPLE tree nodes here. */
1197 code = TREE_CODE (expr);
1198 if (!lto_is_streamable (expr))
1199 internal_error ("tree code %qs is not supported in gimple streams",
1200 tree_code_name[code]);
1201
1202 /* The header of a tree node consists of its tag, the size of
1203 the node, and any other information needed to instantiate
1204 EXPR on the reading side (such as the number of slots in
1205 variable sized nodes). */
1206 tag = lto_tree_code_to_tag (code);
1207 output_record_start (ob, tag);
1208 output_sleb128 (ob, ix);
1209
1210 /* The following will cause bootstrap miscomparisons. Enable with care. */
1211 #ifdef LTO_STREAMER_DEBUG
1212 /* This is used mainly for debugging purposes. When the reader
1213 and the writer do not agree on a streamed node, the pointer
1214 value for EXPR can be used to track down the differences in
1215 the debugger. */
1216 gcc_assert ((HOST_WIDEST_INT) (intptr_t) expr == (intptr_t) expr);
1217 output_sleb128 (ob, (HOST_WIDEST_INT) (intptr_t) expr);
1218 #endif
1219
1220 /* The text in strings and identifiers are completely emitted in
1221 the header. */
1222 if (CODE_CONTAINS_STRUCT (code, TS_STRING))
1223 output_string_cst (ob, ob->main_stream, expr);
1224 else if (CODE_CONTAINS_STRUCT (code, TS_IDENTIFIER))
1225 output_identifier (ob, ob->main_stream, expr);
1226 else if (CODE_CONTAINS_STRUCT (code, TS_VEC))
1227 output_sleb128 (ob, TREE_VEC_LENGTH (expr));
1228 else if (CODE_CONTAINS_STRUCT (code, TS_BINFO))
1229 output_uleb128 (ob, BINFO_N_BASE_BINFOS (expr));
1230 }
1231
1232
1233 /* Write the code and class of builtin EXPR to output block OB. IX is
1234 the index into the streamer cache where EXPR is stored.*/
1235
1236 static void
1237 lto_output_builtin_tree (struct output_block *ob, tree expr, int ix)
1238 {
1239 gcc_assert (lto_stream_as_builtin_p (expr));
1240
1241 if (DECL_BUILT_IN_CLASS (expr) == BUILT_IN_MD
1242 && !targetm.builtin_decl)
1243 sorry ("gimple bytecode streams do not support machine specific builtin "
1244 "functions on this target");
1245
1246 output_record_start (ob, LTO_builtin_decl);
1247 output_uleb128 (ob, DECL_BUILT_IN_CLASS (expr));
1248 output_uleb128 (ob, DECL_FUNCTION_CODE (expr));
1249 output_sleb128 (ob, ix);
1250
1251 if (DECL_ASSEMBLER_NAME_SET_P (expr))
1252 {
1253 /* When the assembler name of a builtin gets a user name,
1254 the new name is always prefixed with '*' by
1255 set_builtin_user_assembler_name. So, to prevent the
1256 reader side from adding a second '*', we omit it here. */
1257 const char *str = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (expr));
1258 if (strlen (str) > 1 && str[0] == '*')
1259 output_string (ob, ob->main_stream, &str[1]);
1260 else
1261 output_string (ob, ob->main_stream, NULL);
1262 }
1263 else
1264 output_string (ob, ob->main_stream, NULL);
1265 }
1266
1267
1268 /* Write a physical representation of tree node EXPR to output block
1269 OB. If REF_P is true, the leaves of EXPR are emitted as references
1270 via lto_output_tree_ref. IX is the index into the streamer cache
1271 where EXPR is stored. */
1272
1273 static void
1274 lto_write_tree (struct output_block *ob, tree expr, bool ref_p, int ix)
1275 {
1276 struct bitpack_d *bp;
1277
1278 /* Write the header, containing everything needed to materialize
1279 EXPR on the reading side. */
1280 lto_output_tree_header (ob, expr, ix);
1281
1282 /* Pack all the non-pointer fields in EXPR into a bitpack and write
1283 the resulting bitpack. */
1284 bp = pack_value_fields (expr);
1285 lto_output_bitpack (ob->main_stream, bp);
1286 bitpack_delete (bp);
1287
1288 /* Write all the pointer fields in EXPR. */
1289 lto_output_tree_pointers (ob, expr, ref_p);
1290
1291 /* Mark the end of EXPR. */
1292 output_zero (ob);
1293 }
1294
1295
1296 /* Emit the integer constant CST to output block OB. If REF_P is true,
1297 CST's type will be emitted as a reference. */
1298
1299 static void
1300 lto_output_integer_cst (struct output_block *ob, tree cst, bool ref_p)
1301 {
1302 output_record_start (ob, lto_tree_code_to_tag (INTEGER_CST));
1303 lto_output_tree_or_ref (ob, TREE_TYPE (cst), ref_p);
1304 lto_output_1_stream (ob->main_stream, TREE_OVERFLOW_P (cst));
1305 output_uleb128 (ob, TREE_INT_CST_LOW (cst));
1306 output_uleb128 (ob, TREE_INT_CST_HIGH (cst));
1307 }
1308
1309
1310 /* Emit the physical representation of tree node EXPR to output block
1311 OB. If REF_P is true, the leaves of EXPR are emitted as references
1312 via lto_output_tree_ref. */
1313
1314 void
1315 lto_output_tree (struct output_block *ob, tree expr, bool ref_p)
1316 {
1317 int ix;
1318 bool existed_p;
1319 unsigned offset;
1320
1321 if (expr == NULL_TREE)
1322 {
1323 output_zero (ob);
1324 return;
1325 }
1326
1327 /* INTEGER_CST nodes are special because they need their original type
1328 to be materialized by the reader (to implement TYPE_CACHED_VALUES). */
1329 if (TREE_CODE (expr) == INTEGER_CST)
1330 {
1331 lto_output_integer_cst (ob, expr, ref_p);
1332 return;
1333 }
1334
1335 /* Determine the offset in the stream where EXPR will be written.
1336 This is used when emitting pickle references so the reader knows
1337 where to reconstruct the pickled object from. This allows
1338 circular and forward references within the same stream. */
1339 offset = ob->main_stream->total_size;
1340
1341 existed_p = lto_streamer_cache_insert (ob->writer_cache, expr, &ix, &offset);
1342 if (existed_p)
1343 {
1344 /* If a node has already been streamed out, make sure that
1345 we don't write it more than once. Otherwise, the reader
1346 will instantiate two different nodes for the same object. */
1347 output_record_start (ob, LTO_tree_pickle_reference);
1348 output_sleb128 (ob, ix);
1349 output_uleb128 (ob, lto_tree_code_to_tag (TREE_CODE (expr)));
1350 output_uleb128 (ob, offset);
1351 }
1352 else if (lto_stream_as_builtin_p (expr))
1353 {
1354 /* MD and NORMAL builtins do not need to be written out
1355 completely as they are always instantiated by the
1356 compiler on startup. The only builtins that need to
1357 be written out are BUILT_IN_FRONTEND. For all other
1358 builtins, we simply write the class and code. */
1359 lto_output_builtin_tree (ob, expr, ix);
1360 }
1361 else
1362 {
1363 /* This is the first time we see EXPR, write its fields
1364 to OB. */
1365 lto_write_tree (ob, expr, ref_p, ix);
1366 }
1367 }
1368
1369
1370 /* Output to OB a list of try/catch handlers starting with FIRST. */
1371
1372 static void
1373 output_eh_try_list (struct output_block *ob, eh_catch first)
1374 {
1375 eh_catch n;
1376
1377 for (n = first; n; n = n->next_catch)
1378 {
1379 output_record_start (ob, LTO_eh_catch);
1380 lto_output_tree_ref (ob, n->type_list);
1381 lto_output_tree_ref (ob, n->filter_list);
1382 lto_output_tree_ref (ob, n->label);
1383 }
1384
1385 output_zero (ob);
1386 }
1387
1388
1389 /* Output EH region R in function FN to OB. CURR_RN is the slot index
1390 that is being emitted in FN->EH->REGION_ARRAY. This is used to
1391 detect EH region sharing. */
1392
1393 static void
1394 output_eh_region (struct output_block *ob, eh_region r)
1395 {
1396 enum LTO_tags tag;
1397
1398 if (r == NULL)
1399 {
1400 output_zero (ob);
1401 return;
1402 }
1403
1404 if (r->type == ERT_CLEANUP)
1405 tag = LTO_ert_cleanup;
1406 else if (r->type == ERT_TRY)
1407 tag = LTO_ert_try;
1408 else if (r->type == ERT_ALLOWED_EXCEPTIONS)
1409 tag = LTO_ert_allowed_exceptions;
1410 else if (r->type == ERT_MUST_NOT_THROW)
1411 tag = LTO_ert_must_not_throw;
1412 else
1413 gcc_unreachable ();
1414
1415 output_record_start (ob, tag);
1416 output_sleb128 (ob, r->index);
1417
1418 if (r->outer)
1419 output_sleb128 (ob, r->outer->index);
1420 else
1421 output_zero (ob);
1422
1423 if (r->inner)
1424 output_sleb128 (ob, r->inner->index);
1425 else
1426 output_zero (ob);
1427
1428 if (r->next_peer)
1429 output_sleb128 (ob, r->next_peer->index);
1430 else
1431 output_zero (ob);
1432
1433 if (r->type == ERT_TRY)
1434 {
1435 output_eh_try_list (ob, r->u.eh_try.first_catch);
1436 }
1437 else if (r->type == ERT_ALLOWED_EXCEPTIONS)
1438 {
1439 lto_output_tree_ref (ob, r->u.allowed.type_list);
1440 lto_output_tree_ref (ob, r->u.allowed.label);
1441 output_uleb128 (ob, r->u.allowed.filter);
1442 }
1443 else if (r->type == ERT_MUST_NOT_THROW)
1444 {
1445 lto_output_tree_ref (ob, r->u.must_not_throw.failure_decl);
1446 lto_output_location (ob, r->u.must_not_throw.failure_loc);
1447 }
1448
1449 if (r->landing_pads)
1450 output_sleb128 (ob, r->landing_pads->index);
1451 else
1452 output_zero (ob);
1453 }
1454
1455
1456 /* Output landing pad LP to OB. */
1457
1458 static void
1459 output_eh_lp (struct output_block *ob, eh_landing_pad lp)
1460 {
1461 if (lp == NULL)
1462 {
1463 output_zero (ob);
1464 return;
1465 }
1466
1467 output_record_start (ob, LTO_eh_landing_pad);
1468 output_sleb128 (ob, lp->index);
1469 if (lp->next_lp)
1470 output_sleb128 (ob, lp->next_lp->index);
1471 else
1472 output_zero (ob);
1473
1474 if (lp->region)
1475 output_sleb128 (ob, lp->region->index);
1476 else
1477 output_zero (ob);
1478
1479 lto_output_tree_ref (ob, lp->post_landing_pad);
1480 }
1481
1482
1483 /* Output the existing eh_table to OB. */
1484
1485 static void
1486 output_eh_regions (struct output_block *ob, struct function *fn)
1487 {
1488 if (fn->eh && fn->eh->region_tree)
1489 {
1490 unsigned i;
1491 eh_region eh;
1492 eh_landing_pad lp;
1493 tree ttype;
1494
1495 output_record_start (ob, LTO_eh_table);
1496
1497 /* Emit the index of the root of the EH region tree. */
1498 output_sleb128 (ob, fn->eh->region_tree->index);
1499
1500 /* Emit all the EH regions in the region array. */
1501 output_sleb128 (ob, VEC_length (eh_region, fn->eh->region_array));
1502 for (i = 0; VEC_iterate (eh_region, fn->eh->region_array, i, eh); i++)
1503 output_eh_region (ob, eh);
1504
1505 /* Emit all landing pads. */
1506 output_sleb128 (ob, VEC_length (eh_landing_pad, fn->eh->lp_array));
1507 for (i = 0; VEC_iterate (eh_landing_pad, fn->eh->lp_array, i, lp); i++)
1508 output_eh_lp (ob, lp);
1509
1510 /* Emit all the runtime type data. */
1511 output_sleb128 (ob, VEC_length (tree, fn->eh->ttype_data));
1512 for (i = 0; VEC_iterate (tree, fn->eh->ttype_data, i, ttype); i++)
1513 lto_output_tree_ref (ob, ttype);
1514
1515 /* Emit the table of action chains. */
1516 if (targetm.arm_eabi_unwinder)
1517 {
1518 tree t;
1519 output_sleb128 (ob, VEC_length (tree, fn->eh->ehspec_data.arm_eabi));
1520 for (i = 0;
1521 VEC_iterate (tree, fn->eh->ehspec_data.arm_eabi, i, t);
1522 i++)
1523 lto_output_tree_ref (ob, t);
1524 }
1525 else
1526 {
1527 uchar c;
1528 output_sleb128 (ob, VEC_length (uchar, fn->eh->ehspec_data.other));
1529 for (i = 0; VEC_iterate (uchar, fn->eh->ehspec_data.other, i, c); i++)
1530 lto_output_1_stream (ob->main_stream, c);
1531 }
1532 }
1533
1534 /* The 0 either terminates the record or indicates that there are no
1535 eh_records at all. */
1536 output_zero (ob);
1537 }
1538
1539
1540 /* Output all of the active ssa names to the ssa_names stream. */
1541
1542 static void
1543 output_ssa_names (struct output_block *ob, struct function *fn)
1544 {
1545 unsigned int i, len;
1546
1547 len = VEC_length (tree, SSANAMES (fn));
1548 output_uleb128 (ob, len);
1549
1550 for (i = 1; i < len; i++)
1551 {
1552 tree ptr = VEC_index (tree, SSANAMES (fn), i);
1553
1554 if (ptr == NULL_TREE
1555 || SSA_NAME_IN_FREE_LIST (ptr)
1556 || !is_gimple_reg (ptr))
1557 continue;
1558
1559 output_uleb128 (ob, i);
1560 lto_output_1_stream (ob->main_stream, SSA_NAME_IS_DEFAULT_DEF (ptr));
1561 lto_output_tree_ref (ob, SSA_NAME_VAR (ptr));
1562 }
1563
1564 output_zero (ob);
1565 }
1566
1567
1568 /* Output the cfg. */
1569
1570 static void
1571 output_cfg (struct output_block *ob, struct function *fn)
1572 {
1573 struct lto_output_stream *tmp_stream = ob->main_stream;
1574 basic_block bb;
1575
1576 ob->main_stream = ob->cfg_stream;
1577
1578 output_uleb128 (ob, profile_status_for_function (fn));
1579
1580 /* Output the number of the highest basic block. */
1581 output_uleb128 (ob, last_basic_block_for_function (fn));
1582
1583 FOR_ALL_BB_FN (bb, fn)
1584 {
1585 edge_iterator ei;
1586 edge e;
1587
1588 output_sleb128 (ob, bb->index);
1589
1590 /* Output the successors and the edge flags. */
1591 output_uleb128 (ob, EDGE_COUNT (bb->succs));
1592 FOR_EACH_EDGE (e, ei, bb->succs)
1593 {
1594 output_uleb128 (ob, e->dest->index);
1595 output_sleb128 (ob, e->probability);
1596 output_sleb128 (ob, e->count);
1597 output_uleb128 (ob, e->flags);
1598 }
1599 }
1600
1601 output_sleb128 (ob, -1);
1602
1603 bb = ENTRY_BLOCK_PTR;
1604 while (bb->next_bb)
1605 {
1606 output_sleb128 (ob, bb->next_bb->index);
1607 bb = bb->next_bb;
1608 }
1609
1610 output_sleb128 (ob, -1);
1611
1612 ob->main_stream = tmp_stream;
1613 }
1614
1615
1616 /* Output PHI function PHI to the main stream in OB. */
1617
1618 static void
1619 output_phi (struct output_block *ob, gimple phi)
1620 {
1621 unsigned i, len = gimple_phi_num_args (phi);
1622
1623 output_record_start (ob, lto_gimple_code_to_tag (GIMPLE_PHI));
1624 output_uleb128 (ob, SSA_NAME_VERSION (PHI_RESULT (phi)));
1625
1626 for (i = 0; i < len; i++)
1627 {
1628 lto_output_tree_ref (ob, gimple_phi_arg_def (phi, i));
1629 output_uleb128 (ob, gimple_phi_arg_edge (phi, i)->src->index);
1630 lto_output_location (ob, gimple_phi_arg_location (phi, i));
1631 }
1632 }
1633
1634
1635 /* Emit statement STMT on the main stream of output block OB. */
1636
1637 static void
1638 output_gimple_stmt (struct output_block *ob, gimple stmt)
1639 {
1640 unsigned i;
1641 enum gimple_code code;
1642 enum LTO_tags tag;
1643 struct bitpack_d *bp;
1644
1645 /* Emit identifying tag. */
1646 code = gimple_code (stmt);
1647 tag = lto_gimple_code_to_tag (code);
1648 output_record_start (ob, tag);
1649
1650 /* Emit the tuple header. */
1651 bp = bitpack_create ();
1652 bp_pack_value (bp, gimple_num_ops (stmt), sizeof (unsigned) * 8);
1653 bp_pack_value (bp, gimple_no_warning_p (stmt), 1);
1654 if (is_gimple_assign (stmt))
1655 bp_pack_value (bp, gimple_assign_nontemporal_move_p (stmt), 1);
1656 bp_pack_value (bp, gimple_has_volatile_ops (stmt), 1);
1657 bp_pack_value (bp, stmt->gsbase.subcode, 16);
1658 lto_output_bitpack (ob->main_stream, bp);
1659 bitpack_delete (bp);
1660
1661 /* Emit location information for the statement. */
1662 lto_output_location (ob, gimple_location (stmt));
1663
1664 /* Emit the lexical block holding STMT. */
1665 lto_output_tree (ob, gimple_block (stmt), true);
1666
1667 /* Emit the operands. */
1668 switch (gimple_code (stmt))
1669 {
1670 case GIMPLE_RESX:
1671 output_sleb128 (ob, gimple_resx_region (stmt));
1672 break;
1673
1674 case GIMPLE_EH_MUST_NOT_THROW:
1675 lto_output_tree_ref (ob, gimple_eh_must_not_throw_fndecl (stmt));
1676 break;
1677
1678 case GIMPLE_EH_DISPATCH:
1679 output_sleb128 (ob, gimple_eh_dispatch_region (stmt));
1680 break;
1681
1682 case GIMPLE_ASM:
1683 lto_output_uleb128_stream (ob->main_stream, gimple_asm_ninputs (stmt));
1684 lto_output_uleb128_stream (ob->main_stream, gimple_asm_noutputs (stmt));
1685 lto_output_uleb128_stream (ob->main_stream, gimple_asm_nclobbers (stmt));
1686 output_string (ob, ob->main_stream, gimple_asm_string (stmt));
1687 /* Fallthru */
1688
1689 case GIMPLE_ASSIGN:
1690 case GIMPLE_CALL:
1691 case GIMPLE_RETURN:
1692 case GIMPLE_SWITCH:
1693 case GIMPLE_LABEL:
1694 case GIMPLE_COND:
1695 case GIMPLE_GOTO:
1696 case GIMPLE_DEBUG:
1697 for (i = 0; i < gimple_num_ops (stmt); i++)
1698 {
1699 tree op = gimple_op (stmt, i);
1700 lto_output_tree_ref (ob, op);
1701 }
1702 break;
1703
1704 case GIMPLE_NOP:
1705 case GIMPLE_PREDICT:
1706 break;
1707
1708 default:
1709 gcc_unreachable ();
1710 }
1711 }
1712
1713
1714 /* Output a basic block BB to the main stream in OB for this FN. */
1715
1716 static void
1717 output_bb (struct output_block *ob, basic_block bb, struct function *fn)
1718 {
1719 gimple_stmt_iterator bsi = gsi_start_bb (bb);
1720
1721 output_record_start (ob,
1722 (!gsi_end_p (bsi)) || phi_nodes (bb)
1723 ? LTO_bb1
1724 : LTO_bb0);
1725
1726 output_uleb128 (ob, bb->index);
1727 output_sleb128 (ob, bb->count);
1728 output_sleb128 (ob, bb->loop_depth);
1729 output_sleb128 (ob, bb->frequency);
1730 output_sleb128 (ob, bb->flags);
1731
1732 if (!gsi_end_p (bsi) || phi_nodes (bb))
1733 {
1734 /* Output the statements. The list of statements is terminated
1735 with a zero. */
1736 for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi))
1737 {
1738 int region;
1739 gimple stmt = gsi_stmt (bsi);
1740
1741 output_gimple_stmt (ob, stmt);
1742
1743 /* Emit the EH region holding STMT. */
1744 region = lookup_stmt_eh_lp_fn (fn, stmt);
1745 if (region != 0)
1746 {
1747 output_record_start (ob, LTO_eh_region);
1748 output_sleb128 (ob, region);
1749 }
1750 else
1751 output_zero (ob);
1752 }
1753
1754 output_zero (ob);
1755
1756 for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); gsi_next (&bsi))
1757 {
1758 gimple phi = gsi_stmt (bsi);
1759
1760 /* Only emit PHIs for gimple registers. PHI nodes for .MEM
1761 will be filled in on reading when the SSA form is
1762 updated. */
1763 if (is_gimple_reg (gimple_phi_result (phi)))
1764 output_phi (ob, phi);
1765 }
1766
1767 output_zero (ob);
1768 }
1769 }
1770
1771 /* Create the header in the file using OB. If the section type is for
1772 a function, set FN to the decl for that function. */
1773
1774 void
1775 produce_asm (struct output_block *ob, tree fn)
1776 {
1777 enum lto_section_type section_type = ob->section_type;
1778 struct lto_function_header header;
1779 char *section_name;
1780 struct lto_output_stream *header_stream;
1781
1782 if (section_type == LTO_section_function_body)
1783 {
1784 const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fn));
1785 section_name = lto_get_section_name (section_type, name);
1786 }
1787 else
1788 section_name = lto_get_section_name (section_type, NULL);
1789
1790 lto_begin_section (section_name, !flag_wpa);
1791 free (section_name);
1792
1793 /* The entire header is stream computed here. */
1794 memset (&header, 0, sizeof (struct lto_function_header));
1795
1796 /* Write the header. */
1797 header.lto_header.major_version = LTO_major_version;
1798 header.lto_header.minor_version = LTO_minor_version;
1799 header.lto_header.section_type = section_type;
1800
1801 header.compressed_size = 0;
1802
1803 if (section_type == LTO_section_function_body)
1804 header.cfg_size = ob->cfg_stream->total_size;
1805 header.main_size = ob->main_stream->total_size;
1806 header.string_size = ob->string_stream->total_size;
1807
1808 header_stream = XCNEW (struct lto_output_stream);
1809 lto_output_data_stream (header_stream, &header, sizeof header);
1810 lto_write_stream (header_stream);
1811 free (header_stream);
1812
1813 /* Put all of the gimple and the string table out the asm file as a
1814 block of text. */
1815 if (section_type == LTO_section_function_body)
1816 lto_write_stream (ob->cfg_stream);
1817 lto_write_stream (ob->main_stream);
1818 lto_write_stream (ob->string_stream);
1819
1820 lto_end_section ();
1821 }
1822
1823
1824 /* Output the body of function NODE->DECL. */
1825
1826 static void
1827 output_function (struct cgraph_node *node)
1828 {
1829 struct bitpack_d *bp;
1830 tree function;
1831 struct function *fn;
1832 basic_block bb;
1833 struct output_block *ob;
1834
1835 function = node->decl;
1836 fn = DECL_STRUCT_FUNCTION (function);
1837 ob = create_output_block (LTO_section_function_body);
1838
1839 clear_line_info (ob);
1840 ob->cgraph_node = node;
1841
1842 gcc_assert (current_function_decl == NULL_TREE && cfun == NULL);
1843
1844 /* Set current_function_decl and cfun. */
1845 current_function_decl = function;
1846 push_cfun (fn);
1847
1848 /* Make string 0 be a NULL string. */
1849 lto_output_1_stream (ob->string_stream, 0);
1850
1851 output_record_start (ob, LTO_function);
1852
1853 /* Write all the attributes for FN. */
1854 bp = bitpack_create ();
1855 bp_pack_value (bp, fn->is_thunk, 1);
1856 bp_pack_value (bp, fn->has_local_explicit_reg_vars, 1);
1857 bp_pack_value (bp, fn->after_tree_profile, 1);
1858 bp_pack_value (bp, fn->returns_pcc_struct, 1);
1859 bp_pack_value (bp, fn->returns_struct, 1);
1860 bp_pack_value (bp, fn->always_inline_functions_inlined, 1);
1861 bp_pack_value (bp, fn->after_inlining, 1);
1862 bp_pack_value (bp, fn->dont_save_pending_sizes_p, 1);
1863 bp_pack_value (bp, fn->stdarg, 1);
1864 bp_pack_value (bp, fn->has_nonlocal_label, 1);
1865 bp_pack_value (bp, fn->calls_alloca, 1);
1866 bp_pack_value (bp, fn->calls_setjmp, 1);
1867 bp_pack_value (bp, fn->function_frequency, 2);
1868 bp_pack_value (bp, fn->va_list_fpr_size, 8);
1869 bp_pack_value (bp, fn->va_list_gpr_size, 8);
1870 lto_output_bitpack (ob->main_stream, bp);
1871 bitpack_delete (bp);
1872
1873 /* Output the static chain and non-local goto save area. */
1874 lto_output_tree_ref (ob, fn->static_chain_decl);
1875 lto_output_tree_ref (ob, fn->nonlocal_goto_save_area);
1876
1877 /* Output all the local variables in the function. */
1878 lto_output_tree_ref (ob, fn->local_decls);
1879
1880 /* Output the head of the arguments list. */
1881 lto_output_tree_ref (ob, DECL_ARGUMENTS (function));
1882
1883 /* Output all the SSA names used in the function. */
1884 output_ssa_names (ob, fn);
1885
1886 /* Output any exception handling regions. */
1887 output_eh_regions (ob, fn);
1888
1889 /* Output DECL_INITIAL for the function, which contains the tree of
1890 lexical scopes. */
1891 lto_output_tree (ob, DECL_INITIAL (function), true);
1892
1893 /* We will renumber the statements. The code that does this uses
1894 the same ordering that we use for serializing them so we can use
1895 the same code on the other end and not have to write out the
1896 statement numbers. */
1897 renumber_gimple_stmt_uids ();
1898
1899 /* Output the code for the function. */
1900 FOR_ALL_BB_FN (bb, fn)
1901 output_bb (ob, bb, fn);
1902
1903 /* The terminator for this function. */
1904 output_zero (ob);
1905
1906 output_cfg (ob, fn);
1907
1908 /* Create a section to hold the pickled output of this function. */
1909 produce_asm (ob, function);
1910
1911 destroy_output_block (ob);
1912
1913 current_function_decl = NULL;
1914 pop_cfun ();
1915 }
1916
1917
1918 /* Return true if alias pair P belongs to the set of cgraph nodes in
1919 SET. If P is a an alias for a VAR_DECL, it can always be emitted.
1920 However, for FUNCTION_DECL aliases, we should only output the pair
1921 if it belongs to a function whose cgraph node is in SET.
1922 Otherwise, the LTRANS phase will get into trouble when finalizing
1923 aliases because the alias will refer to a function not defined in
1924 the file processed by LTRANS. */
1925
1926 static bool
1927 output_alias_pair_p (alias_pair *p, cgraph_node_set set)
1928 {
1929 cgraph_node_set_iterator csi;
1930 struct cgraph_node *target_node;
1931
1932 /* Always emit VAR_DECLs. FIXME lto, we should probably only emit
1933 those VAR_DECLs that are instantiated in this file partition, but
1934 we have no easy way of knowing this based on SET. */
1935 if (TREE_CODE (p->decl) == VAR_DECL)
1936 return true;
1937
1938 /* Check if the assembler name for P->TARGET has its cgraph node in SET. */
1939 gcc_assert (TREE_CODE (p->decl) == FUNCTION_DECL);
1940 target_node = cgraph_node_for_asm (p->target);
1941 csi = cgraph_node_set_find (set, target_node);
1942 return (!csi_end_p (csi));
1943 }
1944
1945
1946 /* Output any unreferenced global symbol defined in SET, alias pairs
1947 and labels. */
1948
1949 static void
1950 output_unreferenced_globals (cgraph_node_set set)
1951 {
1952 struct output_block *ob;
1953 alias_pair *p;
1954 unsigned i;
1955 struct varpool_node *vnode;
1956
1957 ob = create_output_block (LTO_section_static_initializer);
1958 ob->cgraph_node = NULL;
1959
1960 clear_line_info (ob);
1961
1962 /* Make string 0 be a NULL string. */
1963 lto_output_1_stream (ob->string_stream, 0);
1964
1965 /* Emit references for all the global symbols. If a global symbol
1966 was never referenced in any of the functions of this file, it
1967 would not be emitted otherwise. This will result in unreferenced
1968 symbols at link time if a file defines a global symbol but
1969 never references it. */
1970 FOR_EACH_STATIC_VARIABLE (vnode)
1971 {
1972 tree var = vnode->decl;
1973
1974 if (TREE_CODE (var) == VAR_DECL && TREE_PUBLIC (var))
1975 lto_output_tree_ref (ob, var);
1976 }
1977
1978 output_zero (ob);
1979
1980 /* Emit the alias pairs for the nodes in SET. */
1981 for (i = 0; VEC_iterate (alias_pair, alias_pairs, i, p); i++)
1982 {
1983 if (output_alias_pair_p (p, set))
1984 {
1985 lto_output_tree_ref (ob, p->decl);
1986 lto_output_tree_ref (ob, p->target);
1987 }
1988 }
1989
1990 output_zero (ob);
1991
1992 produce_asm (ob, NULL);
1993 destroy_output_block (ob);
1994 }
1995
1996
1997 /* Copy the function body of NODE without deserializing. */
1998
1999 static void
2000 copy_function (struct cgraph_node *node)
2001 {
2002 tree function = node->decl;
2003 struct lto_file_decl_data *file_data = node->local.lto_file_data;
2004 struct lto_output_stream *output_stream = XCNEW (struct lto_output_stream);
2005 const char *data;
2006 size_t len;
2007 const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (function));
2008 char *section_name =
2009 lto_get_section_name (LTO_section_function_body, name);
2010 size_t i, j;
2011 struct lto_in_decl_state *in_state;
2012 struct lto_out_decl_state *out_state = lto_get_out_decl_state ();
2013
2014 lto_begin_section (section_name, !flag_wpa);
2015 free (section_name);
2016
2017 /* We may have renamed the declaration, e.g., a static function. */
2018 name = lto_get_decl_name_mapping (file_data, name);
2019
2020 data = lto_get_section_data (file_data, LTO_section_function_body,
2021 name, &len);
2022 gcc_assert (data);
2023
2024 /* Do a bit copy of the function body. */
2025 lto_output_data_stream (output_stream, data, len);
2026 lto_write_stream (output_stream);
2027
2028 /* Copy decls. */
2029 in_state =
2030 lto_get_function_in_decl_state (node->local.lto_file_data, function);
2031 gcc_assert (in_state);
2032
2033 for (i = 0; i < LTO_N_DECL_STREAMS; i++)
2034 {
2035 size_t n = in_state->streams[i].size;
2036 tree *trees = in_state->streams[i].trees;
2037 struct lto_tree_ref_encoder *encoder = &(out_state->streams[i]);
2038
2039 /* The out state must have the same indices and the in state.
2040 So just copy the vector. All the encoders in the in state
2041 must be empty where we reach here. */
2042 gcc_assert (lto_tree_ref_encoder_size (encoder) == 0);
2043 for (j = 0; j < n; j++)
2044 VEC_safe_push (tree, heap, encoder->trees, trees[j]);
2045 encoder->next_index = n;
2046 }
2047
2048 lto_free_section_data (file_data, LTO_section_function_body, name,
2049 data, len);
2050 free (output_stream);
2051 lto_end_section ();
2052 }
2053
2054
2055 /* Initialize the LTO writer. */
2056
2057 static void
2058 lto_writer_init (void)
2059 {
2060 lto_streamer_init ();
2061 }
2062
2063
2064 /* Main entry point from the pass manager. */
2065
2066 static void
2067 lto_output (cgraph_node_set set)
2068 {
2069 struct cgraph_node *node;
2070 struct lto_out_decl_state *decl_state;
2071 cgraph_node_set_iterator csi;
2072 bitmap output = lto_bitmap_alloc ();
2073
2074 lto_writer_init ();
2075
2076 /* Process only the functions with bodies. */
2077 for (csi = csi_start (set); !csi_end_p (csi); csi_next (&csi))
2078 {
2079 node = csi_node (csi);
2080 if (node->analyzed && !bitmap_bit_p (output, DECL_UID (node->decl)))
2081 {
2082 bitmap_set_bit (output, DECL_UID (node->decl));
2083 decl_state = lto_new_out_decl_state ();
2084 lto_push_out_decl_state (decl_state);
2085 if (!flag_wpa)
2086 output_function (node);
2087 else
2088 copy_function (node);
2089 gcc_assert (lto_get_out_decl_state () == decl_state);
2090 lto_pop_out_decl_state ();
2091 lto_record_function_out_decl_state (node->decl, decl_state);
2092 }
2093 }
2094
2095 /* Emit the callgraph after emitting function bodies. This needs to
2096 be done now to make sure that all the statements in every function
2097 have been renumbered so that edges can be associated with call
2098 statements using the statement UIDs. */
2099 output_cgraph (set);
2100
2101 lto_bitmap_free (output);
2102 }
2103
2104 struct ipa_opt_pass_d pass_ipa_lto_gimple_out =
2105 {
2106 {
2107 IPA_PASS,
2108 "lto_gimple_out", /* name */
2109 gate_lto_out, /* gate */
2110 NULL, /* execute */
2111 NULL, /* sub */
2112 NULL, /* next */
2113 0, /* static_pass_number */
2114 TV_IPA_LTO_GIMPLE_IO, /* tv_id */
2115 0, /* properties_required */
2116 0, /* properties_provided */
2117 0, /* properties_destroyed */
2118 0, /* todo_flags_start */
2119 TODO_dump_func /* todo_flags_finish */
2120 },
2121 NULL, /* generate_summary */
2122 lto_output, /* write_summary */
2123 NULL, /* read_summary */
2124 NULL, /* function_read_summary */
2125 NULL, /* stmt_fixup */
2126 0, /* TODOs */
2127 NULL, /* function_transform */
2128 NULL /* variable_transform */
2129 };
2130
2131
2132 /* Write each node in encoded by ENCODER to OB, as well as those reachable
2133 from it and required for correct representation of its semantics.
2134 Each node in ENCODER must be a global declaration or a type. A node
2135 is written only once, even if it appears multiple times in the
2136 vector. Certain transitively-reachable nodes, such as those
2137 representing expressions, may be duplicated, but such nodes
2138 must not appear in ENCODER itself. */
2139
2140 static void
2141 write_global_stream (struct output_block *ob,
2142 struct lto_tree_ref_encoder *encoder)
2143 {
2144 tree t;
2145 size_t index;
2146 const size_t size = lto_tree_ref_encoder_size (encoder);
2147
2148 for (index = 0; index < size; index++)
2149 {
2150 t = lto_tree_ref_encoder_get_tree (encoder, index);
2151 if (!lto_streamer_cache_lookup (ob->writer_cache, t, NULL))
2152 lto_output_tree (ob, t, false);
2153
2154 if (flag_wpa)
2155 {
2156 /* In WPA we should not emit multiple definitions of the
2157 same symbol to all the files in the link set. If
2158 T had already been emitted as the pervailing definition
2159 in one file, do not emit it in the others. */
2160 /* FIXME lto. We should check if T belongs to the
2161 file we are writing to. */
2162 if (TREE_CODE (t) == VAR_DECL
2163 && TREE_PUBLIC (t)
2164 && !DECL_EXTERNAL (t))
2165 TREE_ASM_WRITTEN (t) = 1;
2166 }
2167 }
2168 }
2169
2170
2171 /* Write a sequence of indices into the globals vector corresponding
2172 to the trees in ENCODER. These are used by the reader to map the
2173 indices used to refer to global entities within function bodies to
2174 their referents. */
2175
2176 static void
2177 write_global_references (struct output_block *ob,
2178 struct lto_output_stream *ref_stream,
2179 struct lto_tree_ref_encoder *encoder)
2180 {
2181 tree t;
2182 int32_t index;
2183 const int32_t size = lto_tree_ref_encoder_size (encoder);
2184
2185 /* Write size as 32-bit unsigned. */
2186 lto_output_data_stream (ref_stream, &size, sizeof (int32_t));
2187
2188 for (index = 0; index < size; index++)
2189 {
2190 int32_t slot_num;
2191
2192 t = lto_tree_ref_encoder_get_tree (encoder, index);
2193 lto_streamer_cache_lookup (ob->writer_cache, t, &slot_num);
2194 gcc_assert (slot_num >= 0);
2195 lto_output_data_stream (ref_stream, &slot_num, sizeof slot_num);
2196 }
2197 }
2198
2199
2200 /* Write all the streams in an lto_out_decl_state STATE using
2201 output block OB and output stream OUT_STREAM. */
2202
2203 static void
2204 lto_output_decl_state_streams (struct output_block *ob,
2205 struct lto_out_decl_state *state)
2206 {
2207 int i;
2208
2209 for (i = 0; i < LTO_N_DECL_STREAMS; i++)
2210 write_global_stream (ob, &state->streams[i]);
2211 }
2212
2213
2214 /* Write all the references in an lto_out_decl_state STATE using
2215 output block OB and output stream OUT_STREAM. */
2216
2217 static void
2218 lto_output_decl_state_refs (struct output_block *ob,
2219 struct lto_output_stream *out_stream,
2220 struct lto_out_decl_state *state)
2221 {
2222 unsigned i;
2223 int32_t ref;
2224 tree decl;
2225
2226 /* Write reference to FUNCTION_DECL. If there is not function,
2227 write reference to void_type_node. */
2228 decl = (state->fn_decl) ? state->fn_decl : void_type_node;
2229 lto_streamer_cache_lookup (ob->writer_cache, decl, &ref);
2230 gcc_assert (ref >= 0);
2231 lto_output_data_stream (out_stream, &ref, sizeof (int32_t));
2232
2233 for (i = 0; i < LTO_N_DECL_STREAMS; i++)
2234 write_global_references (ob, out_stream, &state->streams[i]);
2235 }
2236
2237
2238 /* Return the written size of STATE. */
2239
2240 static size_t
2241 lto_out_decl_state_written_size (struct lto_out_decl_state *state)
2242 {
2243 int i;
2244 size_t size;
2245
2246 size = sizeof (int32_t); /* fn_ref. */
2247 for (i = 0; i < LTO_N_DECL_STREAMS; i++)
2248 {
2249 size += sizeof (int32_t); /* vector size. */
2250 size += (lto_tree_ref_encoder_size (&state->streams[i])
2251 * sizeof (int32_t));
2252 }
2253 return size;
2254 }
2255
2256
2257 /* Helper function of write_symbols_of_kind. CACHE is the streamer
2258 cache with all the pickled nodes. STREAM is the stream where to
2259 write the table. V is a vector with the DECLs that should be on
2260 the table. SEEN is a bitmap of symbols written so far. */
2261
2262 static void
2263 write_symbol_vec (struct lto_streamer_cache_d *cache,
2264 struct lto_output_stream *stream,
2265 VEC(tree,heap) *v, bitmap seen)
2266 {
2267 tree t;
2268 int index;
2269
2270 for (index = 0; VEC_iterate(tree, v, index, t); index++)
2271 {
2272 const char *name;
2273 enum gcc_plugin_symbol_kind kind;
2274 enum gcc_plugin_symbol_visibility visibility;
2275 int slot_num;
2276 uint64_t size;
2277 const char *comdat;
2278
2279 /* None of the following kinds of symbols are needed in the
2280 symbol table. */
2281 if (!TREE_PUBLIC (t)
2282 || is_builtin_fn (t)
2283 || DECL_ABSTRACT (t)
2284 || TREE_CODE (t) == RESULT_DECL)
2285 continue;
2286
2287 gcc_assert (TREE_CODE (t) == VAR_DECL
2288 || TREE_CODE (t) == FUNCTION_DECL);
2289
2290 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (t));
2291
2292 /* FIXME lto: this is from assemble_name_raw in varasm.c. For some
2293 architectures we might have to do the same name manipulations that
2294 ASM_OUTPUT_LABELREF does. */
2295 if (name[0] == '*')
2296 name = &name[1];
2297
2298 lto_streamer_cache_lookup (cache, t, &slot_num);
2299 gcc_assert (slot_num >= 0);
2300
2301 /* Avoid duplicate symbols. */
2302 if (bitmap_bit_p (seen, slot_num))
2303 continue;
2304 else
2305 bitmap_set_bit (seen, slot_num);
2306
2307 if (DECL_EXTERNAL (t))
2308 {
2309 if (DECL_WEAK (t))
2310 kind = GCCPK_WEAKUNDEF;
2311 else
2312 kind = GCCPK_UNDEF;
2313 }
2314 else
2315 {
2316 if (DECL_WEAK (t))
2317 kind = GCCPK_WEAKDEF;
2318 else if (DECL_COMMON (t))
2319 kind = GCCPK_COMMON;
2320 else
2321 kind = GCCPK_DEF;
2322 }
2323
2324 switch (DECL_VISIBILITY(t))
2325 {
2326 case VISIBILITY_DEFAULT:
2327 visibility = GCCPV_DEFAULT;
2328 break;
2329 case VISIBILITY_PROTECTED:
2330 visibility = GCCPV_PROTECTED;
2331 break;
2332 case VISIBILITY_HIDDEN:
2333 visibility = GCCPV_HIDDEN;
2334 break;
2335 case VISIBILITY_INTERNAL:
2336 visibility = GCCPV_INTERNAL;
2337 break;
2338 }
2339
2340 if (kind == GCCPK_COMMON
2341 && DECL_SIZE (t)
2342 && TREE_CODE (DECL_SIZE (t)) == INTEGER_CST)
2343 size = (((uint64_t) TREE_INT_CST_HIGH (DECL_SIZE (t))) << 32)
2344 | TREE_INT_CST_LOW (DECL_SIZE (t));
2345 else
2346 size = 0;
2347
2348 if (DECL_ONE_ONLY (t))
2349 comdat = IDENTIFIER_POINTER (DECL_COMDAT_GROUP (t));
2350 else
2351 comdat = "";
2352
2353 lto_output_data_stream (stream, name, strlen (name) + 1);
2354 lto_output_data_stream (stream, comdat, strlen (comdat) + 1);
2355 lto_output_data_stream (stream, &kind, 1);
2356 lto_output_data_stream (stream, &visibility, 1);
2357 lto_output_data_stream (stream, &size, 8);
2358 lto_output_data_stream (stream, &slot_num, 4);
2359 }
2360 }
2361
2362
2363 /* Write IL symbols of KIND. CACHE is the streamer cache with all the
2364 pickled nodes. SEEN is a bitmap of symbols written so far. */
2365
2366 static void
2367 write_symbols_of_kind (lto_decl_stream_e_t kind,
2368 struct lto_streamer_cache_d *cache, bitmap seen)
2369 {
2370 struct lto_out_decl_state *out_state;
2371 struct lto_output_stream stream;
2372 unsigned num_fns =
2373 VEC_length (lto_out_decl_state_ptr, lto_function_decl_states);
2374 unsigned idx;
2375
2376 memset (&stream, 0, sizeof (stream));
2377 out_state = lto_get_out_decl_state ();
2378 write_symbol_vec (cache, &stream, out_state->streams[kind].trees, seen);
2379
2380 for (idx = 0; idx < num_fns; idx++)
2381 {
2382 out_state =
2383 VEC_index (lto_out_decl_state_ptr, lto_function_decl_states, idx);
2384 write_symbol_vec (cache, &stream, out_state->streams[kind].trees, seen);
2385 }
2386
2387 lto_write_stream (&stream);
2388 }
2389
2390
2391 /* Write an IL symbol table. CACHE is the streamer cache with all the
2392 pickled nodes. */
2393
2394 static void
2395 produce_symtab (struct lto_streamer_cache_d *cache)
2396 {
2397 char *section_name = lto_get_section_name (LTO_section_symtab, NULL);
2398 bitmap seen;
2399
2400 lto_begin_section (section_name, false);
2401 free (section_name);
2402
2403 seen = lto_bitmap_alloc ();
2404 write_symbols_of_kind (LTO_DECL_STREAM_FN_DECL, cache, seen);
2405 write_symbols_of_kind (LTO_DECL_STREAM_VAR_DECL, cache, seen);
2406 lto_bitmap_free (seen);
2407
2408 lto_end_section ();
2409 }
2410
2411
2412 /* This pass is run after all of the functions are serialized and all
2413 of the IPA passes have written their serialized forms. This pass
2414 causes the vector of all of the global decls and types used from
2415 this file to be written in to a section that can then be read in to
2416 recover these on other side. */
2417
2418 static void
2419 produce_asm_for_decls (cgraph_node_set set)
2420 {
2421 struct lto_out_decl_state *out_state;
2422 struct lto_out_decl_state *fn_out_state;
2423 struct lto_decl_header header;
2424 char *section_name;
2425 struct output_block *ob;
2426 struct lto_output_stream *header_stream, *decl_state_stream;
2427 unsigned idx, num_fns;
2428 size_t decl_state_size;
2429 int32_t num_decl_states;
2430
2431 ob = create_output_block (LTO_section_decls);
2432 ob->global = true;
2433
2434 /* Write out unreferenced globals, alias pairs and labels. We defer
2435 doing this until now so that we can write out only what is
2436 needed. */
2437 output_unreferenced_globals (set);
2438
2439 memset (&header, 0, sizeof (struct lto_decl_header));
2440
2441 section_name = lto_get_section_name (LTO_section_decls, NULL);
2442 lto_begin_section (section_name, !flag_wpa);
2443 free (section_name);
2444
2445 /* Make string 0 be a NULL string. */
2446 lto_output_1_stream (ob->string_stream, 0);
2447
2448 /* Write the global symbols. */
2449 out_state = lto_get_out_decl_state ();
2450 num_fns = VEC_length (lto_out_decl_state_ptr, lto_function_decl_states);
2451 lto_output_decl_state_streams (ob, out_state);
2452 for (idx = 0; idx < num_fns; idx++)
2453 {
2454 fn_out_state =
2455 VEC_index (lto_out_decl_state_ptr, lto_function_decl_states, idx);
2456 lto_output_decl_state_streams (ob, fn_out_state);
2457 }
2458
2459 header.lto_header.major_version = LTO_major_version;
2460 header.lto_header.minor_version = LTO_minor_version;
2461 header.lto_header.section_type = LTO_section_decls;
2462
2463 /* Currently not used. This field would allow us to preallocate
2464 the globals vector, so that it need not be resized as it is extended. */
2465 header.num_nodes = -1;
2466
2467 /* Compute the total size of all decl out states. */
2468 decl_state_size = sizeof (int32_t);
2469 decl_state_size += lto_out_decl_state_written_size (out_state);
2470 for (idx = 0; idx < num_fns; idx++)
2471 {
2472 fn_out_state =
2473 VEC_index (lto_out_decl_state_ptr, lto_function_decl_states, idx);
2474 decl_state_size += lto_out_decl_state_written_size (fn_out_state);
2475 }
2476 header.decl_state_size = decl_state_size;
2477
2478 header.main_size = ob->main_stream->total_size;
2479 header.string_size = ob->string_stream->total_size;
2480
2481 header_stream = XCNEW (struct lto_output_stream);
2482 lto_output_data_stream (header_stream, &header, sizeof header);
2483 lto_write_stream (header_stream);
2484 free (header_stream);
2485
2486 /* Write the main out-decl state, followed by out-decl states of
2487 functions. */
2488 decl_state_stream = ((struct lto_output_stream *)
2489 xcalloc (1, sizeof (struct lto_output_stream)));
2490 num_decl_states = num_fns + 1;
2491 lto_output_data_stream (decl_state_stream, &num_decl_states,
2492 sizeof (num_decl_states));
2493 lto_output_decl_state_refs (ob, decl_state_stream, out_state);
2494 for (idx = 0; idx < num_fns; idx++)
2495 {
2496 fn_out_state =
2497 VEC_index (lto_out_decl_state_ptr, lto_function_decl_states, idx);
2498 lto_output_decl_state_refs (ob, decl_state_stream, fn_out_state);
2499 }
2500 lto_write_stream (decl_state_stream);
2501 free(decl_state_stream);
2502
2503 lto_write_stream (ob->main_stream);
2504 lto_write_stream (ob->string_stream);
2505
2506 lto_end_section ();
2507
2508 /* Write the symbol table. */
2509 produce_symtab (ob->writer_cache);
2510
2511 /* Write command line opts. */
2512 lto_write_options ();
2513
2514 /* Deallocate memory and clean up. */
2515 lto_cgraph_encoder_delete (ob->decl_state->cgraph_node_encoder);
2516 VEC_free (lto_out_decl_state_ptr, heap, lto_function_decl_states);
2517 lto_function_decl_states = NULL;
2518 destroy_output_block (ob);
2519 }
2520
2521
2522 struct ipa_opt_pass_d pass_ipa_lto_finish_out =
2523 {
2524 {
2525 IPA_PASS,
2526 "lto_decls_out", /* name */
2527 gate_lto_out, /* gate */
2528 NULL, /* execute */
2529 NULL, /* sub */
2530 NULL, /* next */
2531 0, /* static_pass_number */
2532 TV_IPA_LTO_DECL_IO, /* tv_id */
2533 0, /* properties_required */
2534 0, /* properties_provided */
2535 0, /* properties_destroyed */
2536 0, /* todo_flags_start */
2537 0 /* todo_flags_finish */
2538 },
2539 NULL, /* generate_summary */
2540 produce_asm_for_decls, /* write_summary */
2541 NULL, /* read_summary */
2542 NULL, /* function_read_summary */
2543 NULL, /* stmt_fixup */
2544 0, /* TODOs */
2545 NULL, /* function_transform */
2546 NULL /* variable_transform */
2547 };