Line data Source code
1 : /* Read the GIMPLE representation from a file stream.
2 :
3 : Copyright (C) 2009-2026 Free Software Foundation, Inc.
4 : Contributed by Kenneth Zadeck <zadeck@naturalbridge.com>
5 : Re-implemented by Diego Novillo <dnovillo@google.com>
6 :
7 : This file is part of GCC.
8 :
9 : GCC is free software; you can redistribute it and/or modify it under
10 : the terms of the GNU General Public License as published by the Free
11 : Software Foundation; either version 3, or (at your option) any later
12 : version.
13 :
14 : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15 : WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 : FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 : for more details.
18 :
19 : You should have received a copy of the GNU General Public License
20 : along with GCC; see the file COPYING3. If not see
21 : <http://www.gnu.org/licenses/>. */
22 :
23 : #include "config.h"
24 : #include "system.h"
25 : #include "coretypes.h"
26 : #include "backend.h"
27 : #include "target.h"
28 : #include "rtl.h"
29 : #include "tree.h"
30 : #include "gimple.h"
31 : #include "cfghooks.h"
32 : #include "tree-pass.h"
33 : #include "ssa.h"
34 : #include "gimple-streamer.h"
35 : #include "toplev.h"
36 : #include "gimple-iterator.h"
37 : #include "tree-cfg.h"
38 : #include "tree-into-ssa.h"
39 : #include "tree-dfa.h"
40 : #include "tree-ssa.h"
41 : #include "except.h"
42 : #include "cgraph.h"
43 : #include "cfgloop.h"
44 : #include "debug.h"
45 : #include "alloc-pool.h"
46 : #include "toplev.h"
47 :
48 : /* Allocator used to hold string slot entries for line map streaming. */
49 : static struct object_allocator<struct string_slot> *string_slot_allocator;
50 :
51 : /* The table to hold the file names. */
52 : static hash_table<string_slot_hasher> *file_name_hash_table;
53 :
54 : /* The table to hold the relative pathname prefixes. */
55 :
56 : /* This obstack holds file names used in locators. Line map datastructures
57 : points here and thus it needs to be kept allocated as long as linemaps
58 : exists. */
59 : static struct obstack file_name_obstack;
60 :
61 : /* Map a pair of nul terminated strings where the first one can be
62 : pointer compared, but the second can't, to another string. */
63 : struct string_pair_map
64 : {
65 : const char *str1;
66 : const char *str2;
67 : const char *str3;
68 : hashval_t hash;
69 : bool prefix;
70 : };
71 :
72 : /* Allocator used to hold string pair map entries for line map streaming. */
73 : static struct object_allocator<struct string_pair_map>
74 : *string_pair_map_allocator;
75 :
76 : struct string_pair_map_hasher : nofree_ptr_hash <string_pair_map>
77 : {
78 : static inline hashval_t hash (const string_pair_map *);
79 : static inline bool equal (const string_pair_map *, const string_pair_map *);
80 : };
81 :
82 : inline hashval_t
83 0 : string_pair_map_hasher::hash (const string_pair_map *spm)
84 : {
85 0 : return spm->hash;
86 : }
87 :
88 : inline bool
89 0 : string_pair_map_hasher::equal (const string_pair_map *spm1,
90 : const string_pair_map *spm2)
91 : {
92 0 : return (spm1->hash == spm2->hash
93 0 : && spm1->str1 == spm2->str1
94 0 : && spm1->prefix == spm2->prefix
95 0 : && strcmp (spm1->str2, spm2->str2) == 0);
96 : }
97 :
98 : /* The table to hold the pairs of pathnames and corresponding
99 : resulting pathname. Used for both mapping of get_src_pwd ()
100 : and recorded source working directory to relative path prefix
101 : from current working directory to the recorded one, and for
102 : mapping of that relative path prefix and some relative path
103 : to those concatenated. */
104 : static hash_table<string_pair_map_hasher> *path_name_pair_hash_table;
105 :
106 :
107 : /* Check that tag ACTUAL has one of the given values. NUM_TAGS is the
108 : number of valid tag values to check. */
109 :
110 : void
111 1408978 : lto_tag_check_set (enum LTO_tags actual, int ntags, ...)
112 : {
113 1408978 : va_list ap;
114 1408978 : int i;
115 :
116 1408978 : va_start (ap, ntags);
117 2812846 : for (i = 0; i < ntags; i++)
118 2812846 : if ((unsigned) actual == va_arg (ap, unsigned))
119 : {
120 1408978 : va_end (ap);
121 1408978 : return;
122 : }
123 :
124 0 : va_end (ap);
125 0 : internal_error ("bytecode stream: unexpected tag %s", lto_tag_name (actual));
126 : }
127 :
128 :
129 : /* Read LENGTH bytes from STREAM to ADDR. */
130 :
131 : void
132 0 : lto_input_data_block (class lto_input_block *ib, void *addr, size_t length)
133 : {
134 0 : size_t i;
135 0 : unsigned char *const buffer = (unsigned char *) addr;
136 :
137 0 : for (i = 0; i < length; i++)
138 0 : buffer[i] = streamer_read_uchar (ib);
139 0 : }
140 :
141 : /* Compute the relative path to get to DATA_WD (absolute directory name)
142 : from CWD (another absolute directory name). E.g. for
143 : DATA_WD of "/tmp/foo/bar" and CWD of "/tmp/baz/qux" return
144 : "../../foo/bar". Returned string should be freed by the caller.
145 : Return NULL if absolute file name needs to be used. */
146 :
147 : static char *
148 0 : relative_path_prefix (const char *data_wd, const char *cwd)
149 : {
150 0 : const char *d = data_wd;
151 0 : const char *c = cwd;
152 : #ifdef HAVE_DOS_BASED_FILE_SYSTEM
153 : if (d[1] == ':')
154 : {
155 : if (!IS_DIR_SEPARATOR (d[2]))
156 : return NULL;
157 : if (c[0] == d[0] && c[1] == ':' && IS_DIR_SEPARATOR (c[2]))
158 : {
159 : c += 3;
160 : d += 3;
161 : }
162 : else
163 : return NULL;
164 : }
165 : else if (c[1] == ':')
166 : return NULL;
167 : #endif
168 : do
169 : {
170 0 : while (IS_DIR_SEPARATOR (*d))
171 0 : d++;
172 0 : while (IS_DIR_SEPARATOR (*c))
173 0 : c++;
174 : size_t i;
175 0 : for (i = 0; c[i] && !IS_DIR_SEPARATOR (c[i]) && c[i] == d[i]; i++)
176 : ;
177 0 : if ((c[i] == '\0' || IS_DIR_SEPARATOR (c[i]))
178 0 : && (d[i] == '\0' || IS_DIR_SEPARATOR (d[i])))
179 : {
180 0 : c += i;
181 0 : d += i;
182 0 : if (*c == '\0' || *d == '\0')
183 : break;
184 : }
185 : else
186 : break;
187 : }
188 : while (1);
189 0 : size_t num_up = 0;
190 : do
191 : {
192 0 : while (IS_DIR_SEPARATOR (*c))
193 0 : c++;
194 0 : if (*c == '\0')
195 : break;
196 0 : num_up++;
197 0 : while (*c && !IS_DIR_SEPARATOR (*c))
198 0 : c++;
199 : }
200 : while (1);
201 0 : while (IS_DIR_SEPARATOR (*d))
202 0 : d++;
203 0 : size_t len = strlen (d);
204 0 : if (len == 0 && num_up == 0)
205 0 : return xstrdup (".");
206 0 : char *ret = XNEWVEC (char, num_up * 3 + len + 1);
207 0 : char *p = ret;
208 0 : for (; num_up; num_up--)
209 : {
210 0 : const char dir_up[3] = { '.', '.', DIR_SEPARATOR };
211 0 : memcpy (p, dir_up, 3);
212 0 : p += 3;
213 : }
214 0 : memcpy (p, d, len + 1);
215 0 : return ret;
216 : }
217 :
218 : /* Look up DATA_WD in hash table of relative prefixes. If found,
219 : return relative path from CWD to DATA_WD from the hash table,
220 : otherwise create it. */
221 :
222 : static const char *
223 0 : canon_relative_path_prefix (const char *data_wd, const char *cwd)
224 : {
225 0 : if (!IS_ABSOLUTE_PATH (data_wd) || !IS_ABSOLUTE_PATH (cwd))
226 : return NULL;
227 :
228 0 : if (!path_name_pair_hash_table)
229 : {
230 0 : path_name_pair_hash_table
231 0 : = new hash_table<string_pair_map_hasher> (37);
232 0 : string_pair_map_allocator
233 0 : = new object_allocator <struct string_pair_map>
234 0 : ("line map string pair map hash");
235 : }
236 :
237 0 : inchash::hash h;
238 0 : h.add_ptr (cwd);
239 0 : h.merge_hash (htab_hash_string (data_wd));
240 0 : h.add_int (true);
241 :
242 0 : string_pair_map s_slot;
243 0 : s_slot.str1 = cwd;
244 0 : s_slot.str2 = data_wd;
245 0 : s_slot.str3 = NULL;
246 0 : s_slot.hash = h.end ();
247 0 : s_slot.prefix = true;
248 :
249 0 : string_pair_map **slot
250 0 : = path_name_pair_hash_table->find_slot (&s_slot, INSERT);
251 0 : if (*slot == NULL)
252 : {
253 : /* Compute relative path from cwd directory to data_wd directory.
254 : E.g. if cwd is /tmp/foo/bar and data_wd is /tmp/baz/qux ,
255 : it will return ../../baz/qux . */
256 0 : char *relative_path = relative_path_prefix (data_wd, cwd);
257 0 : const char *relative = relative_path ? relative_path : data_wd;
258 0 : size_t relative_len = strlen (relative);
259 0 : gcc_assert (relative_len);
260 :
261 0 : size_t data_wd_len = strlen (data_wd);
262 0 : bool add_separator = false;
263 0 : if (!IS_DIR_SEPARATOR (relative[relative_len - 1]))
264 0 : add_separator = true;
265 :
266 0 : size_t len = relative_len + 1 + data_wd_len + 1 + add_separator;
267 :
268 0 : char *saved_string = XOBNEWVEC (&file_name_obstack, char, len);
269 0 : struct string_pair_map *new_slot
270 0 : = string_pair_map_allocator->allocate ();
271 0 : memcpy (saved_string, data_wd, data_wd_len + 1);
272 0 : memcpy (saved_string + data_wd_len + 1, relative, relative_len);
273 0 : if (add_separator)
274 0 : saved_string[len - 2] = DIR_SEPARATOR;
275 0 : saved_string[len - 1] = '\0';
276 0 : new_slot->str1 = cwd;
277 0 : new_slot->str2 = saved_string;
278 0 : new_slot->str3 = saved_string + data_wd_len + 1;
279 0 : if (relative_len == 1 && relative[0] == '.')
280 0 : new_slot->str3 = NULL;
281 0 : new_slot->hash = s_slot.hash;
282 0 : new_slot->prefix = true;
283 0 : *slot = new_slot;
284 0 : free (relative_path);
285 0 : return new_slot->str3;
286 : }
287 : else
288 : {
289 0 : string_pair_map *old_slot = *slot;
290 0 : return old_slot->str3;
291 : }
292 : }
293 :
294 : /* Look up the pair of RELATIVE_PREFIX and STRING strings in a hash table.
295 : If found, return the concatenation of those from the hash table,
296 : otherwise concatenate them. */
297 :
298 : static const char *
299 0 : canon_relative_file_name (const char *relative_prefix, const char *string)
300 : {
301 0 : inchash::hash h;
302 0 : h.add_ptr (relative_prefix);
303 0 : h.merge_hash (htab_hash_string (string));
304 :
305 0 : string_pair_map s_slot;
306 0 : s_slot.str1 = relative_prefix;
307 0 : s_slot.str2 = string;
308 0 : s_slot.str3 = NULL;
309 0 : s_slot.hash = h.end ();
310 0 : s_slot.prefix = false;
311 :
312 0 : string_pair_map **slot
313 0 : = path_name_pair_hash_table->find_slot (&s_slot, INSERT);
314 0 : if (*slot == NULL)
315 : {
316 0 : size_t relative_prefix_len = strlen (relative_prefix);
317 0 : size_t string_len = strlen (string);
318 0 : size_t len = relative_prefix_len + string_len + 1;
319 :
320 0 : char *saved_string = XOBNEWVEC (&file_name_obstack, char, len);
321 0 : struct string_pair_map *new_slot
322 0 : = string_pair_map_allocator->allocate ();
323 0 : memcpy (saved_string, relative_prefix, relative_prefix_len);
324 0 : memcpy (saved_string + relative_prefix_len, string, string_len + 1);
325 0 : new_slot->str1 = relative_prefix;
326 0 : new_slot->str2 = saved_string + relative_prefix_len;
327 0 : new_slot->str3 = saved_string;
328 0 : new_slot->hash = s_slot.hash;
329 0 : new_slot->prefix = false;
330 0 : *slot = new_slot;
331 0 : return new_slot->str3;
332 : }
333 : else
334 : {
335 0 : string_pair_map *old_slot = *slot;
336 0 : return old_slot->str3;
337 : }
338 : }
339 :
340 : /* Lookup STRING in file_name_hash_table. If found, return the existing
341 : string, otherwise insert STRING as the canonical version.
342 : If STRING is a relative pathname and RELATIVE_PREFIX is non-NULL, use
343 : canon_relative_file_name instead. */
344 :
345 : static const char *
346 51228 : canon_file_name (const char *relative_prefix, const char *string)
347 : {
348 51228 : if (relative_prefix && !IS_ABSOLUTE_PATH (string))
349 0 : return canon_relative_file_name (relative_prefix, string);
350 :
351 51228 : string_slot **slot;
352 51228 : struct string_slot s_slot;
353 51228 : size_t len = strlen (string);
354 :
355 51228 : s_slot.s = string;
356 51228 : s_slot.len = len;
357 :
358 51228 : slot = file_name_hash_table->find_slot (&s_slot, INSERT);
359 51228 : if (*slot == NULL)
360 : {
361 47063 : char *saved_string;
362 47063 : struct string_slot *new_slot;
363 :
364 47063 : saved_string = XOBNEWVEC (&file_name_obstack, char, len + 1);
365 47063 : new_slot = string_slot_allocator->allocate ();
366 47063 : memcpy (saved_string, string, len + 1);
367 47063 : new_slot->s = saved_string;
368 47063 : new_slot->len = len;
369 47063 : *slot = new_slot;
370 47063 : return saved_string;
371 : }
372 : else
373 : {
374 4165 : struct string_slot *old_slot = *slot;
375 4165 : return old_slot->s;
376 : }
377 : }
378 :
379 : /* Given a map index and offset from the streamed data, convert it to a
380 : location_t in the global line map. */
381 :
382 : static location_t
383 3011279 : get_location_from_idx (size_t map_idx, location_t offset,
384 : const lto_loc_map *loc_map)
385 : {
386 3011279 : if (!map_idx)
387 : return offset;
388 3011279 : gcc_checking_assert (loc_map);
389 3011279 : --map_idx;
390 3011279 : gcc_assert (map_idx < loc_map->nmaps);
391 3011279 : const auto map = LINEMAPS_ORDINARY_MAP_AT (line_table, loc_map->map[map_idx]);
392 3011279 : const location_t res = map->start_location + offset;
393 3011279 : gcc_checking_assert (res < (map == LINEMAPS_LAST_ORDINARY_MAP (line_table)
394 : ? line_table->highest_location + 1
395 : : map[1].start_location));
396 : return res;
397 : }
398 :
399 : /* Pointer to currently alive instance of lto_location_cache. */
400 :
401 : lto_location_cache *lto_location_cache::current_cache;
402 :
403 : /* Apply all changes in location cache. Add locations into linemap and patch
404 : trees. */
405 :
406 : bool
407 627431 : lto_location_cache::apply_location_cache ()
408 : {
409 627431 : if (loc_cache.is_empty ())
410 : return true;
411 :
412 1983800 : for (const auto &cloc: loc_cache)
413 : {
414 1703320 : const location_t loc = cloc.loc;
415 1703320 : const auto range = source_range::from_location (loc);
416 1703320 : *cloc.dest = line_table->get_or_create_combined_loc (loc, range,
417 1703320 : cloc.block,
418 1703320 : cloc.discr);
419 : }
420 560960 : current_cloc = loc_cache[loc_cache.length () - 1];
421 280480 : current_loc = *current_cloc.dest;
422 280480 : loc_cache.truncate (0);
423 280480 : accepted_length = 0;
424 280480 : return true;
425 : }
426 :
427 : /* Tree merging did not succeed; mark all changes in the cache as accepted. */
428 :
429 : void
430 1866707 : lto_location_cache::accept_location_cache ()
431 : {
432 1866707 : gcc_assert (current_cache == this);
433 1866707 : accepted_length = loc_cache.length ();
434 1866707 : }
435 :
436 : /* Tree merging did succeed; throw away recent changes. */
437 :
438 : void
439 146047 : lto_location_cache::revert_location_cache ()
440 : {
441 146047 : loc_cache.truncate (accepted_length);
442 146047 : }
443 :
444 : /* Bitpack packing is more efficient for small values since every 4th bit is a
445 : continuation bit, so it helps to pack values as the delta from the previous
446 : if they can get large. */
447 : template<typename Int>
448 : static Int
449 5949452 : bp_unpack_delta (bitpack_d *bp, Int &prev)
450 : {
451 5949452 : const bool decrease = bp_unpack_value (bp, 1);
452 5949452 : const Int delta = bp_unpack_var_len_unsigned (bp);
453 5949452 : return prev = (decrease ? prev - delta : prev + delta);
454 : }
455 :
456 : /* Read the linemap section of order LINEMAP_ID from FILE_DATA and create an
457 : lto_loc_map object that can be used to find which ordinary map in the
458 : global line_table corresponds to a given streamed-out map index. Always
459 : either returns a non-NULL pointer, or calls fatal_error(). */
460 :
461 : static lto_loc_map *
462 22391 : create_loc_map (lto_file_decl_data *file_data, unsigned linemap_id)
463 : {
464 22391 : timevar_push (TV_IPA_LTO_LINEMAP_IN);
465 :
466 22391 : size_t len;
467 22391 : const auto data = lto_get_section_data (file_data, LTO_section_linemap,
468 : nullptr, linemap_id, &len, true);
469 22391 : if (!data)
470 0 : fatal_error (UNKNOWN_LOCATION,
471 : "linemap section #%u not found in file %qs",
472 : linemap_id, file_data->file_name);
473 :
474 22391 : const auto header = (const lto_simple_header_with_strings *) data;
475 22391 : const char *const main_begin = data + sizeof (*header);
476 22391 : const auto data_in
477 44782 : = lto_data_in_create (file_data, main_begin + header->main_size,
478 22391 : header->string_size, vNULL, false);
479 22391 : lto_input_block ib (main_begin, header->main_size, file_data);
480 22391 : bitpack_d bp = streamer_read_bitpack (&ib);
481 :
482 : /* Create the location map object. */
483 22391 : const size_t nmaps = bp_unpack_var_len_unsigned (&bp);
484 22391 : size_t loc_map_sz = sizeof (lto_loc_map);
485 22391 : if (nmaps > 1)
486 5498 : loc_map_sz += (nmaps - 1) * sizeof (size_t);
487 22391 : const auto loc_map = (lto_loc_map *) ggc_internal_alloc (loc_map_sz);
488 22391 : loc_map->nmaps = nmaps;
489 :
490 : /* Read the line map data. */
491 22391 : const char *stream_relative_path_prefix = nullptr;
492 22391 : const char *stream_file = nullptr;
493 22391 : size_t cur_map_idx = 0;
494 22391 : linenum_type cur_line = 0;
495 73619 : for (size_t i = 0; i != nmaps; ++i)
496 : {
497 51228 : const size_t map_idx = bp_unpack_delta (&bp, cur_map_idx);
498 51228 : gcc_assert (map_idx && map_idx <= nmaps);
499 51228 : const line_map_uint_t num_lines = bp_unpack_var_len_unsigned (&bp);
500 51228 : const bool sysp = bp_unpack_value (&bp, 1);
501 51228 : const unsigned int column_bits = bp_unpack_value (&bp, 8);
502 51228 : const linenum_type to_line = bp_unpack_delta (&bp, cur_line);
503 51228 : const bool file_change = bp_unpack_value (&bp, 1);
504 51228 : if (file_change)
505 : {
506 51228 : const bool pwd_change = bp_unpack_value (&bp, 1);
507 51228 : if (pwd_change)
508 : {
509 2739 : const char *pwd = bp_unpack_string (data_in, &bp);
510 2739 : const char *src_pwd = get_src_pwd ();
511 2739 : stream_relative_path_prefix
512 2739 : = strcmp (pwd, src_pwd) == 0 ? nullptr
513 0 : : canon_relative_path_prefix (pwd, src_pwd);
514 : }
515 51228 : stream_file = canon_file_name (stream_relative_path_prefix,
516 : bp_unpack_string (data_in, &bp));
517 : }
518 51228 : gcc_assert (stream_file);
519 51228 : const auto map
520 51228 : = linemap_add_raw_map (line_table,
521 51228 : line_table->depth ? LC_RENAME : LC_ENTER,
522 51228 : line_table->highest_location + 1, sysp,
523 : column_bits, 0, stream_file, to_line, num_lines);
524 51228 : if (!map)
525 0 : fatal_error (UNKNOWN_LOCATION,
526 : "Ran out of locations while reading linemap section #%u",
527 : linemap_id);
528 51228 : loc_map->map[map_idx - 1] = map - line_table->info_ordinary.maps;
529 51228 : if (flag_wpa || flag_incremental_link == INCREMENTAL_LINK_LTO)
530 : {
531 20717 : const auto out_id = lto_linemap_output_id (linemap_id, file_data);
532 20717 : lto_register_linemap_for_output (map_idx, out_id);
533 : }
534 : }
535 :
536 : /* Process the diagnostics classification history. */
537 22391 : auto &chist = global_dc->get_classification_history ();
538 22391 : const int pop_offset = chist.length ();
539 22391 : using DK = diagnostics::kind;
540 110172 : for (size_t i = 0, nc = bp_unpack_var_len_unsigned (&bp); i != nc; ++i)
541 : {
542 87781 : const size_t map_idx = bp_unpack_var_len_unsigned (&bp);
543 87781 : const location_t offset = bp_unpack_var_len_unsigned (&bp);
544 87781 : const location_t loc = get_location_from_idx (map_idx, offset, loc_map);
545 87781 : const int option = bp_unpack_var_len_int (&bp);
546 87781 : const auto kind = bp_unpack_enum (&bp, diagnostics::kind,
547 : DK::tot_num_diagnostic_kinds);
548 87781 : if (kind == DK::pop)
549 : {
550 45229 : diagnostics::option_classifier::classification_change_t c = {};
551 45229 : c.location = loc;
552 45229 : c.option = option + pop_offset;
553 45229 : c.kind = kind;
554 45229 : chist.safe_push (c);
555 : }
556 : else
557 42552 : global_dc->classify_diagnostic (option, kind, loc);
558 : }
559 : /* Make sure we reset back to the baseline. */
560 22391 : {
561 22391 : diagnostics::option_classifier::classification_change_t c = {};
562 22391 : c.location = line_table->highest_location;
563 22391 : c.kind = DK::pop;
564 22391 : chist.safe_push (c);
565 : }
566 :
567 22391 : lto_data_in_delete (data_in);
568 22391 : lto_free_section_data (file_data, LTO_section_linemap, nullptr,
569 : data, len, true);
570 :
571 22391 : timevar_pop (TV_IPA_LTO_LINEMAP_IN);
572 22391 : return loc_map;
573 : }
574 :
575 : /* Return the location map with given ID, reading it from the LTO object if
576 : necessary. */
577 :
578 : static const lto_loc_map *
579 107459 : get_loc_map (lto_file_decl_data *file_data, unsigned linemap_id)
580 : {
581 : /* During LTRANS, the location maps are stored in a different object. */
582 151971 : while (file_data->loc_map_decl_data)
583 : file_data = file_data->loc_map_decl_data;
584 :
585 107459 : if (vec_safe_length (file_data->loc_maps) <= linemap_id)
586 22164 : vec_safe_grow_cleared (file_data->loc_maps, linemap_id + 1);
587 107459 : auto &res = (*file_data->loc_maps)[linemap_id];
588 107459 : if (!res)
589 22391 : res = create_loc_map (file_data, linemap_id);
590 107459 : return res;
591 : }
592 :
593 :
594 : /* Read a location bitpack from bit pack BP and either update *LOC directly or
595 : add it to the location cache. It is necessary to call apply_location_cache
596 : to guarantee that *LOC has been updated. */
597 :
598 : void
599 4969041 : lto_location_cache::input_location_and_block (location_t *dest,
600 : struct bitpack_d *bp,
601 : class lto_input_block *ib,
602 : class data_in *data_in)
603 : {
604 4969041 : gcc_checking_assert (decl_data);
605 :
606 4969041 : location_t loc;
607 4969041 : unsigned this_discr;
608 4969041 : const bool is_reserved = bp_unpack_value (bp, 1);
609 4969041 : if (is_reserved)
610 : {
611 2045543 : loc = bp_unpack_int_in_range (bp, "loc", 0, RESERVED_LOCATION_COUNT - 1);
612 2045543 : this_discr = 0;
613 : }
614 : else
615 : {
616 2923498 : const bool linemap_change = bp_unpack_value (bp, 1);
617 2923498 : if (linemap_change)
618 : {
619 107459 : const unsigned linemap_id = bp_unpack_var_len_unsigned (bp);
620 107459 : cur_loc_map = get_loc_map (decl_data, linemap_id + linemap_offset);
621 : }
622 2923498 : const auto prev_idx = stream_map_idx;
623 2923498 : bp_unpack_delta (bp, stream_map_idx);
624 2923498 : bp_unpack_delta (bp, stream_loc_offset);
625 2923498 : if (stream_map_idx != prev_idx)
626 : /* The hash code is only there for the benefit of -flto-incremental;
627 : we don't need to do anything with it here. */
628 183033 : bp_unpack_var_len_unsigned (bp);
629 :
630 2923498 : loc = get_location_from_idx (stream_map_idx, stream_loc_offset,
631 : cur_loc_map);
632 2923498 : if (bp_unpack_value (bp, 1))
633 1111262 : stream_discr = bp_unpack_var_len_unsigned (bp);
634 2923498 : this_discr = stream_discr;
635 : }
636 :
637 4969041 : tree this_block = NULL_TREE;
638 4969041 : if (ib)
639 : {
640 2452704 : if (bp_unpack_value (bp, 1))
641 594322 : stream_block = stream_read_tree (ib, data_in);
642 2452704 : this_block = stream_block;
643 : }
644 :
645 : /* If this location can be ordinary rather than ad-hoc, then there is no more
646 : overhead associated with it, so we may as well finalize it now. */
647 4969041 : if (!(this_discr || this_block))
648 : {
649 3242999 : *dest = loc;
650 3265721 : return;
651 : }
652 :
653 : /* This optimization saves location cache operations during gimple
654 : streaming. */
655 1726042 : if (loc == current_cloc.loc
656 190015 : && this_block == current_cloc.block
657 107381 : && this_discr == current_cloc.discr)
658 : {
659 22722 : *dest = current_loc;
660 22722 : return;
661 : }
662 :
663 : /* Keep value RESERVED_LOCATION_COUNT in *dest so linemap lookups will ICE on
664 : it if we erroneously try to use the location before it is ready. */
665 1703320 : *dest = RESERVED_LOCATION_COUNT;
666 :
667 : /* This location needs to be ad-hoc; remember the details for now and create
668 : the ad-hoc location later once we know we need it. */
669 1703320 : cached_location entry = {};
670 1703320 : entry.dest = dest;
671 1703320 : entry.loc = loc;
672 1703320 : entry.block = this_block;
673 1703320 : entry.discr = this_discr;
674 1703320 : loc_cache.safe_push (entry);
675 : }
676 :
677 : void
678 2516337 : lto_location_cache::input_location (location_t *dest, struct bitpack_d *bp,
679 : class data_in *data_in)
680 : {
681 2516337 : return input_location_and_block (dest, bp, NULL, data_in);
682 : }
683 :
684 : void
685 2516337 : lto_input_location (location_t *loc, struct bitpack_d *bp,
686 : class data_in *data_in)
687 : {
688 2516337 : data_in->location_cache.input_location (loc, bp, data_in);
689 2516337 : }
690 :
691 : /* Read a reference to a tree node from DATA_IN using input block IB.
692 : TAG is the expected node that should be found in IB, if TAG belongs
693 : to one of the indexable trees, expect to read a reference index to
694 : be looked up in one of the symbol tables, otherwise read the physical
695 : representation of the tree using stream_read_tree. FN is the
696 : function scope for the read tree. */
697 :
698 : tree
699 4048211 : lto_input_tree_ref (class lto_input_block *ib, class data_in *data_in,
700 : struct function *fn, enum LTO_tags tag)
701 : {
702 4048211 : unsigned HOST_WIDE_INT ix_u;
703 4048211 : tree result = NULL_TREE;
704 :
705 4048211 : if (tag == LTO_ssa_name_ref)
706 : {
707 1614888 : ix_u = streamer_read_uhwi (ib);
708 1614888 : result = (*SSANAMES (fn))[ix_u];
709 : }
710 : else
711 : {
712 2433323 : gcc_checking_assert (tag == LTO_global_stream_ref);
713 2433323 : ix_u = streamer_read_uhwi (ib);
714 2433323 : result = (*data_in->file_data->current_decl_state
715 2433323 : ->streams[LTO_DECL_STREAM])[ix_u];
716 : }
717 :
718 4048211 : gcc_assert (result);
719 :
720 4048211 : return result;
721 : }
722 :
723 : /* Read VAR_DECL reference to DATA from IB. */
724 :
725 : tree
726 74481 : lto_input_var_decl_ref (lto_input_block *ib, lto_file_decl_data *file_data)
727 : {
728 74481 : unsigned int ix_u = streamer_read_uhwi (ib);
729 74481 : tree result = (*file_data->current_decl_state
730 74481 : ->streams[LTO_DECL_STREAM])[ix_u];
731 74481 : gcc_assert (VAR_P (result));
732 74481 : return result;
733 : }
734 :
735 : /* Read VAR_DECL reference to DATA from IB. */
736 :
737 : tree
738 196702 : lto_input_fn_decl_ref (lto_input_block *ib, lto_file_decl_data *file_data)
739 : {
740 196702 : unsigned int ix_u = streamer_read_uhwi (ib);
741 196702 : tree result = (*file_data->current_decl_state
742 196702 : ->streams[LTO_DECL_STREAM])[ix_u];
743 196702 : gcc_assert (TREE_CODE (result) == FUNCTION_DECL);
744 196702 : return result;
745 : }
746 :
747 :
748 : /* Read and return a double-linked list of catch handlers from input
749 : block IB, using descriptors in DATA_IN. */
750 :
751 : static struct eh_catch_d *
752 213 : lto_input_eh_catch_list (class lto_input_block *ib, class data_in *data_in,
753 : eh_catch *last_p)
754 : {
755 213 : eh_catch first;
756 213 : enum LTO_tags tag;
757 :
758 213 : *last_p = first = NULL;
759 213 : tag = streamer_read_record_start (ib);
760 454 : while (tag)
761 : {
762 241 : tree list;
763 241 : eh_catch n;
764 :
765 241 : lto_tag_check_range (tag, LTO_eh_catch, LTO_eh_catch);
766 :
767 : /* Read the catch node. */
768 241 : n = ggc_cleared_alloc<eh_catch_d> ();
769 241 : n->type_list = stream_read_tree (ib, data_in);
770 241 : n->filter_list = stream_read_tree (ib, data_in);
771 241 : n->label = stream_read_tree (ib, data_in);
772 :
773 : /* Register all the types in N->FILTER_LIST. */
774 241 : for (list = n->filter_list; list; list = TREE_CHAIN (list))
775 0 : add_type_for_runtime (TREE_VALUE (list));
776 :
777 : /* Chain N to the end of the list. */
778 241 : if (*last_p)
779 44 : (*last_p)->next_catch = n;
780 241 : n->prev_catch = *last_p;
781 241 : *last_p = n;
782 :
783 : /* Set the head of the list the first time through the loop. */
784 241 : if (first == NULL)
785 197 : first = n;
786 :
787 241 : tag = streamer_read_record_start (ib);
788 : }
789 :
790 213 : return first;
791 : }
792 :
793 :
794 : /* Read and return EH region IX from input block IB, using descriptors
795 : in DATA_IN. */
796 :
797 : static eh_region
798 15595 : input_eh_region (class lto_input_block *ib, class data_in *data_in, int ix)
799 : {
800 15595 : enum LTO_tags tag;
801 15595 : eh_region r;
802 :
803 : /* Read the region header. */
804 15595 : tag = streamer_read_record_start (ib);
805 15595 : if (tag == LTO_null)
806 : return NULL;
807 :
808 9532 : r = ggc_cleared_alloc<eh_region_d> ();
809 9532 : r->index = streamer_read_hwi (ib);
810 :
811 9532 : gcc_assert (r->index == ix);
812 :
813 : /* Read all the region pointers as region numbers. We'll fix up
814 : the pointers once the whole array has been read. */
815 9532 : r->outer = (eh_region) (intptr_t) streamer_read_hwi (ib);
816 9532 : r->inner = (eh_region) (intptr_t) streamer_read_hwi (ib);
817 9532 : r->next_peer = (eh_region) (intptr_t) streamer_read_hwi (ib);
818 :
819 9532 : switch (tag)
820 : {
821 3993 : case LTO_ert_cleanup:
822 3993 : r->type = ERT_CLEANUP;
823 3993 : break;
824 :
825 213 : case LTO_ert_try:
826 213 : {
827 213 : struct eh_catch_d *last_catch;
828 213 : r->type = ERT_TRY;
829 213 : r->u.eh_try.first_catch = lto_input_eh_catch_list (ib, data_in,
830 : &last_catch);
831 213 : r->u.eh_try.last_catch = last_catch;
832 213 : break;
833 : }
834 :
835 321 : case LTO_ert_allowed_exceptions:
836 321 : {
837 321 : tree l;
838 :
839 321 : r->type = ERT_ALLOWED_EXCEPTIONS;
840 321 : r->u.allowed.type_list = stream_read_tree (ib, data_in);
841 321 : r->u.allowed.label = stream_read_tree (ib, data_in);
842 321 : r->u.allowed.filter = streamer_read_uhwi (ib);
843 :
844 323 : for (l = r->u.allowed.type_list; l ; l = TREE_CHAIN (l))
845 2 : add_type_for_runtime (TREE_VALUE (l));
846 : }
847 : break;
848 :
849 5005 : case LTO_ert_must_not_throw:
850 5005 : {
851 5005 : r->type = ERT_MUST_NOT_THROW;
852 5005 : r->u.must_not_throw.failure_decl = stream_read_tree (ib, data_in);
853 5005 : bitpack_d bp = streamer_read_bitpack (ib);
854 5005 : stream_input_location (&r->u.must_not_throw.failure_loc,
855 : &bp, data_in);
856 : }
857 5005 : break;
858 :
859 0 : default:
860 0 : gcc_unreachable ();
861 : }
862 :
863 9532 : r->landing_pads = (eh_landing_pad) (intptr_t) streamer_read_hwi (ib);
864 :
865 9532 : return r;
866 : }
867 :
868 :
869 : /* Read and return EH landing pad IX from input block IB, using descriptors
870 : in DATA_IN. */
871 :
872 : static eh_landing_pad
873 6840 : input_eh_lp (class lto_input_block *ib, class data_in *data_in, int ix)
874 : {
875 6840 : enum LTO_tags tag;
876 6840 : eh_landing_pad lp;
877 :
878 : /* Read the landing pad header. */
879 6840 : tag = streamer_read_record_start (ib);
880 6840 : if (tag == LTO_null)
881 : return NULL;
882 :
883 2566 : lto_tag_check_range (tag, LTO_eh_landing_pad, LTO_eh_landing_pad);
884 :
885 2566 : lp = ggc_cleared_alloc<eh_landing_pad_d> ();
886 2566 : lp->index = streamer_read_hwi (ib);
887 2566 : gcc_assert (lp->index == ix);
888 2566 : lp->next_lp = (eh_landing_pad) (intptr_t) streamer_read_hwi (ib);
889 2566 : lp->region = (eh_region) (intptr_t) streamer_read_hwi (ib);
890 2566 : lp->post_landing_pad = stream_read_tree (ib, data_in);
891 :
892 2566 : return lp;
893 : }
894 :
895 :
896 : /* After reading the EH regions, pointers to peer and children regions
897 : are region numbers. This converts all these region numbers into
898 : real pointers into the rematerialized regions for FN. ROOT_REGION
899 : is the region number for the root EH region in FN. */
900 :
901 : static void
902 3686 : fixup_eh_region_pointers (struct function *fn, HOST_WIDE_INT root_region)
903 : {
904 3686 : unsigned i;
905 3686 : vec<eh_region, va_gc> *eh_array = fn->eh->region_array;
906 3686 : vec<eh_landing_pad, va_gc> *lp_array = fn->eh->lp_array;
907 3686 : eh_region r;
908 3686 : eh_landing_pad lp;
909 :
910 3686 : gcc_assert (eh_array && lp_array);
911 :
912 3686 : gcc_assert (root_region >= 0);
913 3686 : fn->eh->region_tree = (*eh_array)[root_region];
914 :
915 : #define FIXUP_EH_REGION(r) (r) = (*eh_array)[(HOST_WIDE_INT) (intptr_t) (r)]
916 : #define FIXUP_EH_LP(p) (p) = (*lp_array)[(HOST_WIDE_INT) (intptr_t) (p)]
917 :
918 : /* Convert all the index numbers stored in pointer fields into
919 : pointers to the corresponding slots in the EH region array. */
920 19281 : FOR_EACH_VEC_ELT (*eh_array, i, r)
921 : {
922 : /* The array may contain NULL regions. */
923 15595 : if (r == NULL)
924 6063 : continue;
925 :
926 9532 : gcc_assert (i == (unsigned) r->index);
927 9532 : FIXUP_EH_REGION (r->outer);
928 9532 : FIXUP_EH_REGION (r->inner);
929 9532 : FIXUP_EH_REGION (r->next_peer);
930 9532 : FIXUP_EH_LP (r->landing_pads);
931 : }
932 :
933 : /* Convert all the index numbers stored in pointer fields into
934 : pointers to the corresponding slots in the EH landing pad array. */
935 10526 : FOR_EACH_VEC_ELT (*lp_array, i, lp)
936 : {
937 : /* The array may contain NULL landing pads. */
938 6840 : if (lp == NULL)
939 4274 : continue;
940 :
941 2566 : gcc_assert (i == (unsigned) lp->index);
942 2566 : FIXUP_EH_LP (lp->next_lp);
943 2566 : FIXUP_EH_REGION (lp->region);
944 : }
945 :
946 : #undef FIXUP_EH_REGION
947 : #undef FIXUP_EH_LP
948 3686 : }
949 :
950 :
951 : /* Initialize EH support. */
952 :
953 : void
954 42854 : lto_init_eh (void)
955 : {
956 42854 : static bool eh_initialized_p = false;
957 :
958 42854 : if (eh_initialized_p)
959 : return;
960 :
961 : /* Contrary to most other FEs, we only initialize EH support when at
962 : least one of the files in the set contains exception regions in
963 : it. Since this happens much later than the call to init_eh in
964 : lang_dependent_init, we have to set flag_exceptions and call
965 : init_eh again to initialize the EH tables. */
966 3616 : flag_exceptions = 1;
967 3616 : init_eh ();
968 :
969 3616 : eh_initialized_p = true;
970 : }
971 :
972 :
973 : /* Read the exception table for FN from IB using the data descriptors
974 : in DATA_IN. */
975 :
976 : static void
977 84188 : input_eh_regions (class lto_input_block *ib, class data_in *data_in,
978 : struct function *fn)
979 : {
980 84188 : HOST_WIDE_INT i, root_region, len;
981 84188 : enum LTO_tags tag;
982 :
983 84188 : tag = streamer_read_record_start (ib);
984 84188 : if (tag == LTO_null)
985 : return;
986 :
987 3686 : lto_tag_check_range (tag, LTO_eh_table, LTO_eh_table);
988 :
989 3686 : gcc_assert (fn->eh);
990 :
991 3686 : root_region = streamer_read_hwi (ib);
992 3686 : gcc_assert (root_region == (int) root_region);
993 :
994 : /* Read the EH region array. */
995 3686 : len = streamer_read_hwi (ib);
996 3686 : gcc_assert (len == (int) len);
997 3686 : if (len > 0)
998 : {
999 3686 : vec_safe_grow_cleared (fn->eh->region_array, len, true);
1000 22967 : for (i = 0; i < len; i++)
1001 : {
1002 15595 : eh_region r = input_eh_region (ib, data_in, i);
1003 15595 : (*fn->eh->region_array)[i] = r;
1004 : }
1005 : }
1006 :
1007 : /* Read the landing pads. */
1008 3686 : len = streamer_read_hwi (ib);
1009 3686 : gcc_assert (len == (int) len);
1010 3686 : if (len > 0)
1011 : {
1012 3686 : vec_safe_grow_cleared (fn->eh->lp_array, len, true);
1013 14212 : for (i = 0; i < len; i++)
1014 : {
1015 6840 : eh_landing_pad lp = input_eh_lp (ib, data_in, i);
1016 6840 : (*fn->eh->lp_array)[i] = lp;
1017 : }
1018 : }
1019 :
1020 : /* Read the runtime type data. */
1021 3686 : len = streamer_read_hwi (ib);
1022 3686 : gcc_assert (len == (int) len);
1023 3686 : if (len > 0)
1024 : {
1025 0 : vec_safe_grow_cleared (fn->eh->ttype_data, len, true);
1026 0 : for (i = 0; i < len; i++)
1027 : {
1028 0 : tree ttype = stream_read_tree (ib, data_in);
1029 0 : (*fn->eh->ttype_data)[i] = ttype;
1030 : }
1031 : }
1032 :
1033 : /* Read the table of action chains. */
1034 3686 : len = streamer_read_hwi (ib);
1035 3686 : gcc_assert (len == (int) len);
1036 3686 : if (len > 0)
1037 : {
1038 0 : if (targetm.arm_eabi_unwinder)
1039 : {
1040 0 : vec_safe_grow_cleared (fn->eh->ehspec_data.arm_eabi, len, true);
1041 0 : for (i = 0; i < len; i++)
1042 : {
1043 0 : tree t = stream_read_tree (ib, data_in);
1044 0 : (*fn->eh->ehspec_data.arm_eabi)[i] = t;
1045 : }
1046 : }
1047 : else
1048 : {
1049 0 : vec_safe_grow_cleared (fn->eh->ehspec_data.other, len, true);
1050 0 : for (i = 0; i < len; i++)
1051 : {
1052 0 : uchar c = streamer_read_uchar (ib);
1053 0 : (*fn->eh->ehspec_data.other)[i] = c;
1054 : }
1055 : }
1056 : }
1057 :
1058 : /* Reconstruct the EH region tree by fixing up the peer/children
1059 : pointers. */
1060 3686 : fixup_eh_region_pointers (fn, root_region);
1061 :
1062 3686 : tag = streamer_read_record_start (ib);
1063 3686 : lto_tag_check_range (tag, LTO_null, LTO_null);
1064 : }
1065 :
1066 :
1067 : /* Make a new basic block with index INDEX in function FN. */
1068 :
1069 : static basic_block
1070 582380 : make_new_block (struct function *fn, unsigned int index)
1071 : {
1072 582380 : basic_block bb = alloc_block ();
1073 582380 : bb->index = index;
1074 582380 : SET_BASIC_BLOCK_FOR_FN (fn, index, bb);
1075 582380 : n_basic_blocks_for_fn (fn)++;
1076 582380 : return bb;
1077 : }
1078 :
1079 :
1080 : /* Read the CFG for function FN from input block IB. */
1081 :
1082 : static void
1083 84188 : input_cfg (class lto_input_block *ib, class data_in *data_in,
1084 : struct function *fn)
1085 : {
1086 84188 : unsigned int bb_count;
1087 84188 : basic_block p_bb;
1088 84188 : unsigned int i;
1089 84188 : int index;
1090 84188 : bool full_profile = false;
1091 :
1092 84188 : init_empty_tree_cfg_for_function (fn);
1093 :
1094 84188 : profile_status_for_fn (fn) = streamer_read_enum (ib, profile_status_d,
1095 : PROFILE_LAST);
1096 :
1097 84188 : bb_count = streamer_read_uhwi (ib);
1098 :
1099 84188 : last_basic_block_for_fn (fn) = bb_count;
1100 84188 : if (bb_count > basic_block_info_for_fn (fn)->length ())
1101 2202 : vec_safe_grow_cleared (basic_block_info_for_fn (fn), bb_count, true);
1102 :
1103 84188 : if (bb_count > label_to_block_map_for_fn (fn)->length ())
1104 2202 : vec_safe_grow_cleared (label_to_block_map_for_fn (fn), bb_count, true);
1105 :
1106 84188 : index = streamer_read_hwi (ib);
1107 834944 : while (index != -1)
1108 : {
1109 750756 : basic_block bb = BASIC_BLOCK_FOR_FN (fn, index);
1110 750756 : unsigned int edge_count;
1111 :
1112 750756 : if (bb == NULL)
1113 33693 : bb = make_new_block (fn, index);
1114 :
1115 750756 : edge_count = streamer_read_uhwi (ib);
1116 :
1117 : /* Connect up the CFG. */
1118 1613046 : for (i = 0; i < edge_count; i++)
1119 : {
1120 862290 : bitpack_d bp = streamer_read_bitpack (ib);
1121 862290 : unsigned int dest_index = bp_unpack_var_len_unsigned (&bp);
1122 862290 : unsigned int edge_flags = bp_unpack_var_len_unsigned (&bp);
1123 862290 : basic_block dest = BASIC_BLOCK_FOR_FN (fn, dest_index);
1124 :
1125 862290 : if (dest == NULL)
1126 548687 : dest = make_new_block (fn, dest_index);
1127 :
1128 862290 : edge e = make_edge (bb, dest, edge_flags);
1129 862290 : data_in->location_cache.input_location_and_block (&e->goto_locus,
1130 : &bp, ib, data_in);
1131 862290 : e->probability = profile_probability::stream_in (ib);
1132 862290 : if (!e->probability.initialized_p ())
1133 862290 : full_profile = false;
1134 :
1135 : }
1136 :
1137 750756 : index = streamer_read_hwi (ib);
1138 : }
1139 :
1140 84188 : p_bb = ENTRY_BLOCK_PTR_FOR_FN (fn);
1141 84188 : index = streamer_read_hwi (ib);
1142 750756 : while (index != -1)
1143 : {
1144 666568 : basic_block bb = BASIC_BLOCK_FOR_FN (fn, index);
1145 666568 : bb->prev_bb = p_bb;
1146 666568 : p_bb->next_bb = bb;
1147 666568 : p_bb = bb;
1148 666568 : index = streamer_read_hwi (ib);
1149 : }
1150 :
1151 : /* ??? The cfgloop interface is tied to cfun. */
1152 84188 : gcc_assert (cfun == fn);
1153 :
1154 : /* Input the loop tree. */
1155 84188 : unsigned n_loops = streamer_read_uhwi (ib);
1156 84188 : if (n_loops == 0)
1157 : return;
1158 :
1159 84188 : struct loops *loops = ggc_cleared_alloc<struct loops> ();
1160 84188 : init_loops_structure (fn, loops, n_loops);
1161 84188 : set_loops_for_fn (fn, loops);
1162 :
1163 : /* Input each loop and associate it with its loop header so
1164 : flow_loops_find can rebuild the loop tree. */
1165 227441 : for (unsigned i = 1; i < n_loops; ++i)
1166 : {
1167 59065 : int header_index = streamer_read_hwi (ib);
1168 59065 : if (header_index == -1)
1169 : {
1170 21452 : loops->larray->quick_push (NULL);
1171 21452 : continue;
1172 : }
1173 :
1174 37613 : class loop *loop = alloc_loop ();
1175 37613 : loop->header = BASIC_BLOCK_FOR_FN (fn, header_index);
1176 37613 : loop->header->loop_father = loop;
1177 :
1178 : /* Read everything copy_loop_info copies. */
1179 37613 : loop->estimate_state = streamer_read_enum (ib, loop_estimation, EST_LAST);
1180 37613 : loop->any_upper_bound = streamer_read_hwi (ib);
1181 37613 : if (loop->any_upper_bound)
1182 32672 : loop->nb_iterations_upper_bound
1183 32672 : = bound_wide_int::from (streamer_read_widest_int (ib), SIGNED);
1184 37613 : loop->any_likely_upper_bound = streamer_read_hwi (ib);
1185 37613 : if (loop->any_likely_upper_bound)
1186 32672 : loop->nb_iterations_likely_upper_bound
1187 32672 : = bound_wide_int::from (streamer_read_widest_int (ib), SIGNED);
1188 37613 : loop->any_estimate = streamer_read_hwi (ib);
1189 37613 : if (loop->any_estimate)
1190 27300 : loop->nb_iterations_estimate
1191 27300 : = bound_wide_int::from (streamer_read_widest_int (ib), SIGNED);
1192 :
1193 : /* Read OMP SIMD related info. */
1194 37613 : loop->safelen = streamer_read_hwi (ib);
1195 37613 : loop->unroll = streamer_read_hwi (ib);
1196 37613 : loop->owned_clique = streamer_read_hwi (ib);
1197 37613 : loop->dont_vectorize = streamer_read_hwi (ib);
1198 37613 : loop->force_vectorize = streamer_read_hwi (ib);
1199 37613 : loop->finite_p = streamer_read_hwi (ib);
1200 37613 : loop->can_be_parallel = streamer_read_hwi (ib);
1201 37613 : loop->simduid = stream_read_tree (ib, data_in);
1202 :
1203 37613 : place_new_loop (fn, loop);
1204 :
1205 : /* flow_loops_find doesn't like loops not in the tree, hook them
1206 : all as siblings of the tree root temporarily. */
1207 37613 : flow_loop_tree_node_add (loops->tree_root, loop);
1208 : }
1209 :
1210 : /* Rebuild the loop tree. */
1211 84188 : flow_loops_find (loops);
1212 84188 : cfun->cfg->full_profile = full_profile;
1213 : }
1214 :
1215 :
1216 : /* Read the SSA names array for function FN from DATA_IN using input
1217 : block IB. */
1218 :
1219 : static void
1220 84188 : input_ssa_names (class lto_input_block *ib, class data_in *data_in,
1221 : struct function *fn)
1222 : {
1223 84188 : unsigned int i, size;
1224 :
1225 84188 : size = streamer_read_uhwi (ib);
1226 84188 : init_tree_ssa (fn, size);
1227 84188 : cfun->gimple_df->in_ssa_p = true;
1228 84188 : init_ssa_operands (fn);
1229 :
1230 84188 : i = streamer_read_uhwi (ib);
1231 912047 : while (i)
1232 : {
1233 : tree ssa_name, name;
1234 : bool is_default_def;
1235 :
1236 : /* Skip over the elements that had been freed. */
1237 1092972 : while (SSANAMES (fn)->length () < i)
1238 265113 : SSANAMES (fn)->quick_push (NULL_TREE);
1239 :
1240 827859 : is_default_def = (streamer_read_uchar (ib) != 0);
1241 827859 : name = stream_read_tree (ib, data_in);
1242 827859 : ssa_name = make_ssa_name_fn (fn, name, NULL);
1243 :
1244 827859 : if (is_default_def)
1245 : {
1246 84670 : set_ssa_default_def (cfun, SSA_NAME_VAR (ssa_name), ssa_name);
1247 84670 : SSA_NAME_DEF_STMT (ssa_name) = gimple_build_nop ();
1248 : }
1249 :
1250 827859 : i = streamer_read_uhwi (ib);
1251 : }
1252 84188 : }
1253 :
1254 :
1255 : /* Go through all NODE edges and fixup call_stmt pointers
1256 : so they point to STMTS. */
1257 :
1258 : static void
1259 110322 : fixup_call_stmt_edges_1 (struct cgraph_node *node, gimple **stmts,
1260 : struct function *fn)
1261 : {
1262 : #define STMT_UID_NOT_IN_RANGE(uid) \
1263 : (gimple_stmt_max_uid (fn) < uid || uid == 0)
1264 :
1265 110322 : struct cgraph_edge *cedge;
1266 110322 : struct ipa_ref *ref = NULL;
1267 110322 : unsigned int i;
1268 :
1269 480073 : for (cedge = node->callees; cedge; cedge = cedge->next_callee)
1270 : {
1271 369751 : if (STMT_UID_NOT_IN_RANGE (cedge->lto_stmt_uid))
1272 0 : fatal_error (input_location,
1273 : "Cgraph edge statement index out of range");
1274 369751 : cedge->call_stmt = as_a <gcall *> (stmts[cedge->lto_stmt_uid - 1]);
1275 369751 : cedge->lto_stmt_uid = 0;
1276 369751 : if (!cedge->call_stmt)
1277 : fatal_error (input_location,
1278 : "Cgraph edge statement index not found");
1279 : }
1280 112034 : for (cedge = node->indirect_calls; cedge; cedge = cedge->next_callee)
1281 : {
1282 1712 : if (STMT_UID_NOT_IN_RANGE (cedge->lto_stmt_uid))
1283 0 : fatal_error (input_location,
1284 : "Cgraph edge statement index out of range");
1285 1712 : cedge->call_stmt = as_a <gcall *> (stmts[cedge->lto_stmt_uid - 1]);
1286 1712 : cedge->lto_stmt_uid = 0;
1287 1712 : if (!cedge->call_stmt)
1288 : fatal_error (input_location, "Cgraph edge statement index not found");
1289 : }
1290 352061 : for (i = 0; node->iterate_reference (i, ref); i++)
1291 241739 : if (ref->lto_stmt_uid)
1292 : {
1293 236348 : if (STMT_UID_NOT_IN_RANGE (ref->lto_stmt_uid))
1294 0 : fatal_error (input_location,
1295 : "Reference statement index out of range");
1296 236348 : ref->stmt = stmts[ref->lto_stmt_uid - 1];
1297 236348 : ref->lto_stmt_uid = 0;
1298 236348 : if (!ref->stmt)
1299 0 : fatal_error (input_location, "Reference statement index not found");
1300 : }
1301 110322 : }
1302 :
1303 :
1304 : /* Fixup call_stmt pointers in NODE and all clones. */
1305 :
1306 : static void
1307 84188 : fixup_call_stmt_edges (struct cgraph_node *orig, gimple **stmts)
1308 : {
1309 84188 : struct cgraph_node *node;
1310 84188 : struct function *fn;
1311 :
1312 84391 : while (orig->clone_of)
1313 : orig = orig->clone_of;
1314 84188 : fn = DECL_STRUCT_FUNCTION (orig->decl);
1315 :
1316 84188 : if (!orig->thunk)
1317 84188 : fixup_call_stmt_edges_1 (orig, stmts, fn);
1318 84188 : if (orig->clones)
1319 31004 : for (node = orig->clones; node != orig;)
1320 : {
1321 26136 : if (!node->thunk)
1322 26134 : fixup_call_stmt_edges_1 (node, stmts, fn);
1323 26136 : if (node->clones)
1324 : node = node->clones;
1325 23635 : else if (node->next_sibling_clone)
1326 : node = node->next_sibling_clone;
1327 : else
1328 : {
1329 12893 : while (node != orig && !node->next_sibling_clone)
1330 7369 : node = node->clone_of;
1331 5524 : if (node != orig)
1332 656 : node = node->next_sibling_clone;
1333 : }
1334 : }
1335 84188 : }
1336 :
1337 :
1338 : /* Input the base body of struct function FN from DATA_IN
1339 : using input block IB. */
1340 :
1341 : static void
1342 84188 : input_struct_function_base (struct function *fn, class data_in *data_in,
1343 : class lto_input_block *ib)
1344 : {
1345 84188 : struct bitpack_d bp;
1346 84188 : int len;
1347 :
1348 : /* Read the static chain and non-local goto save area. */
1349 84188 : fn->static_chain_decl = stream_read_tree (ib, data_in);
1350 84188 : fn->nonlocal_goto_save_area = stream_read_tree (ib, data_in);
1351 :
1352 : /* Read all the local symbols. */
1353 84188 : len = streamer_read_hwi (ib);
1354 84188 : if (len > 0)
1355 : {
1356 22235 : int i;
1357 22235 : vec_safe_grow_cleared (fn->local_decls, len, true);
1358 182590 : for (i = 0; i < len; i++)
1359 : {
1360 138120 : tree t = stream_read_tree (ib, data_in);
1361 138120 : (*fn->local_decls)[i] = t;
1362 : }
1363 : }
1364 :
1365 : /* Input the current IL state of the function. */
1366 84188 : fn->curr_properties = streamer_read_uhwi (ib);
1367 :
1368 : /* Read all the attributes for FN. */
1369 84188 : bp = streamer_read_bitpack (ib);
1370 84188 : fn->is_thunk = bp_unpack_value (&bp, 1);
1371 84188 : fn->has_local_explicit_reg_vars = bp_unpack_value (&bp, 1);
1372 84188 : fn->returns_pcc_struct = bp_unpack_value (&bp, 1);
1373 84188 : fn->returns_struct = bp_unpack_value (&bp, 1);
1374 84188 : fn->can_throw_non_call_exceptions = bp_unpack_value (&bp, 1);
1375 84188 : fn->can_delete_dead_exceptions = bp_unpack_value (&bp, 1);
1376 84188 : fn->always_inline_functions_inlined = bp_unpack_value (&bp, 1);
1377 84188 : fn->after_inlining = bp_unpack_value (&bp, 1);
1378 84188 : fn->stdarg = bp_unpack_value (&bp, 1);
1379 84188 : fn->has_nonlocal_label = bp_unpack_value (&bp, 1);
1380 84188 : fn->has_forced_label_in_static = bp_unpack_value (&bp, 1);
1381 84188 : fn->calls_alloca = bp_unpack_value (&bp, 1);
1382 84188 : fn->calls_setjmp = bp_unpack_value (&bp, 1);
1383 84188 : fn->calls_eh_return = bp_unpack_value (&bp, 1);
1384 84188 : fn->has_force_vectorize_loops = bp_unpack_value (&bp, 1);
1385 84188 : fn->has_simduid_loops = bp_unpack_value (&bp, 1);
1386 84188 : fn->has_musttail = bp_unpack_value (&bp, 1);
1387 84188 : fn->has_unroll = bp_unpack_value (&bp, 1);
1388 84188 : fn->assume_function = bp_unpack_value (&bp, 1);
1389 84188 : fn->va_list_fpr_size = bp_unpack_value (&bp, 8);
1390 84188 : fn->va_list_gpr_size = bp_unpack_value (&bp, 8);
1391 84188 : fn->last_clique = bp_unpack_value (&bp, sizeof (short) * 8);
1392 :
1393 : /* Input the function start and end loci. */
1394 84188 : stream_input_location (&fn->function_start_locus, &bp, data_in);
1395 84188 : stream_input_location (&fn->function_end_locus, &bp, data_in);
1396 :
1397 : /* Restore the instance discriminators if present. */
1398 84188 : int instance_number = bp_unpack_value (&bp, 1);
1399 84188 : if (instance_number)
1400 : {
1401 0 : instance_number = bp_unpack_value (&bp, sizeof (int) * CHAR_BIT);
1402 0 : maybe_create_decl_to_instance_map ()->put (fn->decl, instance_number);
1403 : }
1404 84188 : }
1405 :
1406 : /* Read a chain of tree nodes from input block IB. DATA_IN contains
1407 : tables and descriptors for the file being read. */
1408 :
1409 : static tree
1410 84255 : streamer_read_chain (class lto_input_block *ib, class data_in *data_in)
1411 : {
1412 84255 : tree first, prev, curr;
1413 :
1414 : /* The chain is written as NULL terminated list of trees. */
1415 84255 : first = prev = NULL_TREE;
1416 173496 : do
1417 : {
1418 173496 : curr = stream_read_tree (ib, data_in);
1419 173496 : if (prev)
1420 89241 : TREE_CHAIN (prev) = curr;
1421 : else
1422 : first = curr;
1423 :
1424 173496 : prev = curr;
1425 : }
1426 173496 : while (curr);
1427 :
1428 84255 : return first;
1429 : }
1430 :
1431 : /* Read the body of function FN_DECL from DATA_IN using input block IB. */
1432 :
1433 : static void
1434 84255 : input_function (tree fn_decl, class data_in *data_in,
1435 : class lto_input_block *ib, class lto_input_block *ib_cfg,
1436 : cgraph_node *node)
1437 : {
1438 84255 : struct function *fn;
1439 84255 : enum LTO_tags tag;
1440 84255 : gimple **stmts;
1441 84255 : basic_block bb;
1442 :
1443 84255 : tag = streamer_read_record_start (ib);
1444 84255 : lto_tag_check (tag, LTO_function);
1445 :
1446 : /* Read decls for parameters and args. */
1447 84255 : DECL_RESULT (fn_decl) = stream_read_tree (ib, data_in);
1448 84255 : DECL_ARGUMENTS (fn_decl) = streamer_read_chain (ib, data_in);
1449 :
1450 : /* Read debug args if available. */
1451 84255 : unsigned n_debugargs = streamer_read_uhwi (ib);
1452 84255 : if (n_debugargs)
1453 : {
1454 23 : vec<tree, va_gc> **debugargs = decl_debug_args_insert (fn_decl);
1455 23 : vec_safe_grow (*debugargs, n_debugargs, true);
1456 108 : for (unsigned i = 0; i < n_debugargs; ++i)
1457 62 : (**debugargs)[i] = stream_read_tree (ib, data_in);
1458 : }
1459 :
1460 : /* Read the tree of lexical scopes for the function. */
1461 84255 : DECL_INITIAL (fn_decl) = stream_read_tree (ib, data_in);
1462 84255 : unsigned block_leaf_count = streamer_read_uhwi (ib);
1463 146022 : while (block_leaf_count--)
1464 61767 : stream_read_tree (ib, data_in);
1465 :
1466 84255 : if (!streamer_read_uhwi (ib))
1467 : return;
1468 :
1469 84188 : push_struct_function (fn_decl);
1470 84188 : fn = DECL_STRUCT_FUNCTION (fn_decl);
1471 :
1472 84188 : gimple_register_cfg_hooks ();
1473 :
1474 84188 : input_struct_function_base (fn, data_in, ib);
1475 84188 : input_cfg (ib_cfg, data_in, fn);
1476 :
1477 : /* Read all the SSA names. */
1478 84188 : input_ssa_names (ib, data_in, fn);
1479 :
1480 : /* Read the exception handling regions in the function. */
1481 84188 : input_eh_regions (ib, data_in, fn);
1482 :
1483 84188 : gcc_assert (DECL_INITIAL (fn_decl));
1484 84188 : DECL_SAVED_TREE (fn_decl) = NULL_TREE;
1485 :
1486 : /* Read all the basic blocks. */
1487 84188 : tag = streamer_read_record_start (ib);
1488 834944 : while (tag)
1489 : {
1490 750756 : input_bb (ib, tag, data_in, fn,
1491 : node->count_materialization_scale);
1492 750756 : tag = streamer_read_record_start (ib);
1493 : }
1494 :
1495 : /* Finalize gimple_location/gimple_block of stmts and phis. */
1496 84188 : data_in->location_cache.apply_location_cache ();
1497 :
1498 : /* Fix up the call statements that are mentioned in the callgraph
1499 : edges. */
1500 84188 : set_gimple_stmt_max_uid (cfun, 0);
1501 834944 : FOR_ALL_BB_FN (bb, cfun)
1502 : {
1503 750756 : gimple_stmt_iterator gsi;
1504 820944 : for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
1505 : {
1506 70188 : gimple *stmt = gsi_stmt (gsi);
1507 70188 : gimple_set_uid (stmt, inc_gimple_stmt_max_uid (cfun));
1508 : }
1509 2910490 : for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
1510 : {
1511 1408978 : gimple *stmt = gsi_stmt (gsi);
1512 1408978 : gimple_set_uid (stmt, inc_gimple_stmt_max_uid (cfun));
1513 : }
1514 : }
1515 84188 : stmts = (gimple **) xcalloc (gimple_stmt_max_uid (fn), sizeof (gimple *));
1516 834944 : FOR_ALL_BB_FN (bb, cfun)
1517 : {
1518 750756 : gimple_stmt_iterator bsi = gsi_start_phis (bb);
1519 820944 : while (!gsi_end_p (bsi))
1520 : {
1521 70188 : gimple *stmt = gsi_stmt (bsi);
1522 70188 : gsi_next (&bsi);
1523 70188 : stmts[gimple_uid (stmt)] = stmt;
1524 : }
1525 750756 : bsi = gsi_start_bb (bb);
1526 2159734 : while (!gsi_end_p (bsi))
1527 : {
1528 1408978 : gimple *stmt = gsi_stmt (bsi);
1529 1408978 : bool remove = false;
1530 : /* If we're recompiling LTO objects with debug stmts but
1531 : we're not supposed to have debug stmts, remove them now.
1532 : We can't remove them earlier because this would cause uid
1533 : mismatches in fixups, but we can do it at this point, as
1534 : long as debug stmts don't require fixups.
1535 : Similarly remove all IFN_*SAN_* internal calls */
1536 1408978 : if (!flag_wpa)
1537 : {
1538 1317153 : if (is_gimple_debug (stmt)
1539 1317153 : && (gimple_debug_nonbind_marker_p (stmt)
1540 8140 : ? !MAY_HAVE_DEBUG_MARKER_STMTS
1541 6029 : : !MAY_HAVE_DEBUG_BIND_STMTS))
1542 : remove = true;
1543 : /* In case the linemap overflows locations can be dropped
1544 : to zero. Thus do not keep nonsensical inline entry markers
1545 : we'd later ICE on. */
1546 1317153 : tree block;
1547 1317153 : if (gimple_debug_inline_entry_p (stmt)
1548 14169 : && (((block = gimple_block (stmt))
1549 991 : && !inlined_function_outer_scope_p (block))
1550 991 : || !debug_inline_points))
1551 : remove = true;
1552 1317153 : if (is_gimple_call (stmt)
1553 1317153 : && gimple_call_internal_p (stmt))
1554 : {
1555 21457 : bool replace = false;
1556 21457 : switch (gimple_call_internal_fn (stmt))
1557 : {
1558 252 : case IFN_UBSAN_NULL:
1559 252 : if ((flag_sanitize
1560 252 : & (SANITIZE_NULL | SANITIZE_ALIGNMENT)) == 0)
1561 : replace = true;
1562 : break;
1563 235 : case IFN_UBSAN_BOUNDS:
1564 235 : if ((flag_sanitize & SANITIZE_BOUNDS) == 0)
1565 : replace = true;
1566 : break;
1567 0 : case IFN_UBSAN_VPTR:
1568 0 : if ((flag_sanitize & SANITIZE_VPTR) == 0)
1569 : replace = true;
1570 : break;
1571 178 : case IFN_UBSAN_OBJECT_SIZE:
1572 178 : if ((flag_sanitize & SANITIZE_OBJECT_SIZE) == 0)
1573 : replace = true;
1574 : break;
1575 166 : case IFN_UBSAN_PTR:
1576 166 : if ((flag_sanitize & SANITIZE_POINTER_OVERFLOW) == 0)
1577 : replace = true;
1578 : break;
1579 934 : case IFN_ASAN_MARK:
1580 934 : if ((flag_sanitize & SANITIZE_ADDRESS) == 0)
1581 : replace = true;
1582 : break;
1583 0 : case IFN_TSAN_FUNC_EXIT:
1584 0 : if ((flag_sanitize & SANITIZE_THREAD) == 0)
1585 : replace = true;
1586 : break;
1587 : default:
1588 : break;
1589 : }
1590 : if (replace)
1591 : {
1592 2 : gimple_call_set_internal_fn (as_a <gcall *> (stmt),
1593 : IFN_NOP);
1594 2 : update_stmt (stmt);
1595 : }
1596 : }
1597 : }
1598 1317153 : if (remove)
1599 : {
1600 4 : gimple_stmt_iterator gsi = bsi;
1601 4 : gsi_next (&bsi);
1602 4 : unlink_stmt_vdef (stmt);
1603 4 : release_defs (stmt);
1604 4 : gsi_remove (&gsi, true);
1605 : }
1606 : else
1607 : {
1608 1408974 : gsi_next (&bsi);
1609 1408974 : stmts[gimple_uid (stmt)] = stmt;
1610 :
1611 : /* Remember that the input function has begin stmt
1612 : markers, so that we know to expect them when emitting
1613 : debug info. */
1614 1408974 : if (!cfun->debug_nonbind_markers
1615 2794658 : && gimple_debug_nonbind_marker_p (stmt))
1616 1367 : cfun->debug_nonbind_markers = true;
1617 : }
1618 : }
1619 : }
1620 :
1621 : /* Set the gimple body to the statement sequence in the entry
1622 : basic block. FIXME lto, this is fairly hacky. The existence
1623 : of a gimple body is used by the cgraph routines, but we should
1624 : really use the presence of the CFG. */
1625 84188 : {
1626 84188 : edge_iterator ei = ei_start (ENTRY_BLOCK_PTR_FOR_FN (cfun)->succs);
1627 168376 : gimple_set_body (fn_decl, bb_seq (ei_edge (ei)->dest));
1628 : }
1629 :
1630 84188 : update_max_bb_count ();
1631 84188 : fixup_call_stmt_edges (node, stmts);
1632 84188 : execute_all_ipa_stmt_fixups (node, stmts);
1633 :
1634 84188 : free_dominance_info (CDI_DOMINATORS);
1635 84188 : free_dominance_info (CDI_POST_DOMINATORS);
1636 84188 : free (stmts);
1637 84188 : pop_cfun ();
1638 : }
1639 :
1640 : /* Read the body of function FN_DECL from DATA_IN using input block IB. */
1641 :
1642 : static void
1643 7728 : input_constructor (tree var, class data_in *data_in,
1644 : class lto_input_block *ib)
1645 : {
1646 7728 : DECL_INITIAL (var) = stream_read_tree (ib, data_in);
1647 7728 : }
1648 :
1649 :
1650 : /* Read the body from DATA for function NODE and fill it in.
1651 : FILE_DATA are the global decls and types. SECTION_TYPE is either
1652 : LTO_section_function_body or LTO_section_static_initializer. If
1653 : section type is LTO_section_function_body, FN must be the decl for
1654 : that function. */
1655 :
1656 : static void
1657 91983 : lto_read_body_or_constructor (struct lto_file_decl_data *file_data, struct symtab_node *node,
1658 : const char *data, enum lto_section_type section_type)
1659 : {
1660 91983 : const struct lto_function_header *header;
1661 91983 : class data_in *data_in;
1662 91983 : int cfg_offset;
1663 91983 : int main_offset;
1664 91983 : int string_offset;
1665 91983 : tree fn_decl = node->decl;
1666 :
1667 91983 : header = (const struct lto_function_header *) data;
1668 91983 : if (TREE_CODE (node->decl) == FUNCTION_DECL)
1669 : {
1670 84255 : cfg_offset = sizeof (struct lto_function_header);
1671 84255 : main_offset = cfg_offset + header->cfg_size;
1672 84255 : string_offset = main_offset + header->main_size;
1673 : }
1674 : else
1675 : {
1676 7728 : main_offset = sizeof (struct lto_function_header);
1677 7728 : string_offset = main_offset + header->main_size;
1678 : }
1679 :
1680 91983 : data_in = lto_data_in_create (file_data, data + string_offset,
1681 91983 : header->string_size, vNULL);
1682 :
1683 91983 : if (section_type == LTO_section_function_body)
1684 : {
1685 91983 : struct lto_in_decl_state *decl_state;
1686 91983 : unsigned from;
1687 :
1688 91983 : gcc_checking_assert (node);
1689 :
1690 : /* Use the function's decl state. */
1691 91983 : decl_state = lto_get_function_in_decl_state (file_data, fn_decl);
1692 91983 : gcc_assert (decl_state);
1693 91983 : file_data->current_decl_state = decl_state;
1694 91983 : data_in->location_cache.set_linemap_offset (decl_state->linemap_id);
1695 :
1696 : /* Set up the struct function. */
1697 91983 : from = data_in->reader_cache->nodes.length ();
1698 91983 : lto_input_block ib_main (data + main_offset, header->main_size,
1699 91983 : file_data);
1700 91983 : if (TREE_CODE (node->decl) == FUNCTION_DECL)
1701 : {
1702 84255 : lto_input_block ib_cfg (data + cfg_offset, header->cfg_size,
1703 84255 : file_data);
1704 84255 : input_function (fn_decl, data_in, &ib_main, &ib_cfg,
1705 : dyn_cast <cgraph_node *>(node));
1706 : }
1707 : else
1708 7728 : input_constructor (fn_decl, data_in, &ib_main);
1709 91983 : data_in->location_cache.apply_location_cache ();
1710 : /* And fixup types we streamed locally. */
1711 91983 : {
1712 91983 : struct streamer_tree_cache_d *cache = data_in->reader_cache;
1713 91983 : unsigned len = cache->nodes.length ();
1714 91983 : unsigned i;
1715 2892864 : for (i = len; i-- > from;)
1716 : {
1717 2800881 : tree t = streamer_tree_cache_get_tree (cache, i);
1718 2800881 : if (t == NULL_TREE)
1719 0 : continue;
1720 :
1721 2800881 : if (TYPE_P (t))
1722 : {
1723 1664 : gcc_assert (TYPE_STRUCTURAL_EQUALITY_P (t));
1724 1664 : if (type_with_alias_set_p (t)
1725 1664 : && canonical_type_used_p (t))
1726 552 : TYPE_CANONICAL (t) = TYPE_MAIN_VARIANT (t);
1727 1664 : if (TYPE_MAIN_VARIANT (t) != t)
1728 : {
1729 113 : gcc_assert (TYPE_NEXT_VARIANT (t) == NULL_TREE);
1730 226 : TYPE_NEXT_VARIANT (t)
1731 113 : = TYPE_NEXT_VARIANT (TYPE_MAIN_VARIANT (t));
1732 113 : TYPE_NEXT_VARIANT (TYPE_MAIN_VARIANT (t)) = t;
1733 : }
1734 : }
1735 : }
1736 : }
1737 :
1738 : /* Restore decl state */
1739 91983 : file_data->current_decl_state = file_data->global_decl_state;
1740 : }
1741 :
1742 91983 : lto_data_in_delete (data_in);
1743 91983 : }
1744 :
1745 :
1746 : /* Read the body of NODE using DATA. FILE_DATA holds the global
1747 : decls and types. */
1748 :
1749 : void
1750 84255 : lto_input_function_body (struct lto_file_decl_data *file_data,
1751 : struct cgraph_node *node, const char *data)
1752 : {
1753 84255 : lto_read_body_or_constructor (file_data, node, data, LTO_section_function_body);
1754 84255 : }
1755 :
1756 : /* Read the body of NODE using DATA. FILE_DATA holds the global
1757 : decls and types. */
1758 :
1759 : void
1760 7728 : lto_input_variable_constructor (struct lto_file_decl_data *file_data,
1761 : struct varpool_node *node, const char *data)
1762 : {
1763 7728 : lto_read_body_or_constructor (file_data, node, data, LTO_section_function_body);
1764 7728 : }
1765 :
1766 :
1767 : /* Queue of acummulated decl -> DIE mappings. Similar to locations those
1768 : are only applied to prevailing tree nodes during tree merging. */
1769 : vec<dref_entry> dref_queue;
1770 :
1771 : /* Read the physical representation of a tree node EXPR from
1772 : input block IB using the per-file context in DATA_IN. */
1773 :
1774 : static void
1775 4398952 : lto_read_tree_1 (class lto_input_block *ib, class data_in *data_in, tree expr)
1776 : {
1777 : /* Read all the bitfield values in EXPR. Note that for LTO, we
1778 : only write language-independent bitfields, so no more unpacking is
1779 : needed. */
1780 4398952 : streamer_read_tree_bitfields (ib, data_in, expr);
1781 :
1782 : /* Read all the pointer fields in EXPR. */
1783 4398952 : streamer_read_tree_body (ib, data_in, expr);
1784 :
1785 : /* Read any LTO-specific data not read by the tree streamer. Do not use
1786 : stream_read_tree here since that flushes the dref_queue in mids of
1787 : SCC reading. */
1788 4398952 : if (DECL_P (expr)
1789 746661 : && TREE_CODE (expr) != FUNCTION_DECL
1790 541089 : && TREE_CODE (expr) != TRANSLATION_UNIT_DECL)
1791 1037414 : DECL_INITIAL (expr)
1792 1037414 : = lto_input_tree_1 (ib, data_in, streamer_read_record_start (ib), 0);
1793 :
1794 : /* Stream references to early generated DIEs. Keep in sync with the
1795 : trees handled in dwarf2out_register_external_die. */
1796 4398952 : if ((DECL_P (expr)
1797 : && TREE_CODE (expr) != FIELD_DECL
1798 : && TREE_CODE (expr) != DEBUG_EXPR_DECL
1799 : && TREE_CODE (expr) != TYPE_DECL)
1800 3750214 : || TREE_CODE (expr) == BLOCK)
1801 : {
1802 931385 : const char *str = streamer_read_string (data_in, ib);
1803 931385 : if (str)
1804 : {
1805 44360 : unsigned HOST_WIDE_INT off = streamer_read_uhwi (ib);
1806 44360 : dref_entry e = { expr, str, off };
1807 44360 : dref_queue.safe_push (e);
1808 : }
1809 : /* When there's no early DIE to refer to but dwarf2out set up
1810 : things in a way to expect that fixup. This tends to happen
1811 : with -g1, see for example PR113488. */
1812 887025 : else if (DECL_P (expr) && DECL_ABSTRACT_ORIGIN (expr) == expr)
1813 0 : DECL_ABSTRACT_ORIGIN (expr) = NULL_TREE;
1814 : }
1815 :
1816 : #ifdef ACCEL_COMPILER
1817 : if ((VAR_P (expr)
1818 : || TREE_CODE (expr) == PARM_DECL
1819 : || TREE_CODE (expr) == FIELD_DECL)
1820 : && DECL_MODE (expr) == VOIDmode)
1821 : {
1822 : tree type = TREE_TYPE (expr);
1823 : if (AGGREGATE_TYPE_P (type))
1824 : SET_DECL_MODE (expr, TYPE_MODE (type));
1825 : else if (VECTOR_TYPE_P (type))
1826 : SET_DECL_MODE (expr, TYPE_MODE_RAW (type));
1827 : }
1828 :
1829 : if (VECTOR_TYPE_P (expr) && TYPE_MODE (expr) == VOIDmode)
1830 : {
1831 : poly_uint64 nunits = TYPE_VECTOR_SUBPARTS (expr);
1832 : tree innertype = TREE_TYPE (expr);
1833 : machine_mode vmode
1834 : = mode_for_vector (SCALAR_TYPE_MODE (innertype), nunits).else_blk ();
1835 : SET_TYPE_MODE (expr, vmode);
1836 : }
1837 : #endif
1838 4398952 : }
1839 :
1840 : /* Read the physical representation of a tree node with tag TAG from
1841 : input block IB using the per-file context in DATA_IN. */
1842 :
1843 : static tree
1844 4210366 : lto_read_tree (class lto_input_block *ib, class data_in *data_in,
1845 : enum LTO_tags tag, hashval_t hash)
1846 : {
1847 : /* Instantiate a new tree node. */
1848 4210366 : tree result = streamer_alloc_tree (ib, data_in, tag);
1849 :
1850 : /* Enter RESULT in the reader cache. This will make RESULT
1851 : available so that circular references in the rest of the tree
1852 : structure can be resolved in subsequent calls to stream_read_tree. */
1853 4210366 : streamer_tree_cache_append (data_in->reader_cache, result, hash);
1854 :
1855 4210366 : lto_read_tree_1 (ib, data_in, result);
1856 :
1857 4210366 : return result;
1858 : }
1859 :
1860 :
1861 : /* Populate the reader cache with trees materialized from the SCC
1862 : following in the IB, DATA_IN stream.
1863 : If SHARED_SCC is true we input LTO_tree_scc. */
1864 :
1865 : hashval_t
1866 2103986 : lto_input_scc (class lto_input_block *ib, class data_in *data_in,
1867 : unsigned *len, unsigned *entry_len, bool shared_scc)
1868 : {
1869 2103986 : unsigned size = streamer_read_uhwi (ib);
1870 2103986 : hashval_t scc_hash = 0;
1871 2103986 : unsigned scc_entry_len = 1;
1872 :
1873 2103986 : if (shared_scc)
1874 : {
1875 753884 : if (size & 1)
1876 0 : scc_entry_len = streamer_read_uhwi (ib);
1877 753884 : size /= 2;
1878 753884 : scc_hash = streamer_read_uhwi (ib);
1879 : }
1880 :
1881 2103986 : if (size == 1)
1882 : {
1883 2056509 : enum LTO_tags tag = streamer_read_record_start (ib);
1884 2056509 : lto_input_tree_1 (ib, data_in, tag, scc_hash);
1885 : }
1886 : else
1887 : {
1888 47477 : unsigned int first = data_in->reader_cache->nodes.length ();
1889 47477 : tree result;
1890 :
1891 : /* Materialize size trees by reading their headers. */
1892 236063 : for (unsigned i = 0; i < size; ++i)
1893 : {
1894 188586 : enum LTO_tags tag = streamer_read_record_start (ib);
1895 188586 : if (tag == LTO_null
1896 188586 : || tag == LTO_global_stream_ref
1897 188586 : || tag == LTO_tree_pickle_reference
1898 188586 : || tag == LTO_integer_cst
1899 : || tag == LTO_tree_scc
1900 188586 : || tag == LTO_trees)
1901 0 : gcc_unreachable ();
1902 :
1903 188586 : result = streamer_alloc_tree (ib, data_in, tag);
1904 188586 : streamer_tree_cache_append (data_in->reader_cache, result, 0);
1905 : }
1906 :
1907 : /* Read the tree bitpacks and references. */
1908 236063 : for (unsigned i = 0; i < size; ++i)
1909 : {
1910 188586 : result = streamer_tree_cache_get_tree (data_in->reader_cache,
1911 : first + i);
1912 188586 : lto_read_tree_1 (ib, data_in, result);
1913 : }
1914 : }
1915 :
1916 2103986 : *len = size;
1917 2103986 : *entry_len = scc_entry_len;
1918 2103986 : return scc_hash;
1919 : }
1920 :
1921 : /* Read reference to tree from IB and DATA_IN.
1922 : This is used for streaming tree bodies where we know that
1923 : the tree is already in cache or is indexable and
1924 : must be matched with stream_write_tree_ref. */
1925 :
1926 : tree
1927 19737116 : stream_read_tree_ref (lto_input_block *ib, data_in *data_in)
1928 : {
1929 19737116 : int ix = streamer_read_hwi (ib);
1930 19737116 : if (!ix)
1931 : return NULL_TREE;
1932 12157197 : if (ix > 0)
1933 9244009 : return streamer_tree_cache_get_tree (data_in->reader_cache, ix - 1);
1934 :
1935 2913188 : ix = -ix - 1;
1936 2913188 : int id = ix & 1;
1937 2913188 : ix /= 2;
1938 :
1939 2913188 : tree ret;
1940 2913188 : if (!id)
1941 2752106 : ret = (*data_in->file_data->current_decl_state
1942 2752106 : ->streams[LTO_DECL_STREAM])[ix];
1943 : else
1944 161082 : ret = (*SSANAMES (cfun))[ix];
1945 : return ret;
1946 : }
1947 :
1948 : /* Read a tree from input block IB using the per-file context in
1949 : DATA_IN. This context is used, for example, to resolve references
1950 : to previously read nodes. */
1951 :
1952 : tree
1953 12802182 : lto_input_tree_1 (class lto_input_block *ib, class data_in *data_in,
1954 : enum LTO_tags tag, hashval_t hash)
1955 : {
1956 12802182 : tree result;
1957 :
1958 12802182 : gcc_assert ((unsigned) tag < (unsigned) LTO_NUM_TAGS);
1959 :
1960 12802182 : if (tag == LTO_null)
1961 : result = NULL_TREE;
1962 : else if (tag == LTO_global_stream_ref || tag == LTO_ssa_name_ref)
1963 : {
1964 : /* If TAG is a reference to an indexable tree, the next value
1965 : in IB is the index into the table where we expect to find
1966 : that tree. */
1967 4048211 : result = lto_input_tree_ref (ib, data_in, cfun, tag);
1968 : }
1969 : else if (tag == LTO_tree_pickle_reference)
1970 : {
1971 : /* If TAG is a reference to a previously read tree, look it up in
1972 : the reader cache. */
1973 1629808 : result = streamer_get_pickled_tree (ib, data_in);
1974 : }
1975 : else if (tag == LTO_integer_cst)
1976 : {
1977 : /* For shared integer constants in singletons we can use the
1978 : existing tree integer constant merging code. */
1979 683924 : tree type = stream_read_tree_ref (ib, data_in);
1980 683924 : unsigned HOST_WIDE_INT len = streamer_read_uhwi (ib);
1981 683924 : unsigned HOST_WIDE_INT i;
1982 683924 : HOST_WIDE_INT abuf[WIDE_INT_MAX_INL_ELTS], *a = abuf;
1983 :
1984 683924 : if (UNLIKELY (len > WIDE_INT_MAX_INL_ELTS))
1985 8 : a = XALLOCAVEC (HOST_WIDE_INT, len);
1986 1373476 : for (i = 0; i < len; i++)
1987 689552 : a[i] = streamer_read_hwi (ib);
1988 683924 : gcc_assert (TYPE_PRECISION (type) <= WIDE_INT_MAX_PRECISION);
1989 683924 : result
1990 683924 : = wide_int_to_tree (type,
1991 683924 : wide_int::from_array (a, len,
1992 683924 : TYPE_PRECISION (type)));
1993 683924 : streamer_tree_cache_append (data_in->reader_cache, result, hash);
1994 : }
1995 : else if (tag == LTO_tree_scc || tag == LTO_trees)
1996 0 : gcc_unreachable ();
1997 : else
1998 : {
1999 : /* Otherwise, materialize a new node from IB. */
2000 4210366 : result = lto_read_tree (ib, data_in, tag, hash);
2001 : }
2002 :
2003 12802182 : return result;
2004 : }
2005 :
2006 : tree
2007 8983618 : lto_input_tree (class lto_input_block *ib, class data_in *data_in)
2008 : {
2009 8983618 : enum LTO_tags tag;
2010 :
2011 : /* Input pickled trees needed to stream in the reference. */
2012 10318359 : while ((tag = streamer_read_record_start (ib)) == LTO_trees)
2013 : {
2014 1334741 : unsigned len, entry_len;
2015 1334741 : lto_input_scc (ib, data_in, &len, &entry_len, false);
2016 :
2017 : /* Register DECLs with the debuginfo machinery. */
2018 2790577 : while (!dref_queue.is_empty ())
2019 : {
2020 10884 : dref_entry e = dref_queue.pop ();
2021 10884 : debug_hooks->register_external_die (e.decl, e.sym, e.off);
2022 : }
2023 : }
2024 8983618 : tree t = lto_input_tree_1 (ib, data_in, tag, 0);
2025 :
2026 8983618 : if (!dref_queue.is_empty ())
2027 : {
2028 9419 : dref_entry e = dref_queue.pop ();
2029 9419 : debug_hooks->register_external_die (e.decl, e.sym, e.off);
2030 9419 : gcc_checking_assert (dref_queue.is_empty ());
2031 : }
2032 8983618 : return t;
2033 : }
2034 :
2035 :
2036 : /* Input toplevel asms. */
2037 :
2038 : void
2039 21740 : lto_input_toplevel_asms (struct lto_file_decl_data *file_data, int order_base)
2040 : {
2041 21740 : size_t len;
2042 21740 : const char *data
2043 21740 : = lto_get_summary_section_data (file_data, LTO_section_asm, &len);
2044 21740 : const struct lto_simple_header_with_strings *header
2045 : = (const struct lto_simple_header_with_strings *) data;
2046 21740 : int string_offset;
2047 21740 : class data_in *data_in;
2048 :
2049 21740 : if (! data)
2050 21629 : return;
2051 :
2052 111 : string_offset = sizeof (*header) + header->main_size;
2053 :
2054 111 : lto_input_block ib (data + sizeof (*header), header->main_size,
2055 111 : file_data);
2056 :
2057 111 : data_in = lto_data_in_create (file_data, data + string_offset,
2058 111 : header->string_size, vNULL);
2059 :
2060 111 : unsigned asm_count = streamer_read_uhwi (&ib);
2061 263 : for (unsigned i = 0; i < asm_count; i++)
2062 : {
2063 152 : tree str = stream_read_tree (&ib, data_in);
2064 152 : asm_node *node = symtab->finalize_toplevel_asm (str);
2065 152 : node->order = streamer_read_hwi (&ib) + order_base;
2066 152 : node->lto_file_data = file_data;
2067 152 : if (node->order >= symtab->order)
2068 0 : symtab->order = node->order + 1;
2069 : }
2070 :
2071 111 : lto_data_in_delete (data_in);
2072 :
2073 111 : lto_free_section_data (file_data, LTO_section_asm, NULL, data, len);
2074 : }
2075 :
2076 :
2077 : /* Input mode table. */
2078 :
2079 : void
2080 0 : lto_input_mode_table (struct lto_file_decl_data *file_data)
2081 : {
2082 0 : size_t len;
2083 0 : const char *data
2084 0 : = lto_get_summary_section_data (file_data, LTO_section_mode_table, &len);
2085 0 : if (! data)
2086 0 : internal_error ("cannot read LTO mode table from %s",
2087 : file_data->file_name);
2088 :
2089 0 : const struct lto_simple_header_with_strings *header
2090 : = (const struct lto_simple_header_with_strings *) data;
2091 0 : int string_offset;
2092 0 : class data_in *data_in;
2093 0 : string_offset = sizeof (*header) + header->main_size;
2094 :
2095 0 : lto_input_block ib (data + sizeof (*header), header->main_size, NULL);
2096 0 : data_in = lto_data_in_create (file_data, data + string_offset,
2097 0 : header->string_size, vNULL);
2098 0 : bitpack_d bp = streamer_read_bitpack (&ib);
2099 :
2100 : #ifdef ACCEL_COMPILER
2101 : host_num_poly_int_coeffs
2102 : = bp_unpack_value (&bp, MAX_NUM_POLY_INT_COEFFS_BITS);
2103 : #endif
2104 :
2105 0 : unsigned mode_bits = bp_unpack_value (&bp, 5);
2106 0 : unsigned char *table = ggc_cleared_vec_alloc<unsigned char> (1 << mode_bits);
2107 :
2108 0 : file_data->mode_table = table;
2109 0 : file_data->mode_bits = mode_bits;
2110 :
2111 0 : table[VOIDmode] = VOIDmode;
2112 0 : table[BLKmode] = BLKmode;
2113 0 : unsigned int m;
2114 0 : while ((m = bp_unpack_value (&bp, mode_bits)) != VOIDmode)
2115 : {
2116 0 : enum mode_class mclass
2117 0 : = bp_unpack_enum (&bp, mode_class, MAX_MODE_CLASS);
2118 0 : poly_uint16 size = bp_unpack_poly_value (&bp, 16);
2119 0 : poly_uint16 prec = bp_unpack_poly_value (&bp, 16);
2120 0 : machine_mode inner = (machine_mode) bp_unpack_value (&bp, mode_bits);
2121 0 : poly_uint16 nunits = bp_unpack_poly_value (&bp, 16);
2122 0 : unsigned int ibit = 0, fbit = 0;
2123 0 : unsigned int real_fmt_len = 0;
2124 0 : const char *real_fmt_name = NULL;
2125 0 : switch (mclass)
2126 : {
2127 0 : case MODE_FRACT:
2128 0 : case MODE_UFRACT:
2129 0 : case MODE_ACCUM:
2130 0 : case MODE_UACCUM:
2131 0 : ibit = bp_unpack_value (&bp, 8);
2132 0 : fbit = bp_unpack_value (&bp, 8);
2133 0 : break;
2134 0 : case MODE_FLOAT:
2135 0 : case MODE_DECIMAL_FLOAT:
2136 0 : real_fmt_name = bp_unpack_indexed_string (data_in, &bp,
2137 : &real_fmt_len);
2138 0 : break;
2139 : default:
2140 : break;
2141 : }
2142 : /* First search just the GET_CLASS_NARROWEST_MODE to wider modes,
2143 : if not found, fallback to all modes. */
2144 0 : int pass;
2145 0 : for (pass = 0; pass < 2; pass++)
2146 0 : for (machine_mode mr = pass ? VOIDmode
2147 0 : : GET_CLASS_NARROWEST_MODE (mclass);
2148 0 : pass ? mr < MAX_MACHINE_MODE : mr != VOIDmode;
2149 0 : pass ? mr = (machine_mode) (mr + 1)
2150 0 : : mr = GET_MODE_WIDER_MODE (mr).else_void ())
2151 0 : if (GET_MODE_CLASS (mr) != mclass
2152 0 : || maybe_ne (GET_MODE_SIZE (mr), size)
2153 0 : || maybe_ne (GET_MODE_PRECISION (mr), prec)
2154 0 : || (inner == m
2155 0 : ? GET_MODE_INNER (mr) != mr
2156 0 : : GET_MODE_INNER (mr) != table[(int) inner])
2157 0 : || GET_MODE_IBIT (mr) != ibit
2158 0 : || GET_MODE_FBIT (mr) != fbit
2159 0 : || maybe_ne (GET_MODE_NUNITS (mr), nunits))
2160 0 : continue;
2161 0 : else if ((mclass == MODE_FLOAT || mclass == MODE_DECIMAL_FLOAT)
2162 0 : && strcmp (REAL_MODE_FORMAT (mr)->name, real_fmt_name) != 0)
2163 0 : continue;
2164 : else
2165 : {
2166 0 : table[m] = mr;
2167 0 : pass = 2;
2168 0 : break;
2169 : }
2170 0 : unsigned int mname_len;
2171 0 : const char *mname = bp_unpack_indexed_string (data_in, &bp, &mname_len);
2172 0 : if (pass == 2)
2173 : {
2174 0 : switch (mclass)
2175 : {
2176 0 : case MODE_VECTOR_BOOL:
2177 0 : case MODE_VECTOR_INT:
2178 0 : case MODE_VECTOR_FLOAT:
2179 0 : case MODE_VECTOR_FRACT:
2180 0 : case MODE_VECTOR_UFRACT:
2181 0 : case MODE_VECTOR_ACCUM:
2182 0 : case MODE_VECTOR_UACCUM:
2183 : /* Vector modes are recomputed on accel side and shouldn't have
2184 : been streamed-out from host. */
2185 0 : gcc_unreachable ();
2186 : /* FALLTHRU */
2187 0 : default:
2188 : /* This is only used for offloading-target compilations and
2189 : is a user-facing error. Give a better error message for
2190 : the common modes; see also mode-classes.def. */
2191 0 : if (mclass == MODE_FLOAT)
2192 0 : fatal_error (UNKNOWN_LOCATION,
2193 : "%s - %u-bit-precision floating-point numbers "
2194 : "unsupported (mode %qs)", TARGET_MACHINE,
2195 0 : prec.to_constant (), mname);
2196 0 : else if (mclass == MODE_DECIMAL_FLOAT)
2197 0 : fatal_error (UNKNOWN_LOCATION,
2198 : "%s - %u-bit-precision decimal floating-point "
2199 : "numbers unsupported (mode %qs)", TARGET_MACHINE,
2200 0 : prec.to_constant (), mname);
2201 0 : else if (mclass == MODE_COMPLEX_FLOAT)
2202 0 : fatal_error (UNKNOWN_LOCATION,
2203 : "%s - %u-bit-precision complex floating-point "
2204 : "numbers unsupported (mode %qs)", TARGET_MACHINE,
2205 0 : prec.to_constant (), mname);
2206 0 : else if (mclass == MODE_INT)
2207 0 : fatal_error (UNKNOWN_LOCATION,
2208 : "%s - %u-bit integer numbers unsupported (mode "
2209 0 : "%qs)", TARGET_MACHINE, prec.to_constant (), mname);
2210 : else
2211 0 : fatal_error (UNKNOWN_LOCATION, "%s - unsupported mode %qs",
2212 : TARGET_MACHINE, mname);
2213 0 : break;
2214 : }
2215 : }
2216 : }
2217 0 : lto_data_in_delete (data_in);
2218 :
2219 0 : lto_free_section_data (file_data, LTO_section_mode_table, NULL, data, len);
2220 0 : }
2221 :
2222 :
2223 : /* Initialization for the LTO reader. */
2224 :
2225 : void
2226 20654 : lto_reader_init (void)
2227 : {
2228 20654 : lto_streamer_init ();
2229 20654 : file_name_hash_table
2230 20654 : = new hash_table<string_slot_hasher> (37);
2231 41308 : string_slot_allocator = new object_allocator <struct string_slot>
2232 20654 : ("line map file name hash");
2233 20654 : gcc_obstack_init (&file_name_obstack);
2234 20654 : }
2235 :
2236 : /* Free hash table used to stream in location file names. */
2237 :
2238 : void
2239 7889 : lto_free_file_name_hash (void)
2240 : {
2241 7889 : delete file_name_hash_table;
2242 7889 : file_name_hash_table = NULL;
2243 15778 : delete string_slot_allocator;
2244 7889 : string_slot_allocator = NULL;
2245 7889 : delete path_name_pair_hash_table;
2246 7889 : path_name_pair_hash_table = NULL;
2247 7889 : delete string_pair_map_allocator;
2248 7889 : string_pair_map_allocator = NULL;
2249 : /* file_name_obstack must stay allocated since it is referred to by
2250 : line map table. */
2251 7889 : }
2252 :
2253 :
2254 : /* Create a new data_in object for FILE_DATA. STRINGS is the string
2255 : table to use with LEN strings. RESOLUTIONS is the vector of linker
2256 : resolutions (NULL if not using a linker plugin). */
2257 :
2258 : class data_in *
2259 223639 : lto_data_in_create (struct lto_file_decl_data *file_data, const char *strings,
2260 : unsigned len,
2261 : vec<ld_plugin_symbol_resolution_t> resolutions,
2262 : bool need_location_cache)
2263 : {
2264 223639 : const auto d = new data_in{need_location_cache ? file_data : nullptr};
2265 223639 : d->file_data = file_data;
2266 223639 : d->strings = strings;
2267 223639 : d->strings_len = len;
2268 223639 : d->globals_resolution = resolutions;
2269 223639 : d->reader_cache = streamer_tree_cache_create (false, false, true);
2270 223639 : return d;
2271 : }
2272 :
2273 :
2274 : /* Remove DATA_IN. */
2275 :
2276 : void
2277 223639 : lto_data_in_delete (class data_in *data_in)
2278 : {
2279 223639 : data_in->globals_resolution.release ();
2280 223639 : streamer_tree_cache_delete (data_in->reader_cache);
2281 223639 : delete data_in;
2282 223639 : }
|