From patchwork Tue Apr 19 19:28:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Trofimovich X-Patchwork-Id: 53046 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 41C043857823 for ; Tue, 19 Apr 2022 19:28:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 41C043857823 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1650396533; bh=siR+zlnAHPbGcuHithfVSbGO/ffOk5NlKRxGuRRfInI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=jA7hGftFyljJ5INjvefYLsax/Y64tTiuY2ynK9GlLoSIzIQnv2m/tu1veV95yjaMi cJNgy2j7UCcXbKOR1Z8MTBP/df2gW67mm0aAqz58UxTtKns+myJogh/dRZiCLKfr3E HCs0WVQLEW3Od+YsRYuYl0v29LNcRpHBeNLvZGmI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id ACE053858D3C for ; Tue, 19 Apr 2022 19:28:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org ACE053858D3C Received: by mail-wm1-x335.google.com with SMTP id o20-20020a05600c511400b0038ebbbb2ad8so2197973wms.0 for ; Tue, 19 Apr 2022 12:28:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=siR+zlnAHPbGcuHithfVSbGO/ffOk5NlKRxGuRRfInI=; b=mwpIKjPsc28vXA61Z5AfEv+bj55ujwESV677BPCxaixnASzo+EYknHW1UIg6YsYPs6 WeTZnj6ON7+u2RbAY9e0370R2IRd40c+RWZ6+L5W2kqG/UKIZNnFI/HoJyCFkqFamsc3 oQ75NJ79j7w7QHgQFXKPYPrQNhtjijwLqXJ+K6fjxdIYMo66i1OtCTHyIMFuH5k46Ksy i6ZnyoWD68dj//a57b39EMkH3YOaNS/ZYWZ8MrHZAh5J6anu9UAyVpFkR5q1Bv9ACphD DN3841TJL9qlpYIRE8BEqd8prU4DTDMDTAAezQQCUNhtBhCovSv23QG9m8qsrVtLmZ/S nxwQ== X-Gm-Message-State: AOAM530iYUOxIyQbuXzmviX+dkQBEa97O3QDeHk7JxD/cU0299/GZydF UoIXFnVCSCuuMnbCPvstEio= X-Google-Smtp-Source: ABdhPJx86PoRybcv3TidJ+6kjWF5AK49xnszuMz42qOJ93vhnt46dCFk8cnJnT0ZaXjYLPolGp25og== X-Received: by 2002:a05:600c:3d06:b0:38e:d74d:ac4c with SMTP id bh6-20020a05600c3d0600b0038ed74dac4cmr145291wmb.42.1650396502480; Tue, 19 Apr 2022 12:28:22 -0700 (PDT) Received: from nz.home (host81-147-8-147.range81-147.btcentralplus.com. [81.147.8.147]) by smtp.gmail.com with ESMTPSA id m8-20020a056000008800b00207b3fa7fc0sm14939787wrx.108.2022.04.19.12.28.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 12:28:22 -0700 (PDT) Received: by nz.home (Postfix, from userid 1000) id 5DCA42DF9F164; Tue, 19 Apr 2022 20:28:21 +0100 (BST) To: gcc-patches@gcc.gnu.org Subject: [PATCH, gcc-11 backport] gcov-profile: Allow negative counts of indirect calls [PR105282] Date: Tue, 19 Apr 2022 20:28:05 +0100 Message-Id: <20220419192805.1328115-1-slyich@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Sergei Trofimovich via Gcc-patches From: Sergei Trofimovich Reply-To: Sergei Trofimovich Cc: Jan Hubicka , Sergei Trofimovich , Nathan Sidwell Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" From: Sergei Trofimovich 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.cc:340 gcc/ChangeLog: PR gcov-profile/105282 * value-prof.cc (stream_out_histogram_value): Allow negative counts on HIST_TYPE_INDIR_CALL. (cherry picked from commit 90a29845bfe7d6002e6c2fd49a97820b00fbc4a3) --- 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);