From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7880) id C15CF385AC39; Thu, 16 Feb 2023 16:27:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C15CF385AC39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676564860; bh=wLvXHE75yCHTG6OJfal5ub9k01chYiO4KU76PQ4UKRo=; h=From:To:Subject:Date:From; b=tLLBpcHJB6iK2VmDlHSAj7hS2UUs/dFnJ0JiNH8GAvLV8KetT6lFE7gH8Qw//n3UL GXUIH1oD2+yc78yq+Ucdf6IgVJzwO9A7C/AKHiVART+xdzOGhoyiwxMKVA9mSqLT7C Gdeu1fwu70R7TzTxMFO3ls9BFxGYQC/4pZOh1LoM= 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)] fixed loading found another bug X-Act-Checkin: gcc X-Git-Author: kubaneko X-Git-Refname: refs/users/kubaneko/heads/histogram X-Git-Oldrev: d509294a9407550b32cb4f4fb0edada22f3f5785 X-Git-Newrev: 4d451bad79dfe9ccaa0bafca461f65d7c28b720c Message-Id: <20230216162740.C15CF385AC39@sourceware.org> Date: Thu, 16 Feb 2023 16:27:40 +0000 (GMT) List-Id: https://gcc.gnu.org/g:4d451bad79dfe9ccaa0bafca461f65d7c28b720c commit 4d451bad79dfe9ccaa0bafca461f65d7c28b720c Author: kubaneko Date: Mon Sep 26 21:51:35 2022 +0000 fixed loading found another bug Diff: --- gcc/profile.cc | 33 +++++++++++++++++++++++++++++++++ gcc/tree-ssa-loop-ivcanon.cc | 2 +- gcc/value-prof.cc | 40 +++------------------------------------- 3 files changed, 37 insertions(+), 38 deletions(-) diff --git a/gcc/profile.cc b/gcc/profile.cc index b9c355f2030..987b764baf5 100644 --- a/gcc/profile.cc +++ b/gcc/profile.cc @@ -919,6 +919,31 @@ compute_value_histograms (histogram_values values, unsigned cfg_checksum, bool topn_p = (hist->type == HIST_TYPE_TOPN_VALUES || hist->type == HIST_TYPE_INDIR_CALL); + + /* Histogram profiler counter is not related to any statement, + so that we have to read the counter and set the value to + the corresponding loop */ + + if (hist->type == HIST_TYPE_HISTOGRAM) + { + printf("tata"); + auto lp = hist->hvalue.lp; + if (act_count[t]){ + if (lp->valid_hist) + { + for (int i=0;i<69;++i){ + lp->hist[i]+=act_count[t][i]; + } + } else { + lp->valid_hist = true; + for (int i=0;i<69;++i){ + lp->hist[i]=act_count[t][i]; + } + } + } + continue; + } + /* TOP N counter uses variable number of counters. */ if (topn_p) { @@ -954,6 +979,7 @@ compute_value_histograms (histogram_values values, unsigned cfg_checksum, hist->hvalue.counters[j] = 0; } + /* Time profiler counter is not related to any statement, so that we have to read the counter and set the value to the corresponding call graph node. */ @@ -1514,6 +1540,13 @@ branch_prob (bool thunk) compute_value_histograms (values, cfg_checksum, lineno_checksum); } + 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]); + } + } + remove_fake_edges (); /* For each edge not on the spanning tree, add counting code. */ diff --git a/gcc/tree-ssa-loop-ivcanon.cc b/gcc/tree-ssa-loop-ivcanon.cc index 766bffa0274..2454600d138 100644 --- a/gcc/tree-ssa-loop-ivcanon.cc +++ b/gcc/tree-ssa-loop-ivcanon.cc @@ -1162,6 +1162,7 @@ canonicalize_loop_induction_variables (class loop *loop, bool create_iv, enum unroll_level ul, bool try_eval, bool allow_peel) { + edge exit = NULL; tree niter; HOST_WIDE_INT maxiter; @@ -1273,7 +1274,6 @@ canonicalize_loop_induction_variables (class loop *loop, if (iv_niter) create_canonical_iv (loop, exit, iv_niter); } - if (ul == UL_ALL) modified |= try_peel_loop (loop, exit, niter, may_be_zero, maxiter); diff --git a/gcc/value-prof.cc b/gcc/value-prof.cc index fe3d87a3108..c4dbd0226b5 100644 --- a/gcc/value-prof.cc +++ b/gcc/value-prof.cc @@ -267,7 +267,7 @@ dump_histogram_value (FILE *dump_file, histogram_value hist) break; case HIST_TYPE_HISTOGRAM: if (hist->hvalue.counters){ - for (int i=0; i<8; ++i){ + for (int i=0; i<=8; ++i){ fprintf (dump_file, "Histogram counter histogram%" PRId64 ":%" PRId64 ".\n", (int64_t) i, @@ -277,7 +277,7 @@ dump_histogram_value (FILE *dump_file, histogram_value hist) fprintf (dump_file, "Histogram counter histogram%" PRId64 ":%" PRId64 ".\n", (int64_t) 1>>i, - (int64_t) hist->hvalue.counters[4+i]); + (int64_t) hist->hvalue.counters[5+i]); } } break; @@ -634,39 +634,6 @@ check_counter (gimple *stmt, const char * name, return false; } -static bool -gimple_loop_histogram_transform (gimple_stmt_iterator *si) -{ - histogram_value histogram; - gassign *stmt; - - stmt = dyn_cast (gsi_stmt (*si)); - histogram = gimple_histogram_value_of_type (cfun, stmt, HIST_TYPE_HISTOGRAM); - debug_gimple_stmt (stmt); - if (!histogram) - return false; - - gcov_type *counter = histogram->hvalue.counters; - auto lp = histogram->hvalue.lp; - - if (lp->valid_hist){ - for (int i=0;i<69;++i){ - lp->hist[i]+=counter[i]; - } - } else { - lp->valid_hist = true; - for (int i=0;i<69;++i){ - lp->hist[i]=counter[i]; - } - } - - gimple_remove_histogram_value (cfun, stmt, histogram); - - update_stmt (gsi_stmt (*si)); - - return true; -} - /* GIMPLE based transformations. */ bool @@ -702,8 +669,7 @@ gimple_value_profile_transformations (void) if (gimple_mod_subtract_transform (&gsi) || gimple_divmod_fixed_value_transform (&gsi) || gimple_mod_pow2_value_transform (&gsi) - || gimple_stringops_transform (&gsi) - || gimple_loop_histogram_transform (&gsi)) + || gimple_stringops_transform (&gsi)) { stmt = gsi_stmt (gsi); changed = true;