public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/kubaneko/heads/histogram)] one histogram per loop, commit edges after deleting fake ones
@ 2022-10-12 11:08 Ondrej Kubanek
0 siblings, 0 replies; 3+ messages in thread
From: Ondrej Kubanek @ 2022-10-12 11:08 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:1c52150cb1c65d7b9c91fdaa8d3b5876a10cd58f
commit 1c52150cb1c65d7b9c91fdaa8d3b5876a10cd58f
Author: kubaneko <kubanek0ondrej@gmail.com>
Date: Tue Oct 11 16:42:27 2022 +0000
one histogram per loop, commit edges after deleting fake ones
Diff:
---
gcc/profile.cc | 7 ++-----
gcc/tree-profile.cc | 37 ++++++++++++++-----------------------
gcc/value-prof.cc | 16 +++++-----------
3 files changed, 21 insertions(+), 39 deletions(-)
diff --git a/gcc/profile.cc b/gcc/profile.cc
index 297f335a439..e11042f3ada 100644
--- a/gcc/profile.cc
+++ b/gcc/profile.cc
@@ -926,7 +926,6 @@ compute_value_histograms (histogram_values values, unsigned cfg_checksum,
if (hist->type == HIST_TYPE_HISTOGRAM)
{
- printf("tata");
auto lp = hist->hvalue.lp;
if (act_count[t]){
if (lp->valid_hist)
@@ -1544,7 +1543,6 @@ branch_prob (bool thunk)
}
for (auto loop : loops_list (cfun, 0)){
- printf("fasdfasdfasdf");
if (loop->valid_hist){
printf("%ld %ld %ld %ld", loop->hist[0], loop->hist[1], loop->hist[2], loop->hist[3]);
}
@@ -1566,10 +1564,9 @@ branch_prob (bool thunk)
if (flag_profile_values)
instrument_values (values);
-
- /* Commit changes done by instrumentation. */
- gsi_commit_edge_inserts ();
}
+ /* Commit changes done by instrumentation. */
+ gsi_commit_edge_inserts ();
free_aux_for_edges ();
diff --git a/gcc/tree-profile.cc b/gcc/tree-profile.cc
index 8f259288ec4..95f1f70fd7c 100644
--- a/gcc/tree-profile.cc
+++ b/gcc/tree-profile.cc
@@ -59,6 +59,9 @@ along with GCC; see the file COPYING3. If not see
#include "alloc-pool.h"
#include "symbol-summary.h"
#include "symtab-thunks.h"
+#include "cfgloop.h"
+
+#include "print-tree.h"
static GTY(()) tree gcov_type_node;
static GTY(()) tree tree_interval_profiler_fn;
@@ -353,33 +356,21 @@ gimple_gen_pow2_profiler (histogram_value value, unsigned tag)
gsi_insert_before (&gsi, call, GSI_NEW_STMT);
}
-/* Output instructions as GIMPLE trees to increment the histogram
- counter. VALUE is the expression whose value is profiled. TAG is the tag
- of the section for counters. */
-
void
gimple_gen_histogram_profiler (histogram_value value, unsigned tag) // , edge_def* edge
{
gimple *stmt = value->hvalue.stmt;
- if (stmt){
- gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
- tree ref_ptr = tree_coverage_counter_addr (tag, 0);
- gcall *call;
- tree val;
-
- ref_ptr = force_gimple_operand_gsi (&gsi, ref_ptr,
- true, NULL_TREE, true, GSI_SAME_STMT);
- val = prepare_instrumented_value (&gsi, value);
- call = gimple_build_call (tree_histogram_profiler_fn, 2, ref_ptr, val);
- gsi_insert_before (&gsi, call, GSI_NEW_STMT);
- } else {
- edge_def *edge = value->hvalue.edge;
- gcc_assert(edge);
- tree ref_ptr = tree_coverage_counter_addr (tag, 0);
- gcall *call;
- tree val = prepare_instrumented_value (NULL, value);
- call = gimple_build_call (tree_histogram_profiler_fn, 2, ref_ptr, val);
- gsi_insert_seq_on_edge (edge, call);
+ gcc_assert(!stmt);
+ auto lp = value->hvalue.lp;
+ gcc_assert(lp);
+ tree ref_ptr = tree_coverage_counter_addr (tag, 0);
+ gcall *call;
+ auto_vec<edge> exits = get_loop_exit_edges (lp);
+ for ( auto exit : exits ){
+ if (!(exit->flags & (EDGE_COMPLEX | EDGE_FAKE))) {
+ call = gimple_build_call (tree_histogram_profiler_fn, 2, ref_ptr, value->hvalue.value);
+ gsi_insert_seq_on_edge (exit, call);
+ }
}
}
diff --git a/gcc/value-prof.cc b/gcc/value-prof.cc
index fad7967a869..b600bdc694a 100644
--- a/gcc/value-prof.cc
+++ b/gcc/value-prof.cc
@@ -128,12 +128,12 @@ gimple_alloc_histogram_value (struct function *fun ATTRIBUTE_UNUSED,
histogram_value
gimple_alloc_histogram_value_loop (struct function *fun ATTRIBUTE_UNUSED,
- enum hist_type type, tree value, edge_def *edge, class loop *lp)
+ enum hist_type type, tree value, class loop *lp)
{
+
histogram_value hist = (histogram_value) xcalloc (1, sizeof (*hist));
hist->hvalue.value = value;
hist->hvalue.stmt = NULL;
- hist->hvalue.edge = edge;
hist->hvalue.lp = lp;
hist->type = type;
return hist;
@@ -1937,16 +1937,10 @@ gimple_histogram_values_to_profile(function *fun, histogram_values * values){
gsi = gsi_start_bb (loop->latch);
create_iv (build_int_cst_type (get_gcov_type(), 0), build_int_cst (get_gcov_type(), 1), NULL_TREE,
loop, &gsi, true, &var, NULL);
- auto_vec<edge> exits = get_loop_exit_edges (loop);
- for ( auto exit : exits ){
- if (!(exit->flags & (EDGE_COMPLEX | EDGE_FAKE))) {
- values->safe_push (gimple_alloc_histogram_value_loop (fun,
- HIST_TYPE_HISTOGRAM,
- var, exit, loop));
- }
- }
+ values->safe_push (gimple_alloc_histogram_value_loop (fun,
+ HIST_TYPE_HISTOGRAM,
+ var, loop));
}
- gsi_commit_edge_inserts ();
}
/* Find values inside STMT for that we want to measure histograms and adds
^ permalink raw reply [flat|nested] 3+ messages in thread
* [gcc(refs/users/kubaneko/heads/histogram)] one histogram per loop, commit edges after deleting fake ones
@ 2023-02-23 23:21 Ondrej Kubanek
0 siblings, 0 replies; 3+ messages in thread
From: Ondrej Kubanek @ 2023-02-23 23:21 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:e44325a383dd859323ab8dd9fad15ecfa80a1264
commit e44325a383dd859323ab8dd9fad15ecfa80a1264
Author: kubaneko <kubanek0ondrej@gmail.com>
Date: Tue Oct 11 16:42:27 2022 +0000
one histogram per loop, commit edges after deleting fake ones
Diff:
---
gcc/profile.cc | 7 ++-----
gcc/tree-profile.cc | 37 ++++++++++++++-----------------------
gcc/value-prof.cc | 16 +++++-----------
3 files changed, 21 insertions(+), 39 deletions(-)
diff --git a/gcc/profile.cc b/gcc/profile.cc
index d571791f1a8..ae20af9619e 100644
--- a/gcc/profile.cc
+++ b/gcc/profile.cc
@@ -926,7 +926,6 @@ compute_value_histograms (histogram_values values, unsigned cfg_checksum,
if (hist->type == HIST_TYPE_HISTOGRAM)
{
- printf("tata");
auto lp = hist->hvalue.lp;
if (act_count[t]){
if (lp->valid_hist)
@@ -1546,7 +1545,6 @@ branch_prob (bool thunk)
}
for (auto loop : loops_list (cfun, 0)){
- printf("fasdfasdfasdf");
if (loop->valid_hist){
printf("%ld %ld %ld %ld", loop->hist[0], loop->hist[1], loop->hist[2], loop->hist[3]);
}
@@ -1568,10 +1566,9 @@ branch_prob (bool thunk)
if (flag_profile_values)
instrument_values (values);
-
- /* Commit changes done by instrumentation. */
- gsi_commit_edge_inserts ();
}
+ /* Commit changes done by instrumentation. */
+ gsi_commit_edge_inserts ();
free_aux_for_edges ();
diff --git a/gcc/tree-profile.cc b/gcc/tree-profile.cc
index 1a7c8243427..1f2cc3ab5cc 100644
--- a/gcc/tree-profile.cc
+++ b/gcc/tree-profile.cc
@@ -59,6 +59,9 @@ along with GCC; see the file COPYING3. If not see
#include "alloc-pool.h"
#include "symbol-summary.h"
#include "symtab-thunks.h"
+#include "cfgloop.h"
+
+#include "print-tree.h"
static GTY(()) tree gcov_type_node;
static GTY(()) tree tree_interval_profiler_fn;
@@ -353,33 +356,21 @@ gimple_gen_pow2_profiler (histogram_value value, unsigned tag)
gsi_insert_before (&gsi, call, GSI_NEW_STMT);
}
-/* Output instructions as GIMPLE trees to increment the histogram
- counter. VALUE is the expression whose value is profiled. TAG is the tag
- of the section for counters. */
-
void
gimple_gen_histogram_profiler (histogram_value value, unsigned tag) // , edge_def* edge
{
gimple *stmt = value->hvalue.stmt;
- if (stmt){
- gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
- tree ref_ptr = tree_coverage_counter_addr (tag, 0);
- gcall *call;
- tree val;
-
- ref_ptr = force_gimple_operand_gsi (&gsi, ref_ptr,
- true, NULL_TREE, true, GSI_SAME_STMT);
- val = prepare_instrumented_value (&gsi, value);
- call = gimple_build_call (tree_histogram_profiler_fn, 2, ref_ptr, val);
- gsi_insert_before (&gsi, call, GSI_NEW_STMT);
- } else {
- edge_def *edge = value->hvalue.edge;
- gcc_assert(edge);
- tree ref_ptr = tree_coverage_counter_addr (tag, 0);
- gcall *call;
- tree val = prepare_instrumented_value (NULL, value);
- call = gimple_build_call (tree_histogram_profiler_fn, 2, ref_ptr, val);
- gsi_insert_seq_on_edge (edge, call);
+ gcc_assert(!stmt);
+ auto lp = value->hvalue.lp;
+ gcc_assert(lp);
+ tree ref_ptr = tree_coverage_counter_addr (tag, 0);
+ gcall *call;
+ auto_vec<edge> exits = get_loop_exit_edges (lp);
+ for ( auto exit : exits ){
+ if (!(exit->flags & (EDGE_COMPLEX | EDGE_FAKE))) {
+ call = gimple_build_call (tree_histogram_profiler_fn, 2, ref_ptr, value->hvalue.value);
+ gsi_insert_seq_on_edge (exit, call);
+ }
}
}
diff --git a/gcc/value-prof.cc b/gcc/value-prof.cc
index 3a1dbd90a07..3d7a2a370f1 100644
--- a/gcc/value-prof.cc
+++ b/gcc/value-prof.cc
@@ -127,12 +127,12 @@ gimple_alloc_histogram_value (struct function *fun ATTRIBUTE_UNUSED,
histogram_value
gimple_alloc_histogram_value_loop (struct function *fun ATTRIBUTE_UNUSED,
- enum hist_type type, tree value, edge_def *edge, class loop *lp)
+ enum hist_type type, tree value, class loop *lp)
{
+
histogram_value hist = (histogram_value) xcalloc (1, sizeof (*hist));
hist->hvalue.value = value;
hist->hvalue.stmt = NULL;
- hist->hvalue.edge = edge;
hist->hvalue.lp = lp;
hist->type = type;
return hist;
@@ -1936,16 +1936,10 @@ gimple_histogram_values_to_profile(function *fun, histogram_values * values){
gsi = gsi_start_bb (loop->latch);
create_iv (build_int_cst_type (get_gcov_type(), 0), build_int_cst (get_gcov_type(), 1), NULL_TREE,
loop, &gsi, true, &var, NULL);
- auto_vec<edge> exits = get_loop_exit_edges (loop);
- for ( auto exit : exits ){
- if (!(exit->flags & (EDGE_COMPLEX | EDGE_FAKE))) {
- values->safe_push (gimple_alloc_histogram_value_loop (fun,
- HIST_TYPE_HISTOGRAM,
- var, exit, loop));
- }
- }
+ values->safe_push (gimple_alloc_histogram_value_loop (fun,
+ HIST_TYPE_HISTOGRAM,
+ var, loop));
}
- gsi_commit_edge_inserts ();
}
/* Find values inside STMT for that we want to measure histograms and adds
^ permalink raw reply [flat|nested] 3+ messages in thread
* [gcc(refs/users/kubaneko/heads/histogram)] one histogram per loop, commit edges after deleting fake ones
@ 2023-02-16 16:27 Ondrej Kubanek
0 siblings, 0 replies; 3+ messages in thread
From: Ondrej Kubanek @ 2023-02-16 16:27 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:0f5e1ef359d5c840f73c2ebf78e71968ef6499f9
commit 0f5e1ef359d5c840f73c2ebf78e71968ef6499f9
Author: kubaneko <kubanek0ondrej@gmail.com>
Date: Tue Oct 11 16:42:27 2022 +0000
one histogram per loop, commit edges after deleting fake ones
Diff:
---
gcc/profile.cc | 7 ++-----
gcc/tree-profile.cc | 37 ++++++++++++++-----------------------
gcc/value-prof.cc | 16 +++++-----------
3 files changed, 21 insertions(+), 39 deletions(-)
diff --git a/gcc/profile.cc b/gcc/profile.cc
index 297f335a439..e11042f3ada 100644
--- a/gcc/profile.cc
+++ b/gcc/profile.cc
@@ -926,7 +926,6 @@ compute_value_histograms (histogram_values values, unsigned cfg_checksum,
if (hist->type == HIST_TYPE_HISTOGRAM)
{
- printf("tata");
auto lp = hist->hvalue.lp;
if (act_count[t]){
if (lp->valid_hist)
@@ -1544,7 +1543,6 @@ branch_prob (bool thunk)
}
for (auto loop : loops_list (cfun, 0)){
- printf("fasdfasdfasdf");
if (loop->valid_hist){
printf("%ld %ld %ld %ld", loop->hist[0], loop->hist[1], loop->hist[2], loop->hist[3]);
}
@@ -1566,10 +1564,9 @@ branch_prob (bool thunk)
if (flag_profile_values)
instrument_values (values);
-
- /* Commit changes done by instrumentation. */
- gsi_commit_edge_inserts ();
}
+ /* Commit changes done by instrumentation. */
+ gsi_commit_edge_inserts ();
free_aux_for_edges ();
diff --git a/gcc/tree-profile.cc b/gcc/tree-profile.cc
index 8f259288ec4..95f1f70fd7c 100644
--- a/gcc/tree-profile.cc
+++ b/gcc/tree-profile.cc
@@ -59,6 +59,9 @@ along with GCC; see the file COPYING3. If not see
#include "alloc-pool.h"
#include "symbol-summary.h"
#include "symtab-thunks.h"
+#include "cfgloop.h"
+
+#include "print-tree.h"
static GTY(()) tree gcov_type_node;
static GTY(()) tree tree_interval_profiler_fn;
@@ -353,33 +356,21 @@ gimple_gen_pow2_profiler (histogram_value value, unsigned tag)
gsi_insert_before (&gsi, call, GSI_NEW_STMT);
}
-/* Output instructions as GIMPLE trees to increment the histogram
- counter. VALUE is the expression whose value is profiled. TAG is the tag
- of the section for counters. */
-
void
gimple_gen_histogram_profiler (histogram_value value, unsigned tag) // , edge_def* edge
{
gimple *stmt = value->hvalue.stmt;
- if (stmt){
- gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
- tree ref_ptr = tree_coverage_counter_addr (tag, 0);
- gcall *call;
- tree val;
-
- ref_ptr = force_gimple_operand_gsi (&gsi, ref_ptr,
- true, NULL_TREE, true, GSI_SAME_STMT);
- val = prepare_instrumented_value (&gsi, value);
- call = gimple_build_call (tree_histogram_profiler_fn, 2, ref_ptr, val);
- gsi_insert_before (&gsi, call, GSI_NEW_STMT);
- } else {
- edge_def *edge = value->hvalue.edge;
- gcc_assert(edge);
- tree ref_ptr = tree_coverage_counter_addr (tag, 0);
- gcall *call;
- tree val = prepare_instrumented_value (NULL, value);
- call = gimple_build_call (tree_histogram_profiler_fn, 2, ref_ptr, val);
- gsi_insert_seq_on_edge (edge, call);
+ gcc_assert(!stmt);
+ auto lp = value->hvalue.lp;
+ gcc_assert(lp);
+ tree ref_ptr = tree_coverage_counter_addr (tag, 0);
+ gcall *call;
+ auto_vec<edge> exits = get_loop_exit_edges (lp);
+ for ( auto exit : exits ){
+ if (!(exit->flags & (EDGE_COMPLEX | EDGE_FAKE))) {
+ call = gimple_build_call (tree_histogram_profiler_fn, 2, ref_ptr, value->hvalue.value);
+ gsi_insert_seq_on_edge (exit, call);
+ }
}
}
diff --git a/gcc/value-prof.cc b/gcc/value-prof.cc
index fad7967a869..b600bdc694a 100644
--- a/gcc/value-prof.cc
+++ b/gcc/value-prof.cc
@@ -128,12 +128,12 @@ gimple_alloc_histogram_value (struct function *fun ATTRIBUTE_UNUSED,
histogram_value
gimple_alloc_histogram_value_loop (struct function *fun ATTRIBUTE_UNUSED,
- enum hist_type type, tree value, edge_def *edge, class loop *lp)
+ enum hist_type type, tree value, class loop *lp)
{
+
histogram_value hist = (histogram_value) xcalloc (1, sizeof (*hist));
hist->hvalue.value = value;
hist->hvalue.stmt = NULL;
- hist->hvalue.edge = edge;
hist->hvalue.lp = lp;
hist->type = type;
return hist;
@@ -1937,16 +1937,10 @@ gimple_histogram_values_to_profile(function *fun, histogram_values * values){
gsi = gsi_start_bb (loop->latch);
create_iv (build_int_cst_type (get_gcov_type(), 0), build_int_cst (get_gcov_type(), 1), NULL_TREE,
loop, &gsi, true, &var, NULL);
- auto_vec<edge> exits = get_loop_exit_edges (loop);
- for ( auto exit : exits ){
- if (!(exit->flags & (EDGE_COMPLEX | EDGE_FAKE))) {
- values->safe_push (gimple_alloc_histogram_value_loop (fun,
- HIST_TYPE_HISTOGRAM,
- var, exit, loop));
- }
- }
+ values->safe_push (gimple_alloc_histogram_value_loop (fun,
+ HIST_TYPE_HISTOGRAM,
+ var, loop));
}
- gsi_commit_edge_inserts ();
}
/* Find values inside STMT for that we want to measure histograms and adds
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-23 23:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-12 11:08 [gcc(refs/users/kubaneko/heads/histogram)] one histogram per loop, commit edges after deleting fake ones Ondrej Kubanek
2023-02-16 16:27 Ondrej Kubanek
2023-02-23 23:21 Ondrej Kubanek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).