From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1692609089; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=sI5SHOuNY8dhaEbi/qCbwC+aNli7JgDA2q+V73uX+EI=; b=AhUxwRQIUIGamc8FGxaHfJzD2A5oNA19Nr8xIzefwRis3NBxyc7/oBRgU53A121fjC9Ys4 pvw9tfPlr4bzabopuJwK0DnEW/WVkR9G4kWnJmWvyhMLQnbt1FlOIO4rRUUM13m6IKK9gg nJF2jIIoCz1p9Xi+cI9L8p5/ZQ37b2E= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1692609089; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=sI5SHOuNY8dhaEbi/qCbwC+aNli7JgDA2q+V73uX+EI=; b=GGazuGzStKcYN1YCQdLdI6fZc/aQIDeD4/7mKuQXWK7ZRxs7qyL8F24/XSGlwiFkZ+f6jm 8XOgx+uuYHl2Y3Dw== 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) From: Richard Biener 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 Content-Type: text/plain; charset=US-ASCII 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 List-Id: Message-ID: <20230821091129._PUYxEz5zosbh-mtzgvRRx-s2zHC0xXUujsJeIdWFRM@z> 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" } } */ -- 2.35.3