On Mon, 2 May 2011, Jan Hubicka wrote: > Hi, > lto_input_1_unsigned and lto_output_1_stream are the most frequently called > functions > during the WPA stage. Obviously these are simple accesors that should be > inline. > Note that even with LTO bootstrap these won't get inlined unless we declare > them > inline or use -O3 or FDO. > > Bootstrapped/regtested x86_64-linux, OK?
Ok. Thanks, Richard. > Honza > > * lto-section-in.c (lto_input_1_unsigned): Move to lto-streamer.h > (lto_section_overrun): New. > * lto-section-out.c (append_block): Rename to ... > (lto_append_block): ... this one; export. > (lto_output_1_stream): Move lto lto-streamer.h > (lto_output_data_stream): Update. > * lto-streamer.h (lto_section_overrun, lto_append_block): Declare. > (lto_output_1_stream, lto_input_1_unsigned): Turn into inline > functions. > > Index: lto-section-in.c > =================================================================== > *** lto-section-in.c (revision 173234) > --- lto-section-in.c (working copy) > *************** const char *lto_section_name[LTO_N_SECTI > *** 62,77 **** > "inline" > }; > > - unsigned char > - lto_input_1_unsigned (struct lto_input_block *ib) > - { > - if (ib->p >= ib->len) > - internal_error ("bytecode stream: trying to read %d bytes " > - "after the end of the input buffer", ib->p - ib->len); > - > - return (ib->data[ib->p++]); > - } > - > > /* Read an ULEB128 Number of IB. */ > > --- 62,67 ---- > *************** lto_get_function_in_decl_state (struct l > *** 486,488 **** > --- 476,488 ---- > slot = htab_find_slot (file_data->function_decl_states, &temp, NO_INSERT); > return slot? ((struct lto_in_decl_state*) *slot) : NULL; > } > + > + > + /* Report read pass end of the section. */ > + > + void > + lto_section_overrun (struct lto_input_block *ib) > + { > + internal_error ("bytecode stream: trying to read %d bytes " > + "after the end of the input buffer", ib->p - ib->len); > + } > Index: lto-section-out.c > =================================================================== > *** lto-section-out.c (revision 173234) > --- lto-section-out.c (working copy) > *************** lto_write_stream (struct lto_output_stre > *** 194,201 **** > > /* Adds a new block to output stream OBS. */ > > ! static void > ! append_block (struct lto_output_stream *obs) > { > struct lto_char_ptr_base *new_block; > > --- 194,201 ---- > > /* Adds a new block to output stream OBS. */ > > ! void > ! lto_append_block (struct lto_output_stream *obs) > { > struct lto_char_ptr_base *new_block; > > *************** append_block (struct lto_output_stream * > *** 234,256 **** > } > > > - /* Write a character to the output block. */ > - > - void > - lto_output_1_stream (struct lto_output_stream *obs, char c) > - { > - /* No space left. */ > - if (obs->left_in_block == 0) > - append_block (obs); > - > - /* Write the actual character. */ > - *obs->current_pointer = c; > - obs->current_pointer++; > - obs->total_size++; > - obs->left_in_block--; > - } > - > - > /* Write raw DATA of length LEN to the output block OB. */ > > void > --- 234,239 ---- > *************** lto_output_data_stream (struct lto_outpu > *** 263,269 **** > > /* No space left. */ > if (obs->left_in_block == 0) > ! append_block (obs); > > /* Determine how many bytes to copy in this loop. */ > if (len <= obs->left_in_block) > --- 246,252 ---- > > /* No space left. */ > if (obs->left_in_block == 0) > ! lto_append_block (obs); > > /* Determine how many bytes to copy in this loop. */ > if (len <= obs->left_in_block) > Index: lto-streamer.h > =================================================================== > *** lto-streamer.h (revision 173234) > --- lto-streamer.h (working copy) > *************** extern const char *lto_get_section_data > *** 758,764 **** > extern void lto_free_section_data (struct lto_file_decl_data *, > enum lto_section_type, > const char *, const char *, size_t); > - extern unsigned char lto_input_1_unsigned (struct lto_input_block *); > extern unsigned HOST_WIDE_INT lto_input_uleb128 (struct lto_input_block *); > extern unsigned HOST_WIDEST_INT lto_input_widest_uint_uleb128 ( > struct lto_input_block *); > --- 758,763 ---- > *************** extern hashval_t lto_hash_in_decl_state > *** 774,779 **** > --- 773,779 ---- > extern int lto_eq_in_decl_state (const void *, const void *); > extern struct lto_in_decl_state *lto_get_function_in_decl_state ( > struct lto_file_decl_data *, tree); > + extern void lto_section_overrun (struct lto_input_block *) > ATTRIBUTE_NORETURN; > > /* In lto-section-out.c */ > extern hashval_t lto_hash_decl_slot_node (const void *); > *************** extern int lto_eq_type_slot_node (const > *** 783,789 **** > extern void lto_begin_section (const char *, bool); > extern void lto_end_section (void); > extern void lto_write_stream (struct lto_output_stream *); > - extern void lto_output_1_stream (struct lto_output_stream *, char); > extern void lto_output_data_stream (struct lto_output_stream *, const void > *, > size_t); > extern void lto_output_uleb128_stream (struct lto_output_stream *, > --- 783,788 ---- > *************** extern void lto_push_out_decl_state (str > *** 817,822 **** > --- 816,822 ---- > extern struct lto_out_decl_state *lto_pop_out_decl_state (void); > extern void lto_record_function_out_decl_state (tree, > struct lto_out_decl_state *); > + extern void lto_append_block (struct lto_output_stream *); > > > /* In lto-streamer.c. */ > *************** bp_unpack_value (struct bitpack_d *bp, u > *** 1174,1177 **** > --- 1174,1205 ---- > return val & mask; > } > > + > + /* Write a character to the output block. */ > + > + static inline void > + lto_output_1_stream (struct lto_output_stream *obs, char c) > + { > + /* No space left. */ > + if (obs->left_in_block == 0) > + lto_append_block (obs); > + > + /* Write the actual character. */ > + *obs->current_pointer = c; > + obs->current_pointer++; > + obs->total_size++; > + obs->left_in_block--; > + } > + > + > + /* Read byte from the input block. */ > + > + static inline unsigned char > + lto_input_1_unsigned (struct lto_input_block *ib) > + { > + if (ib->p >= ib->len) > + lto_section_overrun (ib); > + return (ib->data[ib->p++]); > + } > + > #endif /* GCC_LTO_STREAMER_H */ > > -- Richard Guenther <rguent...@suse.de> Novell / SUSE Labs SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 - GF: Markus Rex