From patchwork Thu Aug 22 05:38:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 1975244 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; unprotected) header.d=HOTMAIL.DE header.i=@HOTMAIL.DE header.a=rsa-sha256 header.s=selector1 header.b=jt7+81H/; 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 4WqBnt5b80z1yYZ for ; Thu, 22 Aug 2024 15:38:42 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EBC2A3860753 for ; Thu, 22 Aug 2024 05:38:38 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazolkn190130002.outbound.protection.outlook.com [IPv6:2a01:111:f403:d200::2]) by sourceware.org (Postfix) with ESMTPS id 6C54B3858C66 for ; Thu, 22 Aug 2024 05:38:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6C54B3858C66 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=hotmail.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=hotmail.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6C54B3858C66 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:d200::2 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1724305100; cv=pass; b=If4lW23bNkBwIkdWtWTmL5bPJ1spUGFl6X+GxGpafjE2Hc9VkOTz+wcxteW0SjBPts0uHmKRc4QKmisjeU/rejz5DG1zWq6ak2nGBbtWIz2J6Ag62k+LH1EAbsxzyn08hXSskq7KpUtk1R4WqS4GRgykulOce39l7IsSPvqjXCM= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1724305100; c=relaxed/simple; bh=4fZjGDTaxY75EnQSSBoAEEDpNAlXfefxmquaIXADK60=; h=DKIM-Signature:Message-ID:Date:To:From:Subject:MIME-Version; b=O29esjQz5JEYh2dczhmKUvFA3f3h9kS8vAKOkkL0XN95eooOs446QXbT0H+BNA8ou3oHaeHWcVb4/DBLmifD8brXbtrAWgI1tW7pPHY5GjtP49oKDt78IR3vV9jlPYW0wk5UwbUuJG0pE5HBbKK/K8K4mTUdWVqiGJbostJoDwU= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LFCIygIWn7MvJLvMF/DJII43XFdX2CdgS9BoiReGVSOFOBZony4781Ip/QVGoVgkDeqWa2cMVwLCLL18xcbyFuntHKJiNqArqFMw7z7qLwX2mI9ZvPIdRcp0VijzhXMmOvPZeqPM/XgWNcAxQKbhKa8vYGJel+60j7wxCly+HKfJDtGHmfWEXCOXSS3zt6hglygtuCEqXLljlcPgMazIxhB9aEJR88leHsHDQk+B+rG3xYE0L1ZIk9S8oaUIkylDoialesFS43/Mx5qS4Jo0IPDRx3nKy1z79kWJEhpxdCRsmt3AucIAgG61bKLheo+2JJAnDK2YcgW9AlqKrCQR7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1wGhtdqIumHTKYAC64+BYE8rdMlLE5xNoEKL5T0KhMw=; b=O0OyaWLjz2kAhEfsVzr3QEp0xmIw1ysHDV54TOHyijD/HbnCeBXLv17hZ2QgYbeAcrVYBopNCIDdfdSPAvTnoGQsSBe0bChTZumgIcFGOesHAJbJUedcB0GgCwrgPqlF2775cMDCTKHeLLfWFAT0/u39NvmBUFxel80XDRCmAfTu7BwpJIHu+ZH5mhUa7QmrfpCIj3OL78Djt7zlZxq7UMhP6PmOx0uIZxHOOUtkqm6ahbP5eKCxjKe6wZ+uN/MFjWnDG2MjvqsPiEcbPk2ZBsAzFIeiXNzKY1KOvSyf5EDzhDwDva1KbCPgDkawyDOjOV1721Ufbuzdh2xEXD+FCw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=HOTMAIL.DE; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1wGhtdqIumHTKYAC64+BYE8rdMlLE5xNoEKL5T0KhMw=; b=jt7+81H/ccsDrU2P0H1dwI7VYIfAf46JjNn0i8YjKBDsnRpb0IgcgTN2Yzcb4t0Q+AH43oTCeID/dZqre0IMRxOln2YMLHecxnnF6tEEtuCWRoBUi8AMe/7E/jGcLAxY6H05fRgoMSdM3LblRLPNMLO94Rn1bZdZOiqv7WSjRgO678FPUa7nELqKyqqkD8V7dnzBSL4aRfVec4qtXslaaCjG2Auh2RDxIOgR9HKkE4mUVbq+A6rLagH6aSDjPLATo89gG6WRqvQJ7lYvKtITyy1reEvNLI9ovQcTwFqtg6+eQuTEU3uJZJSxYOP7Nukso2ISdVms24jBxkPBLFXxMQ== Received: from AS1PR01MB9465.eurprd01.prod.exchangelabs.com (2603:10a6:20b:4d3::20) by PR3PR01MB6908.eurprd01.prod.exchangelabs.com (2603:10a6:102:79::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.18; Thu, 22 Aug 2024 05:38:14 +0000 Received: from AS1PR01MB9465.eurprd01.prod.exchangelabs.com ([fe80::ea10:4661:33e:18c]) by AS1PR01MB9465.eurprd01.prod.exchangelabs.com ([fe80::ea10:4661:33e:18c%7]) with mapi id 15.20.7875.023; Thu, 22 Aug 2024 05:38:14 +0000 Message-ID: Date: Thu, 22 Aug 2024 07:38:16 +0200 User-Agent: Mozilla Thunderbird Content-Language: en-US To: gcc-patches , Richard Biener From: Bernd Edlinger Subject: [PATCH v2] Do not emit a redundant DW_TAG_lexical_block for inlined subroutines X-TMN: [FdXTeGXv1ie9l75bVtVQhxs1JYAu5RkzBzxqqkgOmTaJ79tK6YOVLIA/2wL78D7b] X-ClientProxiedBy: FR0P281CA0164.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:b3::6) To AS1PR01MB9465.eurprd01.prod.exchangelabs.com (2603:10a6:20b:4d3::20) X-Microsoft-Original-Message-ID: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS1PR01MB9465:EE_|PR3PR01MB6908:EE_ X-MS-Office365-Filtering-Correlation-Id: d0866d15-3c43-4ba4-9758-08dcc26c9dfb X-Microsoft-Antispam: BCL:0; ARA:14566002|461199028|19110799003|15080799003|5072599009|8060799006|1602099012|4302099013|3412199025|440099028; X-Microsoft-Antispam-Message-Info: rGMr7z0GUbhsway43Wf2f0tXBznsQ1Kc2e8G2TKK0HLvDamwBSOcSjN8dqpZKUaep19BjgsULjWG8UTgsHSK8W6NOrWsGtIYW/AFTipMWqOVnh8TwAGbxjel9sKTAUV2wflGzSV7d2srsqzkYFq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HlFA8sl?= =?utf-8?q?A+3BWs4VbOKNg7QDnQr+hb3wlqCcaSe1vEm5Nn6QnattV6rQG6Mb1aD3JMtW55nbL?= =?utf-8?q?/LWjAysCTPb1o13kLXUsrJxpKZFOXHKw0vOQ0qvkIBc+rpAoPx7IJOyHduk1sDRPz?= =?utf-8?q?tv+qkQpA9cshlt7/?= X-OriginatorOrg: sct-15-20-7719-20-msonline-outlook-ba98d.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: d0866d15-3c43-4ba4-9758-08dcc26c9dfb X-MS-Exchange-CrossTenant-AuthSource: AS1PR01MB9465.eurprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 05:38:14.5084 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR01MB6908 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 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 While this already works correctly for the case when an inlined subroutine contains only one subrange, a redundant DW_TAG_lexical_block is still emitted when the subroutine has multiple blocks. Fixes: ac02e5b75451 ("re PR debug/37801 (DWARF output for inlined functions doesn't always use DW_TAG_inlined_subroutine)") gcc/ChangeLog: PR debug/87440 * dwarf2out.cc (gen_inlined_subroutine_die): Handle the case of multiple subranges correctly. gcc/testsuite/ChangeLog: * gcc.dg/debug/dwarf2/inline7.c: New test. --- gcc/dwarf2out.cc | 15 ++++++++++++--- gcc/testsuite/gcc.dg/debug/dwarf2/inline7.c | 20 ++++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/inline7.c v2: Addressed review commments, added a testcase. Bootstrapped and regression-tested on x86_64-pc-linux-gnu, OK for trunk? diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc index 357efaa5990..362d695674b 100644 --- a/gcc/dwarf2out.cc +++ b/gcc/dwarf2out.cc @@ -25171,17 +25171,26 @@ gen_inlined_subroutine_die (tree stmt, dw_die_ref context_die) Do that by doing the recursion to subblocks on the single subblock of STMT. */ bool unwrap_one = false; - if (BLOCK_SUBBLOCKS (stmt) && !BLOCK_CHAIN (BLOCK_SUBBLOCKS (stmt))) + tree sub = BLOCK_SUBBLOCKS (stmt); + if (sub) { - tree origin = block_ultimate_origin (BLOCK_SUBBLOCKS (stmt)); + tree origin = block_ultimate_origin (sub); if (origin && TREE_CODE (origin) == BLOCK && BLOCK_SUPERCONTEXT (origin) == decl) unwrap_one = true; + for (tree next = BLOCK_CHAIN (sub); unwrap_one && next; + next = BLOCK_CHAIN (next)) + if (BLOCK_FRAGMENT_ORIGIN (next) != sub) + unwrap_one = false; } decls_for_scope (stmt, subr_die, !unwrap_one); if (unwrap_one) - decls_for_scope (BLOCK_SUBBLOCKS (stmt), subr_die); + { + decls_for_scope (sub, subr_die); + for (sub = BLOCK_CHAIN (sub); sub; sub = BLOCK_CHAIN (sub)) + gen_block_die (sub, subr_die); + } } /* Generate a DIE for a field in a record, or structure. CTX is required: see diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/inline7.c b/gcc/testsuite/gcc.dg/debug/dwarf2/inline7.c new file mode 100644 index 00000000000..48d457216b1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/inline7.c @@ -0,0 +1,20 @@ +/* Verify that both inline instances have a DW_AT_ranges but + no extra DW_TAG_lexical_block. */ +/* { dg-options "-O -gdwarf -dA" } */ +/* { dg-do compile } */ +/* { dg-final { scan-assembler-times "\\(DIE \\(\[^\n\]*\\) DW_TAG_inlined_subroutine" 2 } } */ +/* { dg-final { scan-assembler-times " DW_AT_ranges" 2 } } */ +/* { dg-final { scan-assembler-times "\\(DIE \\(\[^\n\]*\\) DW_TAG_lexical_block" 0 } } */ + +static int foo (int i) +{ + volatile int j = i + 3; + if (j == 3) + return 0; + return j - 2; +} +int main() +{ + volatile int z = foo (-2) && foo (-1); + return z; +}