From patchwork Thu Jul 11 07:17:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?J=C3=B8rgen_Kvalsvik?= X-Patchwork-Id: 1959107 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=kolabnow.com header.i=@kolabnow.com header.a=rsa-sha256 header.s=dkim20240523 header.b=A0vcD78T; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WKQzv5DBcz1xqr for ; Thu, 11 Jul 2024 17:18:03 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EDBFC3861809 for ; Thu, 11 Jul 2024 07:18:01 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx.kolabnow.com (mx.kolabnow.com [212.103.80.155]) by sourceware.org (Postfix) with ESMTPS id 0EACD3858D28 for ; Thu, 11 Jul 2024 07:17:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0EACD3858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=lambda.is Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=lambda.is ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0EACD3858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=212.103.80.155 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720682261; cv=none; b=PyWokJpwECm0JS9vEwQ3OUqRd+JJCmWwZpBr7xwiYHg7HciY0AHvBoheHNCbBgWEdPqXh92dgMyJ+woQr7STaLHhsQErOjPm3ohol+K0j9MefzrMKV2T5Gf0MWV80ENRvdPkzYXlanZcgfhKMJ9irDPwOr3iK5V4iJKPUvNv4xw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720682261; c=relaxed/simple; bh=i1qVWbh1A9F379GNjJFy++sj3Yf6IJhPjgQsIxrpwG8=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=ujA76f95B+FRdWltEFG7ChuF3+AZ94mzSCwXIQZ4nQhzk0QdtpcLKhHp76GpoX6wjNIxdtHf+JOy6L2X1bMP0pPr8qslsoSCW5OyTYkUzhQ1HCHYEVSIHFyYZ5Com8hC8s6uL3uXLXWUYGVAqydoz804buz/6swRgxJIcLoZA4w= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from localhost (unknown [127.0.0.1]) by mx.kolabnow.com (Postfix) with ESMTP id 209CE20E5A99; Thu, 11 Jul 2024 09:17:38 +0200 (CEST) Authentication-Results: ext-mx-out011.mykolab.com (amavis); dkim=pass (2048-bit key) reason="pass (just generated, assumed good)" header.d=kolabnow.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kolabnow.com; h= content-transfer-encoding:mime-version:message-id:date:date :subject:subject:from:from:received:received:received; s= dkim20240523; t=1720682255; x=1722496656; bh=C3h8MAYI3Dlt3AYlMt4 q86ImJ9sU+Y5aQSsTEIWDlsA=; b=A0vcD78TZZH6HbLc2bOMoHMDkq4+l5cZFjS 7lc0NSx7diJkz82jimk1zyrCxZtEXp0wtYxEDWyq1dfPGY96oJZpfhgHYv9PXwQf JjSl+MQdW3t4QlayyiyBQN2yc5fDBtQWUj00lOmfXrdmo2KfsouGatJ0XuhNP33D N6jETKfcRbwXVgMCvVASvGQgMJJn6kVGWq2cCRGbe65NEE74wrXbWJnI6VO+bE3h iuk2N5cOhaT5X3k3Y6uEKxG9T0x8cYYf2CyrFwV6jGO2FnZgs8KQ+wO/WayzDYTs aBDJopf2byArnbKHq+5C7HgW8JNx74SLicwQSFg6A3wfk0CRmxw== X-Virus-Scanned: amavis at mykolab.com X-Spam-Score: -0.999 X-Spam-Level: X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 Received: from mx.kolabnow.com ([127.0.0.1]) by localhost (ext-mx-out011.mykolab.com [127.0.0.1]) (amavis, port 10024) with ESMTP id 9S0obUIkZLRO; Thu, 11 Jul 2024 09:17:35 +0200 (CEST) Received: from int-mx011.mykolab.com (unknown [10.9.13.11]) by mx.kolabnow.com (Postfix) with ESMTPS id 2FC6420E5A80; Thu, 11 Jul 2024 09:17:35 +0200 (CEST) Received: from ext-subm010.mykolab.com (unknown [10.9.6.10]) by int-mx011.mykolab.com (Postfix) with ESMTPS id F0DF63073F54; Thu, 11 Jul 2024 09:17:34 +0200 (CEST) From: =?utf-8?q?J=C3=B8rgen_Kvalsvik?= To: gcc-patches@gcc.gnu.org Cc: hubicka@ucw.cz, =?utf-8?q?J=C3=B8rgen_Kvalsvik?= Subject: [pushed] Ensure function.end_line in source_info.lines Date: Thu, 11 Jul 2024 09:17:24 +0200 Message-Id: <20240711071725.2485482-1-j@lambda.is> MIME-Version: 1.0 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Ensure that the function.end_line in the lines vector for the source file, even if it is not explicitly touched by a basic block. This ensures consistency with what you would expect. For example, this file has sources[sum.cc].lines.size () == 23 and main.end_line == 2 without adjusting sources.lines, which in this case is a no-op. #####: 17:int main () -: 18:{ #####: 19: sum (1, 2); #####: 20: sum (1.1, 2); #####: 21: sum (2.2, 2.3); #####: 22:} This is a useful property when combined with selective reporting. gcc/ChangeLog: * gcov.cc (process_all_functions): Ensure fn.end_line is included source[fn].lines. --- gcc/gcov.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gcc/gcov.cc b/gcc/gcov.cc index 2e4bd9d3c5d..7b4a075c5db 100644 --- a/gcc/gcov.cc +++ b/gcc/gcov.cc @@ -1544,6 +1544,12 @@ process_all_functions (void) } } + /* Make sure to include the last line for this function even when it + is not directly covered by a basic block, for example when } is on + its own line. */ + if (sources[fn->src].lines.size () <= fn->end_line) + sources[fn->src].lines.resize (fn->end_line + 1); + /* Allocate lines for group function, following start_line and end_line information of the function. */ if (fn->is_group)