From patchwork Fri Feb 16 09:14:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 202009 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp390915dyb; Fri, 16 Feb 2024 01:15:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVq/UG8AUCcoKkDDVT8ovvubRWoHmnDyIsQbeQTu6sREsoZWNo9pdR2A5FqyladXNxxvkpjW8yAgR840T+EdKioutawzg== X-Google-Smtp-Source: AGHT+IE+laLVoi9vzqx6de5ntE7iAUitgO4gNAW/lbha5pNdfu2eLlsn8Nc08pgPClmM0IuITl0N X-Received: by 2002:a05:622a:1104:b0:42c:6f82:d852 with SMTP id e4-20020a05622a110400b0042c6f82d852mr5650158qty.24.1708074905481; Fri, 16 Feb 2024 01:15:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708074905; cv=pass; d=google.com; s=arc-20160816; b=ZkkJ+jCw3CdE3dupB5Ux7ZB4NypL9Loym2+X9xJzvQf+JMrXiYdU2Z6HqrHrgBVdLl V84uZVMdJdQYQaprNks0cVJlScIMlXzNFdOyXce23JpQT2okpSkE4lQz2pc6F2FnY12i XdG/iXSnFYVWHvVGuUgg8FuHgxKXf3HrvfdMDRKOvIaaqfFxJofURiwIm1Bx2QIZvDD/ /PmXo7eOLWikql7a3T7KsKu2SyzXwrIe9OawBvJ6ycgzoIkipcwYIhn4QrLUuM+cDnlq QlShuNE2YmxS4s4fTfbwpoUKCAdIKkOy4/ZdPFU2XFWUDZDPOk3BMptFPNHJXWQ4oqly /ASw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:reply-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=KgSn/gayUalg1l/2DPKG0CGalxS+FHNiCFuDyqmm7wk=; fh=0xZT+NBKSeH8qOu04/61f1ZGePpF4jF/gxp331YE14k=; b=qxIuOyxLLY+nhtA/Vp8i38rusprVsbNPMbRH1ZemzIaxyrRYdXeAe5+Bbz8AJXDsum tmn5aLSsyBHAuRYDNF3YqgO8OsWf63JNFMGX/XdxWe9rm0mvkk7zTjcYoqSuPqY7oKI+ 6nou7o+Uv3vn0ihMjifR9pXaIu7LCa3CoU6SG5yL46t3n9EVA2QvS+dZdxYmKvgATDMd GoH6yrtCyhoJEavjc2glMA4bHTdQ4zb/VR2hY5wZ1N6Tq03m+Gn4ONF78hsrZS8o92NP GEB2EyEM2Urw5HnZI9ehDOoLhwhHgnKwjFWeVfvK15jVDTI2fkDuI4unoqdGFqbVrUU5 Yf0w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iJgjwOLt; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id t20-20020ac85314000000b0042dbdd00580si3280294qtn.27.2024.02.16.01.15.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 01:15:05 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iJgjwOLt; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2C0A6385828F for ; Fri, 16 Feb 2024 09:15:05 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 786AD3858C54 for ; Fri, 16 Feb 2024 09:14:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 786AD3858C54 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 786AD3858C54 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708074864; cv=none; b=Hzdb7UIgBQx/7+4P3Xo5s1FJUiojf14m9unKkqux+9uslojy1iIGFgvrbwt+h9zWD2zzzVhAMrgwbJ7m3m4eTaIF25ul/5Fu1JXOxb5HOdbrt89RBYzcAEdWEx2Xxl1GpwIDxFv0F6HyV4j9E2nxr4TwDOYOYQ/IADJq859uIGM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708074864; c=relaxed/simple; bh=Jui+7LwGr5E6kq6QMZTCpOBH9VLUloYBjbBd6/vIddM=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=xxPYY1M+0iPCrK272r0A17+g8ifcGYaXkttSara66Q2HqMRb301znx4PMfhT9xKhYl/a6p98qSLbD0Gc0cP+jHx3QK0JQGn6tf3CrHoDNYUU4bDjxDksosRlOYod9e4kUCxGHopUjYK/QGiF37qFVVKfadKiz/bhg9dNVyimc+w= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708074862; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=KgSn/gayUalg1l/2DPKG0CGalxS+FHNiCFuDyqmm7wk=; b=iJgjwOLt8LkNbIyDNneZoUwqtMpifRfb8+ypaRF2xVDmiqH0+bLGZLhQQLxt5xGsyCWPmw qn5AMCOaPb6elCcUDTxJrQvsPpCbDnH+5FA6rxt6kKB/1bdv1igol37eAm6hgSSJxo853I xi74+WKikckN/4N+7Tkl8PphNtVFbjU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-379-rXgTuGx1N-i7bkiG8OWf-A-1; Fri, 16 Feb 2024 04:14:20 -0500 X-MC-Unique: rXgTuGx1N-i7bkiG8OWf-A-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1BCE983BA87 for ; Fri, 16 Feb 2024 09:14:20 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.8]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D33991C060B1; Fri, 16 Feb 2024 09:14:19 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 41G9EHKs4070378 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 16 Feb 2024 10:14:17 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 41G9EGnF4070377; Fri, 16 Feb 2024 10:14:16 +0100 Date: Fri, 16 Feb 2024 10:14:16 +0100 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] dwarf2out: Emit DW_AT_export_symbols on anon unions/structs [PR113918] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791046352033668486 X-GMAIL-MSGID: 1791046352033668486 Hi! DWARF5 added DW_AT_export_symbols both for use on inline namespaces (where we emit it), but also on anonymous unions/structs (and we didn't emit that attribute there). The following patch fixes it. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2024-02-16 Jakub Jelinek PR debug/113918 * dwarf2out.cc (gen_field_die): Emit DW_AT_export_symbols on anonymous unions or structs for -gdwarf-5 or -gno-strict-dwarf. * c-c++-common/dwarf2/pr113918.c: New test. Jakub --- gcc/dwarf2out.cc.jj 2024-02-10 11:25:09.836476263 +0100 +++ gcc/dwarf2out.cc 2024-02-15 13:38:14.485675460 +0100 @@ -25153,6 +25153,20 @@ gen_field_die (tree decl, struct vlr_con add_accessibility_attribute (decl_die, decl); + /* Add DW_AT_export_symbols to anonymous unions or structs. */ + if ((dwarf_version >= 5 || !dwarf_strict) && DECL_NAME (decl) == NULL_TREE) + if (tree type = member_declared_type (decl)) + { + tree type_id = TYPE_IDENTIFIER (TYPE_MAIN_VARIANT (type)); + if (RECORD_OR_UNION_TYPE_P (type) + && (type_id == NULL_TREE || IDENTIFIER_ANON_P (type_id))) + { + dw_die_ref type_die = lookup_type_die (TYPE_MAIN_VARIANT (type)); + if (type_die && get_AT (type_die, DW_AT_export_symbols) == NULL) + add_AT_flag (type_die, DW_AT_export_symbols, 1); + } + } + /* Equate decl number to die, so that we can look up this decl later on. */ equate_decl_number_to_die (decl, decl_die); } --- gcc/testsuite/c-c++-common/dwarf2/pr113918.c.jj 2024-02-15 13:26:53.935984554 +0100 +++ gcc/testsuite/c-c++-common/dwarf2/pr113918.c 2024-02-15 13:26:48.773055181 +0100 @@ -0,0 +1,33 @@ +/* PR debug/113918 */ +/* { dg-do compile } */ +/* { dg-options "-gdwarf-5 -dA -fno-merge-debug-strings" } */ + +struct S { + union { + int i; + long long j; + }; + struct { + int k; + long long l; + }; + union { + int m; + long long n; + } u; + struct { + int o; + long long p; + } v; +} s; + +int +main () +{ + s.i = 1; + s.k = 2; + s.u.m = 3; + s.v.o = 4; +} + +/* { dg-final { scan-assembler-times "DW_AT_export_symbols" 4 } } */