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