From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7880) id EF4623851151; Wed, 12 Oct 2022 11:08:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EF4623851151 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665572919; bh=ArLmlltxzv+anfRGIgEnB30N7HftEFCKgsSI5zRTC6E=; h=From:To:Subject:Date:From; b=Y/RRibDR6+5Nc45DyDIbgvAxP6K/ziRO33Z5pIpyFUX9M+ESfrluk8hMFOKEmox1i eZbU6ek5pFg12its93zAME4pX1hDIRJbKG4uqOThR9+YUxZCgjXHIFDGUEomBB3TEC 1AmP0wFR7nr0Ct6uc8m+AQ/XKtDk+J8MjUZiCaeA= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Ondrej Kubanek To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/kubaneko/heads/histogram)] one histogram per loop, commit edges after deleting fake ones X-Act-Checkin: gcc X-Git-Author: kubaneko X-Git-Refname: refs/users/kubaneko/heads/histogram X-Git-Oldrev: 97ceb05c9251922d918c8eb7d9a267d120b48323 X-Git-Newrev: 1c52150cb1c65d7b9c91fdaa8d3b5876a10cd58f Message-Id: <20221012110839.EF4623851151@sourceware.org> Date: Wed, 12 Oct 2022 11:08:39 +0000 (GMT) List-Id: https://gcc.gnu.org/g:1c52150cb1c65d7b9c91fdaa8d3b5876a10cd58f commit 1c52150cb1c65d7b9c91fdaa8d3b5876a10cd58f Author: kubaneko 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 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 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