1*e4b17023SJohn Marino /* Input functions for reading LTO sections. 2*e4b17023SJohn Marino 3*e4b17023SJohn Marino Copyright 2009, 2010 Free Software Foundation, Inc. 4*e4b17023SJohn Marino Contributed by Kenneth Zadeck <zadeck@naturalbridge.com> 5*e4b17023SJohn Marino 6*e4b17023SJohn Marino This file is part of GCC. 7*e4b17023SJohn Marino 8*e4b17023SJohn Marino GCC is free software; you can redistribute it and/or modify it under 9*e4b17023SJohn Marino the terms of the GNU General Public License as published by the Free 10*e4b17023SJohn Marino Software Foundation; either version 3, or (at your option) any later 11*e4b17023SJohn Marino version. 12*e4b17023SJohn Marino 13*e4b17023SJohn Marino GCC is distributed in the hope that it will be useful, but WITHOUT ANY 14*e4b17023SJohn Marino WARRANTY; without even the implied warranty of MERCHANTABILITY or 15*e4b17023SJohn Marino FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16*e4b17023SJohn Marino for more details. 17*e4b17023SJohn Marino 18*e4b17023SJohn Marino You should have received a copy of the GNU General Public License 19*e4b17023SJohn Marino along with GCC; see the file COPYING3. If not see 20*e4b17023SJohn Marino <http://www.gnu.org/licenses/>. */ 21*e4b17023SJohn Marino 22*e4b17023SJohn Marino #include "config.h" 23*e4b17023SJohn Marino #include "system.h" 24*e4b17023SJohn Marino #include "coretypes.h" 25*e4b17023SJohn Marino #include "tm.h" 26*e4b17023SJohn Marino #include "tree.h" 27*e4b17023SJohn Marino #include "expr.h" 28*e4b17023SJohn Marino #include "flags.h" 29*e4b17023SJohn Marino #include "params.h" 30*e4b17023SJohn Marino #include "input.h" 31*e4b17023SJohn Marino #include "hashtab.h" 32*e4b17023SJohn Marino #include "basic-block.h" 33*e4b17023SJohn Marino #include "tree-flow.h" 34*e4b17023SJohn Marino #include "cgraph.h" 35*e4b17023SJohn Marino #include "function.h" 36*e4b17023SJohn Marino #include "ggc.h" 37*e4b17023SJohn Marino #include "diagnostic-core.h" 38*e4b17023SJohn Marino #include "except.h" 39*e4b17023SJohn Marino #include "vec.h" 40*e4b17023SJohn Marino #include "timevar.h" 41*e4b17023SJohn Marino #include "output.h" 42*e4b17023SJohn Marino #include "lto-streamer.h" 43*e4b17023SJohn Marino #include "lto-compress.h" 44*e4b17023SJohn Marino #include "ggc.h" 45*e4b17023SJohn Marino 46*e4b17023SJohn Marino /* Section names. These must correspond to the values of 47*e4b17023SJohn Marino enum lto_section_type. */ 48*e4b17023SJohn Marino const char *lto_section_name[LTO_N_SECTION_TYPES] = 49*e4b17023SJohn Marino { 50*e4b17023SJohn Marino "decls", 51*e4b17023SJohn Marino "function_body", 52*e4b17023SJohn Marino "statics", 53*e4b17023SJohn Marino "cgraph", 54*e4b17023SJohn Marino "vars", 55*e4b17023SJohn Marino "refs", 56*e4b17023SJohn Marino "asm", 57*e4b17023SJohn Marino "jmpfuncs", 58*e4b17023SJohn Marino "pureconst", 59*e4b17023SJohn Marino "reference", 60*e4b17023SJohn Marino "symtab", 61*e4b17023SJohn Marino "opts", 62*e4b17023SJohn Marino "cgraphopt", 63*e4b17023SJohn Marino "inline" 64*e4b17023SJohn Marino }; 65*e4b17023SJohn Marino 66*e4b17023SJohn Marino 67*e4b17023SJohn Marino /* Hooks so that the ipa passes can call into the lto front end to get 68*e4b17023SJohn Marino sections. */ 69*e4b17023SJohn Marino 70*e4b17023SJohn Marino static struct lto_file_decl_data ** file_decl_data; 71*e4b17023SJohn Marino static lto_get_section_data_f* get_section_f; 72*e4b17023SJohn Marino static lto_free_section_data_f* free_section_f; 73*e4b17023SJohn Marino 74*e4b17023SJohn Marino 75*e4b17023SJohn Marino /* This is called from the lto front end to set up the hooks that are 76*e4b17023SJohn Marino used by the ipa passes to get the data that they will 77*e4b17023SJohn Marino deserialize. */ 78*e4b17023SJohn Marino 79*e4b17023SJohn Marino void 80*e4b17023SJohn Marino lto_set_in_hooks (struct lto_file_decl_data ** data, 81*e4b17023SJohn Marino lto_get_section_data_f* get_f, 82*e4b17023SJohn Marino lto_free_section_data_f* free_f) 83*e4b17023SJohn Marino { 84*e4b17023SJohn Marino file_decl_data = data; 85*e4b17023SJohn Marino get_section_f = get_f; 86*e4b17023SJohn Marino free_section_f = free_f; 87*e4b17023SJohn Marino } 88*e4b17023SJohn Marino 89*e4b17023SJohn Marino 90*e4b17023SJohn Marino /* Return an array of file decl datas for all of the files passed to 91*e4b17023SJohn Marino this compilation. */ 92*e4b17023SJohn Marino 93*e4b17023SJohn Marino struct lto_file_decl_data ** 94*e4b17023SJohn Marino lto_get_file_decl_data (void) 95*e4b17023SJohn Marino { 96*e4b17023SJohn Marino gcc_assert (file_decl_data); 97*e4b17023SJohn Marino return file_decl_data; 98*e4b17023SJohn Marino } 99*e4b17023SJohn Marino 100*e4b17023SJohn Marino /* Buffer structure for accumulating data from compression callbacks. */ 101*e4b17023SJohn Marino 102*e4b17023SJohn Marino struct lto_buffer 103*e4b17023SJohn Marino { 104*e4b17023SJohn Marino char *data; 105*e4b17023SJohn Marino size_t length; 106*e4b17023SJohn Marino }; 107*e4b17023SJohn Marino 108*e4b17023SJohn Marino /* Compression callback, append LENGTH bytes from DATA to the buffer pointed 109*e4b17023SJohn Marino to by OPAQUE. */ 110*e4b17023SJohn Marino 111*e4b17023SJohn Marino static void 112*e4b17023SJohn Marino lto_append_data (const char *data, unsigned length, void *opaque) 113*e4b17023SJohn Marino { 114*e4b17023SJohn Marino struct lto_buffer *buffer = (struct lto_buffer *) opaque; 115*e4b17023SJohn Marino 116*e4b17023SJohn Marino buffer->data = (char *) xrealloc (buffer->data, buffer->length + length); 117*e4b17023SJohn Marino memcpy (buffer->data + buffer->length, data, length); 118*e4b17023SJohn Marino buffer->length += length; 119*e4b17023SJohn Marino } 120*e4b17023SJohn Marino 121*e4b17023SJohn Marino /* Header placed in returned uncompressed data streams. Allows the 122*e4b17023SJohn Marino uncompressed allocated data to be mapped back to the underlying 123*e4b17023SJohn Marino compressed data for use with free_section_f. */ 124*e4b17023SJohn Marino 125*e4b17023SJohn Marino struct lto_data_header 126*e4b17023SJohn Marino { 127*e4b17023SJohn Marino const char *data; 128*e4b17023SJohn Marino size_t len; 129*e4b17023SJohn Marino }; 130*e4b17023SJohn Marino 131*e4b17023SJohn Marino /* Return a char pointer to the start of a data stream for an LTO pass 132*e4b17023SJohn Marino or function. FILE_DATA indicates where to obtain the data. 133*e4b17023SJohn Marino SECTION_TYPE is the type of information to be obtained. NAME is 134*e4b17023SJohn Marino the name of the function and is only used when finding a function 135*e4b17023SJohn Marino body; otherwise it is NULL. LEN is the size of the data 136*e4b17023SJohn Marino returned. */ 137*e4b17023SJohn Marino 138*e4b17023SJohn Marino const char * 139*e4b17023SJohn Marino lto_get_section_data (struct lto_file_decl_data *file_data, 140*e4b17023SJohn Marino enum lto_section_type section_type, 141*e4b17023SJohn Marino const char *name, 142*e4b17023SJohn Marino size_t *len) 143*e4b17023SJohn Marino { 144*e4b17023SJohn Marino const char *data = (get_section_f) (file_data, section_type, name, len); 145*e4b17023SJohn Marino const size_t header_length = sizeof (struct lto_data_header); 146*e4b17023SJohn Marino struct lto_data_header *header; 147*e4b17023SJohn Marino struct lto_buffer buffer; 148*e4b17023SJohn Marino struct lto_compression_stream *stream; 149*e4b17023SJohn Marino lto_stats.section_size[section_type] += *len; 150*e4b17023SJohn Marino 151*e4b17023SJohn Marino if (data == NULL) 152*e4b17023SJohn Marino return NULL; 153*e4b17023SJohn Marino 154*e4b17023SJohn Marino /* FIXME lto: WPA mode does not write compressed sections, so for now 155*e4b17023SJohn Marino suppress uncompression if flag_ltrans. */ 156*e4b17023SJohn Marino if (flag_ltrans) 157*e4b17023SJohn Marino return data; 158*e4b17023SJohn Marino 159*e4b17023SJohn Marino /* Create a mapping header containing the underlying data and length, 160*e4b17023SJohn Marino and prepend this to the uncompression buffer. The uncompressed data 161*e4b17023SJohn Marino then follows, and a pointer to the start of the uncompressed data is 162*e4b17023SJohn Marino returned. */ 163*e4b17023SJohn Marino header = (struct lto_data_header *) xmalloc (header_length); 164*e4b17023SJohn Marino header->data = data; 165*e4b17023SJohn Marino header->len = *len; 166*e4b17023SJohn Marino 167*e4b17023SJohn Marino buffer.data = (char *) header; 168*e4b17023SJohn Marino buffer.length = header_length; 169*e4b17023SJohn Marino 170*e4b17023SJohn Marino stream = lto_start_uncompression (lto_append_data, &buffer); 171*e4b17023SJohn Marino lto_uncompress_block (stream, data, *len); 172*e4b17023SJohn Marino lto_end_uncompression (stream); 173*e4b17023SJohn Marino 174*e4b17023SJohn Marino *len = buffer.length - header_length; 175*e4b17023SJohn Marino return buffer.data + header_length; 176*e4b17023SJohn Marino } 177*e4b17023SJohn Marino 178*e4b17023SJohn Marino 179*e4b17023SJohn Marino /* Free the data found from the above call. The first three 180*e4b17023SJohn Marino parameters are the same as above. DATA is the data to be freed and 181*e4b17023SJohn Marino LEN is the length of that data. */ 182*e4b17023SJohn Marino 183*e4b17023SJohn Marino void 184*e4b17023SJohn Marino lto_free_section_data (struct lto_file_decl_data *file_data, 185*e4b17023SJohn Marino enum lto_section_type section_type, 186*e4b17023SJohn Marino const char *name, 187*e4b17023SJohn Marino const char *data, 188*e4b17023SJohn Marino size_t len) 189*e4b17023SJohn Marino { 190*e4b17023SJohn Marino const size_t header_length = sizeof (struct lto_data_header); 191*e4b17023SJohn Marino const char *real_data = data - header_length; 192*e4b17023SJohn Marino const struct lto_data_header *header 193*e4b17023SJohn Marino = (const struct lto_data_header *) real_data; 194*e4b17023SJohn Marino 195*e4b17023SJohn Marino gcc_assert (free_section_f); 196*e4b17023SJohn Marino 197*e4b17023SJohn Marino /* FIXME lto: WPA mode does not write compressed sections, so for now 198*e4b17023SJohn Marino suppress uncompression mapping if flag_ltrans. */ 199*e4b17023SJohn Marino if (flag_ltrans) 200*e4b17023SJohn Marino { 201*e4b17023SJohn Marino (free_section_f) (file_data, section_type, name, data, len); 202*e4b17023SJohn Marino return; 203*e4b17023SJohn Marino } 204*e4b17023SJohn Marino 205*e4b17023SJohn Marino /* The underlying data address has been extracted from the mapping header. 206*e4b17023SJohn Marino Free that, then free the allocated uncompression buffer. */ 207*e4b17023SJohn Marino (free_section_f) (file_data, section_type, name, header->data, header->len); 208*e4b17023SJohn Marino free (CONST_CAST (char *, real_data)); 209*e4b17023SJohn Marino } 210*e4b17023SJohn Marino 211*e4b17023SJohn Marino 212*e4b17023SJohn Marino /* Load a section of type SECTION_TYPE from FILE_DATA, parse the 213*e4b17023SJohn Marino header and then return an input block pointing to the section. The 214*e4b17023SJohn Marino raw pointer to the section is returned in DATAR and LEN. These are 215*e4b17023SJohn Marino used to free the section. Return NULL if the section is not present. */ 216*e4b17023SJohn Marino 217*e4b17023SJohn Marino struct lto_input_block * 218*e4b17023SJohn Marino lto_create_simple_input_block (struct lto_file_decl_data *file_data, 219*e4b17023SJohn Marino enum lto_section_type section_type, 220*e4b17023SJohn Marino const char **datar, size_t *len) 221*e4b17023SJohn Marino { 222*e4b17023SJohn Marino const char *data = lto_get_section_data (file_data, section_type, NULL, len); 223*e4b17023SJohn Marino const struct lto_simple_header * header 224*e4b17023SJohn Marino = (const struct lto_simple_header *) data; 225*e4b17023SJohn Marino 226*e4b17023SJohn Marino struct lto_input_block* ib_main; 227*e4b17023SJohn Marino int main_offset = sizeof (struct lto_simple_header); 228*e4b17023SJohn Marino 229*e4b17023SJohn Marino if (!data) 230*e4b17023SJohn Marino return NULL; 231*e4b17023SJohn Marino 232*e4b17023SJohn Marino ib_main = XNEW (struct lto_input_block); 233*e4b17023SJohn Marino 234*e4b17023SJohn Marino *datar = data; 235*e4b17023SJohn Marino LTO_INIT_INPUT_BLOCK_PTR (ib_main, data + main_offset, 236*e4b17023SJohn Marino 0, header->main_size); 237*e4b17023SJohn Marino 238*e4b17023SJohn Marino return ib_main; 239*e4b17023SJohn Marino } 240*e4b17023SJohn Marino 241*e4b17023SJohn Marino 242*e4b17023SJohn Marino /* Close the section returned from a call to 243*e4b17023SJohn Marino LTO_CREATE_SIMPLE_INPUT_BLOCK. IB is the input block returned from 244*e4b17023SJohn Marino that call. The FILE_DATA and SECTION_TYPE are the same as what was 245*e4b17023SJohn Marino passed to that call and the DATA and LEN are what was returned from 246*e4b17023SJohn Marino that call. */ 247*e4b17023SJohn Marino 248*e4b17023SJohn Marino void 249*e4b17023SJohn Marino lto_destroy_simple_input_block (struct lto_file_decl_data *file_data, 250*e4b17023SJohn Marino enum lto_section_type section_type, 251*e4b17023SJohn Marino struct lto_input_block *ib, 252*e4b17023SJohn Marino const char *data, size_t len) 253*e4b17023SJohn Marino { 254*e4b17023SJohn Marino free (ib); 255*e4b17023SJohn Marino lto_free_section_data (file_data, section_type, NULL, data, len); 256*e4b17023SJohn Marino } 257*e4b17023SJohn Marino 258*e4b17023SJohn Marino /*****************************************************************************/ 259*e4b17023SJohn Marino /* Record renamings of static declarations */ 260*e4b17023SJohn Marino /*****************************************************************************/ 261*e4b17023SJohn Marino 262*e4b17023SJohn Marino struct lto_renaming_slot 263*e4b17023SJohn Marino { 264*e4b17023SJohn Marino const char *old_name; 265*e4b17023SJohn Marino const char *new_name; 266*e4b17023SJohn Marino }; 267*e4b17023SJohn Marino 268*e4b17023SJohn Marino /* Returns a hash code for P. */ 269*e4b17023SJohn Marino 270*e4b17023SJohn Marino static hashval_t 271*e4b17023SJohn Marino hash_name (const void *p) 272*e4b17023SJohn Marino { 273*e4b17023SJohn Marino const struct lto_renaming_slot *ds = (const struct lto_renaming_slot *) p; 274*e4b17023SJohn Marino return (hashval_t) htab_hash_string (ds->new_name); 275*e4b17023SJohn Marino } 276*e4b17023SJohn Marino 277*e4b17023SJohn Marino /* Returns nonzero if P1 and P2 are equal. */ 278*e4b17023SJohn Marino 279*e4b17023SJohn Marino static int 280*e4b17023SJohn Marino eq_name (const void *p1, const void *p2) 281*e4b17023SJohn Marino { 282*e4b17023SJohn Marino const struct lto_renaming_slot *s1 = 283*e4b17023SJohn Marino (const struct lto_renaming_slot *) p1; 284*e4b17023SJohn Marino const struct lto_renaming_slot *s2 = 285*e4b17023SJohn Marino (const struct lto_renaming_slot *) p2; 286*e4b17023SJohn Marino 287*e4b17023SJohn Marino return strcmp (s1->new_name, s2->new_name) == 0; 288*e4b17023SJohn Marino } 289*e4b17023SJohn Marino 290*e4b17023SJohn Marino /* Free a renaming table entry. */ 291*e4b17023SJohn Marino 292*e4b17023SJohn Marino static void 293*e4b17023SJohn Marino renaming_slot_free (void *slot) 294*e4b17023SJohn Marino { 295*e4b17023SJohn Marino struct lto_renaming_slot *s = (struct lto_renaming_slot *) slot; 296*e4b17023SJohn Marino 297*e4b17023SJohn Marino free (CONST_CAST (void *, (const void *) s->old_name)); 298*e4b17023SJohn Marino free (CONST_CAST (void *, (const void *) s->new_name)); 299*e4b17023SJohn Marino free ((void *) s); 300*e4b17023SJohn Marino } 301*e4b17023SJohn Marino 302*e4b17023SJohn Marino /* Create an empty hash table for recording declaration renamings. */ 303*e4b17023SJohn Marino 304*e4b17023SJohn Marino htab_t 305*e4b17023SJohn Marino lto_create_renaming_table (void) 306*e4b17023SJohn Marino { 307*e4b17023SJohn Marino return htab_create (37, hash_name, eq_name, renaming_slot_free); 308*e4b17023SJohn Marino } 309*e4b17023SJohn Marino 310*e4b17023SJohn Marino /* Record a declaration name mapping OLD_NAME -> NEW_NAME. DECL_DATA 311*e4b17023SJohn Marino holds the renaming hash table to use. */ 312*e4b17023SJohn Marino 313*e4b17023SJohn Marino void 314*e4b17023SJohn Marino lto_record_renamed_decl (struct lto_file_decl_data *decl_data, 315*e4b17023SJohn Marino const char *old_name, const char *new_name) 316*e4b17023SJohn Marino { 317*e4b17023SJohn Marino void **slot; 318*e4b17023SJohn Marino struct lto_renaming_slot r_slot; 319*e4b17023SJohn Marino 320*e4b17023SJohn Marino r_slot.new_name = new_name; 321*e4b17023SJohn Marino slot = htab_find_slot (decl_data->renaming_hash_table, &r_slot, INSERT); 322*e4b17023SJohn Marino if (*slot == NULL) 323*e4b17023SJohn Marino { 324*e4b17023SJohn Marino struct lto_renaming_slot *new_slot = XNEW (struct lto_renaming_slot); 325*e4b17023SJohn Marino new_slot->old_name = xstrdup (old_name); 326*e4b17023SJohn Marino new_slot->new_name = xstrdup (new_name); 327*e4b17023SJohn Marino *slot = new_slot; 328*e4b17023SJohn Marino } 329*e4b17023SJohn Marino else 330*e4b17023SJohn Marino gcc_unreachable (); 331*e4b17023SJohn Marino } 332*e4b17023SJohn Marino 333*e4b17023SJohn Marino 334*e4b17023SJohn Marino /* Given a string NAME, return the string that it has been mapped to 335*e4b17023SJohn Marino by lto_record_renamed_decl. If NAME was not renamed, it is 336*e4b17023SJohn Marino returned unchanged. DECL_DATA holds the renaming hash table to use. */ 337*e4b17023SJohn Marino 338*e4b17023SJohn Marino const char * 339*e4b17023SJohn Marino lto_get_decl_name_mapping (struct lto_file_decl_data *decl_data, 340*e4b17023SJohn Marino const char *name) 341*e4b17023SJohn Marino { 342*e4b17023SJohn Marino htab_t renaming_hash_table = decl_data->renaming_hash_table; 343*e4b17023SJohn Marino struct lto_renaming_slot *slot; 344*e4b17023SJohn Marino struct lto_renaming_slot r_slot; 345*e4b17023SJohn Marino 346*e4b17023SJohn Marino r_slot.new_name = name; 347*e4b17023SJohn Marino slot = (struct lto_renaming_slot *) htab_find (renaming_hash_table, &r_slot); 348*e4b17023SJohn Marino if (slot) 349*e4b17023SJohn Marino return slot->old_name; 350*e4b17023SJohn Marino else 351*e4b17023SJohn Marino return name; 352*e4b17023SJohn Marino } 353*e4b17023SJohn Marino 354*e4b17023SJohn Marino /*****************************************************************************/ 355*e4b17023SJohn Marino /* Input decl state object. */ 356*e4b17023SJohn Marino /*****************************************************************************/ 357*e4b17023SJohn Marino 358*e4b17023SJohn Marino /* Return a newly created in-decl state object. */ 359*e4b17023SJohn Marino 360*e4b17023SJohn Marino struct lto_in_decl_state * 361*e4b17023SJohn Marino lto_new_in_decl_state (void) 362*e4b17023SJohn Marino { 363*e4b17023SJohn Marino return ggc_alloc_cleared_lto_in_decl_state (); 364*e4b17023SJohn Marino } 365*e4b17023SJohn Marino 366*e4b17023SJohn Marino /* Delete STATE and its components. */ 367*e4b17023SJohn Marino 368*e4b17023SJohn Marino void 369*e4b17023SJohn Marino lto_delete_in_decl_state (struct lto_in_decl_state *state) 370*e4b17023SJohn Marino { 371*e4b17023SJohn Marino int i; 372*e4b17023SJohn Marino 373*e4b17023SJohn Marino for (i = 0; i < LTO_N_DECL_STREAMS; i++) 374*e4b17023SJohn Marino if (state->streams[i].trees) 375*e4b17023SJohn Marino ggc_free (state->streams[i].trees); 376*e4b17023SJohn Marino ggc_free (state); 377*e4b17023SJohn Marino } 378*e4b17023SJohn Marino 379*e4b17023SJohn Marino /* Hashtable helpers. lto_in_decl_states are hash by their function decls. */ 380*e4b17023SJohn Marino 381*e4b17023SJohn Marino hashval_t 382*e4b17023SJohn Marino lto_hash_in_decl_state (const void *p) 383*e4b17023SJohn Marino { 384*e4b17023SJohn Marino const struct lto_in_decl_state *state = (const struct lto_in_decl_state *) p; 385*e4b17023SJohn Marino return htab_hash_pointer (state->fn_decl); 386*e4b17023SJohn Marino } 387*e4b17023SJohn Marino 388*e4b17023SJohn Marino /* Return true if the fn_decl field of the lto_in_decl_state pointed to by 389*e4b17023SJohn Marino P1 equals to the function decl P2. */ 390*e4b17023SJohn Marino 391*e4b17023SJohn Marino int 392*e4b17023SJohn Marino lto_eq_in_decl_state (const void *p1, const void *p2) 393*e4b17023SJohn Marino { 394*e4b17023SJohn Marino const struct lto_in_decl_state *state1 = 395*e4b17023SJohn Marino (const struct lto_in_decl_state *) p1; 396*e4b17023SJohn Marino const struct lto_in_decl_state *state2 = 397*e4b17023SJohn Marino (const struct lto_in_decl_state *) p2; 398*e4b17023SJohn Marino return state1->fn_decl == state2->fn_decl; 399*e4b17023SJohn Marino } 400*e4b17023SJohn Marino 401*e4b17023SJohn Marino 402*e4b17023SJohn Marino /* Search the in-decl state of a function FUNC contained in the file 403*e4b17023SJohn Marino associated with FILE_DATA. Return NULL if not found. */ 404*e4b17023SJohn Marino 405*e4b17023SJohn Marino struct lto_in_decl_state* 406*e4b17023SJohn Marino lto_get_function_in_decl_state (struct lto_file_decl_data *file_data, 407*e4b17023SJohn Marino tree func) 408*e4b17023SJohn Marino { 409*e4b17023SJohn Marino struct lto_in_decl_state temp; 410*e4b17023SJohn Marino void **slot; 411*e4b17023SJohn Marino 412*e4b17023SJohn Marino temp.fn_decl = func; 413*e4b17023SJohn Marino slot = htab_find_slot (file_data->function_decl_states, &temp, NO_INSERT); 414*e4b17023SJohn Marino return slot? ((struct lto_in_decl_state*) *slot) : NULL; 415*e4b17023SJohn Marino } 416*e4b17023SJohn Marino 417*e4b17023SJohn Marino 418*e4b17023SJohn Marino /* Report read pass end of the section. */ 419*e4b17023SJohn Marino 420*e4b17023SJohn Marino void 421*e4b17023SJohn Marino lto_section_overrun (struct lto_input_block *ib) 422*e4b17023SJohn Marino { 423*e4b17023SJohn Marino fatal_error ("bytecode stream: trying to read %d bytes " 424*e4b17023SJohn Marino "after the end of the input buffer", ib->p - ib->len); 425*e4b17023SJohn Marino } 426*e4b17023SJohn Marino 427*e4b17023SJohn Marino /* Report out of range value. */ 428*e4b17023SJohn Marino 429*e4b17023SJohn Marino void 430*e4b17023SJohn Marino lto_value_range_error (const char *purpose, HOST_WIDE_INT val, 431*e4b17023SJohn Marino HOST_WIDE_INT min, HOST_WIDE_INT max) 432*e4b17023SJohn Marino { 433*e4b17023SJohn Marino fatal_error ("%s out of range: Range is %i to %i, value is %i", 434*e4b17023SJohn Marino purpose, (int)min, (int)max, (int)val); 435*e4b17023SJohn Marino } 436