summaryrefslogtreecommitdiff
path: root/gcc/cgraph.c
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2019-12-08 18:02:30 +0100
committerJan Hubicka <hubicka@gcc.gnu.org>2019-12-08 17:02:30 +0000
commit6d8fd122c4f856e9c6037adc310505f2d65347d9 (patch)
tree8e29349bdc425541a2785219964901a5ba270470 /gcc/cgraph.c
parenta8d9d6649e621e6e0d0887bd7f5a6069cb9cfa72 (diff)
Fix overflows in -fprofile-reorder-functions
This patch fixes three sissues with -fprofile-reorder-functions: 1) First is that tp_first_run is stored as 32bit integer while it can easily overflow (and does so during Firefox profiling). 2) Second problem is that flag_profile_functions can not be tested w/o function context. The changes to expand_all_functions makes it to work on mixed units by first outputting all functions w/o -fprofile-reorder-function (or with no profile info) and then outputting in first_run order 3) LTO partitioner was mixing up order by tp_first_run and by order. for no_reorder we definitly want to order via first, while for everything else we want to roder by second. I have also merged duplicated comparators since they are bit fragile into tp_first_run_node_cmp. I originaly started to look into this because of undefined symbols with Firefox PGO builds. These symbols went away with fixing these bug but I am not quite sure how. it is possible that there is another problem in lto_blanced_map but even after reading the noreorder code few times carefuly I did not find it. Other explanation would be that our new qsort with broken comparator due to overflow can actualy remove some entries in the array, but that sounds bit crazy. Bootstrapped/regested x86_64-linux. * cgraph.c (cgraph_node::dump): Make tp_first_run 64bit. * cgraph.h (cgrpah_node): Likewise. (tp_first_run_node_cmp): Deeclare. * cgraphunit.c (node_cmp): Rename to ... (tp_first_run_node_cmp): ... this; export; watch for 64bit overflows; clear tp_first_run for no_reorder and !flag_profile_reorder_functions. (expand_all_functions): Collect tp_first_run and normal functions to two vectors so the other functions remain sorted. Do not check for flag_profile_reorder_functions it is function local flag. * profile.c (compute_value_histograms): Update tp_first_run printing. * lto-partition.c (node_cmp): Turn into simple order comparsions. (varpool_node_cmp): Remove. (add_sorted_nodes): Use node_cmp. (lto_balanced_map): Use tp_first_run_node_cmp. From-SVN: r279093
Diffstat (limited to 'gcc/cgraph.c')
-rw-r--r--gcc/cgraph.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 7288440708e..5c72e832a23 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -1954,7 +1954,7 @@ cgraph_node::dump (FILE *f)
count.dump (f);
}
if (tp_first_run > 0)
- fprintf (f, " first_run:%i", tp_first_run);
+ fprintf (f, " first_run:%" PRId64, (int64_t) tp_first_run);
if (origin)
fprintf (f, " nested in:%s", origin->asm_name ());
if (gimple_has_body_p (decl))