On Thu, Nov 29, 2012 at 8:17 AM, Jan Hubicka <hubi...@ucw.cz> wrote: >> This patch ensures that the histograms from the profile summary are streamed >> through the LTO files so that the working set can be computed for use in >> downstream optimizations. >> >> Bootstrapped and tested on x86_64-unknown-linux-gnu. Ok for trunk? >> >> Thanks, >> Teresa >> >> 2012-11-28 Teresa Johnson <tejohn...@google.com> >> >> * lto-cgraph.c (output_profile_summary): Stream out sum_all >> and histogram. >> (input_profile_summary): Stream in sum_all and histogram. >> (merge_profile_summaries): Merge sum_all and histogram. >> (input_symtab): Call compute_working_sets after merging >> summaries. >> * gcov-io.c (gcov_histo_index): Make extern for compiler. >> * gcov-io.h (gcov_histo_index): Ditto. >> * profile.c (compute_working_sets): Remove static keyword. >> * profile.h (compute_working_sets): Ditto. > > OK. >> >> Index: lto-cgraph.c >> =================================================================== >> --- lto-cgraph.c (revision 193909) >> +++ lto-cgraph.c (working copy) >> @@ -46,6 +46,7 @@ along with GCC; see the file COPYING3. If not see >> #include "tree-streamer.h" >> #include "gcov-io.h" >> #include "tree-pass.h" >> +#include "profile.h" > > Please update dependencies in Makefile.in
ok. >> + /* Count number of non-zero histogram entries, and fill in a bit >> vector >> + of non-zero indices. */ >> + counters. */ >> + for (bv_ix = 0; bv_ix < GCOV_HISTOGRAM_BITVECTOR_SIZE; bv_ix++) >> + histo_bitvector[bv_ix] = 0; >> + for (h_ix = 0; h_ix < GCOV_HISTOGRAM_SIZE; h_ix++) >> + { >> + if (profile_info->histogram[h_ix].num_counters > 0) >> + { >> + histo_bitvector[h_ix / 32] |= 1 << (h_ix % 32); >> + h_cnt++; >> + } > > I think this would be more readable if you just produced a bitpack instead of > doing it > by hand, like into gcov-io. I assume you mean use the bitpack streaming functionality used other places in lto-cgraph.c, and not change the way it is done in gcov-io.c where this was cloned from? I will change the lto-cgraph.c code to use the bitpacking. >> + lto_gcov_summary.sum_all = MAX (lto_gcov_summary.sum_all, >> + (file_data->profile_info.sum_all >> + * scale >> + + REG_BR_PROB_BASE / 2) >> + / REG_BR_PROB_BASE); > > Use RDIV for the scaling. ok. This was cloned from the way we do other scalings in the same function, I will change them all to use RDIV. >> -#if IN_LIBGCOV || !IN_GCOV >> +#if !IN_GCOV >> /* Determine the index into histogram for VALUE. */ >> >> -static unsigned >> +GCOV_LINKAGE unsigned > I would probably go around the trouble of declaring this static in GCOV, > so it is inlined at we do not bload libgcov more than needed. Do you mean leave it static when IN_LIBGCOV? It isn't included when IN_GCOV. I just need it extern when in the compiler. So do you mean make it static when IN_LIBGCOV and GCOV_LINKAGE (i.e. extern) when !IN_LIBGCOV? Thanks, Teresa > > Thanks, > Honza -- Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413