From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1851) id CB8293838016; Thu, 21 Apr 2022 09:27:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CB8293838016 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Martin Liska To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-9896] gcov-profile: Allow negative counts of indirect calls [PR105282] X-Act-Checkin: gcc X-Git-Author: Sergei Trofimovich X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: 1eee4e08a64f6e931b0c5dd1bb854a2b7ad3d58f X-Git-Newrev: 7b879564ec2bda6b5441fbaf231d70ec6359db01 Message-Id: <20220421092744.CB8293838016@sourceware.org> Date: Thu, 21 Apr 2022 09:27:44 +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: Thu, 21 Apr 2022 09:27:44 -0000 https://gcc.gnu.org/g:7b879564ec2bda6b5441fbaf231d70ec6359db01 commit r11-9896-g7b879564ec2bda6b5441fbaf231d70ec6359db01 Author: Sergei Trofimovich Date: Fri Apr 15 08:35:27 2022 +0100 gcov-profile: Allow negative counts of indirect calls [PR105282] TOPN metrics are histograms that contain overall count and per-bucket count. Overall count can be negative when two profiles merge and some of per-bucket metrics are disacarded. Noticed as an ICE on python PGO build where gcc crashes as: during IPA pass: modref a.c:36:1: ICE: in stream_out_histogram_value, at value-prof.cc:340 36 | } | ^ stream_out_histogram_value(output_block*, histogram_value_t*) gcc/value-prof.c:340 gcc/ChangeLog: PR gcov-profile/105282 * value-prof.c (stream_out_histogram_value): Allow negative counts on HIST_TYPE_INDIR_CALL. (cherry picked from commit 90a29845bfe7d6002e6c2fd49a97820b00fbc4a3) Diff: --- gcc/value-prof.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gcc/value-prof.c b/gcc/value-prof.c index 42748771192..688089b04d2 100644 --- a/gcc/value-prof.c +++ b/gcc/value-prof.c @@ -336,6 +336,10 @@ stream_out_histogram_value (struct output_block *ob, histogram_value hist) /* Note that the IOR counter tracks pointer values and these can have sign bit set. */ ; + else if (hist->type == HIST_TYPE_INDIR_CALL && i == 0) + /* 'all' counter overflow is stored as a negative value. Individual + counters and values are expected to be non-negative. */ + ; else gcc_assert (value >= 0);