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