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 175972 : streamer_read_string_cst (class data_in *data_in, class lto_input_block *ib)
46 : {
47 175972 : unsigned int len;
48 175972 : const char * ptr;
49 :
50 175972 : ptr = streamer_read_indexed_string (data_in, ib, &len);
51 175972 : if (!ptr)
52 : return NULL;
53 175972 : 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 732857 : input_identifier (class data_in *data_in, class lto_input_block *ib)
62 : {
63 732857 : unsigned int len;
64 732857 : const char *ptr;
65 :
66 732857 : ptr = streamer_read_indexed_string (data_in, ib, &len);
67 732857 : if (!ptr)
68 : return NULL;
69 732857 : 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 343158 : streamer_read_chain (class lto_input_block *ib, class data_in *data_in)
78 : {
79 343158 : tree first, prev, curr;
80 :
81 : /* The chain is written as NULL terminated list of trees. */
82 343158 : first = prev = NULL_TREE;
83 573990 : do
84 : {
85 573990 : curr = stream_read_tree_ref (ib, data_in);
86 573990 : if (prev)
87 230832 : TREE_CHAIN (prev) = curr;
88 : else
89 : first = curr;
90 :
91 573990 : prev = curr;
92 : }
93 573990 : while (curr);
94 :
95 343158 : 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 4424140 : 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 4424140 : if (!TYPE_P (expr))
108 : {
109 3923138 : TREE_SIDE_EFFECTS (expr) = (unsigned) bp_unpack_value (bp, 1);
110 3923138 : TREE_CONSTANT (expr) = (unsigned) bp_unpack_value (bp, 1);
111 3923138 : 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 3923138 : TREE_PUBLIC (expr) = (unsigned) bp_unpack_value (bp, 1);
117 : }
118 : else
119 501002 : bp_unpack_value (bp, 4);
120 4424140 : TREE_ADDRESSABLE (expr) = (unsigned) bp_unpack_value (bp, 1);
121 4424140 : TREE_THIS_VOLATILE (expr) = (unsigned) bp_unpack_value (bp, 1);
122 4424140 : if (DECL_P (expr))
123 : {
124 751394 : DECL_UNSIGNED (expr) = (unsigned) bp_unpack_value (bp, 1);
125 751394 : DECL_NAMELESS (expr) = (unsigned) bp_unpack_value (bp, 1);
126 : }
127 3672746 : else if (TYPE_P (expr))
128 501002 : TYPE_UNSIGNED (expr) = (unsigned) bp_unpack_value (bp, 1);
129 : else
130 3171744 : bp_unpack_value (bp, 1);
131 4424140 : TREE_ASM_WRITTEN (expr) = (unsigned) bp_unpack_value (bp, 1);
132 4424140 : if (TYPE_P (expr))
133 501002 : TYPE_ARTIFICIAL (expr) = (unsigned) bp_unpack_value (bp, 1);
134 : else
135 3923138 : TREE_NO_WARNING (expr) = (unsigned) bp_unpack_value (bp, 1);
136 4424140 : TREE_NOTHROW (expr) = (unsigned) bp_unpack_value (bp, 1);
137 4424140 : TREE_STATIC (expr) = (unsigned) bp_unpack_value (bp, 1);
138 4424140 : if (TREE_CODE (expr) != TREE_BINFO)
139 4418153 : TREE_PRIVATE (expr) = (unsigned) bp_unpack_value (bp, 1);
140 : else
141 5987 : bp_unpack_value (bp, 1);
142 4424140 : TREE_PROTECTED (expr) = (unsigned) bp_unpack_value (bp, 1);
143 4424140 : TREE_DEPRECATED (expr) = (unsigned) bp_unpack_value (bp, 1);
144 4424140 : if (TYPE_P (expr))
145 : {
146 501002 : if (AGGREGATE_TYPE_P (expr))
147 98336 : TYPE_REVERSE_STORAGE_ORDER (expr) = (unsigned) bp_unpack_value (bp, 1);
148 : else
149 402666 : TYPE_SATURATING (expr) = (unsigned) bp_unpack_value (bp, 1);
150 : #ifndef ACCEL_COMPILER
151 501002 : TYPE_ADDR_SPACE (expr) = (unsigned) bp_unpack_value (bp, 8);
152 : #endif
153 : }
154 3923138 : else if (TREE_CODE (expr) == BIT_FIELD_REF || TREE_CODE (expr) == MEM_REF)
155 : {
156 313792 : REF_REVERSE_STORAGE_ORDER (expr) = (unsigned) bp_unpack_value (bp, 1);
157 313792 : bp_unpack_value (bp, 8);
158 : }
159 3609346 : 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 3609346 : 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 3609346 : bp_unpack_value (bp, 9);
171 4424140 : }
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 36366 : unpack_ts_int_cst_value_fields (struct bitpack_d *bp, tree expr)
179 : {
180 36366 : int i;
181 82002 : for (i = 0; i < TREE_INT_CST_EXT_NUNITS (expr); i++)
182 45636 : TREE_INT_CST_ELT (expr, i) = bp_unpack_var_len_int (bp);
183 36366 : }
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 103989 : unpack_ts_real_cst_value_fields (struct bitpack_d *bp, tree expr)
191 : {
192 103989 : REAL_VALUE_TYPE r;
193 :
194 103989 : bp_unpack_real_value (bp, &r);
195 103989 : memcpy (TREE_REAL_CST_PTR (expr), &r, sizeof (REAL_VALUE_TYPE));
196 103989 : }
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 751394 : unpack_ts_decl_common_value_fields (struct bitpack_d *bp, tree expr)
217 : {
218 751394 : SET_DECL_MODE (expr, bp_unpack_machine_mode (bp));
219 751394 : DECL_NONLOCAL (expr) = (unsigned) bp_unpack_value (bp, 1);
220 751394 : DECL_VIRTUAL_P (expr) = (unsigned) bp_unpack_value (bp, 1);
221 751394 : DECL_IGNORED_P (expr) = (unsigned) bp_unpack_value (bp, 1);
222 751394 : DECL_ABSTRACT_P (expr) = (unsigned) bp_unpack_value (bp, 1);
223 751394 : DECL_ARTIFICIAL (expr) = (unsigned) bp_unpack_value (bp, 1);
224 751394 : DECL_USER_ALIGN (expr) = (unsigned) bp_unpack_value (bp, 1);
225 751394 : DECL_PRESERVE_P (expr) = (unsigned) bp_unpack_value (bp, 1);
226 751394 : DECL_EXTERNAL (expr) = (unsigned) bp_unpack_value (bp, 1);
227 751394 : DECL_NOT_GIMPLE_REG_P (expr) = (unsigned) bp_unpack_value (bp, 1);
228 751394 : 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 751394 : if (TREE_CODE (expr) == LABEL_DECL)
234 : {
235 19059 : 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 19059 : LABEL_DECL_UID (expr) = -1;
240 : }
241 :
242 732335 : else if (TREE_CODE (expr) == FIELD_DECL)
243 : {
244 78665 : DECL_PACKED (expr) = (unsigned) bp_unpack_value (bp, 1);
245 78665 : DECL_NONADDRESSABLE_P (expr) = (unsigned) bp_unpack_value (bp, 1);
246 78665 : DECL_PADDING_P (expr) = (unsigned) bp_unpack_value (bp, 1);
247 78665 : unsigned val = (unsigned) bp_unpack_value (bp, 1);
248 78665 : if (DECL_BIT_FIELD (expr))
249 : SET_DECL_FIELD_CXX_ZERO_WIDTH_BIT_FIELD (expr, val);
250 : else
251 78665 : SET_DECL_FIELD_ABI_IGNORED (expr, val);
252 78665 : expr->decl_common.off_align = bp_unpack_value (bp, 8);
253 78665 : DECL_NOT_FLEXARRAY (expr) = (unsigned) bp_unpack_value (bp, 1);
254 : }
255 :
256 653670 : else if (VAR_P (expr))
257 : {
258 214823 : DECL_HAS_DEBUG_EXPR_P (expr) = (unsigned) bp_unpack_value (bp, 1);
259 214823 : DECL_NONLOCAL_FRAME (expr) = (unsigned) bp_unpack_value (bp, 1);
260 : }
261 :
262 438847 : else if (TREE_CODE (expr) == PARM_DECL)
263 100254 : DECL_HIDDEN_STRING_LENGTH (expr) = (unsigned) bp_unpack_value (bp, 1);
264 :
265 751394 : if (TREE_CODE (expr) == RESULT_DECL
266 : || TREE_CODE (expr) == PARM_DECL
267 : || VAR_P (expr))
268 : {
269 401741 : DECL_BY_REFERENCE (expr) = (unsigned) bp_unpack_value (bp, 1);
270 401741 : if (VAR_P (expr) || TREE_CODE (expr) == PARM_DECL)
271 315077 : DECL_HAS_VALUE_EXPR_P (expr) = (unsigned) bp_unpack_value (bp, 1);
272 : }
273 751394 : }
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 650063 : unpack_ts_decl_wrtl_value_fields (struct bitpack_d *bp, tree expr)
281 : {
282 650063 : DECL_REGISTER (expr) = (unsigned) bp_unpack_value (bp, 1);
283 650063 : }
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 443741 : unpack_ts_decl_with_vis_value_fields (struct bitpack_d *bp, tree expr)
291 : {
292 443741 : DECL_COMMON (expr) = (unsigned) bp_unpack_value (bp, 1);
293 443741 : DECL_DLLIMPORT_P (expr) = (unsigned) bp_unpack_value (bp, 1);
294 443741 : DECL_WEAK (expr) = (unsigned) bp_unpack_value (bp, 1);
295 443741 : DECL_SEEN_IN_BIND_EXPR_P (expr) = (unsigned) bp_unpack_value (bp, 1);
296 443741 : DECL_COMDAT (expr) = (unsigned) bp_unpack_value (bp, 1);
297 443741 : DECL_VISIBILITY (expr) = (enum symbol_visibility) bp_unpack_value (bp, 2);
298 443741 : DECL_VISIBILITY_SPECIFIED (expr) = (unsigned) bp_unpack_value (bp, 1);
299 :
300 443741 : if (VAR_P (expr))
301 : {
302 214823 : DECL_HARD_REGISTER (expr) = (unsigned) bp_unpack_value (bp, 1);
303 214823 : DECL_IN_CONSTANT_POOL (expr) = (unsigned) bp_unpack_value (bp, 1);
304 : }
305 :
306 443741 : if (TREE_CODE (expr) == FUNCTION_DECL)
307 : {
308 207251 : DECL_FINAL_P (expr) = (unsigned) bp_unpack_value (bp, 1);
309 207251 : DECL_CXX_CONSTRUCTOR_P (expr) = (unsigned) bp_unpack_value (bp, 1);
310 207251 : DECL_CXX_DESTRUCTOR_P (expr) = (unsigned) bp_unpack_value (bp, 1);
311 : }
312 443741 : }
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 207251 : unpack_ts_function_decl_value_fields (struct bitpack_d *bp, tree expr)
320 : {
321 207251 : built_in_class cl = bp_unpack_enum (bp, built_in_class, BUILT_IN_LAST);
322 207251 : DECL_STATIC_CONSTRUCTOR (expr) = (unsigned) bp_unpack_value (bp, 1);
323 207251 : DECL_STATIC_DESTRUCTOR (expr) = (unsigned) bp_unpack_value (bp, 1);
324 207251 : DECL_UNINLINABLE (expr) = (unsigned) bp_unpack_value (bp, 1);
325 207251 : DECL_POSSIBLY_INLINED (expr) = (unsigned) bp_unpack_value (bp, 1);
326 207251 : DECL_IS_NOVOPS (expr) = (unsigned) bp_unpack_value (bp, 1);
327 207251 : DECL_IS_RETURNS_TWICE (expr) = (unsigned) bp_unpack_value (bp, 1);
328 207251 : DECL_IS_MALLOC (expr) = (unsigned) bp_unpack_value (bp, 1);
329 207251 : FUNCTION_DECL_DECL_TYPE (expr) = (function_decl_type) bp_unpack_value (bp, 2);
330 207251 : DECL_SET_IS_OPERATOR_DELETE (expr, (unsigned) bp_unpack_value (bp, 1));
331 207251 : DECL_DECLARED_INLINE_P (expr) = (unsigned) bp_unpack_value (bp, 1);
332 207251 : DECL_STATIC_CHAIN (expr) = (unsigned) bp_unpack_value (bp, 1);
333 207251 : DECL_NO_INLINE_WARNING_P (expr) = (unsigned) bp_unpack_value (bp, 1);
334 414502 : DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (expr)
335 207251 : = (unsigned) bp_unpack_value (bp, 1);
336 207251 : DECL_NO_LIMIT_STACK (expr) = (unsigned) bp_unpack_value (bp, 1);
337 207251 : DECL_DISREGARD_INLINE_LIMITS (expr) = (unsigned) bp_unpack_value (bp, 1);
338 207251 : DECL_PURE_P (expr) = (unsigned) bp_unpack_value (bp, 1);
339 207251 : DECL_LOOPING_CONST_OR_PURE_P (expr) = (unsigned) bp_unpack_value (bp, 1);
340 207251 : DECL_IS_REPLACEABLE_OPERATOR (expr) = (unsigned) bp_unpack_value (bp, 1);
341 207251 : unsigned int fcode = 0;
342 207251 : if (cl != NOT_BUILT_IN)
343 : {
344 31022 : fcode = bp_unpack_value (bp, 32);
345 31022 : if (cl == BUILT_IN_NORMAL && fcode >= END_BUILTINS)
346 0 : fatal_error (input_location,
347 : "machine independent builtin code out of range");
348 31022 : 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 207251 : set_decl_built_in_function (expr, cl, fcode);
357 207251 : }
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 501002 : unpack_ts_type_common_value_fields (struct bitpack_d *bp, tree expr)
365 : {
366 501002 : machine_mode mode;
367 :
368 501002 : mode = bp_unpack_machine_mode (bp);
369 501002 : SET_TYPE_MODE (expr, mode);
370 : /* TYPE_NO_FORCE_BLK is private to stor-layout and need
371 : no streaming. */
372 501002 : TYPE_PACKED (expr) = (unsigned) bp_unpack_value (bp, 1);
373 501002 : TYPE_RESTRICT (expr) = (unsigned) bp_unpack_value (bp, 1);
374 501002 : TYPE_USER_ALIGN (expr) = (unsigned) bp_unpack_value (bp, 1);
375 501002 : TYPE_READONLY (expr) = (unsigned) bp_unpack_value (bp, 1);
376 501002 : TYPE_LANG_FLAG_0 (expr) = (unsigned) bp_unpack_value (bp, 1);
377 501002 : if (RECORD_OR_UNION_TYPE_P (expr))
378 : {
379 58594 : TYPE_TRANSPARENT_AGGR (expr) = (unsigned) bp_unpack_value (bp, 1);
380 58594 : TYPE_FINAL_P (expr) = (unsigned) bp_unpack_value (bp, 1);
381 58594 : TYPE_CXX_ODR_P (expr) = (unsigned) bp_unpack_value (bp, 1);
382 : }
383 442408 : else if (TREE_CODE (expr) == ARRAY_TYPE)
384 39742 : TYPE_NONALIASED_COMPONENT (expr) = (unsigned) bp_unpack_value (bp, 1);
385 501002 : if (TREE_CODE (expr) == ARRAY_TYPE || TREE_CODE (expr) == INTEGER_TYPE)
386 96817 : TYPE_STRING_FLAG (expr) = (unsigned) bp_unpack_value (bp, 1);
387 501002 : if (AGGREGATE_TYPE_P (expr))
388 98336 : TYPE_TYPELESS_STORAGE (expr) = (unsigned) bp_unpack_value (bp, 1);
389 501002 : if (!lto_stream_offload_p)
390 501002 : 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 501002 : if (FUNC_OR_METHOD_TYPE_P (expr))
400 149276 : TYPE_NO_NAMED_ARGS_STDARG_P (expr) = (unsigned) bp_unpack_value (bp, 1);
401 501002 : if (RECORD_OR_UNION_TYPE_P (expr))
402 58594 : TYPE_INCLUDES_FLEXARRAY (expr) = (unsigned) bp_unpack_value (bp, 1);
403 501002 : TYPE_PRECISION_RAW (expr) = bp_unpack_var_len_unsigned (bp);
404 501002 : 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 501002 : }
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 284564 : unpack_ts_block_value_fields (class data_in *data_in,
428 : struct bitpack_d *bp, tree expr)
429 : {
430 : /* BLOCK_NUMBER is recomputed. */
431 284564 : stream_input_location (&BLOCK_SOURCE_LOCATION (expr), bp, data_in);
432 284564 : }
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 22541 : unpack_ts_translation_unit_decl_value_fields (class data_in *data_in,
439 : struct bitpack_d *bp, tree expr)
440 : {
441 22541 : TRANSLATION_UNIT_LANGUAGE (expr) = xstrdup (bp_unpack_string (data_in, bp));
442 22541 : vec_safe_push (all_translation_units, expr);
443 22541 : }
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 208 : unpack_ts_omp_clause_value_fields (class data_in *data_in,
451 : struct bitpack_d *bp, tree expr)
452 : {
453 208 : stream_input_location (&OMP_CLAUSE_LOCATION (expr), bp, data_in);
454 208 : 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 208 : }
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 4424140 : streamer_read_tree_bitfields (class lto_input_block *ib,
502 : class data_in *data_in, tree expr)
503 : {
504 4424140 : enum tree_code code;
505 4424140 : struct bitpack_d bp;
506 :
507 : /* Read the bitpack of non-pointer values from IB. */
508 4424140 : bp = streamer_read_bitpack (ib);
509 4424140 : 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 4424140 : unpack_ts_base_value_fields (&bp, expr);
514 :
515 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_INT_CST))
516 36366 : unpack_ts_int_cst_value_fields (&bp, expr);
517 :
518 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_REAL_CST))
519 103989 : unpack_ts_real_cst_value_fields (&bp, expr);
520 :
521 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_FIXED_CST))
522 0 : unpack_ts_fixed_cst_value_fields (&bp, expr);
523 :
524 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_MINIMAL))
525 751394 : stream_input_location (&DECL_SOURCE_LOCATION (expr), &bp, data_in);
526 :
527 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
528 751394 : unpack_ts_decl_common_value_fields (&bp, expr);
529 :
530 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_WRTL))
531 650063 : unpack_ts_decl_wrtl_value_fields (&bp, expr);
532 :
533 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS))
534 443741 : unpack_ts_decl_with_vis_value_fields (&bp, expr);
535 :
536 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_FUNCTION_DECL))
537 207251 : unpack_ts_function_decl_value_fields (&bp, expr);
538 :
539 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_TYPE_COMMON))
540 501002 : unpack_ts_type_common_value_fields (&bp, expr);
541 :
542 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_EXP))
543 : {
544 1314466 : stream_input_location (&EXPR_CHECK (expr)->exp.locus, &bp, data_in);
545 1314466 : if (code == MEM_REF
546 1314466 : || code == TARGET_MEM_REF)
547 : {
548 621178 : MR_DEPENDENCE_CLIQUE (expr)
549 310589 : = (unsigned)bp_unpack_value (&bp, sizeof (short) * 8);
550 310589 : if (MR_DEPENDENCE_CLIQUE (expr) != 0)
551 20018 : MR_DEPENDENCE_BASE (expr)
552 10009 : = (unsigned)bp_unpack_value (&bp, sizeof (short) * 8);
553 : }
554 1003877 : else if (code == CALL_EXPR)
555 0 : CALL_EXPR_IFN (expr) = bp_unpack_enum (&bp, internal_fn, IFN_LAST);
556 : }
557 :
558 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_BLOCK))
559 284564 : unpack_ts_block_value_fields (data_in, &bp, expr);
560 :
561 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_TRANSLATION_UNIT_DECL))
562 22541 : unpack_ts_translation_unit_decl_value_fields (data_in, &bp, expr);
563 :
564 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_OPTIMIZATION))
565 22135 : cl_optimization_stream_in (data_in, &bp, TREE_OPTIMIZATION (expr));
566 :
567 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_CONSTRUCTOR))
568 : {
569 57612 : CLOBBER_KIND (expr)
570 28806 : = bp_unpack_enum (&bp, clobber_kind, CLOBBER_LAST);
571 28806 : unsigned HOST_WIDE_INT length = bp_unpack_var_len_unsigned (&bp);
572 28806 : if (length > 0)
573 12591 : vec_safe_grow (CONSTRUCTOR_ELTS (expr), length, true);
574 : }
575 :
576 : #ifndef ACCEL_COMPILER
577 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_TARGET_OPTION))
578 : {
579 21698 : cl_target_option_stream_in (data_in, &bp, TREE_TARGET_OPTION (expr));
580 21698 : if (targetm.target_option.post_stream_in)
581 21698 : targetm.target_option.post_stream_in (TREE_TARGET_OPTION (expr));
582 : }
583 : #endif
584 :
585 4424140 : if (code == OMP_CLAUSE)
586 208 : unpack_ts_omp_clause_value_fields (data_in, &bp, expr);
587 4424140 : }
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 4424140 : streamer_alloc_tree (class lto_input_block *ib, class data_in *data_in,
596 : enum LTO_tags tag)
597 : {
598 4424140 : enum tree_code code;
599 4424140 : tree result;
600 :
601 4424140 : result = NULL_TREE;
602 :
603 4424140 : 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 4424140 : gcc_assert (code != SSA_NAME);
608 :
609 : /* Instantiate a new tree using the header data. */
610 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_STRING))
611 170122 : result = streamer_read_string_cst (data_in, ib);
612 4254018 : else if (CODE_CONTAINS_STRUCT (code, TS_IDENTIFIER))
613 732857 : result = input_identifier (data_in, ib);
614 3521161 : 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 3521159 : else if (CODE_CONTAINS_STRUCT (code, TS_VECTOR))
620 : {
621 2869 : bitpack_d bp = streamer_read_bitpack (ib);
622 2869 : unsigned int log2_npatterns = bp_unpack_value (&bp, 8);
623 2869 : unsigned int nelts_per_pattern = bp_unpack_value (&bp, 8);
624 2869 : result = make_vector (log2_npatterns, nelts_per_pattern);
625 : }
626 3518290 : else if (CODE_CONTAINS_STRUCT (code, TS_BINFO))
627 : {
628 5987 : unsigned HOST_WIDE_INT len = streamer_read_uhwi (ib);
629 5987 : result = make_tree_binfo (len);
630 : }
631 3512303 : else if (CODE_CONTAINS_STRUCT (code, TS_INT_CST))
632 : {
633 36366 : unsigned HOST_WIDE_INT len = streamer_read_uhwi (ib);
634 36366 : unsigned HOST_WIDE_INT ext_len = streamer_read_uhwi (ib);
635 36366 : result = make_int_cst (len, ext_len);
636 : }
637 3475937 : 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 3475937 : else if (code == OMP_CLAUSE)
643 : {
644 208 : enum omp_clause_code subcode
645 208 : = (enum omp_clause_code) streamer_read_uhwi (ib);
646 208 : return build_omp_clause (UNKNOWN_LOCATION, subcode);
647 : }
648 3475729 : 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 3475710 : 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 4095743 : lto_input_ts_common_tree_pointers (class lto_input_block *ib,
679 : class data_in *data_in, tree expr)
680 : {
681 4095743 : if (TREE_CODE (expr) != IDENTIFIER_NODE)
682 3362886 : TREE_TYPE (expr) = stream_read_tree_ref (ib, data_in);
683 4095743 : }
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 2869 : lto_input_ts_vector_tree_pointers (class lto_input_block *ib,
692 : class data_in *data_in, tree expr)
693 : {
694 2869 : unsigned int count = vector_cst_encoded_nelts (expr);
695 16404 : for (unsigned int i = 0; i < count; ++i)
696 10666 : VECTOR_CST_ENCODED_ELT (expr, i) = stream_read_tree_ref (ib, data_in);
697 2869 : }
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 6895 : lto_input_ts_complex_tree_pointers (class lto_input_block *ib,
748 : class data_in *data_in, tree expr)
749 : {
750 6895 : TREE_REALPART (expr) = stream_read_tree_ref (ib, data_in);
751 6895 : TREE_IMAGPART (expr) = stream_read_tree_ref (ib, data_in);
752 6895 : }
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 751394 : lto_input_ts_decl_minimal_tree_pointers (class lto_input_block *ib,
761 : class data_in *data_in, tree expr)
762 : {
763 751394 : DECL_NAME (expr) = stream_read_tree_ref (ib, data_in);
764 751394 : DECL_CONTEXT (expr) = stream_read_tree_ref (ib, data_in);
765 751394 : }
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 751394 : lto_input_ts_decl_common_tree_pointers (class lto_input_block *ib,
774 : class data_in *data_in, tree expr)
775 : {
776 751394 : DECL_SIZE (expr) = stream_read_tree_ref (ib, data_in);
777 751394 : DECL_SIZE_UNIT (expr) = stream_read_tree_ref (ib, data_in);
778 751394 : DECL_ATTRIBUTES (expr) = stream_read_tree_ref (ib, data_in);
779 751394 : DECL_ABSTRACT_ORIGIN (expr) = stream_read_tree_ref (ib, data_in);
780 :
781 536571 : if ((VAR_P (expr) || TREE_CODE (expr) == PARM_DECL)
782 851648 : && DECL_HAS_VALUE_EXPR_P (expr))
783 5926 : SET_DECL_VALUE_EXPR (expr, stream_read_tree_ref (ib, data_in));
784 :
785 751394 : if (VAR_P (expr)
786 751394 : && DECL_HAS_DEBUG_EXPR_P (expr))
787 : {
788 866 : tree dexpr = stream_read_tree_ref (ib, data_in);
789 866 : if (dexpr)
790 866 : SET_DECL_DEBUG_EXPR (expr, dexpr);
791 : }
792 751394 : }
793 :
794 :
795 : /* Read all pointer fields in the TS_DECL_NON_COMMON structure of
796 : EXPR from input block IB. DATA_IN contains tables and descriptors for the
797 : file being read. */
798 :
799 : static void
800 0 : lto_input_ts_decl_non_common_tree_pointers (class lto_input_block *,
801 : class data_in *, tree)
802 : {
803 0 : }
804 :
805 :
806 : /* Read all pointer fields in the TS_DECL_WITH_VIS structure of EXPR
807 : from input block IB. DATA_IN contains tables and descriptors for the
808 : file being read. */
809 :
810 : static void
811 443741 : lto_input_ts_decl_with_vis_tree_pointers (class lto_input_block *ib,
812 : class data_in *data_in, tree expr)
813 : {
814 443741 : tree id;
815 :
816 443741 : id = stream_read_tree_ref (ib, data_in);
817 443741 : if (id)
818 : {
819 298378 : gcc_assert (TREE_CODE (id) == IDENTIFIER_NODE);
820 298378 : SET_DECL_ASSEMBLER_NAME (expr, id);
821 : }
822 443741 : }
823 :
824 :
825 : /* Read all pointer fields in the TS_FIELD_DECL structure of EXPR from
826 : input block IB. DATA_IN contains tables and descriptors for the
827 : file being read. */
828 :
829 : static void
830 78665 : lto_input_ts_field_decl_tree_pointers (class lto_input_block *ib,
831 : class data_in *data_in, tree expr)
832 : {
833 78665 : DECL_FIELD_OFFSET (expr) = stream_read_tree_ref (ib, data_in);
834 78665 : DECL_BIT_FIELD_TYPE (expr) = stream_read_tree_ref (ib, data_in);
835 78665 : DECL_BIT_FIELD_REPRESENTATIVE (expr) = stream_read_tree_ref (ib, data_in);
836 78665 : DECL_FIELD_BIT_OFFSET (expr) = stream_read_tree_ref (ib, data_in);
837 78665 : }
838 :
839 :
840 : /* Read all pointer fields in the TS_FUNCTION_DECL structure of EXPR
841 : from input block IB. DATA_IN contains tables and descriptors for the
842 : file being read. */
843 :
844 : static void
845 207251 : lto_input_ts_function_decl_tree_pointers (class lto_input_block *ib,
846 : class data_in *data_in, tree expr)
847 : {
848 : /* DECL_STRUCT_FUNCTION is loaded on demand by cgraph_get_body. */
849 207251 : DECL_FUNCTION_PERSONALITY (expr) = stream_read_tree_ref (ib, data_in);
850 : #ifndef ACCEL_COMPILER
851 207251 : DECL_FUNCTION_SPECIFIC_TARGET (expr) = stream_read_tree_ref (ib, data_in);
852 : #endif
853 414502 : DECL_FUNCTION_SPECIFIC_OPTIMIZATION (expr)
854 207251 : = stream_read_tree_ref (ib, data_in);
855 : #ifdef ACCEL_COMPILER
856 : {
857 : tree opts = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (expr);
858 : if (opts)
859 : {
860 : struct gcc_options tmp, tmp_set;
861 : init_options_struct (&tmp, NULL);
862 : memset (&tmp_set, 0, sizeof (tmp_set));
863 : cl_optimization_restore (&tmp, &tmp_set, TREE_OPTIMIZATION (opts));
864 : finish_options (&tmp, &tmp_set, UNKNOWN_LOCATION);
865 : opts = build_optimization_node (&tmp, &tmp_set);
866 : DECL_FUNCTION_SPECIFIC_OPTIMIZATION (expr) = opts;
867 : }
868 : }
869 : #endif
870 207251 : }
871 :
872 :
873 : /* Read all pointer fields in the TS_TYPE_COMMON structure of EXPR from
874 : input block IB. DATA_IN contains tables and descriptors for the file
875 : being read. */
876 :
877 : static void
878 501002 : lto_input_ts_type_common_tree_pointers (class lto_input_block *ib,
879 : class data_in *data_in, tree expr)
880 : {
881 501002 : TYPE_SIZE (expr) = stream_read_tree_ref (ib, data_in);
882 501002 : TYPE_SIZE_UNIT (expr) = stream_read_tree_ref (ib, data_in);
883 501002 : TYPE_ATTRIBUTES (expr) = stream_read_tree_ref (ib, data_in);
884 501002 : TYPE_NAME (expr) = stream_read_tree_ref (ib, data_in);
885 : /* Do not stream TYPE_POINTER_TO or TYPE_REFERENCE_TO. They will be
886 : reconstructed during fixup. */
887 : /* Do not stream TYPE_NEXT_VARIANT, we reconstruct the variant lists
888 : during fixup. */
889 501002 : TYPE_MAIN_VARIANT (expr) = stream_read_tree_ref (ib, data_in);
890 501002 : TYPE_CONTEXT (expr) = stream_read_tree_ref (ib, data_in);
891 : /* TYPE_CANONICAL gets re-computed during type merging. */
892 501002 : TYPE_CANONICAL (expr) = NULL_TREE;
893 501002 : }
894 :
895 : /* Read all pointer fields in the TS_TYPE_NON_COMMON structure of EXPR
896 : from input block IB. DATA_IN contains tables and descriptors for the
897 : file being read. */
898 :
899 : static void
900 501002 : lto_input_ts_type_non_common_tree_pointers (class lto_input_block *ib,
901 : class data_in *data_in,
902 : tree expr)
903 : {
904 501002 : if (TREE_CODE (expr) == ARRAY_TYPE)
905 39742 : TYPE_DOMAIN (expr) = stream_read_tree_ref (ib, data_in);
906 461260 : else if (RECORD_OR_UNION_TYPE_P (expr))
907 58594 : TYPE_FIELDS (expr) = streamer_read_chain (ib, data_in);
908 402666 : else if (FUNC_OR_METHOD_TYPE_P (expr))
909 149276 : TYPE_ARG_TYPES (expr) = stream_read_tree_ref (ib, data_in);
910 :
911 501002 : if (!POINTER_TYPE_P (expr))
912 316252 : TYPE_MIN_VALUE_RAW (expr) = stream_read_tree_ref (ib, data_in);
913 501002 : TYPE_MAX_VALUE_RAW (expr) = stream_read_tree_ref (ib, data_in);
914 501002 : }
915 :
916 :
917 : /* Read all pointer fields in the TS_LIST structure of EXPR from input
918 : block IB. DATA_IN contains tables and descriptors for the
919 : file being read. */
920 :
921 : static void
922 440761 : lto_input_ts_list_tree_pointers (class lto_input_block *ib,
923 : class data_in *data_in, tree expr)
924 : {
925 440761 : TREE_PURPOSE (expr) = stream_read_tree_ref (ib, data_in);
926 440761 : TREE_VALUE (expr) = stream_read_tree_ref (ib, data_in);
927 440761 : TREE_CHAIN (expr) = stream_read_tree_ref (ib, data_in);
928 440761 : }
929 :
930 :
931 : /* Read all pointer fields in the TS_VEC structure of EXPR from input
932 : block IB. DATA_IN contains tables and descriptors for the
933 : file being read. */
934 :
935 : static void
936 2 : lto_input_ts_vec_tree_pointers (class lto_input_block *ib,
937 : class data_in *data_in, tree expr)
938 : {
939 2 : int i;
940 :
941 : /* Note that TREE_VEC_LENGTH was read by streamer_alloc_tree to
942 : instantiate EXPR. */
943 10 : for (i = 0; i < TREE_VEC_LENGTH (expr); i++)
944 8 : TREE_VEC_ELT (expr, i) = stream_read_tree_ref (ib, data_in);
945 2 : }
946 :
947 :
948 : /* Read all pointer fields in the TS_EXP structure of EXPR from input
949 : block IB. DATA_IN contains tables and descriptors for the
950 : file being read. */
951 :
952 :
953 : static void
954 1314466 : lto_input_ts_exp_tree_pointers (class lto_input_block *ib,
955 : class data_in *data_in, tree expr)
956 : {
957 1314466 : int i;
958 1314466 : tree block;
959 :
960 3214405 : for (i = 0; i < TREE_OPERAND_LENGTH (expr); i++)
961 1899939 : TREE_OPERAND (expr, i) = stream_read_tree_ref (ib, data_in);
962 :
963 1314466 : block = stream_read_tree_ref (ib, data_in);
964 :
965 : /* TODO: Block is stored in the locus information. It may make more sense to
966 : to make it go via the location cache. */
967 1314466 : if (block)
968 : {
969 220746 : data_in->location_cache.apply_location_cache ();
970 220746 : TREE_SET_BLOCK (expr, block);
971 : }
972 1314466 : }
973 :
974 :
975 : /* Read all pointer fields in the TS_BLOCK structure of EXPR from input
976 : block IB. DATA_IN contains tables and descriptors for the
977 : file being read. */
978 :
979 : static void
980 284564 : lto_input_ts_block_tree_pointers (class lto_input_block *ib,
981 : class data_in *data_in, tree expr)
982 : {
983 284564 : BLOCK_VARS (expr) = streamer_read_chain (ib, data_in);
984 :
985 284564 : BLOCK_SUPERCONTEXT (expr) = stream_read_tree_ref (ib, data_in);
986 284564 : BLOCK_ABSTRACT_ORIGIN (expr) = stream_read_tree_ref (ib, data_in);
987 : /* We may end up prevailing a decl with DECL_ORIGIN (t) != t here
988 : which breaks the invariant that BLOCK_ABSTRACT_ORIGIN is the
989 : ultimate origin. Fixup here.
990 : ??? This should get fixed with moving to DIE references. */
991 284564 : if (DECL_P (BLOCK_ORIGIN (expr)))
992 66498 : BLOCK_ABSTRACT_ORIGIN (expr) = DECL_ORIGIN (BLOCK_ABSTRACT_ORIGIN (expr));
993 : /* Do not stream BLOCK_NONLOCALIZED_VARS. We cannot handle debug information
994 : for early inlined BLOCKs so drop it on the floor instead of ICEing in
995 : dwarf2out.cc. */
996 :
997 : /* BLOCK_FRAGMENT_ORIGIN and BLOCK_FRAGMENT_CHAIN is not live at LTO
998 : streaming time. */
999 :
1000 : /* We re-compute BLOCK_SUBBLOCKS of our parent here instead
1001 : of streaming it. For non-BLOCK BLOCK_SUPERCONTEXTs we still
1002 : stream the child relationship explicitly. */
1003 284564 : if (BLOCK_SUPERCONTEXT (expr)
1004 284564 : && TREE_CODE (BLOCK_SUPERCONTEXT (expr)) == BLOCK)
1005 : {
1006 181397 : BLOCK_CHAIN (expr) = BLOCK_SUBBLOCKS (BLOCK_SUPERCONTEXT (expr));
1007 181397 : BLOCK_SUBBLOCKS (BLOCK_SUPERCONTEXT (expr)) = expr;
1008 : }
1009 :
1010 : /* The global block is rooted at the TU decl. Hook it here to
1011 : avoid the need to stream in this block during WPA time. */
1012 103167 : else if (BLOCK_SUPERCONTEXT (expr)
1013 103167 : && TREE_CODE (BLOCK_SUPERCONTEXT (expr)) == TRANSLATION_UNIT_DECL)
1014 0 : DECL_INITIAL (BLOCK_SUPERCONTEXT (expr)) = expr;
1015 :
1016 : /* The function-level block is connected at the time we read in
1017 : function bodies for the same reason. */
1018 284564 : }
1019 :
1020 :
1021 : /* Read all pointer fields in the TS_BINFO structure of EXPR from input
1022 : block IB. DATA_IN contains tables and descriptors for the
1023 : file being read. */
1024 :
1025 : static void
1026 5987 : lto_input_ts_binfo_tree_pointers (class lto_input_block *ib,
1027 : class data_in *data_in, tree expr)
1028 : {
1029 12166 : tree t;
1030 :
1031 : /* Note that the number of slots in EXPR was read in
1032 : streamer_alloc_tree when instantiating EXPR. However, the
1033 : vector is empty so we cannot rely on vec::length to know how many
1034 : elements to read. So, this list is emitted as a 0-terminated
1035 : list on the writer side. */
1036 12166 : do
1037 : {
1038 12166 : t = stream_read_tree_ref (ib, data_in);
1039 12166 : if (t)
1040 6179 : BINFO_BASE_BINFOS (expr)->quick_push (t);
1041 : }
1042 12166 : while (t);
1043 :
1044 5987 : BINFO_OFFSET (expr) = stream_read_tree_ref (ib, data_in);
1045 5987 : BINFO_VTABLE (expr) = stream_read_tree_ref (ib, data_in);
1046 :
1047 : /* Do not walk BINFO_INHERITANCE_CHAIN, BINFO_SUBVTT_INDEX,
1048 : BINFO_BASE_ACCESSES and BINFO_VPTR_INDEX; these are used by C++ FE
1049 : only. */
1050 5987 : }
1051 :
1052 :
1053 : /* Read all pointer fields in the TS_CONSTRUCTOR structure of EXPR from
1054 : input block IB. DATA_IN contains tables and descriptors for the
1055 : file being read. */
1056 :
1057 : static void
1058 28806 : lto_input_ts_constructor_tree_pointers (class lto_input_block *ib,
1059 : class data_in *data_in, tree expr)
1060 : {
1061 28806 : unsigned i;
1062 :
1063 117796 : for (i = 0; i < CONSTRUCTOR_NELTS (expr); i++)
1064 : {
1065 88990 : constructor_elt e;
1066 88990 : e.index = stream_read_tree_ref (ib, data_in);
1067 88990 : e.value = stream_read_tree_ref (ib, data_in);
1068 88990 : (*CONSTRUCTOR_ELTS (expr))[i] = e;
1069 : }
1070 28806 : }
1071 :
1072 :
1073 : /* Read all pointer fields in the TS_RAW_DATA_CST structure of EXPR from
1074 : input block IB. DATA_IN contains tables and descriptors for the
1075 : file being read. */
1076 :
1077 : static void
1078 17 : lto_input_ts_raw_data_cst_tree_pointers (class lto_input_block *ib,
1079 : class data_in *data_in, tree expr)
1080 : {
1081 17 : RAW_DATA_OWNER (expr) = stream_read_tree_ref (ib, data_in);
1082 17 : gcc_checking_assert (RAW_DATA_OWNER (expr)
1083 : && TREE_CODE (RAW_DATA_OWNER (expr)) == STRING_CST);
1084 17 : RAW_DATA_POINTER (expr) = (TREE_STRING_POINTER (RAW_DATA_OWNER (expr))
1085 17 : + (uintptr_t) RAW_DATA_POINTER (expr));
1086 17 : }
1087 :
1088 :
1089 : /* Read all pointer fields in the TS_OMP_CLAUSE structure of EXPR from
1090 : input block IB. DATA_IN contains tables and descriptors for the
1091 : file being read. */
1092 :
1093 : static void
1094 208 : lto_input_ts_omp_clause_tree_pointers (class lto_input_block *ib,
1095 : class data_in *data_in, tree expr)
1096 : {
1097 208 : int i;
1098 :
1099 486 : for (i = 0; i < omp_clause_num_ops[OMP_CLAUSE_CODE (expr)]; i++)
1100 278 : OMP_CLAUSE_OPERAND (expr, i) = stream_read_tree_ref (ib, data_in);
1101 208 : OMP_CLAUSE_CHAIN (expr) = stream_read_tree_ref (ib, data_in);
1102 208 : }
1103 :
1104 :
1105 : /* Read all pointer fields in EXPR from input block IB. DATA_IN
1106 : contains tables and descriptors for the file being read. */
1107 :
1108 : void
1109 4424140 : streamer_read_tree_body (class lto_input_block *ib, class data_in *data_in,
1110 : tree expr)
1111 : {
1112 4424140 : enum tree_code code;
1113 :
1114 4424140 : code = TREE_CODE (expr);
1115 :
1116 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_TYPED))
1117 4095743 : lto_input_ts_common_tree_pointers (ib, data_in, expr);
1118 :
1119 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_VECTOR))
1120 2869 : lto_input_ts_vector_tree_pointers (ib, data_in, expr);
1121 :
1122 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_POLY_INT_CST))
1123 0 : lto_input_ts_poly_tree_pointers (ib, data_in, expr);
1124 :
1125 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_COMPLEX))
1126 6895 : lto_input_ts_complex_tree_pointers (ib, data_in, expr);
1127 :
1128 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_MINIMAL))
1129 751394 : lto_input_ts_decl_minimal_tree_pointers (ib, data_in, expr);
1130 :
1131 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
1132 751394 : lto_input_ts_decl_common_tree_pointers (ib, data_in, expr);
1133 :
1134 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_NON_COMMON))
1135 4424140 : lto_input_ts_decl_non_common_tree_pointers (ib, data_in, expr);
1136 :
1137 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS))
1138 443741 : lto_input_ts_decl_with_vis_tree_pointers (ib, data_in, expr);
1139 :
1140 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_FIELD_DECL))
1141 78665 : lto_input_ts_field_decl_tree_pointers (ib, data_in, expr);
1142 :
1143 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_FUNCTION_DECL))
1144 207251 : lto_input_ts_function_decl_tree_pointers (ib, data_in, expr);
1145 :
1146 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_TYPE_COMMON))
1147 501002 : lto_input_ts_type_common_tree_pointers (ib, data_in, expr);
1148 :
1149 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_TYPE_NON_COMMON))
1150 501002 : lto_input_ts_type_non_common_tree_pointers (ib, data_in, expr);
1151 :
1152 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_LIST))
1153 440761 : lto_input_ts_list_tree_pointers (ib, data_in, expr);
1154 :
1155 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_VEC))
1156 2 : lto_input_ts_vec_tree_pointers (ib, data_in, expr);
1157 :
1158 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_EXP))
1159 1314466 : lto_input_ts_exp_tree_pointers (ib, data_in, expr);
1160 :
1161 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_BLOCK))
1162 284564 : lto_input_ts_block_tree_pointers (ib, data_in, expr);
1163 :
1164 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_BINFO))
1165 5987 : lto_input_ts_binfo_tree_pointers (ib, data_in, expr);
1166 :
1167 4424140 : if (CODE_CONTAINS_STRUCT (code, TS_CONSTRUCTOR))
1168 28806 : lto_input_ts_constructor_tree_pointers (ib, data_in, expr);
1169 :
1170 4424140 : if (code == RAW_DATA_CST)
1171 17 : lto_input_ts_raw_data_cst_tree_pointers (ib, data_in, expr);
1172 :
1173 4424140 : if (code == OMP_CLAUSE)
1174 208 : lto_input_ts_omp_clause_tree_pointers (ib, data_in, expr);
1175 4424140 : }
1176 :
1177 :
1178 : /* Read an index IX from input block IB and return the tree node at
1179 : DATA_IN->FILE_DATA->GLOBALS_INDEX[IX]. */
1180 :
1181 : tree
1182 1634889 : streamer_get_pickled_tree (class lto_input_block *ib, class data_in *data_in)
1183 : {
1184 1634889 : unsigned HOST_WIDE_INT ix;
1185 1634889 : tree result;
1186 :
1187 1634889 : ix = streamer_read_uhwi (ib);
1188 1634889 : result = streamer_tree_cache_get_tree (data_in->reader_cache, ix);
1189 1634889 : return result;
1190 : }
|