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 : :
40 : :
41 : : /* Read a STRING_CST from the string table in DATA_IN using input
42 : : block IB. */
43 : :
44 : : tree
45 : 173106 : streamer_read_string_cst (class data_in *data_in, class lto_input_block *ib)
46 : : {
47 : 173106 : unsigned int len;
48 : 173106 : const char * ptr;
49 : :
50 : 173106 : ptr = streamer_read_indexed_string (data_in, ib, &len);
51 : 173106 : if (!ptr)
52 : : return NULL;
53 : 173042 : 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 : 689428 : input_identifier (class data_in *data_in, class lto_input_block *ib)
62 : : {
63 : 689428 : unsigned int len;
64 : 689428 : const char *ptr;
65 : :
66 : 689428 : ptr = streamer_read_indexed_string (data_in, ib, &len);
67 : 689428 : if (!ptr)
68 : : return NULL;
69 : 689428 : 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 : 325534 : streamer_read_chain (class lto_input_block *ib, class data_in *data_in)
78 : : {
79 : 325534 : tree first, prev, curr;
80 : :
81 : : /* The chain is written as NULL terminated list of trees. */
82 : 325534 : first = prev = NULL_TREE;
83 : 541992 : do
84 : : {
85 : 541992 : curr = stream_read_tree_ref (ib, data_in);
86 : 541992 : if (prev)
87 : 216458 : TREE_CHAIN (prev) = curr;
88 : : else
89 : : first = curr;
90 : :
91 : 541992 : prev = curr;
92 : : }
93 : 541992 : while (curr);
94 : :
95 : 325534 : 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 : 4241846 : 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 : 4241846 : if (!TYPE_P (expr))
108 : : {
109 : 3776826 : TREE_SIDE_EFFECTS (expr) = (unsigned) bp_unpack_value (bp, 1);
110 : 3776826 : TREE_CONSTANT (expr) = (unsigned) bp_unpack_value (bp, 1);
111 : 3776826 : 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 : 3776826 : TREE_PUBLIC (expr) = (unsigned) bp_unpack_value (bp, 1);
117 : : }
118 : : else
119 : 465020 : bp_unpack_value (bp, 4);
120 : 4241846 : TREE_ADDRESSABLE (expr) = (unsigned) bp_unpack_value (bp, 1);
121 : 4241846 : TREE_THIS_VOLATILE (expr) = (unsigned) bp_unpack_value (bp, 1);
122 : 4241846 : if (DECL_P (expr))
123 : : {
124 : 722375 : DECL_UNSIGNED (expr) = (unsigned) bp_unpack_value (bp, 1);
125 : 722375 : DECL_NAMELESS (expr) = (unsigned) bp_unpack_value (bp, 1);
126 : : }
127 : 3519471 : else if (TYPE_P (expr))
128 : 465020 : TYPE_UNSIGNED (expr) = (unsigned) bp_unpack_value (bp, 1);
129 : : else
130 : 3054451 : bp_unpack_value (bp, 1);
131 : 4241846 : TREE_ASM_WRITTEN (expr) = (unsigned) bp_unpack_value (bp, 1);
132 : 4241846 : if (TYPE_P (expr))
133 : 465020 : TYPE_ARTIFICIAL (expr) = (unsigned) bp_unpack_value (bp, 1);
134 : : else
135 : 3776826 : TREE_NO_WARNING (expr) = (unsigned) bp_unpack_value (bp, 1);
136 : 4241846 : TREE_NOTHROW (expr) = (unsigned) bp_unpack_value (bp, 1);
137 : 4241846 : TREE_STATIC (expr) = (unsigned) bp_unpack_value (bp, 1);
138 : 4241846 : if (TREE_CODE (expr) != TREE_BINFO)
139 : 4235887 : TREE_PRIVATE (expr) = (unsigned) bp_unpack_value (bp, 1);
140 : : else
141 : 5959 : bp_unpack_value (bp, 1);
142 : 4241846 : TREE_PROTECTED (expr) = (unsigned) bp_unpack_value (bp, 1);
143 : 4241846 : TREE_DEPRECATED (expr) = (unsigned) bp_unpack_value (bp, 1);
144 : 4241846 : if (TYPE_P (expr))
145 : : {
146 : 465020 : if (AGGREGATE_TYPE_P (expr))
147 : 91315 : TYPE_REVERSE_STORAGE_ORDER (expr) = (unsigned) bp_unpack_value (bp, 1);
148 : : else
149 : 373705 : TYPE_SATURATING (expr) = (unsigned) bp_unpack_value (bp, 1);
150 : : #ifndef ACCEL_COMPILER
151 : 465020 : TYPE_ADDR_SPACE (expr) = (unsigned) bp_unpack_value (bp, 8);
152 : : #endif
153 : : }
154 : 3776826 : else if (TREE_CODE (expr) == BIT_FIELD_REF || TREE_CODE (expr) == MEM_REF)
155 : : {
156 : 307504 : REF_REVERSE_STORAGE_ORDER (expr) = (unsigned) bp_unpack_value (bp, 1);
157 : 307504 : bp_unpack_value (bp, 8);
158 : : }
159 : 3469322 : 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 : 3469322 : 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 : 3469322 : bp_unpack_value (bp, 9);
171 : 4241846 : }
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 : 32360 : unpack_ts_int_cst_value_fields (struct bitpack_d *bp, tree expr)
179 : : {
180 : 32360 : int i;
181 : 65751 : for (i = 0; i < TREE_INT_CST_EXT_NUNITS (expr); i++)
182 : 33391 : TREE_INT_CST_ELT (expr, i) = bp_unpack_var_len_int (bp);
183 : 32360 : }
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 : 103080 : unpack_ts_real_cst_value_fields (struct bitpack_d *bp, tree expr)
191 : : {
192 : 103080 : REAL_VALUE_TYPE r;
193 : :
194 : 103080 : bp_unpack_real_value (bp, &r);
195 : 103080 : memcpy (TREE_REAL_CST_PTR (expr), &r, sizeof (REAL_VALUE_TYPE));
196 : 103080 : }
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 : 722375 : unpack_ts_decl_common_value_fields (struct bitpack_d *bp, tree expr)
217 : : {
218 : 722375 : SET_DECL_MODE (expr, bp_unpack_machine_mode (bp));
219 : 722375 : DECL_NONLOCAL (expr) = (unsigned) bp_unpack_value (bp, 1);
220 : 722375 : DECL_VIRTUAL_P (expr) = (unsigned) bp_unpack_value (bp, 1);
221 : 722375 : DECL_IGNORED_P (expr) = (unsigned) bp_unpack_value (bp, 1);
222 : 722375 : DECL_ABSTRACT_P (expr) = (unsigned) bp_unpack_value (bp, 1);
223 : 722375 : DECL_ARTIFICIAL (expr) = (unsigned) bp_unpack_value (bp, 1);
224 : 722375 : DECL_USER_ALIGN (expr) = (unsigned) bp_unpack_value (bp, 1);
225 : 722375 : DECL_PRESERVE_P (expr) = (unsigned) bp_unpack_value (bp, 1);
226 : 722375 : DECL_EXTERNAL (expr) = (unsigned) bp_unpack_value (bp, 1);
227 : 722375 : DECL_NOT_GIMPLE_REG_P (expr) = (unsigned) bp_unpack_value (bp, 1);
228 : 722375 : 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 : 722375 : if (TREE_CODE (expr) == LABEL_DECL)
234 : : {
235 : 19620 : 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 : 19620 : LABEL_DECL_UID (expr) = -1;
240 : : }
241 : :
242 : 702755 : else if (TREE_CODE (expr) == FIELD_DECL)
243 : : {
244 : 73319 : DECL_PACKED (expr) = (unsigned) bp_unpack_value (bp, 1);
245 : 73319 : DECL_NONADDRESSABLE_P (expr) = (unsigned) bp_unpack_value (bp, 1);
246 : 73319 : DECL_PADDING_P (expr) = (unsigned) bp_unpack_value (bp, 1);
247 : 73319 : unsigned val = (unsigned) bp_unpack_value (bp, 1);
248 : 73319 : if (DECL_BIT_FIELD (expr))
249 : 3113 : SET_DECL_FIELD_CXX_ZERO_WIDTH_BIT_FIELD (expr, val);
250 : : else
251 : 70206 : SET_DECL_FIELD_ABI_IGNORED (expr, val);
252 : 73319 : expr->decl_common.off_align = bp_unpack_value (bp, 8);
253 : 73319 : DECL_NOT_FLEXARRAY (expr) = (unsigned) bp_unpack_value (bp, 1);
254 : : }
255 : :
256 : 629436 : else if (VAR_P (expr))
257 : : {
258 : 207157 : DECL_HAS_DEBUG_EXPR_P (expr) = (unsigned) bp_unpack_value (bp, 1);
259 : 207157 : DECL_NONLOCAL_FRAME (expr) = (unsigned) bp_unpack_value (bp, 1);
260 : : }
261 : :
262 : 422279 : else if (TREE_CODE (expr) == PARM_DECL)
263 : 96600 : DECL_HIDDEN_STRING_LENGTH (expr) = (unsigned) bp_unpack_value (bp, 1);
264 : :
265 : 722375 : if (TREE_CODE (expr) == RESULT_DECL
266 : : || TREE_CODE (expr) == PARM_DECL
267 : : || VAR_P (expr))
268 : : {
269 : 388827 : DECL_BY_REFERENCE (expr) = (unsigned) bp_unpack_value (bp, 1);
270 : 388827 : if (VAR_P (expr) || TREE_CODE (expr) == PARM_DECL)
271 : 303757 : DECL_HAS_VALUE_EXPR_P (expr) = (unsigned) bp_unpack_value (bp, 1);
272 : : }
273 : 722375 : }
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 : 625567 : unpack_ts_decl_wrtl_value_fields (struct bitpack_d *bp, tree expr)
281 : : {
282 : 625567 : DECL_REGISTER (expr) = (unsigned) bp_unpack_value (bp, 1);
283 : 625567 : }
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 : 423935 : unpack_ts_decl_with_vis_value_fields (struct bitpack_d *bp, tree expr)
291 : : {
292 : 423935 : DECL_COMMON (expr) = (unsigned) bp_unpack_value (bp, 1);
293 : 423935 : DECL_DLLIMPORT_P (expr) = (unsigned) bp_unpack_value (bp, 1);
294 : 423935 : DECL_WEAK (expr) = (unsigned) bp_unpack_value (bp, 1);
295 : 423935 : DECL_SEEN_IN_BIND_EXPR_P (expr) = (unsigned) bp_unpack_value (bp, 1);
296 : 423935 : DECL_COMDAT (expr) = (unsigned) bp_unpack_value (bp, 1);
297 : 423935 : DECL_VISIBILITY (expr) = (enum symbol_visibility) bp_unpack_value (bp, 2);
298 : 423935 : DECL_VISIBILITY_SPECIFIED (expr) = (unsigned) bp_unpack_value (bp, 1);
299 : :
300 : 423935 : if (VAR_P (expr))
301 : : {
302 : 207157 : DECL_HARD_REGISTER (expr) = (unsigned) bp_unpack_value (bp, 1);
303 : 207157 : DECL_IN_CONSTANT_POOL (expr) = (unsigned) bp_unpack_value (bp, 1);
304 : : }
305 : :
306 : 423935 : if (TREE_CODE (expr) == FUNCTION_DECL)
307 : : {
308 : 196882 : DECL_FINAL_P (expr) = (unsigned) bp_unpack_value (bp, 1);
309 : 196882 : DECL_CXX_CONSTRUCTOR_P (expr) = (unsigned) bp_unpack_value (bp, 1);
310 : 196882 : DECL_CXX_DESTRUCTOR_P (expr) = (unsigned) bp_unpack_value (bp, 1);
311 : : }
312 : 423935 : }
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 : 196882 : unpack_ts_function_decl_value_fields (struct bitpack_d *bp, tree expr)
320 : : {
321 : 196882 : built_in_class cl = bp_unpack_enum (bp, built_in_class, BUILT_IN_LAST);
322 : 196882 : DECL_STATIC_CONSTRUCTOR (expr) = (unsigned) bp_unpack_value (bp, 1);
323 : 196882 : DECL_STATIC_DESTRUCTOR (expr) = (unsigned) bp_unpack_value (bp, 1);
324 : 196882 : DECL_UNINLINABLE (expr) = (unsigned) bp_unpack_value (bp, 1);
325 : 196882 : DECL_POSSIBLY_INLINED (expr) = (unsigned) bp_unpack_value (bp, 1);
326 : 196882 : DECL_IS_NOVOPS (expr) = (unsigned) bp_unpack_value (bp, 1);
327 : 196882 : DECL_IS_RETURNS_TWICE (expr) = (unsigned) bp_unpack_value (bp, 1);
328 : 196882 : DECL_IS_MALLOC (expr) = (unsigned) bp_unpack_value (bp, 1);
329 : 196882 : FUNCTION_DECL_DECL_TYPE (expr) = (function_decl_type) bp_unpack_value (bp, 2);
330 : 196882 : DECL_SET_IS_OPERATOR_DELETE (expr, (unsigned) bp_unpack_value (bp, 1));
331 : 196882 : DECL_DECLARED_INLINE_P (expr) = (unsigned) bp_unpack_value (bp, 1);
332 : 196882 : DECL_STATIC_CHAIN (expr) = (unsigned) bp_unpack_value (bp, 1);
333 : 196882 : DECL_NO_INLINE_WARNING_P (expr) = (unsigned) bp_unpack_value (bp, 1);
334 : 393764 : DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (expr)
335 : 196882 : = (unsigned) bp_unpack_value (bp, 1);
336 : 196882 : DECL_NO_LIMIT_STACK (expr) = (unsigned) bp_unpack_value (bp, 1);
337 : 196882 : DECL_DISREGARD_INLINE_LIMITS (expr) = (unsigned) bp_unpack_value (bp, 1);
338 : 196882 : DECL_PURE_P (expr) = (unsigned) bp_unpack_value (bp, 1);
339 : 196882 : DECL_LOOPING_CONST_OR_PURE_P (expr) = (unsigned) bp_unpack_value (bp, 1);
340 : 196882 : DECL_IS_REPLACEABLE_OPERATOR (expr) = (unsigned) bp_unpack_value (bp, 1);
341 : 196882 : unsigned int fcode = 0;
342 : 196882 : if (cl != NOT_BUILT_IN)
343 : : {
344 : 29169 : fcode = bp_unpack_value (bp, 32);
345 : 29169 : if (cl == BUILT_IN_NORMAL && fcode >= END_BUILTINS)
346 : 0 : fatal_error (input_location,
347 : : "machine independent builtin code out of range");
348 : 29169 : else if (cl == BUILT_IN_MD)
349 : : {
350 : 148 : tree result = targetm.builtin_decl (fcode, true);
351 : 148 : if (!result || result == error_mark_node)
352 : 0 : fatal_error (input_location,
353 : : "target specific builtin not available");
354 : : }
355 : : }
356 : 196882 : set_decl_built_in_function (expr, cl, fcode);
357 : 196882 : }
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 : 465020 : unpack_ts_type_common_value_fields (struct bitpack_d *bp, tree expr)
365 : : {
366 : 465020 : machine_mode mode;
367 : :
368 : 465020 : mode = bp_unpack_machine_mode (bp);
369 : 465020 : SET_TYPE_MODE (expr, mode);
370 : : /* TYPE_NO_FORCE_BLK is private to stor-layout and need
371 : : no streaming. */
372 : 465020 : TYPE_PACKED (expr) = (unsigned) bp_unpack_value (bp, 1);
373 : 465020 : TYPE_RESTRICT (expr) = (unsigned) bp_unpack_value (bp, 1);
374 : 465020 : TYPE_USER_ALIGN (expr) = (unsigned) bp_unpack_value (bp, 1);
375 : 465020 : TYPE_READONLY (expr) = (unsigned) bp_unpack_value (bp, 1);
376 : 465020 : TYPE_LANG_FLAG_0 (expr) = (unsigned) bp_unpack_value (bp, 1);
377 : 465020 : if (RECORD_OR_UNION_TYPE_P (expr))
378 : : {
379 : 54323 : TYPE_TRANSPARENT_AGGR (expr) = (unsigned) bp_unpack_value (bp, 1);
380 : 54323 : TYPE_FINAL_P (expr) = (unsigned) bp_unpack_value (bp, 1);
381 : 54323 : TYPE_CXX_ODR_P (expr) = (unsigned) bp_unpack_value (bp, 1);
382 : : }
383 : 410697 : else if (TREE_CODE (expr) == ARRAY_TYPE)
384 : 36992 : TYPE_NONALIASED_COMPONENT (expr) = (unsigned) bp_unpack_value (bp, 1);
385 : 465020 : if (TREE_CODE (expr) == ARRAY_TYPE || TREE_CODE (expr) == INTEGER_TYPE)
386 : 88717 : TYPE_STRING_FLAG (expr) = (unsigned) bp_unpack_value (bp, 1);
387 : 465020 : if (AGGREGATE_TYPE_P (expr))
388 : 91315 : TYPE_TYPELESS_STORAGE (expr) = (unsigned) bp_unpack_value (bp, 1);
389 : 465020 : TYPE_EMPTY_P (expr) = (unsigned) bp_unpack_value (bp, 1);
390 : 465020 : if (FUNC_OR_METHOD_TYPE_P (expr))
391 : 138652 : TYPE_NO_NAMED_ARGS_STDARG_P (expr) = (unsigned) bp_unpack_value (bp, 1);
392 : 465020 : if (RECORD_OR_UNION_TYPE_P (expr))
393 : 54323 : TYPE_INCLUDES_FLEXARRAY (expr) = (unsigned) bp_unpack_value (bp, 1);
394 : 465020 : TYPE_PRECISION_RAW (expr) = bp_unpack_var_len_unsigned (bp);
395 : 465020 : SET_TYPE_ALIGN (expr, bp_unpack_var_len_unsigned (bp));
396 : : #ifdef ACCEL_COMPILER
397 : : if (TYPE_ALIGN (expr) > targetm.absolute_biggest_alignment)
398 : : SET_TYPE_ALIGN (expr, targetm.absolute_biggest_alignment);
399 : :
400 : : /* Host streams out VOIDmode for aggregate type. */
401 : : if (AGGREGATE_TYPE_P (expr) && TYPE_MODE (expr) == VOIDmode)
402 : : {
403 : : if (TREE_CODE (expr) == ARRAY_TYPE)
404 : : compute_array_mode (expr);
405 : : else if (RECORD_OR_UNION_TYPE_P (expr))
406 : : compute_record_mode (expr);
407 : : else
408 : : gcc_unreachable ();
409 : : }
410 : : #endif
411 : 465020 : }
412 : :
413 : :
414 : : /* Unpack all the non-pointer fields of the TS_BLOCK structure
415 : : of expression EXPR from bitpack BP. */
416 : :
417 : : static void
418 : 271211 : unpack_ts_block_value_fields (class data_in *data_in,
419 : : struct bitpack_d *bp, tree expr)
420 : : {
421 : : /* BLOCK_NUMBER is recomputed. */
422 : 271211 : stream_input_location (&BLOCK_SOURCE_LOCATION (expr), bp, data_in);
423 : 271211 : }
424 : :
425 : : /* Unpack all the non-pointer fields of the TS_TRANSLATION_UNIT_DECL
426 : : structure of expression EXPR from bitpack BP. */
427 : :
428 : : static void
429 : 23364 : unpack_ts_translation_unit_decl_value_fields (class data_in *data_in,
430 : : struct bitpack_d *bp, tree expr)
431 : : {
432 : 23364 : TRANSLATION_UNIT_LANGUAGE (expr) = xstrdup (bp_unpack_string (data_in, bp));
433 : 23364 : vec_safe_push (all_translation_units, expr);
434 : 23364 : }
435 : :
436 : :
437 : : /* Unpack all the non-pointer fields of the TS_OMP_CLAUSE
438 : : structure of expression EXPR from bitpack BP. */
439 : :
440 : : static void
441 : 202 : unpack_ts_omp_clause_value_fields (class data_in *data_in,
442 : : struct bitpack_d *bp, tree expr)
443 : : {
444 : 202 : stream_input_location (&OMP_CLAUSE_LOCATION (expr), bp, data_in);
445 : 202 : switch (OMP_CLAUSE_CODE (expr))
446 : : {
447 : 0 : case OMP_CLAUSE_DEFAULT:
448 : 0 : OMP_CLAUSE_DEFAULT_KIND (expr)
449 : 0 : = bp_unpack_enum (bp, omp_clause_default_kind,
450 : : OMP_CLAUSE_DEFAULT_LAST);
451 : 0 : break;
452 : 0 : case OMP_CLAUSE_SCHEDULE:
453 : 0 : OMP_CLAUSE_SCHEDULE_KIND (expr)
454 : 0 : = bp_unpack_enum (bp, omp_clause_schedule_kind,
455 : : OMP_CLAUSE_SCHEDULE_LAST);
456 : 0 : break;
457 : 0 : case OMP_CLAUSE_DEPEND:
458 : 0 : OMP_CLAUSE_DEPEND_KIND (expr)
459 : 0 : = bp_unpack_enum (bp, omp_clause_depend_kind, OMP_CLAUSE_DEPEND_LAST);
460 : 0 : break;
461 : 0 : case OMP_CLAUSE_DOACROSS:
462 : 0 : OMP_CLAUSE_DOACROSS_KIND (expr)
463 : 0 : = bp_unpack_enum (bp, omp_clause_doacross_kind,
464 : : OMP_CLAUSE_DOACROSS_LAST);
465 : 0 : break;
466 : 0 : case OMP_CLAUSE_MAP:
467 : 0 : OMP_CLAUSE_SET_MAP_KIND (expr, bp_unpack_enum (bp, gomp_map_kind,
468 : : GOMP_MAP_LAST));
469 : 0 : break;
470 : 0 : case OMP_CLAUSE_PROC_BIND:
471 : 0 : OMP_CLAUSE_PROC_BIND_KIND (expr)
472 : 0 : = bp_unpack_enum (bp, omp_clause_proc_bind_kind,
473 : : OMP_CLAUSE_PROC_BIND_LAST);
474 : 0 : break;
475 : 0 : case OMP_CLAUSE_REDUCTION:
476 : 0 : case OMP_CLAUSE_TASK_REDUCTION:
477 : 0 : case OMP_CLAUSE_IN_REDUCTION:
478 : 0 : OMP_CLAUSE_REDUCTION_CODE (expr)
479 : 0 : = bp_unpack_enum (bp, tree_code, MAX_TREE_CODES);
480 : 0 : break;
481 : : default:
482 : : break;
483 : : }
484 : 202 : }
485 : :
486 : :
487 : : /* Read all the language-independent bitfield values for EXPR from IB.
488 : : Return the partially unpacked bitpack so the caller can unpack any other
489 : : bitfield values that the writer may have written. */
490 : :
491 : : void
492 : 4241846 : streamer_read_tree_bitfields (class lto_input_block *ib,
493 : : class data_in *data_in, tree expr)
494 : : {
495 : 4241846 : enum tree_code code;
496 : 4241846 : struct bitpack_d bp;
497 : :
498 : : /* Read the bitpack of non-pointer values from IB. */
499 : 4241846 : bp = streamer_read_bitpack (ib);
500 : 4241846 : code = TREE_CODE (expr);
501 : :
502 : : /* Note that all these functions are highly sensitive to changes in
503 : : the types and sizes of each of the fields being packed. */
504 : 4241846 : unpack_ts_base_value_fields (&bp, expr);
505 : :
506 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_INT_CST))
507 : 32360 : unpack_ts_int_cst_value_fields (&bp, expr);
508 : :
509 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_REAL_CST))
510 : 103080 : unpack_ts_real_cst_value_fields (&bp, expr);
511 : :
512 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_FIXED_CST))
513 : 0 : unpack_ts_fixed_cst_value_fields (&bp, expr);
514 : :
515 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_MINIMAL))
516 : 722375 : stream_input_location (&DECL_SOURCE_LOCATION (expr), &bp, data_in);
517 : :
518 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
519 : 722375 : unpack_ts_decl_common_value_fields (&bp, expr);
520 : :
521 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_WRTL))
522 : 625567 : unpack_ts_decl_wrtl_value_fields (&bp, expr);
523 : :
524 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS))
525 : 423935 : unpack_ts_decl_with_vis_value_fields (&bp, expr);
526 : :
527 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_FUNCTION_DECL))
528 : 196882 : unpack_ts_function_decl_value_fields (&bp, expr);
529 : :
530 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_TYPE_COMMON))
531 : 465020 : unpack_ts_type_common_value_fields (&bp, expr);
532 : :
533 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_EXP))
534 : : {
535 : 1292997 : stream_input_location (&EXPR_CHECK (expr)->exp.locus, &bp, data_in);
536 : 1292997 : if (code == MEM_REF
537 : 1292997 : || code == TARGET_MEM_REF)
538 : : {
539 : 608664 : MR_DEPENDENCE_CLIQUE (expr)
540 : 304332 : = (unsigned)bp_unpack_value (&bp, sizeof (short) * 8);
541 : 304332 : if (MR_DEPENDENCE_CLIQUE (expr) != 0)
542 : 20072 : MR_DEPENDENCE_BASE (expr)
543 : 10036 : = (unsigned)bp_unpack_value (&bp, sizeof (short) * 8);
544 : : }
545 : 988665 : else if (code == CALL_EXPR)
546 : 0 : CALL_EXPR_IFN (expr) = bp_unpack_enum (&bp, internal_fn, IFN_LAST);
547 : : }
548 : :
549 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_BLOCK))
550 : 271211 : unpack_ts_block_value_fields (data_in, &bp, expr);
551 : :
552 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_TRANSLATION_UNIT_DECL))
553 : 23364 : unpack_ts_translation_unit_decl_value_fields (data_in, &bp, expr);
554 : :
555 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_OPTIMIZATION))
556 : 23019 : cl_optimization_stream_in (data_in, &bp, TREE_OPTIMIZATION (expr));
557 : :
558 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_CONSTRUCTOR))
559 : : {
560 : 55602 : CLOBBER_KIND (expr)
561 : 27801 : = bp_unpack_enum (&bp, clobber_kind, CLOBBER_LAST);
562 : 27801 : unsigned HOST_WIDE_INT length = bp_unpack_var_len_unsigned (&bp);
563 : 27801 : if (length > 0)
564 : 12145 : vec_safe_grow (CONSTRUCTOR_ELTS (expr), length, true);
565 : : }
566 : :
567 : : #ifndef ACCEL_COMPILER
568 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_TARGET_OPTION))
569 : : {
570 : 22586 : cl_target_option_stream_in (data_in, &bp, TREE_TARGET_OPTION (expr));
571 : 22586 : if (targetm.target_option.post_stream_in)
572 : 22586 : targetm.target_option.post_stream_in (TREE_TARGET_OPTION (expr));
573 : : }
574 : : #endif
575 : :
576 : 4241846 : if (code == OMP_CLAUSE)
577 : 202 : unpack_ts_omp_clause_value_fields (data_in, &bp, expr);
578 : 4241846 : }
579 : :
580 : :
581 : : /* Materialize a new tree from input block IB using descriptors in
582 : : DATA_IN. The code for the new tree should match TAG. Store in
583 : : *IX_P the index into the reader cache where the new tree is stored. */
584 : :
585 : : tree
586 : 4241846 : streamer_alloc_tree (class lto_input_block *ib, class data_in *data_in,
587 : : enum LTO_tags tag)
588 : : {
589 : 4241846 : enum tree_code code;
590 : 4241846 : tree result;
591 : :
592 : 4241846 : result = NULL_TREE;
593 : :
594 : 4241846 : code = lto_tag_to_tree_code (tag);
595 : :
596 : : /* We should never see an SSA_NAME tree. Only the version numbers of
597 : : SSA names are ever written out. See input_ssa_names. */
598 : 4241846 : gcc_assert (code != SSA_NAME);
599 : :
600 : : /* Instantiate a new tree using the header data. */
601 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_STRING))
602 : 167501 : result = streamer_read_string_cst (data_in, ib);
603 : 4074345 : else if (CODE_CONTAINS_STRUCT (code, TS_IDENTIFIER))
604 : 689428 : result = input_identifier (data_in, ib);
605 : 3384917 : else if (CODE_CONTAINS_STRUCT (code, TS_VEC))
606 : : {
607 : 2 : HOST_WIDE_INT len = streamer_read_hwi (ib);
608 : 2 : result = make_tree_vec (len);
609 : : }
610 : 3384915 : else if (CODE_CONTAINS_STRUCT (code, TS_VECTOR))
611 : : {
612 : 2688 : bitpack_d bp = streamer_read_bitpack (ib);
613 : 2688 : unsigned int log2_npatterns = bp_unpack_value (&bp, 8);
614 : 2688 : unsigned int nelts_per_pattern = bp_unpack_value (&bp, 8);
615 : 2688 : result = make_vector (log2_npatterns, nelts_per_pattern);
616 : : }
617 : 3382227 : else if (CODE_CONTAINS_STRUCT (code, TS_BINFO))
618 : : {
619 : 5959 : unsigned HOST_WIDE_INT len = streamer_read_uhwi (ib);
620 : 5959 : result = make_tree_binfo (len);
621 : : }
622 : 3376268 : else if (CODE_CONTAINS_STRUCT (code, TS_INT_CST))
623 : : {
624 : 32360 : unsigned HOST_WIDE_INT len = streamer_read_uhwi (ib);
625 : 32360 : unsigned HOST_WIDE_INT ext_len = streamer_read_uhwi (ib);
626 : 32360 : result = make_int_cst (len, ext_len);
627 : : }
628 : 3343908 : else if (code == CALL_EXPR)
629 : : {
630 : 0 : unsigned HOST_WIDE_INT nargs = streamer_read_uhwi (ib);
631 : 0 : return build_vl_exp (CALL_EXPR, nargs + 3);
632 : : }
633 : 3343908 : else if (code == OMP_CLAUSE)
634 : : {
635 : 202 : enum omp_clause_code subcode
636 : 202 : = (enum omp_clause_code) streamer_read_uhwi (ib);
637 : 202 : return build_omp_clause (UNKNOWN_LOCATION, subcode);
638 : : }
639 : 3343706 : else if (code == RAW_DATA_CST)
640 : : {
641 : 19 : unsigned HOST_WIDE_INT len = streamer_read_uhwi (ib);
642 : 19 : if (len == 0)
643 : 2 : result = streamer_read_string_cst (data_in, ib);
644 : : else
645 : : {
646 : 17 : unsigned HOST_WIDE_INT off = streamer_read_uhwi (ib);
647 : 17 : result = make_node (code);
648 : 17 : RAW_DATA_LENGTH (result) = len;
649 : 17 : RAW_DATA_POINTER (result) = (const char *) (uintptr_t) off;
650 : : }
651 : : }
652 : : else
653 : : {
654 : : /* For all other nodes, materialize the tree with a raw
655 : : make_node call. */
656 : 3343687 : result = make_node (code);
657 : : }
658 : :
659 : : return result;
660 : : }
661 : :
662 : :
663 : : /* Read all pointer fields in the TS_COMMON structure of EXPR from input
664 : : block IB. DATA_IN contains tables and descriptors for the
665 : : file being read. */
666 : :
667 : :
668 : : static void
669 : 3925030 : lto_input_ts_common_tree_pointers (class lto_input_block *ib,
670 : : class data_in *data_in, tree expr)
671 : : {
672 : 3925030 : if (TREE_CODE (expr) != IDENTIFIER_NODE)
673 : 3235602 : TREE_TYPE (expr) = stream_read_tree_ref (ib, data_in);
674 : 3925030 : }
675 : :
676 : :
677 : : /* Read all pointer fields in the TS_VECTOR structure of EXPR from input
678 : : block IB. DATA_IN contains tables and descriptors for the
679 : : file being read. */
680 : :
681 : : static void
682 : 2688 : lto_input_ts_vector_tree_pointers (class lto_input_block *ib,
683 : : class data_in *data_in, tree expr)
684 : : {
685 : 2688 : unsigned int count = vector_cst_encoded_nelts (expr);
686 : 11785 : for (unsigned int i = 0; i < count; ++i)
687 : 9097 : VECTOR_CST_ENCODED_ELT (expr, i) = stream_read_tree_ref (ib, data_in);
688 : 2688 : }
689 : :
690 : :
691 : : /* Read all pointer fields in the TS_POLY_INT_CST structure of EXPR from
692 : : input block IB. DATA_IN contains tables and descriptors for the
693 : : file being read. */
694 : :
695 : : static void
696 : 0 : lto_input_ts_poly_tree_pointers (class lto_input_block *ib,
697 : : class data_in *data_in, tree expr)
698 : : {
699 : : #ifdef ACCEL_COMPILER
700 : : /* Ensure that we have streamed-in host_num_poly_int_coeffs. */
701 : : const unsigned num_poly_int_coeffs = host_num_poly_int_coeffs;
702 : : gcc_assert (num_poly_int_coeffs > 0);
703 : : #else
704 : 0 : const unsigned num_poly_int_coeffs = NUM_POLY_INT_COEFFS;
705 : : #endif
706 : :
707 : 0 : unsigned i;
708 : 0 : if (num_poly_int_coeffs <= NUM_POLY_INT_COEFFS)
709 : : {
710 : 0 : for (i = 0; i < num_poly_int_coeffs; i++)
711 : 0 : POLY_INT_CST_COEFF (expr, i) = stream_read_tree_ref (ib, data_in);
712 : :
713 : 0 : tree coeff_type = TREE_TYPE (POLY_INT_CST_COEFF (expr, 0));
714 : 0 : for (; i < NUM_POLY_INT_COEFFS; i++)
715 : : POLY_INT_CST_COEFF (expr, i) = build_zero_cst (coeff_type);
716 : : }
717 : : else
718 : : {
719 : : for (i = 0; i < NUM_POLY_INT_COEFFS; i++)
720 : : POLY_INT_CST_COEFF (expr, i) = stream_read_tree_ref (ib, data_in);
721 : : for (; i < num_poly_int_coeffs; i++)
722 : : {
723 : : tree val = stream_read_tree_ref (ib, data_in);
724 : : if (!integer_zerop (val))
725 : : fatal_error (input_location,
726 : : "degree of %<poly_int%> exceeds "
727 : : "%<NUM_POLY_INT_COEFFS%>");
728 : : }
729 : : }
730 : 0 : }
731 : :
732 : :
733 : : /* Read all pointer fields in the TS_COMPLEX structure of EXPR from input
734 : : block IB. DATA_IN contains tables and descriptors for the
735 : : file being read. */
736 : :
737 : : static void
738 : 6907 : lto_input_ts_complex_tree_pointers (class lto_input_block *ib,
739 : : class data_in *data_in, tree expr)
740 : : {
741 : 6907 : TREE_REALPART (expr) = stream_read_tree_ref (ib, data_in);
742 : 6907 : TREE_IMAGPART (expr) = stream_read_tree_ref (ib, data_in);
743 : 6907 : }
744 : :
745 : :
746 : : /* Read all pointer fields in the TS_DECL_MINIMAL structure of EXPR
747 : : from input block IB. DATA_IN contains tables and descriptors for the
748 : : file being read. */
749 : :
750 : : static void
751 : 722375 : lto_input_ts_decl_minimal_tree_pointers (class lto_input_block *ib,
752 : : class data_in *data_in, tree expr)
753 : : {
754 : 722375 : DECL_NAME (expr) = stream_read_tree_ref (ib, data_in);
755 : 722375 : DECL_CONTEXT (expr) = stream_read_tree_ref (ib, data_in);
756 : 722375 : }
757 : :
758 : :
759 : : /* Read all pointer fields in the TS_DECL_COMMON structure of EXPR from
760 : : input block IB. DATA_IN contains tables and descriptors for the
761 : : file being read. */
762 : :
763 : : static void
764 : 722375 : lto_input_ts_decl_common_tree_pointers (class lto_input_block *ib,
765 : : class data_in *data_in, tree expr)
766 : : {
767 : 722375 : DECL_SIZE (expr) = stream_read_tree_ref (ib, data_in);
768 : 722375 : DECL_SIZE_UNIT (expr) = stream_read_tree_ref (ib, data_in);
769 : 722375 : DECL_ATTRIBUTES (expr) = stream_read_tree_ref (ib, data_in);
770 : 722375 : DECL_ABSTRACT_ORIGIN (expr) = stream_read_tree_ref (ib, data_in);
771 : :
772 : 515218 : if ((VAR_P (expr) || TREE_CODE (expr) == PARM_DECL)
773 : 818975 : && DECL_HAS_VALUE_EXPR_P (expr))
774 : 5445 : SET_DECL_VALUE_EXPR (expr, stream_read_tree_ref (ib, data_in));
775 : :
776 : 722375 : if (VAR_P (expr)
777 : 722375 : && DECL_HAS_DEBUG_EXPR_P (expr))
778 : : {
779 : 682 : tree dexpr = stream_read_tree_ref (ib, data_in);
780 : 682 : if (dexpr)
781 : 682 : SET_DECL_DEBUG_EXPR (expr, dexpr);
782 : : }
783 : 722375 : }
784 : :
785 : :
786 : : /* Read all pointer fields in the TS_DECL_NON_COMMON structure of
787 : : EXPR from input block IB. DATA_IN contains tables and descriptors for the
788 : : file being read. */
789 : :
790 : : static void
791 : 0 : lto_input_ts_decl_non_common_tree_pointers (class lto_input_block *,
792 : : class data_in *, tree)
793 : : {
794 : 0 : }
795 : :
796 : :
797 : : /* Read all pointer fields in the TS_DECL_WITH_VIS structure of EXPR
798 : : from input block IB. DATA_IN contains tables and descriptors for the
799 : : file being read. */
800 : :
801 : : static void
802 : 423935 : lto_input_ts_decl_with_vis_tree_pointers (class lto_input_block *ib,
803 : : class data_in *data_in, tree expr)
804 : : {
805 : 423935 : tree id;
806 : :
807 : 423935 : id = stream_read_tree_ref (ib, data_in);
808 : 423935 : if (id)
809 : : {
810 : 284435 : gcc_assert (TREE_CODE (id) == IDENTIFIER_NODE);
811 : 284435 : SET_DECL_ASSEMBLER_NAME (expr, id);
812 : : }
813 : 423935 : }
814 : :
815 : :
816 : : /* Read all pointer fields in the TS_FIELD_DECL structure of EXPR from
817 : : input block IB. DATA_IN contains tables and descriptors for the
818 : : file being read. */
819 : :
820 : : static void
821 : 73319 : lto_input_ts_field_decl_tree_pointers (class lto_input_block *ib,
822 : : class data_in *data_in, tree expr)
823 : : {
824 : 73319 : DECL_FIELD_OFFSET (expr) = stream_read_tree_ref (ib, data_in);
825 : 73319 : DECL_BIT_FIELD_TYPE (expr) = stream_read_tree_ref (ib, data_in);
826 : 73319 : DECL_BIT_FIELD_REPRESENTATIVE (expr) = stream_read_tree_ref (ib, data_in);
827 : 73319 : DECL_FIELD_BIT_OFFSET (expr) = stream_read_tree_ref (ib, data_in);
828 : 73319 : }
829 : :
830 : :
831 : : /* Read all pointer fields in the TS_FUNCTION_DECL structure of EXPR
832 : : from input block IB. DATA_IN contains tables and descriptors for the
833 : : file being read. */
834 : :
835 : : static void
836 : 196882 : lto_input_ts_function_decl_tree_pointers (class lto_input_block *ib,
837 : : class data_in *data_in, tree expr)
838 : : {
839 : : /* DECL_STRUCT_FUNCTION is loaded on demand by cgraph_get_body. */
840 : 196882 : DECL_FUNCTION_PERSONALITY (expr) = stream_read_tree_ref (ib, data_in);
841 : : #ifndef ACCEL_COMPILER
842 : 196882 : DECL_FUNCTION_SPECIFIC_TARGET (expr) = stream_read_tree_ref (ib, data_in);
843 : : #endif
844 : 393764 : DECL_FUNCTION_SPECIFIC_OPTIMIZATION (expr)
845 : 196882 : = stream_read_tree_ref (ib, data_in);
846 : : #ifdef ACCEL_COMPILER
847 : : {
848 : : tree opts = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (expr);
849 : : if (opts)
850 : : {
851 : : struct gcc_options tmp, tmp_set;
852 : : init_options_struct (&tmp, NULL);
853 : : memset (&tmp_set, 0, sizeof (tmp_set));
854 : : cl_optimization_restore (&tmp, &tmp_set, TREE_OPTIMIZATION (opts));
855 : : finish_options (&tmp, &tmp_set, UNKNOWN_LOCATION);
856 : : opts = build_optimization_node (&tmp, &tmp_set);
857 : : DECL_FUNCTION_SPECIFIC_OPTIMIZATION (expr) = opts;
858 : : }
859 : : }
860 : : #endif
861 : 196882 : }
862 : :
863 : :
864 : : /* Read all pointer fields in the TS_TYPE_COMMON structure of EXPR from
865 : : input block IB. DATA_IN contains tables and descriptors for the file
866 : : being read. */
867 : :
868 : : static void
869 : 465020 : lto_input_ts_type_common_tree_pointers (class lto_input_block *ib,
870 : : class data_in *data_in, tree expr)
871 : : {
872 : 465020 : TYPE_SIZE (expr) = stream_read_tree_ref (ib, data_in);
873 : 465020 : TYPE_SIZE_UNIT (expr) = stream_read_tree_ref (ib, data_in);
874 : 465020 : TYPE_ATTRIBUTES (expr) = stream_read_tree_ref (ib, data_in);
875 : 465020 : TYPE_NAME (expr) = stream_read_tree_ref (ib, data_in);
876 : : /* Do not stream TYPE_POINTER_TO or TYPE_REFERENCE_TO. They will be
877 : : reconstructed during fixup. */
878 : : /* Do not stream TYPE_NEXT_VARIANT, we reconstruct the variant lists
879 : : during fixup. */
880 : 465020 : TYPE_MAIN_VARIANT (expr) = stream_read_tree_ref (ib, data_in);
881 : 465020 : TYPE_CONTEXT (expr) = stream_read_tree_ref (ib, data_in);
882 : : /* TYPE_CANONICAL gets re-computed during type merging. */
883 : 465020 : TYPE_CANONICAL (expr) = NULL_TREE;
884 : 465020 : }
885 : :
886 : : /* Read all pointer fields in the TS_TYPE_NON_COMMON structure of EXPR
887 : : from input block IB. DATA_IN contains tables and descriptors for the
888 : : file being read. */
889 : :
890 : : static void
891 : 465020 : lto_input_ts_type_non_common_tree_pointers (class lto_input_block *ib,
892 : : class data_in *data_in,
893 : : tree expr)
894 : : {
895 : 465020 : if (TREE_CODE (expr) == ARRAY_TYPE)
896 : 36992 : TYPE_DOMAIN (expr) = stream_read_tree_ref (ib, data_in);
897 : 428028 : else if (RECORD_OR_UNION_TYPE_P (expr))
898 : 54323 : TYPE_FIELDS (expr) = streamer_read_chain (ib, data_in);
899 : 373705 : else if (FUNC_OR_METHOD_TYPE_P (expr))
900 : 138652 : TYPE_ARG_TYPES (expr) = stream_read_tree_ref (ib, data_in);
901 : :
902 : 465020 : if (!POINTER_TYPE_P (expr))
903 : 292036 : TYPE_MIN_VALUE_RAW (expr) = stream_read_tree_ref (ib, data_in);
904 : 465020 : TYPE_MAX_VALUE_RAW (expr) = stream_read_tree_ref (ib, data_in);
905 : 465020 : }
906 : :
907 : :
908 : : /* Read all pointer fields in the TS_LIST structure of EXPR from input
909 : : block IB. DATA_IN contains tables and descriptors for the
910 : : file being read. */
911 : :
912 : : static void
913 : 408691 : lto_input_ts_list_tree_pointers (class lto_input_block *ib,
914 : : class data_in *data_in, tree expr)
915 : : {
916 : 408691 : TREE_PURPOSE (expr) = stream_read_tree_ref (ib, data_in);
917 : 408691 : TREE_VALUE (expr) = stream_read_tree_ref (ib, data_in);
918 : 408691 : TREE_CHAIN (expr) = stream_read_tree_ref (ib, data_in);
919 : 408691 : }
920 : :
921 : :
922 : : /* Read all pointer fields in the TS_VEC structure of EXPR from input
923 : : block IB. DATA_IN contains tables and descriptors for the
924 : : file being read. */
925 : :
926 : : static void
927 : 2 : lto_input_ts_vec_tree_pointers (class lto_input_block *ib,
928 : : class data_in *data_in, tree expr)
929 : : {
930 : 2 : int i;
931 : :
932 : : /* Note that TREE_VEC_LENGTH was read by streamer_alloc_tree to
933 : : instantiate EXPR. */
934 : 10 : for (i = 0; i < TREE_VEC_LENGTH (expr); i++)
935 : 8 : TREE_VEC_ELT (expr, i) = stream_read_tree_ref (ib, data_in);
936 : 2 : }
937 : :
938 : :
939 : : /* Read all pointer fields in the TS_EXP structure of EXPR from input
940 : : block IB. DATA_IN contains tables and descriptors for the
941 : : file being read. */
942 : :
943 : :
944 : : static void
945 : 1292997 : lto_input_ts_exp_tree_pointers (class lto_input_block *ib,
946 : : class data_in *data_in, tree expr)
947 : : {
948 : 1292997 : int i;
949 : 1292997 : tree block;
950 : :
951 : 3152019 : for (i = 0; i < TREE_OPERAND_LENGTH (expr); i++)
952 : 1859022 : TREE_OPERAND (expr, i) = stream_read_tree_ref (ib, data_in);
953 : :
954 : 1292997 : block = stream_read_tree_ref (ib, data_in);
955 : :
956 : : /* TODO: Block is stored in the locus information. It may make more sense to
957 : : to make it go via the location cache. */
958 : 1292997 : if (block)
959 : : {
960 : 216747 : data_in->location_cache.apply_location_cache ();
961 : 216747 : TREE_SET_BLOCK (expr, block);
962 : : }
963 : 1292997 : }
964 : :
965 : :
966 : : /* Read all pointer fields in the TS_BLOCK structure of EXPR from input
967 : : block IB. DATA_IN contains tables and descriptors for the
968 : : file being read. */
969 : :
970 : : static void
971 : 271211 : lto_input_ts_block_tree_pointers (class lto_input_block *ib,
972 : : class data_in *data_in, tree expr)
973 : : {
974 : 271211 : BLOCK_VARS (expr) = streamer_read_chain (ib, data_in);
975 : :
976 : 271211 : BLOCK_SUPERCONTEXT (expr) = stream_read_tree_ref (ib, data_in);
977 : 271211 : BLOCK_ABSTRACT_ORIGIN (expr) = stream_read_tree_ref (ib, data_in);
978 : : /* We may end up prevailing a decl with DECL_ORIGIN (t) != t here
979 : : which breaks the invariant that BLOCK_ABSTRACT_ORIGIN is the
980 : : ultimate origin. Fixup here.
981 : : ??? This should get fixed with moving to DIE references. */
982 : 271211 : if (DECL_P (BLOCK_ORIGIN (expr)))
983 : 61185 : BLOCK_ABSTRACT_ORIGIN (expr) = DECL_ORIGIN (BLOCK_ABSTRACT_ORIGIN (expr));
984 : : /* Do not stream BLOCK_NONLOCALIZED_VARS. We cannot handle debug information
985 : : for early inlined BLOCKs so drop it on the floor instead of ICEing in
986 : : dwarf2out.cc. */
987 : :
988 : : /* BLOCK_FRAGMENT_ORIGIN and BLOCK_FRAGMENT_CHAIN is not live at LTO
989 : : streaming time. */
990 : :
991 : : /* We re-compute BLOCK_SUBBLOCKS of our parent here instead
992 : : of streaming it. For non-BLOCK BLOCK_SUPERCONTEXTs we still
993 : : stream the child relationship explicitly. */
994 : 271211 : if (BLOCK_SUPERCONTEXT (expr)
995 : 271211 : && TREE_CODE (BLOCK_SUPERCONTEXT (expr)) == BLOCK)
996 : : {
997 : 171489 : BLOCK_CHAIN (expr) = BLOCK_SUBBLOCKS (BLOCK_SUPERCONTEXT (expr));
998 : 171489 : BLOCK_SUBBLOCKS (BLOCK_SUPERCONTEXT (expr)) = expr;
999 : : }
1000 : :
1001 : : /* The global block is rooted at the TU decl. Hook it here to
1002 : : avoid the need to stream in this block during WPA time. */
1003 : 99722 : else if (BLOCK_SUPERCONTEXT (expr)
1004 : 99722 : && TREE_CODE (BLOCK_SUPERCONTEXT (expr)) == TRANSLATION_UNIT_DECL)
1005 : 0 : DECL_INITIAL (BLOCK_SUPERCONTEXT (expr)) = expr;
1006 : :
1007 : : /* The function-level block is connected at the time we read in
1008 : : function bodies for the same reason. */
1009 : 271211 : }
1010 : :
1011 : :
1012 : : /* Read all pointer fields in the TS_BINFO structure of EXPR from input
1013 : : block IB. DATA_IN contains tables and descriptors for the
1014 : : file being read. */
1015 : :
1016 : : static void
1017 : 5959 : lto_input_ts_binfo_tree_pointers (class lto_input_block *ib,
1018 : : class data_in *data_in, tree expr)
1019 : : {
1020 : 12148 : tree t;
1021 : :
1022 : : /* Note that the number of slots in EXPR was read in
1023 : : streamer_alloc_tree when instantiating EXPR. However, the
1024 : : vector is empty so we cannot rely on vec::length to know how many
1025 : : elements to read. So, this list is emitted as a 0-terminated
1026 : : list on the writer side. */
1027 : 12148 : do
1028 : : {
1029 : 12148 : t = stream_read_tree_ref (ib, data_in);
1030 : 12148 : if (t)
1031 : 6189 : BINFO_BASE_BINFOS (expr)->quick_push (t);
1032 : : }
1033 : 12148 : while (t);
1034 : :
1035 : 5959 : BINFO_OFFSET (expr) = stream_read_tree_ref (ib, data_in);
1036 : 5959 : BINFO_VTABLE (expr) = stream_read_tree_ref (ib, data_in);
1037 : :
1038 : : /* Do not walk BINFO_INHERITANCE_CHAIN, BINFO_SUBVTT_INDEX,
1039 : : BINFO_BASE_ACCESSES and BINFO_VPTR_INDEX; these are used by C++ FE
1040 : : only. */
1041 : 5959 : }
1042 : :
1043 : :
1044 : : /* Read all pointer fields in the TS_CONSTRUCTOR structure of EXPR from
1045 : : input block IB. DATA_IN contains tables and descriptors for the
1046 : : file being read. */
1047 : :
1048 : : static void
1049 : 27801 : lto_input_ts_constructor_tree_pointers (class lto_input_block *ib,
1050 : : class data_in *data_in, tree expr)
1051 : : {
1052 : 27801 : unsigned i;
1053 : :
1054 : 113948 : for (i = 0; i < CONSTRUCTOR_NELTS (expr); i++)
1055 : : {
1056 : 86147 : constructor_elt e;
1057 : 86147 : e.index = stream_read_tree_ref (ib, data_in);
1058 : 86147 : e.value = stream_read_tree_ref (ib, data_in);
1059 : 86147 : (*CONSTRUCTOR_ELTS (expr))[i] = e;
1060 : : }
1061 : 27801 : }
1062 : :
1063 : :
1064 : : /* Read all pointer fields in the TS_RAW_DATA_CST structure of EXPR from
1065 : : input block IB. DATA_IN contains tables and descriptors for the
1066 : : file being read. */
1067 : :
1068 : : static void
1069 : 17 : lto_input_ts_raw_data_cst_tree_pointers (class lto_input_block *ib,
1070 : : class data_in *data_in, tree expr)
1071 : : {
1072 : 17 : RAW_DATA_OWNER (expr) = stream_read_tree_ref (ib, data_in);
1073 : 17 : gcc_checking_assert (RAW_DATA_OWNER (expr)
1074 : : && TREE_CODE (RAW_DATA_OWNER (expr)) == STRING_CST);
1075 : 17 : RAW_DATA_POINTER (expr) = (TREE_STRING_POINTER (RAW_DATA_OWNER (expr))
1076 : 17 : + (uintptr_t) RAW_DATA_POINTER (expr));
1077 : 17 : }
1078 : :
1079 : :
1080 : : /* Read all pointer fields in the TS_OMP_CLAUSE structure of EXPR from
1081 : : input block IB. DATA_IN contains tables and descriptors for the
1082 : : file being read. */
1083 : :
1084 : : static void
1085 : 202 : lto_input_ts_omp_clause_tree_pointers (class lto_input_block *ib,
1086 : : class data_in *data_in, tree expr)
1087 : : {
1088 : 202 : int i;
1089 : :
1090 : 477 : for (i = 0; i < omp_clause_num_ops[OMP_CLAUSE_CODE (expr)]; i++)
1091 : 275 : OMP_CLAUSE_OPERAND (expr, i) = stream_read_tree_ref (ib, data_in);
1092 : 202 : OMP_CLAUSE_CHAIN (expr) = stream_read_tree_ref (ib, data_in);
1093 : 202 : }
1094 : :
1095 : :
1096 : : /* Read all pointer fields in EXPR from input block IB. DATA_IN
1097 : : contains tables and descriptors for the file being read. */
1098 : :
1099 : : void
1100 : 4241846 : streamer_read_tree_body (class lto_input_block *ib, class data_in *data_in,
1101 : : tree expr)
1102 : : {
1103 : 4241846 : enum tree_code code;
1104 : :
1105 : 4241846 : code = TREE_CODE (expr);
1106 : :
1107 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_TYPED))
1108 : 3925030 : lto_input_ts_common_tree_pointers (ib, data_in, expr);
1109 : :
1110 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_VECTOR))
1111 : 2688 : lto_input_ts_vector_tree_pointers (ib, data_in, expr);
1112 : :
1113 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_POLY_INT_CST))
1114 : 0 : lto_input_ts_poly_tree_pointers (ib, data_in, expr);
1115 : :
1116 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_COMPLEX))
1117 : 6907 : lto_input_ts_complex_tree_pointers (ib, data_in, expr);
1118 : :
1119 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_MINIMAL))
1120 : 722375 : lto_input_ts_decl_minimal_tree_pointers (ib, data_in, expr);
1121 : :
1122 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
1123 : 722375 : lto_input_ts_decl_common_tree_pointers (ib, data_in, expr);
1124 : :
1125 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_NON_COMMON))
1126 : 4241846 : lto_input_ts_decl_non_common_tree_pointers (ib, data_in, expr);
1127 : :
1128 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS))
1129 : 423935 : lto_input_ts_decl_with_vis_tree_pointers (ib, data_in, expr);
1130 : :
1131 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_FIELD_DECL))
1132 : 73319 : lto_input_ts_field_decl_tree_pointers (ib, data_in, expr);
1133 : :
1134 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_FUNCTION_DECL))
1135 : 196882 : lto_input_ts_function_decl_tree_pointers (ib, data_in, expr);
1136 : :
1137 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_TYPE_COMMON))
1138 : 465020 : lto_input_ts_type_common_tree_pointers (ib, data_in, expr);
1139 : :
1140 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_TYPE_NON_COMMON))
1141 : 465020 : lto_input_ts_type_non_common_tree_pointers (ib, data_in, expr);
1142 : :
1143 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_LIST))
1144 : 408691 : lto_input_ts_list_tree_pointers (ib, data_in, expr);
1145 : :
1146 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_VEC))
1147 : 2 : lto_input_ts_vec_tree_pointers (ib, data_in, expr);
1148 : :
1149 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_EXP))
1150 : 1292997 : lto_input_ts_exp_tree_pointers (ib, data_in, expr);
1151 : :
1152 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_BLOCK))
1153 : 271211 : lto_input_ts_block_tree_pointers (ib, data_in, expr);
1154 : :
1155 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_BINFO))
1156 : 5959 : lto_input_ts_binfo_tree_pointers (ib, data_in, expr);
1157 : :
1158 : 4241846 : if (CODE_CONTAINS_STRUCT (code, TS_CONSTRUCTOR))
1159 : 27801 : lto_input_ts_constructor_tree_pointers (ib, data_in, expr);
1160 : :
1161 : 4241846 : if (code == RAW_DATA_CST)
1162 : 17 : lto_input_ts_raw_data_cst_tree_pointers (ib, data_in, expr);
1163 : :
1164 : 4241846 : if (code == OMP_CLAUSE)
1165 : 202 : lto_input_ts_omp_clause_tree_pointers (ib, data_in, expr);
1166 : 4241846 : }
1167 : :
1168 : :
1169 : : /* Read an index IX from input block IB and return the tree node at
1170 : : DATA_IN->FILE_DATA->GLOBALS_INDEX[IX]. */
1171 : :
1172 : : tree
1173 : 1600901 : streamer_get_pickled_tree (class lto_input_block *ib, class data_in *data_in)
1174 : : {
1175 : 1600901 : unsigned HOST_WIDE_INT ix;
1176 : 1600901 : tree result;
1177 : :
1178 : 1600901 : ix = streamer_read_uhwi (ib);
1179 : 1600901 : result = streamer_tree_cache_get_tree (data_in->reader_cache, ix);
1180 : 1600901 : return result;
1181 : : }
|