Hi.
Attempt of the patch is to remove all histograms right after
"profile_estimate" pass. Then nobody should use them. That
will simplify code we'll not need verification and currently
we leaked some histograms till the end of compilation.
Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
Ready to be installed?
Martin
gcc/ChangeLog:
2018-07-31 Martin Liska
* auto-profile.c (afdo_indirect_call): Do not remove
histograms.
* cfgexpand.c (pass_expand::execute): Likewise.
* cgraph.c (release_function_body): Likewise.
* gimple-iterator.c (gsi_replace): Likewise.
(gsi_remove): Likewise.
* ipa-profile.c (ipa_profile_generate_summary):
Release all histograms.
* tree-cfg.c (verify_gimple_in_cfg): Do not
verify histograms.
(move_block_to_fn): Do not remove histograms.
* value-prof.c (gimple_remove_histogram_value):
Remove.
(gimple_remove_stmt_histograms): Likewise.
(visit_hist): Likewise.
(verify_histograms): Likewise.
(gimple_divmod_fixed_value_transform): Do not
remove histograms.
(gimple_mod_pow2_value_transform): Likewise.
(gimple_mod_subtract_transform): Likewise.
(gimple_ic_transform): Likewise.
(gimple_stringops_transform): Likewise.
(stringop_block_profile): Likewise.
(gimple_find_values_to_profile): Do not produce
extra dump file output.
* value-prof.h: Remove declarations.
gcc/testsuite/ChangeLog:
2018-07-31 Martin Liska
* gcc.dg/tree-prof/val-prof-6.c: Do not scan histograms
in optimized dump, it's already removed in that pass.
---
gcc/auto-profile.c | 1 -
gcc/cfgexpand.c | 1 -
gcc/cgraph.c| 2 -
gcc/gimple-iterator.c | 2 -
gcc/ipa-profile.c | 6 +-
gcc/testsuite/gcc.dg/tree-prof/val-prof-6.c | 6 +-
gcc/tree-cfg.c | 2 -
gcc/value-prof.c| 127 +---
gcc/value-prof.h| 3 -
9 files changed, 11 insertions(+), 139 deletions(-)
diff --git a/gcc/auto-profile.c b/gcc/auto-profile.c
index 197fa10e08c..c3b5083f034 100644
--- a/gcc/auto-profile.c
+++ b/gcc/auto-profile.c
@@ -1063,7 +1063,6 @@ afdo_indirect_call (gimple_stmt_iterator *gsi, const icall_target_map ,
= indirect_edge->make_speculative (direct_call,
profile_count::uninitialized ());
new_edge->redirect_call_stmt_to_callee ();
- gimple_remove_histogram_value (cfun, stmt, hist);
inline_call (new_edge, true, NULL, NULL, false);
}
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index d6e3c382085..1dda8e29f99 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -6397,7 +6397,6 @@ pass_expand::execute (function *fun)
/* Expansion is used by optimization passes too, set maybe_hot_insn_p
conservatively to true until they are all profile aware. */
delete lab_rtx_for_bb;
- free_histograms (fun);
construct_exit_block ();
insn_locations_finalize ();
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index d19f1aacab8..c88029c4631 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -1728,8 +1728,6 @@ release_function_body (tree decl)
clear_edges (fn);
fn->cfg = NULL;
}
- if (fn->value_histograms)
- free_histograms (fn);
gimple_set_body (decl, NULL);
/* Struct function hangs a lot of data that would leak if we didn't
removed all pointers to it. */
diff --git a/gcc/gimple-iterator.c b/gcc/gimple-iterator.c
index c0131f3654c..61011f37360 100644
--- a/gcc/gimple-iterator.c
+++ b/gcc/gimple-iterator.c
@@ -445,7 +445,6 @@ gsi_replace (gimple_stmt_iterator *gsi, gimple *stmt, bool update_eh_info)
/* Free all the data flow information for ORIG_STMT. */
gimple_set_bb (orig_stmt, NULL);
- gimple_remove_stmt_histograms (cfun, orig_stmt);
delink_stmt_imm_use (orig_stmt);
gsi_set_stmt (gsi, stmt);
@@ -573,7 +572,6 @@ gsi_remove (gimple_stmt_iterator *i, bool remove_permanently)
close. */
cfun->debug_marker_count--;
require_eh_edge_purge = remove_stmt_from_eh_lp (stmt);
- gimple_remove_stmt_histograms (cfun, stmt);
}
/* Update the iterator and re-wire the links in I->SEQ. */
diff --git a/gcc/ipa-profile.c b/gcc/ipa-profile.c
index f921d1bb6f4..4aa73917274 100644
--- a/gcc/ipa-profile.c
+++ b/gcc/ipa-profile.c
@@ -216,8 +216,6 @@ ipa_profile_generate_summary (void)
e->indirect_info->common_target_probability = REG_BR_PROB_BASE;
}
}
- gimple_remove_histogram_value (DECL_STRUCT_FUNCTION (node->decl),
- stmt, h);
}
}
time += estimate_num_insns (stmt, _time_weights);
@@ -228,6 +226,10 @@ ipa_profile_generate_summary (void)
time, size);
}
histogram.qsort (cmp_counts);
+
+ /* Remove all