From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7880) id 1B35C3857026; Thu, 23 Feb 2023 23:21:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1B35C3857026 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677194502; bh=4e5Ts3/Q676f2HtoGD46KMSAILlgSIp8jaM4CjZmm/c=; h=From:To:Subject:Date:From; b=IMAh2uij/joglErbHB6FXqIP8pS3LV+ZvPzmDF4vTH+rDTD4L0DWnbxD6icd1EpXd M5L/4ekB3ESEAYgSNwCSeQPuNoJ0bhcwIXK0669E9duirkySayEjRapqX2PfuPLsWY 2ekzPfbirJVuABqQuhqPgXhi0wxNnsOJMcuqvCP4= 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: 158017f839421c3b8b337fa400224bb0c3f3db02 X-Git-Newrev: e44325a383dd859323ab8dd9fad15ecfa80a1264 Message-Id: <20230223232142.1B35C3857026@sourceware.org> Date: Thu, 23 Feb 2023 23:21:42 +0000 (GMT) List-Id: https://gcc.gnu.org/g:e44325a383dd859323ab8dd9fad15ecfa80a1264 commit e44325a383dd859323ab8dd9fad15ecfa80a1264 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 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 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 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