aboutsummaryrefslogtreecommitdiff
path: root/gcc/lto/lto-partition.c
diff options
context:
space:
mode:
authorMartin Liska <marxin.liska@gmail.com>2013-12-17 22:20:12 +0000
committerMartin Liska <marxin@gcc.gnu.org>2013-12-17 22:20:12 +0000
commit9cec31f43afbdb326fddbc144e9aea63986828e4 (patch)
tree3ad29a01dabd9e49f49f9ebdc04f7655721d6300 /gcc/lto/lto-partition.c
parent14407011d62da724e88ac0cb30390d3f8fda2b9f (diff)
downloadgcc-9cec31f43afbdb326fddbc144e9aea63986828e4.zip
gcc-9cec31f43afbdb326fddbc144e9aea63986828e4.tar.gz
gcc-9cec31f43afbdb326fddbc144e9aea63986828e4.tar.bz2
Time profile-based function reordering (phase 2).
Co-Authored-By: Jan Hubicka <jh@suse.cz> From-SVN: r206070
Diffstat (limited to 'gcc/lto/lto-partition.c')
-rw-r--r--gcc/lto/lto-partition.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/gcc/lto/lto-partition.c b/gcc/lto/lto-partition.c
index 5b46af9..5e0335e 100644
--- a/gcc/lto/lto-partition.c
+++ b/gcc/lto/lto-partition.c
@@ -286,9 +286,11 @@ add_symbol_to_partition (ltrans_partition part, symtab_node *node)
Be lax about comdats; they may or may not be duplicated and we may
end up in need to duplicate keyed comdat because it has unkeyed alias. */
+
gcc_assert (get_symbol_class (node) == SYMBOL_DUPLICATE
|| DECL_COMDAT (node->decl)
|| !symbol_partitioned_p (node));
+
add_symbol_to_partition_1 (part, node);
}
@@ -401,6 +403,25 @@ node_cmp (const void *pa, const void *pb)
{
const struct cgraph_node *a = *(const struct cgraph_node * const *) pa;
const struct cgraph_node *b = *(const struct cgraph_node * const *) pb;
+
+ /* Profile reorder flag enables function reordering based on first execution
+ of a function. All functions with profile are placed in ascending
+ order at the beginning. */
+
+ if (flag_profile_reorder_functions)
+ {
+ /* Functions with time profile are sorted in ascending order. */
+ if (a->tp_first_run && b->tp_first_run)
+ return a->tp_first_run != b->tp_first_run
+ ? a->tp_first_run - b->tp_first_run
+ : a->order - b->order;
+
+ /* Functions with time profile are sorted before the functions
+ that do not have the profile. */
+ if (a->tp_first_run || b->tp_first_run)
+ return b->tp_first_run - a->tp_first_run;
+ }
+
return b->order - a->order;
}
@@ -487,10 +508,13 @@ lto_balanced_map (void)
get better about minimizing the function bounday, but until that
things works smoother if we order in source order. */
qsort (order, n_nodes, sizeof (struct cgraph_node *), node_cmp);
+
+ if (cgraph_dump_file)
+ for(i = 0; i < n_nodes; i++)
+ fprintf (cgraph_dump_file, "Balanced map symbol order:%s:%u\n", order[i]->name (), order[i]->tp_first_run);
+
if (!flag_toplevel_reorder)
{
- qsort (order, n_nodes, sizeof (struct cgraph_node *), node_cmp);
-
FOR_EACH_VARIABLE (vnode)
if (get_symbol_class (vnode) == SYMBOL_PARTITION)
n_varpool_nodes++;
@@ -855,7 +879,7 @@ may_need_named_section_p (lto_symtab_encoder_t encoder, symtab_node *node)
of the same name in partition ENCODER (or in whole compilation unit if
ENCODER is NULL) and if so, mangle the statics. Always mangle all
conflicting statics, so we reduce changes of silently miscompiling
- asm statemnets referring to them by symbol name. */
+ asm statements referring to them by symbol name. */
static void
rename_statics (lto_symtab_encoder_t encoder, symtab_node *node)