Line data Source code
1 : /* Routines for reading trees from a file stream.
2 :
3 : Copyright (C) 2011-2026 Free Software Foundation, Inc.
4 : Contributed by Diego Novillo <dnovillo@google.com>
5 :
6 : This file is part of GCC.
7 :
8 : GCC is free software; you can redistribute it and/or modify it under
9 : the terms of the GNU General Public License as published by the Free
10 : Software Foundation; either version 3, or (at your option) any later
11 : version.
12 :
13 : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 : WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 : FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 : for more details.
17 :
18 : You should have received a copy of the GNU General Public License
19 : along with GCC; see the file COPYING3. If not see
20 : <http://www.gnu.org/licenses/>. */
21 :
22 : #include "config.h"
23 : #include "system.h"
24 : #include "coretypes.h"
25 : #include "backend.h"
26 : #include "target.h"
27 : #include "tree.h"
28 : #include "gimple.h"
29 : #include "stringpool.h"
30 : #include "tree-streamer.h"
31 : #include "cgraph.h"
32 : #include "builtins.h"
33 : #include "gomp-constants.h"
34 : #include "attribs.h"
35 : #include "asan.h"
36 : #include "opts.h"
37 : #include "stor-layout.h"
38 : #include "hooks.h" /* For 'hook_bool_const_tree_false'. */
39 :
40 :
41 : /* Read a STRING_CST from the string table in DATA_IN using input
42 : block IB. */
43 :
44 : tree
45 177057 : streamer_read_string_cst (class data_in *data_in, class lto_input_block *ib)
46 : {
47 177057 : unsigned int len;
48 177057 : const char * ptr;
49 :
50 177057 : ptr = streamer_read_indexed_string (data_in, ib, &len);
51 177057 : if (!ptr)
52 : return NULL;
53 177057 : return build_string (len, ptr);
54 : }
55 :
56 :
57 : /* Read an IDENTIFIER from the string table in DATA_IN using input
58 : block IB. */
59 :
60 : static tree
61 754867 : input_identifier (class data_in *data_in, class lto_input_block *ib)
62 : {
63 754867 : unsigned int len;
64 754867 : const char *ptr;
65 :
66 754867 : ptr = streamer_read_indexed_string (data_in, ib, &len);
67 754867 : if (!ptr)
68 : return NULL;
69 754867 : return get_identifier_with_length (ptr, len);
70 : }
71 :
72 :
73 : /* Read a chain of tree nodes from input block IB. DATA_IN contains
74 : tables and descriptors for the file being read. */
75 :
76 : static tree
77 348557 : streamer_read_chain (class lto_input_block *ib, class data_in *data_in)
78 : {
79 348557 : tree first, prev, curr;
80 :
81 : /* The chain is written as NULL terminated list of trees. */
82 348557 : first = prev = NULL_TREE;
83 583558 : do
84 : {
85 583558 : curr = stream_read_tree_ref (ib, data_in);
86 583558 : if (prev)
87 235001 : TREE_CHAIN (prev) = curr;
88 : else
89 : first = curr;
90 :
91 583558 : prev = curr;
92 : }
93 583558 : while (curr);
94 :
95 348557 : return first;
96 : }
97 :
98 :
99 : /* Unpack all the non-pointer fields of the TS_BASE structure of
100 : expression EXPR from bitpack BP. */
101 :
102 : static inline void
103 4571721 : unpack_ts_base_value_fields (struct bitpack_d *bp, tree expr)
104 : {
105 : /* Note that the code for EXPR has already been unpacked to create EXPR in
106 : streamer_alloc_tree. */
107 4571721 : if (!TYPE_P (expr))
108 : {
109 4056134 : TREE_SIDE_EFFECTS (expr) = (unsigned) bp_unpack_value (bp, 1);
110 4056134 : TREE_CONSTANT (expr) = (unsigned) bp_unpack_value (bp, 1);
111 4056134 : TREE_READONLY (expr) = (unsigned) bp_unpack_value (bp, 1);
112 :
113 : /* TREE_PUBLIC is used on types to indicate that the type
114 : has a TYPE_CACHED_VALUES vector. This is not streamed out,
115 : so we skip it here. */
116 4056134 : TREE_PUBLIC (expr) = (unsigned) bp_unpack_value (bp, 1);
117 : }
118 : else
119 515587 : bp_unpack_value (bp, 4);
120 4571721 : TREE_ADDRESSABLE (expr) = (unsigned) bp_unpack_value (bp, 1);
121 4571721 : TREE_THIS_VOLATILE (expr) = (unsigned) bp_unpack_value (bp, 1);
122 4571721 : if (DECL_P (expr))
123 : {
124 770532 : DECL_UNSIGNED (expr) = (unsigned) bp_unpack_value (bp, 1);
125 770532 : DECL_NAMELESS (expr) = (unsigned) bp_unpack_value (bp, 1);
126 : }
127 3801189 : else if (TYPE_P (expr))
128 515587 : TYPE_UNSIGNED (expr) = (unsigned) bp_unpack_value (bp, 1);
129 : else
130 3285602 : bp_unpack_value (bp, 1);
131 4571721 : TREE_ASM_WRITTEN (expr) = (unsigned) bp_unpack_value (bp, 1);
132 4571721 : if (TYPE_P (expr))
133 515587 : TYPE_ARTIFICIAL (expr) = (unsigned) bp_unpack_value (bp, 1);
134 : else
135 4056134 : TREE_NO_WARNING (expr) = (unsigned) bp_unpack_value (bp, 1);
136 4571721 : TREE_NOTHROW (expr) = (unsigned) bp_unpack_value (bp, 1);
137 4571721 : TREE_STATIC (expr) = (unsigned) bp_unpack_value (bp, 1);
138 4571721 : if (TREE_CODE (expr) != TREE_BINFO)
139 4565698 : TREE_PRIVATE (expr) = (unsigned) bp_unpack_value (bp, 1);
140 : else
141 6023 : bp_unpack_value (bp, 1);
142 4571721 : TREE_PROTECTED (expr) = (unsigned) bp_unpack_value (bp, 1);
143 4571721 : TREE_DEPRECATED (expr) = (unsigned) bp_unpack_value (bp, 1);
144 4571721 : if (TYPE_P (expr))
145 : {
146 515587 : if (AGGREGATE_TYPE_P (expr))
147 100187 : TYPE_REVERSE_STORAGE_ORDER (expr) = (unsigned) bp_unpack_value (bp, 1);
148 : else
149 415400 : TYPE_SATURATING (expr) = (unsigned) bp_unpack_value (bp, 1);
150 : #ifndef ACCEL_COMPILER
151 515587 : TYPE_ADDR_SPACE (expr) = (unsigned) bp_unpack_value (bp, 8);
152 : #endif
153 : }
154 4056134 : else if (TREE_CODE (expr) == BIT_FIELD_REF || TREE_CODE (expr) == MEM_REF)
155 : {
156 333745 : REF_REVERSE_STORAGE_ORDER (expr) = (unsigned) bp_unpack_value (bp, 1);
157 333745 : bp_unpack_value (bp, 8);
158 : }
159 3722389 : else if (TREE_CODE (expr) == SSA_NAME)
160 : {
161 0 : SSA_NAME_IS_DEFAULT_DEF (expr) = (unsigned) bp_unpack_value (bp, 1);
162 0 : bp_unpack_value (bp, 8);
163 : }
164 3722389 : else if (TREE_CODE (expr) == CALL_EXPR)
165 : {
166 0 : CALL_EXPR_BY_DESCRIPTOR (expr) = (unsigned) bp_unpack_value (bp, 1);
167 0 : bp_unpack_value (bp, 8);
168 : }
169 : else
170 3722389 : bp_unpack_value (bp, 9);
171 4571721 : }
172 :
173 :
174 : /* Unpack all the non-pointer fields of the TS_INT_CST structure of
175 : expression EXPR from bitpack BP. */
176 :
177 : static void
178 37794 : unpack_ts_int_cst_value_fields (struct bitpack_d *bp, tree expr)
179 : {
180 37794 : int i;
181 85107 : for (i = 0; i < TREE_INT_CST_EXT_NUNITS (expr); i++)
182 47313 : TREE_INT_CST_ELT (expr, i) = bp_unpack_var_len_int (bp);
183 37794 : }
184 :
185 :
186 : /* Unpack all the non-pointer fields of the TS_REAL_CST structure of
187 : expression EXPR from bitpack BP. */
188 :
189 : static void
190 104385 : unpack_ts_real_cst_value_fields (struct bitpack_d *bp, tree expr)
191 : {
192 104385 : REAL_VALUE_TYPE r;
193 :
194 104385 : bp_unpack_real_value (bp, &r);
195 104385 : memcpy (TREE_REAL_CST_PTR (expr), &r, sizeof (REAL_VALUE_TYPE));
196 104385 : }
197 :
198 :
199 : /* Unpack all the non-pointer fields of the TS_FIXED_CST structure of
200 : expression EXPR from bitpack BP. */
201 :
202 : static void
203 0 : unpack_ts_fixed_cst_value_fields (struct bitpack_d *bp, tree expr)
204 : {
205 0 : FIXED_VALUE_TYPE *fp = ggc_alloc<fixed_value> ();
206 0 : fp->mode = as_a <scalar_mode> (bp_unpack_machine_mode (bp));
207 0 : fp->data.low = bp_unpack_var_len_int (bp);
208 0 : fp->data.high = bp_unpack_var_len_int (bp);
209 0 : TREE_FIXED_CST_PTR (expr) = fp;
210 0 : }
211 :
212 : /* Unpack all the non-pointer fields of the TS_DECL_COMMON structure
213 : of expression EXPR from bitpack BP. */
214 :
215 : static void
216 770532 : unpack_ts_decl_common_value_fields (struct bitpack_d *bp, tree expr)
217 : {
218 770532 : SET_DECL_MODE (expr, bp_unpack_machine_mode (bp));
219 770532 : DECL_NONLOCAL (expr) = (unsigned) bp_unpack_value (bp, 1);
220 770532 : DECL_VIRTUAL_P (expr) = (unsigned) bp_unpack_value (bp, 1);
221 770532 : DECL_IGNORED_P (expr) = (unsigned) bp_unpack_value (bp, 1);
222 770532 : DECL_ABSTRACT_P (expr) = (unsigned) bp_unpack_value (bp, 1);
223 770532 : DECL_ARTIFICIAL (expr) = (unsigned) bp_unpack_value (bp, 1);
224 770532 : DECL_USER_ALIGN (expr) = (unsigned) bp_unpack_value (bp, 1);
225 770532 : DECL_PRESERVE_P (expr) = (unsigned) bp_unpack_value (bp, 1);
226 770532 : DECL_EXTERNAL (expr) = (unsigned) bp_unpack_value (bp, 1);
227 770532 : DECL_NOT_GIMPLE_REG_P (expr) = (unsigned) bp_unpack_value (bp, 1);
228 770532 : SET_DECL_ALIGN (expr, (unsigned) bp_unpack_var_len_unsigned (bp));
229 : #ifdef ACCEL_COMPILER
230 : if (DECL_ALIGN (expr) > targetm.absolute_biggest_alignment)
231 : SET_DECL_ALIGN (expr, targetm.absolute_biggest_alignment);
232 : #endif
233 770532 : if (TREE_CODE (expr) == LABEL_DECL)
234 : {
235 20211 : EH_LANDING_PAD_NR (expr) = (int) bp_unpack_var_len_unsigned (bp);
236 :
237 : /* Always assume an initial value of -1 for LABEL_DECL_UID to
238 : force gimple_set_bb to recreate label_to_block_map. */
239 20211 : LABEL_DECL_UID (expr) = -1;
240 : }
241 :
242 750321 : else if (TREE_CODE (expr) == FIELD_DECL)
243 : {
244 79170 : DECL_PACKED (expr) = (unsigned) bp_unpack_value (bp, 1);
245 79170 : DECL_NONADDRESSABLE_P (expr) = (unsigned) bp_unpack_value (bp, 1);
246 79170 : DECL_PADDING_P (expr) = (unsigned) bp_unpack_value (bp, 1);
247 79170 : unsigned val = (unsigned) bp_unpack_value (bp, 1);
248 79170 : if (DECL_BIT_FIELD (expr))
249 : SET_DECL_FIELD_CXX_ZERO_WIDTH_BIT_FIELD (expr, val);
250 : else
251 79170 : SET_DECL_FIELD_ABI_IGNORED (expr, val);
252 79170 : expr->decl_common.off_align = bp_unpack_value (bp, 8);
253 79170 : DECL_NOT_FLEXARRAY (expr) = (unsigned) bp_unpack_value (bp, 1);
254 : }
255 :
256 671151 : else if (VAR_P (expr))
257 : {
258 220139 : DECL_HAS_DEBUG_EXPR_P (expr) = (unsigned) bp_unpack_value (bp, 1);
259 220139 : DECL_NONLOCAL_FRAME (expr) = (unsigned) bp_unpack_value (bp, 1);
260 : }
261 :
262 451012 : else if (TREE_CODE (expr) == PARM_DECL)
263 102366 : DECL_HIDDEN_STRING_LENGTH (expr) = (unsigned) bp_unpack_value (bp, 1);
264 :
265 770532 : if (TREE_CODE (expr) == RESULT_DECL
266 : || TREE_CODE (expr) == PARM_DECL
267 : || VAR_P (expr))
268 : {
269 411451 : DECL_BY_REFERENCE (expr) = (unsigned) bp_unpack_value (bp, 1);
270 411451 : if (VAR_P (expr) || TREE_CODE (expr) == PARM_DECL)
271 322505 : DECL_HAS_VALUE_EXPR_P (expr) = (unsigned) bp_unpack_value (bp, 1);
272 : }
273 770532 : }
274 :
275 :
276 : /* Unpack all the non-pointer fields of the TS_DECL_WRTL structure
277 : of expression EXPR from bitpack BP. */
278 :
279 : static void
280 666830 : unpack_ts_decl_wrtl_value_fields (struct bitpack_d *bp, tree expr)
281 : {
282 666830 : DECL_REGISTER (expr) = (unsigned) bp_unpack_value (bp, 1);
283 666830 : }
284 :
285 :
286 : /* Unpack all the non-pointer fields of the TS_DECL_WITH_VIS structure
287 : of expression EXPR from bitpack BP. */
288 :
289 : static void
290 454962 : unpack_ts_decl_with_vis_value_fields (struct bitpack_d *bp, tree expr)
291 : {
292 454962 : DECL_COMMON (expr) = (unsigned) bp_unpack_value (bp, 1);
293 454962 : DECL_DLLIMPORT_P (expr) = (unsigned) bp_unpack_value (bp, 1);
294 454962 : DECL_WEAK (expr) = (unsigned) bp_unpack_value (bp, 1);
295 454962 : DECL_SEEN_IN_BIND_EXPR_P (expr) = (unsigned) bp_unpack_value (bp, 1);
296 454962 : DECL_COMDAT (expr) = (unsigned) bp_unpack_value (bp, 1);
297 454962 : DECL_VISIBILITY (expr) = (enum symbol_visibility) bp_unpack_value (bp, 2);
298 454962 : DECL_VISIBILITY_SPECIFIED (expr) = (unsigned) bp_unpack_value (bp, 1);
299 :
300 454962 : if (VAR_P (expr))
301 : {
302 220139 : DECL_HARD_REGISTER (expr) = (unsigned) bp_unpack_value (bp, 1);
303 220139 : DECL_IN_CONSTANT_POOL (expr) = (unsigned) bp_unpack_value (bp, 1);
304 : }
305 :
306 454962 : if (TREE_CODE (expr) == FUNCTION_DECL)
307 : {
308 212980 : DECL_FINAL_P (expr) = (unsigned) bp_unpack_value (bp, 1);
309 212980 : DECL_CXX_CONSTRUCTOR_P (expr) = (unsigned) bp_unpack_value (bp, 1);
310 212980 : DECL_CXX_DESTRUCTOR_P (expr) = (unsigned) bp_unpack_value (bp, 1);
311 : }
312 454962 : }
313 :
314 :
315 : /* Unpack all the non-pointer fields of the TS_FUNCTION_DECL structure
316 : of expression EXPR from bitpack BP. */
317 :
318 : static void
319 212980 : unpack_ts_function_decl_value_fields (struct bitpack_d *bp, tree expr)
320 : {
321 212980 : built_in_class cl = bp_unpack_enum (bp, built_in_class, BUILT_IN_LAST);
322 212980 : DECL_STATIC_CONSTRUCTOR (expr) = (unsigned) bp_unpack_value (bp, 1);
323 212980 : DECL_STATIC_DESTRUCTOR (expr) = (unsigned) bp_unpack_value (bp, 1);
324 212980 : DECL_UNINLINABLE (expr) = (unsigned) bp_unpack_value (bp, 1);
325 212980 : DECL_POSSIBLY_INLINED (expr) = (unsigned) bp_unpack_value (bp, 1);
326 212980 : DECL_IS_NOVOPS (expr) = (unsigned) bp_unpack_value (bp, 1);
327 212980 : DECL_IS_RETURNS_TWICE (expr) = (unsigned) bp_unpack_value (bp, 1);
328 212980 : DECL_IS_MALLOC (expr) = (unsigned) bp_unpack_value (bp, 1);
329 212980 : FUNCTION_DECL_DECL_TYPE (expr) = (function_decl_type) bp_unpack_value (bp, 2);
330 212980 : DECL_SET_IS_OPERATOR_DELETE (expr, (unsigned) bp_unpack_value (bp, 1));
331 212980 : DECL_DECLARED_INLINE_P (expr) = (unsigned) bp_unpack_value (bp, 1);
332 212980 : DECL_STATIC_CHAIN (expr) = (unsigned) bp_unpack_value (bp, 1);
333 212980 : DECL_NO_INLINE_WARNING_P (expr) = (unsigned) bp_unpack_value (bp, 1);
334 425960 : DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (expr)
335 212980 : = (unsigned) bp_unpack_value (bp, 1);
336 212980 : DECL_NO_LIMIT_STACK (expr) = (unsigned) bp_unpack_value (bp, 1);
337 212980 : DECL_DISREGARD_INLINE_LIMITS (expr) = (unsigned) bp_unpack_value (bp, 1);
338 212980 : DECL_PURE_P (expr) = (unsigned) bp_unpack_value (bp, 1);
339 212980 : DECL_LOOPING_CONST_OR_PURE_P (expr) = (unsigned) bp_unpack_value (bp, 1);
340 212980 : DECL_IS_REPLACEABLE_OPERATOR (expr) = (unsigned) bp_unpack_value (bp, 1);
341 212980 : unsigned int fcode = 0;
342 212980 : if (cl != NOT_BUILT_IN)
343 : {
344 32048 : fcode = bp_unpack_value (bp, 32);
345 32048 : if (cl == BUILT_IN_NORMAL && fcode >= END_BUILTINS)
346 0 : fatal_error (input_location,
347 : "machine independent builtin code out of range");
348 32048 : else if (cl == BUILT_IN_MD)
349 : {
350 154 : tree result = targetm.builtin_decl (fcode, true);
351 154 : if (!result || result == error_mark_node)
352 0 : fatal_error (input_location,
353 : "target specific builtin not available");
354 : }
355 : }
356 212980 : set_decl_built_in_function (expr, cl, fcode);
357 212980 : }
358 :
359 :
360 : /* Unpack all the non-pointer fields of the TS_TYPE_COMMON structure
361 : of expression EXPR from bitpack BP. */
362 :
363 : static void
364 515587 : unpack_ts_type_common_value_fields (struct bitpack_d *bp, tree expr)
365 : {
366 515587 : machine_mode mode;
367 :
368 515587 : mode = bp_unpack_machine_mode (bp);
369 515587 : SET_TYPE_MODE (expr, mode);
370 : /* TYPE_NO_FORCE_BLK is private to stor-layout and need
371 : no streaming. */
372 515587 : TYPE_PACKED (expr) = (unsigned) bp_unpack_value (bp, 1);
373 515587 : TYPE_RESTRICT (expr) = (unsigned) bp_unpack_value (bp, 1);
374 515587 : TYPE_USER_ALIGN (expr) = (unsigned) bp_unpack_value (bp, 1);
375 515587 : TYPE_READONLY (expr) = (unsigned) bp_unpack_value (bp, 1);
376 515587 : TYPE_LANG_FLAG_0 (expr) = (unsigned) bp_unpack_value (bp, 1);
377 515587 : if (RECORD_OR_UNION_TYPE_P (expr))
378 : {
379 59220 : TYPE_TRANSPARENT_AGGR (expr) = (unsigned) bp_unpack_value (bp, 1);
380 59220 : TYPE_FINAL_P (expr) = (unsigned) bp_unpack_value (bp, 1);
381 59220 : TYPE_CXX_ODR_P (expr) = (unsigned) bp_unpack_value (bp, 1);
382 : }
383 456367 : else if (TREE_CODE (expr) == ARRAY_TYPE)
384 40967 : TYPE_NONALIASED_COMPONENT (expr) = (unsigned) bp_unpack_value (bp, 1);
385 515587 : if (TREE_CODE (expr) == ARRAY_TYPE || TREE_CODE (expr) == INTEGER_TYPE)
386 99682 : TYPE_STRING_FLAG (expr) = (unsigned) bp_unpack_value (bp, 1);
387 515587 : if (AGGREGATE_TYPE_P (expr))
388 100187 : TYPE_TYPELESS_STORAGE (expr) = (unsigned) bp_unpack_value (bp, 1);
389 515587 : if (!lto_stream_offload_p)
390 515587 : TYPE_EMPTY_P (expr) = (unsigned) bp_unpack_value (bp, 1);
391 : else
392 : {
393 : /* All offload targets use the default ('false') 'TARGET_EMPTY_RECORD_P'.
394 : If that ever changes, we'll have to properly initialize 'TYPE_EMPTY_P'
395 : here, see 'stor-layout.cc:finalize_type_size' and PR120308. */
396 0 : gcc_assert (targetm.calls.empty_record_p == hook_bool_const_tree_false);
397 0 : TYPE_EMPTY_P (expr) = 0;
398 : }
399 515587 : if (FUNC_OR_METHOD_TYPE_P (expr))
400 154670 : TYPE_NO_NAMED_ARGS_STDARG_P (expr) = (unsigned) bp_unpack_value (bp, 1);
401 515587 : if (RECORD_OR_UNION_TYPE_P (expr))
402 59220 : TYPE_INCLUDES_FLEXARRAY (expr) = (unsigned) bp_unpack_value (bp, 1);
403 515587 : TYPE_PRECISION_RAW (expr) = bp_unpack_var_len_unsigned (bp);
404 515587 : SET_TYPE_ALIGN (expr, bp_unpack_var_len_unsigned (bp));
405 : #ifdef ACCEL_COMPILER
406 : if (TYPE_ALIGN (expr) > targetm.absolute_biggest_alignment)
407 : SET_TYPE_ALIGN (expr, targetm.absolute_biggest_alignment);
408 :
409 : /* Host streams out VOIDmode for aggregate type. */
410 : if (AGGREGATE_TYPE_P (expr) && TYPE_MODE (expr) == VOIDmode)
411 : {
412 : if (TREE_CODE (expr) == ARRAY_TYPE)
413 : compute_array_mode (expr);
414 : else if (RECORD_OR_UNION_TYPE_P (expr))
415 : compute_record_mode (expr);
416 : else
417 : gcc_unreachable ();
418 : }
419 : #endif
420 515587 : }
421 :
422 :
423 : /* Unpack all the non-pointer fields of the TS_BLOCK structure
424 : of expression EXPR from bitpack BP. */
425 :
426 : static void
427 289337 : unpack_ts_block_value_fields (class data_in *data_in,
428 : struct bitpack_d *bp, tree expr)
429 : {
430 : /* BLOCK_NUMBER is recomputed. */
431 289337 : stream_input_location (&BLOCK_SOURCE_LOCATION (expr), bp, data_in);
432 289337 : }
433 :
434 : /* Unpack all the non-pointer fields of the TS_TRANSLATION_UNIT_DECL
435 : structure of expression EXPR from bitpack BP. */
436 :
437 : static void
438 24407 : unpack_ts_translation_unit_decl_value_fields (class data_in *data_in,
439 : struct bitpack_d *bp, tree expr)
440 : {
441 24407 : TRANSLATION_UNIT_LANGUAGE (expr) = xstrdup (bp_unpack_string (data_in, bp));
442 24407 : vec_safe_push (all_translation_units, expr);
443 24407 : }
444 :
445 :
446 : /* Unpack all the non-pointer fields of the TS_OMP_CLAUSE
447 : structure of expression EXPR from bitpack BP. */
448 :
449 : static void
450 210 : unpack_ts_omp_clause_value_fields (class data_in *data_in,
451 : struct bitpack_d *bp, tree expr)
452 : {
453 210 : stream_input_location (&OMP_CLAUSE_LOCATION (expr), bp, data_in);
454 210 : switch (OMP_CLAUSE_CODE (expr))
455 : {
456 0 : case OMP_CLAUSE_DEFAULT:
457 0 : OMP_CLAUSE_DEFAULT_KIND (expr)
458 0 : = bp_unpack_enum (bp, omp_clause_default_kind,
459 : OMP_CLAUSE_DEFAULT_LAST);
460 0 : break;
461 0 : case OMP_CLAUSE_SCHEDULE:
462 0 : OMP_CLAUSE_SCHEDULE_KIND (expr)
463 0 : = bp_unpack_enum (bp, omp_clause_schedule_kind,
464 : OMP_CLAUSE_SCHEDULE_LAST);
465 0 : break;
466 0 : case OMP_CLAUSE_DEPEND:
467 0 : OMP_CLAUSE_DEPEND_KIND (expr)
468 0 : = bp_unpack_enum (bp, omp_clause_depend_kind, OMP_CLAUSE_DEPEND_LAST);
469 0 : break;
470 0 : case OMP_CLAUSE_DOACROSS:
471 0 : OMP_CLAUSE_DOACROSS_KIND (expr)
472 0 : = bp_unpack_enum (bp, omp_clause_doacross_kind,
473 : OMP_CLAUSE_DOACROSS_LAST);
474 0 : break;
475 0 : case OMP_CLAUSE_MAP:
476 0 : OMP_CLAUSE_SET_MAP_KIND (expr, bp_unpack_enum (bp, gomp_map_kind,
477 : GOMP_MAP_LAST));
478 0 : break;
479 0 : case OMP_CLAUSE_PROC_BIND:
480 0 : OMP_CLAUSE_PROC_BIND_KIND (expr)
481 0 : = bp_unpack_enum (bp, omp_clause_proc_bind_kind,
482 : OMP_CLAUSE_PROC_BIND_LAST);
483 0 : break;
484 0 : case OMP_CLAUSE_REDUCTION:
485 0 : case OMP_CLAUSE_TASK_REDUCTION:
486 0 : case OMP_CLAUSE_IN_REDUCTION:
487 0 : OMP_CLAUSE_REDUCTION_CODE (expr)
488 0 : = bp_unpack_enum (bp, tree_code, MAX_TREE_CODES);
489 0 : break;
490 : default:
491 : break;
492 : }
493 210 : }
494 :
495 :
496 : /* Read all the language-independent bitfield values for EXPR from IB.
497 : Return the partially unpacked bitpack so the caller can unpack any other
498 : bitfield values that the writer may have written. */
499 :
500 : void
501 4571721 : streamer_read_tree_bitfields (class lto_input_block *ib,
502 : class data_in *data_in, tree expr)
503 : {
504 4571721 : enum tree_code code;
505 4571721 : struct bitpack_d bp;
506 :
507 : /* Read the bitpack of non-pointer values from IB. */
508 4571721 : bp = streamer_read_bitpack (ib);
509 4571721 : code = TREE_CODE (expr);
510 :
511 : /* Note that all these functions are highly sensitive to changes in
512 : the types and sizes of each of the fields being packed. */
513 4571721 : unpack_ts_base_value_fields (&bp, expr);
514 :
515 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_INT_CST))
516 37794 : unpack_ts_int_cst_value_fields (&bp, expr);
517 :
518 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_REAL_CST))
519 104385 : unpack_ts_real_cst_value_fields (&bp, expr);
520 :
521 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_FIXED_CST))
522 0 : unpack_ts_fixed_cst_value_fields (&bp, expr);
523 :
524 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_MINIMAL))
525 770532 : stream_input_location (&DECL_SOURCE_LOCATION (expr), &bp, data_in);
526 :
527 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
528 770532 : unpack_ts_decl_common_value_fields (&bp, expr);
529 :
530 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_WRTL))
531 666830 : unpack_ts_decl_wrtl_value_fields (&bp, expr);
532 :
533 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS))
534 454962 : unpack_ts_decl_with_vis_value_fields (&bp, expr);
535 :
536 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_FUNCTION_DECL))
537 212980 : unpack_ts_function_decl_value_fields (&bp, expr);
538 :
539 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_TYPE_COMMON))
540 515587 : unpack_ts_type_common_value_fields (&bp, expr);
541 :
542 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_EXP))
543 : {
544 1377622 : stream_input_location (&EXPR_CHECK (expr)->exp.locus, &bp, data_in);
545 1377622 : if (code == MEM_REF
546 1377622 : || code == TARGET_MEM_REF)
547 : {
548 660782 : MR_DEPENDENCE_CLIQUE (expr)
549 330391 : = (unsigned)bp_unpack_value (&bp, sizeof (short) * 8);
550 330391 : if (MR_DEPENDENCE_CLIQUE (expr) != 0)
551 20716 : MR_DEPENDENCE_BASE (expr)
552 10358 : = (unsigned)bp_unpack_value (&bp, sizeof (short) * 8);
553 : }
554 1047231 : else if (code == CALL_EXPR)
555 0 : CALL_EXPR_IFN (expr) = bp_unpack_enum (&bp, internal_fn, IFN_LAST);
556 : }
557 :
558 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_BLOCK))
559 289337 : unpack_ts_block_value_fields (data_in, &bp, expr);
560 :
561 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_TRANSLATION_UNIT_DECL))
562 24407 : unpack_ts_translation_unit_decl_value_fields (data_in, &bp, expr);
563 :
564 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_OPTIMIZATION))
565 23978 : cl_optimization_stream_in (data_in, &bp, TREE_OPTIMIZATION (expr));
566 :
567 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_CONSTRUCTOR))
568 : {
569 59358 : CLOBBER_KIND (expr)
570 29679 : = bp_unpack_enum (&bp, clobber_kind, CLOBBER_LAST);
571 29679 : unsigned HOST_WIDE_INT length = bp_unpack_var_len_unsigned (&bp);
572 29679 : if (length > 0)
573 12892 : vec_safe_grow (CONSTRUCTOR_ELTS (expr), length, true);
574 : }
575 :
576 : #ifndef ACCEL_COMPILER
577 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_TARGET_OPTION))
578 : {
579 23535 : cl_target_option_stream_in (data_in, &bp, TREE_TARGET_OPTION (expr));
580 23535 : if (targetm.target_option.post_stream_in)
581 23535 : targetm.target_option.post_stream_in (TREE_TARGET_OPTION (expr));
582 : }
583 : #endif
584 :
585 4571721 : if (code == OMP_CLAUSE)
586 210 : unpack_ts_omp_clause_value_fields (data_in, &bp, expr);
587 4571721 : }
588 :
589 :
590 : /* Materialize a new tree from input block IB using descriptors in
591 : DATA_IN. The code for the new tree should match TAG. Store in
592 : *IX_P the index into the reader cache where the new tree is stored. */
593 :
594 : tree
595 4571721 : streamer_alloc_tree (class lto_input_block *ib, class data_in *data_in,
596 : enum LTO_tags tag)
597 : {
598 4571721 : enum tree_code code;
599 4571721 : tree result;
600 :
601 4571721 : result = NULL_TREE;
602 :
603 4571721 : code = lto_tag_to_tree_code (tag);
604 :
605 : /* We should never see an SSA_NAME tree. Only the version numbers of
606 : SSA names are ever written out. See input_ssa_names. */
607 4571721 : gcc_assert (code != SSA_NAME);
608 :
609 : /* Instantiate a new tree using the header data. */
610 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_STRING))
611 171086 : result = streamer_read_string_cst (data_in, ib);
612 4400635 : else if (CODE_CONTAINS_STRUCT (code, TS_IDENTIFIER))
613 754867 : result = input_identifier (data_in, ib);
614 3645768 : else if (CODE_CONTAINS_STRUCT (code, TS_VEC))
615 : {
616 2 : HOST_WIDE_INT len = streamer_read_hwi (ib);
617 2 : result = make_tree_vec (len);
618 : }
619 3645766 : else if (CODE_CONTAINS_STRUCT (code, TS_VECTOR))
620 : {
621 3078 : bitpack_d bp = streamer_read_bitpack (ib);
622 3078 : unsigned int log2_npatterns = bp_unpack_value (&bp, 8);
623 3078 : unsigned int nelts_per_pattern = bp_unpack_value (&bp, 8);
624 3078 : result = make_vector (log2_npatterns, nelts_per_pattern);
625 : }
626 3642688 : else if (CODE_CONTAINS_STRUCT (code, TS_BINFO))
627 : {
628 6023 : unsigned HOST_WIDE_INT len = streamer_read_uhwi (ib);
629 6023 : result = make_tree_binfo (len);
630 : }
631 3636665 : else if (CODE_CONTAINS_STRUCT (code, TS_INT_CST))
632 : {
633 37794 : unsigned HOST_WIDE_INT len = streamer_read_uhwi (ib);
634 37794 : unsigned HOST_WIDE_INT ext_len = streamer_read_uhwi (ib);
635 37794 : result = make_int_cst (len, ext_len);
636 : }
637 3598871 : else if (code == CALL_EXPR)
638 : {
639 0 : unsigned HOST_WIDE_INT nargs = streamer_read_uhwi (ib);
640 0 : return build_vl_exp (CALL_EXPR, nargs + 3);
641 : }
642 3598871 : else if (code == OMP_CLAUSE)
643 : {
644 210 : enum omp_clause_code subcode
645 210 : = (enum omp_clause_code) streamer_read_uhwi (ib);
646 210 : return build_omp_clause (UNKNOWN_LOCATION, subcode);
647 : }
648 3598661 : else if (code == RAW_DATA_CST)
649 : {
650 19 : unsigned HOST_WIDE_INT len = streamer_read_uhwi (ib);
651 19 : if (len == 0)
652 2 : result = streamer_read_string_cst (data_in, ib);
653 : else
654 : {
655 17 : unsigned HOST_WIDE_INT off = streamer_read_uhwi (ib);
656 17 : result = make_node (code);
657 17 : RAW_DATA_LENGTH (result) = len;
658 17 : RAW_DATA_POINTER (result) = (const char *) (uintptr_t) off;
659 : }
660 : }
661 : else
662 : {
663 : /* For all other nodes, materialize the tree with a raw
664 : make_node call. */
665 3598642 : result = make_node (code);
666 : }
667 :
668 : return result;
669 : }
670 :
671 :
672 : /* Read all pointer fields in the TS_COMMON structure of EXPR from input
673 : block IB. DATA_IN contains tables and descriptors for the
674 : file being read. */
675 :
676 :
677 : static void
678 4234871 : lto_input_ts_common_tree_pointers (class lto_input_block *ib,
679 : class data_in *data_in, tree expr)
680 : {
681 4234871 : if (TREE_CODE (expr) != IDENTIFIER_NODE)
682 3480004 : TREE_TYPE (expr) = stream_read_tree_ref (ib, data_in);
683 4234871 : }
684 :
685 :
686 : /* Read all pointer fields in the TS_VECTOR structure of EXPR from input
687 : block IB. DATA_IN contains tables and descriptors for the
688 : file being read. */
689 :
690 : static void
691 3078 : lto_input_ts_vector_tree_pointers (class lto_input_block *ib,
692 : class data_in *data_in, tree expr)
693 : {
694 3078 : unsigned int count = vector_cst_encoded_nelts (expr);
695 17803 : for (unsigned int i = 0; i < count; ++i)
696 11647 : VECTOR_CST_ENCODED_ELT (expr, i) = stream_read_tree_ref (ib, data_in);
697 3078 : }
698 :
699 :
700 : /* Read all pointer fields in the TS_POLY_INT_CST structure of EXPR from
701 : input block IB. DATA_IN contains tables and descriptors for the
702 : file being read. */
703 :
704 : static void
705 0 : lto_input_ts_poly_tree_pointers (class lto_input_block *ib,
706 : class data_in *data_in, tree expr)
707 : {
708 : #ifdef ACCEL_COMPILER
709 : /* Ensure that we have streamed-in host_num_poly_int_coeffs. */
710 : const unsigned num_poly_int_coeffs = host_num_poly_int_coeffs;
711 : gcc_assert (num_poly_int_coeffs > 0);
712 : #else
713 0 : const unsigned num_poly_int_coeffs = NUM_POLY_INT_COEFFS;
714 : #endif
715 :
716 0 : unsigned i;
717 0 : if (num_poly_int_coeffs <= NUM_POLY_INT_COEFFS)
718 : {
719 0 : for (i = 0; i < num_poly_int_coeffs; i++)
720 0 : POLY_INT_CST_COEFF (expr, i) = stream_read_tree_ref (ib, data_in);
721 :
722 0 : tree coeff_type = TREE_TYPE (POLY_INT_CST_COEFF (expr, 0));
723 0 : for (; i < NUM_POLY_INT_COEFFS; i++)
724 : POLY_INT_CST_COEFF (expr, i) = build_zero_cst (coeff_type);
725 : }
726 : else
727 : {
728 : for (i = 0; i < NUM_POLY_INT_COEFFS; i++)
729 : POLY_INT_CST_COEFF (expr, i) = stream_read_tree_ref (ib, data_in);
730 : for (; i < num_poly_int_coeffs; i++)
731 : {
732 : tree val = stream_read_tree_ref (ib, data_in);
733 : if (!integer_zerop (val))
734 : fatal_error (input_location,
735 : "degree of %<poly_int%> exceeds "
736 : "%<NUM_POLY_INT_COEFFS%>");
737 : }
738 : }
739 0 : }
740 :
741 :
742 : /* Read all pointer fields in the TS_COMPLEX structure of EXPR from input
743 : block IB. DATA_IN contains tables and descriptors for the
744 : file being read. */
745 :
746 : static void
747 6899 : lto_input_ts_complex_tree_pointers (class lto_input_block *ib,
748 : class data_in *data_in, tree expr)
749 : {
750 6899 : TREE_REALPART (expr) = stream_read_tree_ref (ib, data_in);
751 6899 : TREE_IMAGPART (expr) = stream_read_tree_ref (ib, data_in);
752 6899 : }
753 :
754 :
755 : /* Read all pointer fields in the TS_DECL_MINIMAL structure of EXPR
756 : from input block IB. DATA_IN contains tables and descriptors for the
757 : file being read. */
758 :
759 : static void
760 770532 : lto_input_ts_decl_minimal_tree_pointers (class lto_input_block *ib,
761 : class data_in *data_in, tree expr)
762 : {
763 770532 : DECL_NAME (expr) = stream_read_tree_ref (ib, data_in);
764 770532 : DECL_CONTEXT (expr) = stream_read_tree_ref (ib, data_in);
765 770532 : }
766 :
767 :
768 : /* Read all pointer fields in the TS_DECL_COMMON structure of EXPR from
769 : input block IB. DATA_IN contains tables and descriptors for the
770 : file being read. */
771 :
772 : static void
773 770532 : lto_input_ts_decl_common_tree_pointers (class lto_input_block *ib,
774 : class data_in *data_in, tree expr,
775 : int *origin_ref)
776 : {
777 770532 : DECL_SIZE (expr) = stream_read_tree_ref (ib, data_in);
778 770532 : DECL_SIZE_UNIT (expr) = stream_read_tree_ref (ib, data_in);
779 770532 : DECL_ATTRIBUTES (expr) = stream_read_tree_ref (ib, data_in);
780 770532 : DECL_ABSTRACT_ORIGIN (expr) = stream_read_tree_ref (ib, data_in, origin_ref);
781 :
782 550393 : if ((VAR_P (expr) || TREE_CODE (expr) == PARM_DECL)
783 872898 : && DECL_HAS_VALUE_EXPR_P (expr))
784 5926 : SET_DECL_VALUE_EXPR (expr, stream_read_tree_ref (ib, data_in));
785 :
786 770532 : if (VAR_P (expr)
787 770532 : && DECL_HAS_DEBUG_EXPR_P (expr))
788 : {
789 860 : tree dexpr = stream_read_tree_ref (ib, data_in);
790 860 : if (dexpr)
791 860 : SET_DECL_DEBUG_EXPR (expr, dexpr);
792 : }
793 770532 : }
794 :
795 :
796 : /* Read all pointer fields in the TS_DECL_NON_COMMON structure of
797 : EXPR from input block IB. DATA_IN contains tables and descriptors for the
798 : file being read. */
799 :
800 : static void
801 0 : lto_input_ts_decl_non_common_tree_pointers (class lto_input_block *,
802 : class data_in *, tree)
803 : {
804 0 : }
805 :
806 :
807 : /* Read all pointer fields in the TS_DECL_WITH_VIS structure of EXPR
808 : from input block IB. DATA_IN contains tables and descriptors for the
809 : file being read. */
810 :
811 : static void
812 454962 : lto_input_ts_decl_with_vis_tree_pointers (class lto_input_block *ib,
813 : class data_in *data_in, tree expr)
814 : {
815 454962 : tree id;
816 :
817 454962 : id = stream_read_tree_ref (ib, data_in);
818 454962 : if (id)
819 : {
820 305355 : gcc_assert (TREE_CODE (id) == IDENTIFIER_NODE);
821 305355 : SET_DECL_ASSEMBLER_NAME (expr, id);
822 : }
823 454962 : }
824 :
825 :
826 : /* Read all pointer fields in the TS_FIELD_DECL structure of EXPR from
827 : input block IB. DATA_IN contains tables and descriptors for the
828 : file being read. */
829 :
830 : static void
831 79170 : lto_input_ts_field_decl_tree_pointers (class lto_input_block *ib,
832 : class data_in *data_in, tree expr)
833 : {
834 79170 : DECL_FIELD_OFFSET (expr) = stream_read_tree_ref (ib, data_in);
835 79170 : DECL_BIT_FIELD_TYPE (expr) = stream_read_tree_ref (ib, data_in);
836 79170 : DECL_BIT_FIELD_REPRESENTATIVE (expr) = stream_read_tree_ref (ib, data_in);
837 79170 : DECL_FIELD_BIT_OFFSET (expr) = stream_read_tree_ref (ib, data_in);
838 79170 : }
839 :
840 :
841 : /* Read all pointer fields in the TS_FUNCTION_DECL structure of EXPR
842 : from input block IB. DATA_IN contains tables and descriptors for the
843 : file being read. */
844 :
845 : static void
846 212980 : lto_input_ts_function_decl_tree_pointers (class lto_input_block *ib,
847 : class data_in *data_in, tree expr)
848 : {
849 : /* DECL_STRUCT_FUNCTION is loaded on demand by cgraph_get_body. */
850 212980 : DECL_FUNCTION_PERSONALITY (expr) = stream_read_tree_ref (ib, data_in);
851 : #ifndef ACCEL_COMPILER
852 212980 : DECL_FUNCTION_SPECIFIC_TARGET (expr) = stream_read_tree_ref (ib, data_in);
853 : #endif
854 425960 : DECL_FUNCTION_SPECIFIC_OPTIMIZATION (expr)
855 212980 : = stream_read_tree_ref (ib, data_in);
856 : #ifdef ACCEL_COMPILER
857 : {
858 : tree opts = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (expr);
859 : if (opts)
860 : {
861 : struct gcc_options tmp, tmp_set;
862 : init_options_struct (&tmp, NULL);
863 : memset (&tmp_set, 0, sizeof (tmp_set));
864 : cl_optimization_restore (&tmp, &tmp_set, TREE_OPTIMIZATION (opts));
865 : finish_options (&tmp, &tmp_set, UNKNOWN_LOCATION);
866 : opts = build_optimization_node (&tmp, &tmp_set);
867 : DECL_FUNCTION_SPECIFIC_OPTIMIZATION (expr) = opts;
868 : }
869 : }
870 : #endif
871 212980 : }
872 :
873 :
874 : /* Read all pointer fields in the TS_TYPE_COMMON structure of EXPR from
875 : input block IB. DATA_IN contains tables and descriptors for the file
876 : being read. */
877 :
878 : static void
879 515587 : lto_input_ts_type_common_tree_pointers (class lto_input_block *ib,
880 : class data_in *data_in, tree expr)
881 : {
882 515587 : TYPE_SIZE (expr) = stream_read_tree_ref (ib, data_in);
883 515587 : TYPE_SIZE_UNIT (expr) = stream_read_tree_ref (ib, data_in);
884 515587 : TYPE_ATTRIBUTES (expr) = stream_read_tree_ref (ib, data_in);
885 515587 : TYPE_NAME (expr) = stream_read_tree_ref (ib, data_in);
886 : /* Do not stream TYPE_POINTER_TO or TYPE_REFERENCE_TO. They will be
887 : reconstructed during fixup. */
888 : /* Do not stream TYPE_NEXT_VARIANT, we reconstruct the variant lists
889 : during fixup. */
890 515587 : TYPE_MAIN_VARIANT (expr) = stream_read_tree_ref (ib, data_in);
891 515587 : TYPE_CONTEXT (expr) = stream_read_tree_ref (ib, data_in);
892 : /* TYPE_CANONICAL gets re-computed during type merging. */
893 515587 : TYPE_CANONICAL (expr) = NULL_TREE;
894 515587 : }
895 :
896 : /* Read all pointer fields in the TS_TYPE_NON_COMMON structure of EXPR
897 : from input block IB. DATA_IN contains tables and descriptors for the
898 : file being read. */
899 :
900 : static void
901 515587 : lto_input_ts_type_non_common_tree_pointers (class lto_input_block *ib,
902 : class data_in *data_in,
903 : tree expr)
904 : {
905 515587 : if (TREE_CODE (expr) == ARRAY_TYPE)
906 40967 : TYPE_DOMAIN (expr) = stream_read_tree_ref (ib, data_in);
907 474620 : else if (RECORD_OR_UNION_TYPE_P (expr))
908 59220 : TYPE_FIELDS (expr) = streamer_read_chain (ib, data_in);
909 415400 : else if (FUNC_OR_METHOD_TYPE_P (expr))
910 154670 : TYPE_ARG_TYPES (expr) = stream_read_tree_ref (ib, data_in);
911 :
912 515587 : if (!POINTER_TYPE_P (expr))
913 326031 : TYPE_MIN_VALUE_RAW (expr) = stream_read_tree_ref (ib, data_in);
914 515587 : TYPE_MAX_VALUE_RAW (expr) = stream_read_tree_ref (ib, data_in);
915 515587 : }
916 :
917 :
918 : /* Read all pointer fields in the TS_LIST structure of EXPR from input
919 : block IB. DATA_IN contains tables and descriptors for the
920 : file being read. */
921 :
922 : static void
923 457088 : lto_input_ts_list_tree_pointers (class lto_input_block *ib,
924 : class data_in *data_in, tree expr)
925 : {
926 457088 : TREE_PURPOSE (expr) = stream_read_tree_ref (ib, data_in);
927 457088 : TREE_VALUE (expr) = stream_read_tree_ref (ib, data_in);
928 457088 : TREE_CHAIN (expr) = stream_read_tree_ref (ib, data_in);
929 457088 : }
930 :
931 :
932 : /* Read all pointer fields in the TS_VEC structure of EXPR from input
933 : block IB. DATA_IN contains tables and descriptors for the
934 : file being read. */
935 :
936 : static void
937 2 : lto_input_ts_vec_tree_pointers (class lto_input_block *ib,
938 : class data_in *data_in, tree expr)
939 : {
940 2 : int i;
941 :
942 : /* Note that TREE_VEC_LENGTH was read by streamer_alloc_tree to
943 : instantiate EXPR. */
944 10 : for (i = 0; i < TREE_VEC_LENGTH (expr); i++)
945 8 : TREE_VEC_ELT (expr, i) = stream_read_tree_ref (ib, data_in);
946 2 : }
947 :
948 :
949 : /* Read all pointer fields in the TS_EXP structure of EXPR from input
950 : block IB. DATA_IN contains tables and descriptors for the
951 : file being read. */
952 :
953 :
954 : static void
955 1377622 : lto_input_ts_exp_tree_pointers (class lto_input_block *ib,
956 : class data_in *data_in, tree expr)
957 : {
958 1377622 : int i;
959 1377622 : tree block;
960 :
961 3418298 : for (i = 0; i < TREE_OPERAND_LENGTH (expr); i++)
962 2040676 : TREE_OPERAND (expr, i) = stream_read_tree_ref (ib, data_in);
963 :
964 1377622 : block = stream_read_tree_ref (ib, data_in);
965 :
966 : /* TODO: Block is stored in the locus information. It may make more sense to
967 : to make it go via the location cache. */
968 1377622 : if (block)
969 : {
970 222424 : data_in->location_cache.apply_location_cache ();
971 222424 : TREE_SET_BLOCK (expr, block);
972 : }
973 1377622 : }
974 :
975 :
976 : /* Read all pointer fields in the TS_BLOCK structure of EXPR from input
977 : block IB. DATA_IN contains tables and descriptors for the
978 : file being read. */
979 :
980 : static void
981 289337 : lto_input_ts_block_tree_pointers (class lto_input_block *ib,
982 : class data_in *data_in, tree expr,
983 : int *origin_ref)
984 : {
985 289337 : BLOCK_VARS (expr) = streamer_read_chain (ib, data_in);
986 :
987 289337 : BLOCK_SUPERCONTEXT (expr) = stream_read_tree_ref (ib, data_in);
988 289337 : BLOCK_ABSTRACT_ORIGIN (expr) = stream_read_tree_ref (ib, data_in, origin_ref);
989 : /* We may end up prevailing a decl with DECL_ORIGIN (t) != t here
990 : which breaks the invariant that BLOCK_ABSTRACT_ORIGIN is the
991 : ultimate origin. Fixup here.
992 : ??? This should get fixed with moving to DIE references. */
993 289337 : if (DECL_P (BLOCK_ORIGIN (expr)))
994 66927 : BLOCK_ABSTRACT_ORIGIN (expr) = DECL_ORIGIN (BLOCK_ABSTRACT_ORIGIN (expr));
995 : /* Do not stream BLOCK_NONLOCALIZED_VARS. We cannot handle debug information
996 : for early inlined BLOCKs so drop it on the floor instead of ICEing in
997 : dwarf2out.cc. */
998 :
999 : /* BLOCK_FRAGMENT_ORIGIN and BLOCK_FRAGMENT_CHAIN is not live at LTO
1000 : streaming time. */
1001 :
1002 : /* We re-compute BLOCK_SUBBLOCKS of our parent here instead
1003 : of streaming it. For non-BLOCK BLOCK_SUPERCONTEXTs we still
1004 : stream the child relationship explicitly. */
1005 289337 : if (BLOCK_SUPERCONTEXT (expr)
1006 289337 : && TREE_CODE (BLOCK_SUPERCONTEXT (expr)) == BLOCK)
1007 : {
1008 183553 : BLOCK_CHAIN (expr) = BLOCK_SUBBLOCKS (BLOCK_SUPERCONTEXT (expr));
1009 183553 : BLOCK_SUBBLOCKS (BLOCK_SUPERCONTEXT (expr)) = expr;
1010 : }
1011 :
1012 : /* The global block is rooted at the TU decl. Hook it here to
1013 : avoid the need to stream in this block during WPA time. */
1014 105784 : else if (BLOCK_SUPERCONTEXT (expr)
1015 105784 : && TREE_CODE (BLOCK_SUPERCONTEXT (expr)) == TRANSLATION_UNIT_DECL)
1016 0 : DECL_INITIAL (BLOCK_SUPERCONTEXT (expr)) = expr;
1017 :
1018 : /* The function-level block is connected at the time we read in
1019 : function bodies for the same reason. */
1020 289337 : }
1021 :
1022 :
1023 : /* Read all pointer fields in the TS_BINFO structure of EXPR from input
1024 : block IB. DATA_IN contains tables and descriptors for the
1025 : file being read. */
1026 :
1027 : static void
1028 6023 : lto_input_ts_binfo_tree_pointers (class lto_input_block *ib,
1029 : class data_in *data_in, tree expr)
1030 : {
1031 12223 : tree t;
1032 :
1033 : /* Note that the number of slots in EXPR was read in
1034 : streamer_alloc_tree when instantiating EXPR. However, the
1035 : vector is empty so we cannot rely on vec::length to know how many
1036 : elements to read. So, this list is emitted as a 0-terminated
1037 : list on the writer side. */
1038 12223 : do
1039 : {
1040 12223 : t = stream_read_tree_ref (ib, data_in);
1041 12223 : if (t)
1042 6200 : BINFO_BASE_BINFOS (expr)->quick_push (t);
1043 : }
1044 12223 : while (t);
1045 :
1046 6023 : BINFO_OFFSET (expr) = stream_read_tree_ref (ib, data_in);
1047 6023 : BINFO_VTABLE (expr) = stream_read_tree_ref (ib, data_in);
1048 :
1049 : /* Do not walk BINFO_INHERITANCE_CHAIN, BINFO_SUBVTT_INDEX,
1050 : BINFO_BASE_ACCESSES and BINFO_VPTR_INDEX; these are used by C++ FE
1051 : only. */
1052 6023 : }
1053 :
1054 :
1055 : /* Read all pointer fields in the TS_CONSTRUCTOR structure of EXPR from
1056 : input block IB. DATA_IN contains tables and descriptors for the
1057 : file being read. */
1058 :
1059 : static void
1060 29679 : lto_input_ts_constructor_tree_pointers (class lto_input_block *ib,
1061 : class data_in *data_in, tree expr)
1062 : {
1063 29679 : unsigned i;
1064 :
1065 120506 : for (i = 0; i < CONSTRUCTOR_NELTS (expr); i++)
1066 : {
1067 90827 : constructor_elt e;
1068 90827 : e.index = stream_read_tree_ref (ib, data_in);
1069 90827 : e.value = stream_read_tree_ref (ib, data_in);
1070 90827 : (*CONSTRUCTOR_ELTS (expr))[i] = e;
1071 : }
1072 29679 : }
1073 :
1074 :
1075 : /* Read all pointer fields in the TS_RAW_DATA_CST structure of EXPR from
1076 : input block IB. DATA_IN contains tables and descriptors for the
1077 : file being read. */
1078 :
1079 : static void
1080 17 : lto_input_ts_raw_data_cst_tree_pointers (class lto_input_block *ib,
1081 : class data_in *data_in, tree expr)
1082 : {
1083 17 : RAW_DATA_OWNER (expr) = stream_read_tree_ref (ib, data_in);
1084 17 : gcc_checking_assert (RAW_DATA_OWNER (expr)
1085 : && TREE_CODE (RAW_DATA_OWNER (expr)) == STRING_CST);
1086 17 : RAW_DATA_POINTER (expr) = (TREE_STRING_POINTER (RAW_DATA_OWNER (expr))
1087 17 : + (uintptr_t) RAW_DATA_POINTER (expr));
1088 17 : }
1089 :
1090 :
1091 : /* Read all pointer fields in the TS_OMP_CLAUSE structure of EXPR from
1092 : input block IB. DATA_IN contains tables and descriptors for the
1093 : file being read. */
1094 :
1095 : static void
1096 210 : lto_input_ts_omp_clause_tree_pointers (class lto_input_block *ib,
1097 : class data_in *data_in, tree expr)
1098 : {
1099 210 : int i;
1100 :
1101 588 : for (i = 0; i < omp_clause_num_ops[OMP_CLAUSE_CODE (expr)]; i++)
1102 378 : OMP_CLAUSE_OPERAND (expr, i) = stream_read_tree_ref (ib, data_in);
1103 210 : OMP_CLAUSE_CHAIN (expr) = stream_read_tree_ref (ib, data_in);
1104 210 : }
1105 :
1106 :
1107 : /* Read all pointer fields in EXPR from input block IB. DATA_IN
1108 : contains tables and descriptors for the file being read. */
1109 :
1110 : void
1111 4571721 : streamer_read_tree_body (class lto_input_block *ib, class data_in *data_in,
1112 : tree expr, int *origin_ref)
1113 : {
1114 4571721 : enum tree_code code;
1115 :
1116 4571721 : code = TREE_CODE (expr);
1117 :
1118 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_TYPED))
1119 4234871 : lto_input_ts_common_tree_pointers (ib, data_in, expr);
1120 :
1121 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_VECTOR))
1122 3078 : lto_input_ts_vector_tree_pointers (ib, data_in, expr);
1123 :
1124 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_POLY_INT_CST))
1125 0 : lto_input_ts_poly_tree_pointers (ib, data_in, expr);
1126 :
1127 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_COMPLEX))
1128 6899 : lto_input_ts_complex_tree_pointers (ib, data_in, expr);
1129 :
1130 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_MINIMAL))
1131 770532 : lto_input_ts_decl_minimal_tree_pointers (ib, data_in, expr);
1132 :
1133 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
1134 770532 : lto_input_ts_decl_common_tree_pointers (ib, data_in, expr, origin_ref);
1135 :
1136 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_NON_COMMON))
1137 4571721 : lto_input_ts_decl_non_common_tree_pointers (ib, data_in, expr);
1138 :
1139 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS))
1140 454962 : lto_input_ts_decl_with_vis_tree_pointers (ib, data_in, expr);
1141 :
1142 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_FIELD_DECL))
1143 79170 : lto_input_ts_field_decl_tree_pointers (ib, data_in, expr);
1144 :
1145 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_FUNCTION_DECL))
1146 212980 : lto_input_ts_function_decl_tree_pointers (ib, data_in, expr);
1147 :
1148 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_TYPE_COMMON))
1149 515587 : lto_input_ts_type_common_tree_pointers (ib, data_in, expr);
1150 :
1151 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_TYPE_NON_COMMON))
1152 515587 : lto_input_ts_type_non_common_tree_pointers (ib, data_in, expr);
1153 :
1154 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_LIST))
1155 457088 : lto_input_ts_list_tree_pointers (ib, data_in, expr);
1156 :
1157 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_VEC))
1158 2 : lto_input_ts_vec_tree_pointers (ib, data_in, expr);
1159 :
1160 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_EXP))
1161 1377622 : lto_input_ts_exp_tree_pointers (ib, data_in, expr);
1162 :
1163 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_BLOCK))
1164 289337 : lto_input_ts_block_tree_pointers (ib, data_in, expr, origin_ref);
1165 :
1166 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_BINFO))
1167 6023 : lto_input_ts_binfo_tree_pointers (ib, data_in, expr);
1168 :
1169 4571721 : if (CODE_CONTAINS_STRUCT (code, TS_CONSTRUCTOR))
1170 29679 : lto_input_ts_constructor_tree_pointers (ib, data_in, expr);
1171 :
1172 4571721 : if (code == RAW_DATA_CST)
1173 17 : lto_input_ts_raw_data_cst_tree_pointers (ib, data_in, expr);
1174 :
1175 4571721 : if (code == OMP_CLAUSE)
1176 210 : lto_input_ts_omp_clause_tree_pointers (ib, data_in, expr);
1177 4571721 : }
1178 :
1179 :
1180 : /* Read an index IX from input block IB and return the tree node at
1181 : DATA_IN->FILE_DATA->GLOBALS_INDEX[IX]. */
1182 :
1183 : tree
1184 1624427 : streamer_get_pickled_tree (class lto_input_block *ib, class data_in *data_in)
1185 : {
1186 1624427 : unsigned HOST_WIDE_INT ix;
1187 1624427 : tree result;
1188 :
1189 1624427 : ix = streamer_read_uhwi (ib);
1190 1624427 : result = streamer_tree_cache_get_tree (data_in->reader_cache, ix);
1191 1624427 : return result;
1192 : }
|