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