From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7840) id 78C6F396DC2F; Tue, 3 Aug 2021 21:38:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 78C6F396DC2F MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Eugene Rozenfeld To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-2711] Fix indirect call inlining with AutoFDO X-Act-Checkin: gcc X-Git-Author: Eugene Rozenfeld X-Git-Refname: refs/heads/master X-Git-Oldrev: 9265b378531391498ec1727f67a45da72a6c07e9 X-Git-Newrev: 285aa6895d479bed8e72ad363290846645b6faa0 Message-Id: <20210803213838.78C6F396DC2F@sourceware.org> Date: Tue, 3 Aug 2021 21:38:38 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Aug 2021 21:38:38 -0000 https://gcc.gnu.org/g:285aa6895d479bed8e72ad363290846645b6faa0 commit r12-2711-g285aa6895d479bed8e72ad363290846645b6faa0 Author: Eugene Rozenfeld Date: Mon Aug 2 18:36:09 2021 -0700 Fix indirect call inlining with AutoFDO The histogram value for indirect calls was incorrectly set up. That is fixed now. With this change the tree-prof tests checking indirect call inlining with AutoFDO in gcc.dg and g++.dg are passing. Resolves: PR gcov-profile/71672 - inlining indirect calls does not work with autofdo gcc/ChangeLog: PR gcov-profile/71672 * auto-profile.c (afdo_indirect_call): Fix setup of the historgram value for indirect calls. Diff: --- gcc/auto-profile.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/gcc/auto-profile.c b/gcc/auto-profile.c index b23b82b2df4..4c1fc6b536b 100644 --- a/gcc/auto-profile.c +++ b/gcc/auto-profile.c @@ -1009,13 +1009,18 @@ afdo_indirect_call (gimple_stmt_iterator *gsi, const icall_target_map &map, histogram_value hist = gimple_alloc_histogram_value ( cfun, HIST_TYPE_INDIR_CALL, stmt, callee); - hist->n_counters = 3; + hist->n_counters = 4; hist->hvalue.counters = XNEWVEC (gcov_type, hist->n_counters); gimple_add_histogram_value (cfun, stmt, hist); - hist->hvalue.counters[0] = direct_call->profile_id; - hist->hvalue.counters[1] = max_iter->second; - hist->hvalue.counters[2] = total; + // Total counter + hist->hvalue.counters[0] = total; + // Number of value/counter pairs + hist->hvalue.counters[1] = 1; + // Value + hist->hvalue.counters[2] = direct_call->profile_id; + // Counter + hist->hvalue.counters[3] = max_iter->second; if (!transform) return;