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