From patchwork Mon Aug 21 09:11:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 136353 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp2876807vqi; Mon, 21 Aug 2023 02:12:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGp2OkRkrsNlZVHXkf2RfM4AOZJgGY9eEZ87sI3TcxLpeLFZ2qi/dYRpIqGGZsIYamZpXT6 X-Received: by 2002:aa7:c754:0:b0:523:4933:b024 with SMTP id c20-20020aa7c754000000b005234933b024mr4210761eds.14.1692609148087; Mon, 21 Aug 2023 02:12:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692609148; cv=none; d=google.com; s=arc-20160816; b=w9B6IKDKxsggbI8DAAZlW13qe5IjAdWeEmAcU71ol7Po42H81d4QQi4/BTIabb4oZS pyIoLhJsj3siZYQbA07QReNVJKMCOOHGy85+rCQAQDohCjXsLKS5SF7i1VTR3wLkx5Oc 7byo8wBnX8SKX3wGg5njkxufBx4swn22+0YMnZyogqiMCmOH8PKCsS94oIczAhOyaIEF BR0BRNVcuWuB43LbcKad4l5tzOngFtdvGW58F0FYb0QuF1OubR6qQS49K7Vi7y+oo5/f 8np/Aiun6Am8Qz9Y9FjdihiYO4+NGfn1GSXmdwbcs9URdUZGpJzn6JMajnkCdijXszqL vQWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:sender:errors-to:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:user-agent:subject:cc:to:date:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=sI5SHOuNY8dhaEbi/qCbwC+aNli7JgDA2q+V73uX+EI=; fh=MVcEVG+ug4ZJdUg0yPKniAExbADwGuuIfw2a8/iPR70=; b=s08/ykMmeBGXaa4KWwQdcyIb1NPiAXPZdz4hPzV+SjuX5RJn5LNx3dafhkAXyMy5En Jq6d/GJqKyO2ygsKO2i0J/PDkre6WnDGPhgn+fljNi41OfCaPEPk5iDdsJscpXFnPIV9 yc/7ijNadg90w0EmKuo3UDbSaeBMnllwFJ39ZEqh87L/NHJSbxtdCGq7pETHUdf2IImm hAvBRQatjNjRhW1nUx//HwnVmHDKq4JaQkBVLmmLtPaxn3US2tHSfRzEJah2pxDWvcZQ QHFWXB57VabaKDLByeOgbnMxANWA0ofkBumC22E1RpGlfdCl6g9tczo0JzL9vqYFEKXK 342A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Rtzny7+3; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id t9-20020a056402020900b00523280b647bsi5066303edv.629.2023.08.21.02.12.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Aug 2023 02:12:28 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Rtzny7+3; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0E895385773C for ; Mon, 21 Aug 2023 09:12:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0E895385773C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1692609147; bh=sI5SHOuNY8dhaEbi/qCbwC+aNli7JgDA2q+V73uX+EI=; h=Date:To:cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=Rtzny7+393HXtN9YWMJ9Am6xu2FQlIAwFUNAC2q8CsYIz3gFj3WZ9iOJ+uzkDQ4M+ 9emH9T2yzjSllu6f5zAFGVNFFW99AeamfuMuw3jza/H4FrQgxUE/BSHI0XdZxR3yF1 ke4wl/DCRDmy+Bfo6oV3Gd8nZZcmo5qDBFZ5Qr9c= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 9C0A2385771C for ; Mon, 21 Aug 2023 09:11:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9C0A2385771C Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id BC607205CE; Mon, 21 Aug 2023 09:11:29 +0000 (UTC) Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id B3DF32C143; Mon, 21 Aug 2023 09:11:29 +0000 (UTC) Date: Mon, 21 Aug 2023 09:11:29 +0000 (UTC) To: gcc-patches@gcc.gnu.org cc: jason@redhat.com Subject: [PATCH] debug/111080 - avoid outputting debug info for unused restrict qualified type User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MISSING_MID, SPF_HELO_NONE, SPF_PASS, TXREP 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" Message-Id: <20230821091227.0E895385773C@sourceware.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774829330051438448 X-GMAIL-MSGID: 1774829330051438448 The following applies some maintainance with respect to type qualifiers and kinds added by later DWARF standards to prune_unused_types_walk. The particular case in the bug is not handling (thus marking required) all restrict qualified type DIEs. I've found more DW_TAG_*_type that are unhandled, looked up the DWARF docs and added them as well based on common sense. Bootstrapped and tested on x86_64-unknown-linux-gnu, OK? Thanks, Richard. PR debug/111080 * dwarf2out.cc (prune_unused_types_walk): Handle DW_TAG_restrict_type, DW_TAG_shared_type, DW_TAG_atomic_type, DW_TAG_immutable_type, DW_TAG_coarray_type, DW_TAG_unspecified_type and DW_TAG_dynamic_type as to only output them when referenced. * gcc.dg/debug/dwarf2/pr111080.c: New testcase. --- gcc/dwarf2out.cc | 7 +++++++ gcc/testsuite/gcc.dg/debug/dwarf2/pr111080.c | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/pr111080.c diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc index fa0fe4c41bb..69018bde238 100644 --- a/gcc/dwarf2out.cc +++ b/gcc/dwarf2out.cc @@ -30141,8 +30141,13 @@ prune_unused_types_walk (dw_die_ref die) case DW_TAG_reference_type: case DW_TAG_rvalue_reference_type: case DW_TAG_volatile_type: + case DW_TAG_restrict_type: + case DW_TAG_shared_type: + case DW_TAG_atomic_type: + case DW_TAG_immutable_type: case DW_TAG_typedef: case DW_TAG_array_type: + case DW_TAG_coarray_type: case DW_TAG_friend: case DW_TAG_enumeration_type: case DW_TAG_subroutine_type: @@ -30151,6 +30156,8 @@ prune_unused_types_walk (dw_die_ref die) case DW_TAG_subrange_type: case DW_TAG_ptr_to_member_type: case DW_TAG_file_type: + case DW_TAG_unspecified_type: + case DW_TAG_dynamic_type: /* Type nodes are useful only when other DIEs reference them --- don't mark them. */ /* FALLTHROUGH */ diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/pr111080.c b/gcc/testsuite/gcc.dg/debug/dwarf2/pr111080.c new file mode 100644 index 00000000000..3949d7e7c64 --- /dev/null +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/pr111080.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-save-temps -gdwarf-3 -dA" } */ + +struct foo { + int field_number_1; + int field_number_2; + int field_number_3; + int field_number_4; + int field_number_5; +}; + +typedef int fun_t(struct foo *restrict); + +int main() { + return 0; +} + +/* { dg-final { scan-assembler-not "DW_TAG_structure_type" } } */