public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Ondrej Kubanek <kubaneko@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/kubaneko/heads/histogram)] one histogram per loop, commit edges after deleting fake ones Date: Thu, 16 Feb 2023 16:27:50 +0000 (GMT) [thread overview] Message-ID: <20230216162750.E978B3858028@sourceware.org> (raw) 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
next reply other threads:[~2023-02-16 16:27 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-02-16 16:27 Ondrej Kubanek [this message] -- strict thread matches above, loose matches on Subject: below -- 2023-02-23 23:21 Ondrej Kubanek 2022-10-12 11:08 Ondrej Kubanek
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230216162750.E978B3858028@sourceware.org \ --to=kubaneko@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).