This was contributed by: 2011-04-13 Neil Vachharajani <nvach...@gmail.com>
On Wed, Apr 13, 2011 at 3:25 PM, Xinliang David Li <davi...@google.com> wrote: > Hi, in current FDO implementation, the source file version used in > profile-generate needs to strictly match the version used in > profile-use -- simple formating changes will invalidate the profile > data (use of it will lead to compiler error or ICE). There are two > main problems that lead to the weakness: > > 1) the function checksum is computed based on line number and number > of basic blocks -- this means any line number change will invalidate > the profile data. In fact, line number should play very minimal role > in profile matching decision. Another problem is that number of basic > blocks is also not a good indicator whether CFG matches or not. > 2) cgraph's pid is used as the key to find the matching profile data > for a function. If there is any new function added, or if the order of > the functions changes, the profile data is invalidated. > > The attached is a patch from google that improves this. > 1) function checksum is split into two parts: lineno checksum and cfg checksum > 2) function assembler name is used in profile hashing. > > Bootstrapped and regression tested on x86_64/linux. > > Ok for trunk? > > Thanks, > > David > > 2011-04-13 Xinliang David Li <davi...@google.com> > > * tree.c (crc32_byte): New function. > * tree.h (crc32_byte): New function. > * gcov.c (function_info): Add new fields. > (read_graph_file): Handle new fields. > (read_count_file): Handle name. > * gcov-io.c (gcov_string_length): New function. > (gcov_write_words): Bug fix. > (gcov_read_words): Bug fix. > * gcov-io.h: New interfaces. > * profile.c (get_exec_counts): New parameter. > (compute_branch_probablilities): New parameter. > (compute_value_histogram): New parameter. > (branch_prob): Pass cfg_checksum. > * coverage.c (get_const_string_type): New function. > (hash_counts_entry_hash): Use string hash. > (hash_counts_entry_eq): Use string compare. > (htab_counts_entry_del): Delete name. > (read_count_file): Add handling of cfg checksum. > (get_coverage_counts): New parameter. > (xstrdup_mask_random): New function. > (coverage_compute_lineno_checksum): New function. > (coverage_compute_cfg_checksum): New function. > (coverage_begin_output): New parameter. > (coverage_end_function): New parameter. > (build_fn_info_type): Build new fields. > (build_fn_info_value): Build new field values. > * coverage.h: Interface changes. > * libgcov.c (gcov_exit): Dump new fields. > * gcov_dump.c (tag_function): Print new fields. >