From patchwork Thu Feb 29 12:10:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 208333 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp346771dyb; Thu, 29 Feb 2024 04:11:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXDsm0uBHw9/RfIvoQ6NGlnKC/OtmBg/lPAf91AJiO7ljb+VbhZl8XNvgHCsgcsnHWgf+r1koK/bIM0g64b68bDIVSnww== X-Google-Smtp-Source: AGHT+IEuKT2EIRcQqbyz2docE6RAUt+JXUYgG38Yce52GGDwNbkIn0woOYK8vIJDaJdusBBZHUwX X-Received: by 2002:ac8:5f47:0:b0:42e:7fd6:9dc5 with SMTP id y7-20020ac85f47000000b0042e7fd69dc5mr2614932qta.22.1709208701658; Thu, 29 Feb 2024 04:11:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709208701; cv=pass; d=google.com; s=arc-20160816; b=O/f9WJVDwexDkpiESUFTbfv2DIrIIKbUABXdAdeYfT6DodUFNMWxG2T8VYXYkDNzY7 NLW9njaR9b/06eZdawy9URAnw6oiBXX+Pj9T/2hN3RDFOCEz3xaezMP7ZgAip4in9yri qzVDbOO1/n5b0rm5QbBXYhulq71PipJCz63ZicDE4n+Lm4E/Wzw0RGonBYxL3UiPNRlt FHKaKtWQHnTlDAzCeUPjRIe35DZXEzUgwDTd+ZoiVfqLEhZ3AWX3qRyPBBZYK2gGOj56 YylUvoJj3kd48puaSL0IoGxVzWa+tpsqmsarvOFZI+x8fiJMHrM4OPfB1tJVow12haPO MTlA== 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=8DDiQGvQaPkQ98pQ79aEBX/AckQUyESi/TBmFeW/X2w=; fh=0xZT+NBKSeH8qOu04/61f1ZGePpF4jF/gxp331YE14k=; b=b7iKwB+y8X3a/MSOYR4MNI7tFuqTZlcDZGFWaKyl5zAgenSOtK0VSJVs/CMdXYh0As LW+ch/T+/9Q1Uw/+7xaez/7Nq9c74C7WeUX9j77KSffzYgMetDu8mkh0NflZk6zTLxzU FS7WzofBSg5rfitDDu75Q0I+6s+bk3/UgVZfjXh4ZT9+vNtKunXv7QsLSfkaXxpld7FO BOWooVdN6QAsIfuDtUvR1ik7JdKsst7sGUWZzU2jLHT1Vx1PoHLD++yRe25QEVvBckDQ QywSp0IfeaLq5iYOJzAmk2/Zwfz1GAH7kngSM5sQc1XFKx2HlkkXt9HHE52/iTKKyPbK zT9g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dAZYALar; arc=pass (i=1); 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=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id i3-20020a05620a0a0300b00787be694966si1227464qka.499.2024.02.29.04.11.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 04:11:41 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=dAZYALar; arc=pass (i=1); 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=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5C53E3858429 for ; Thu, 29 Feb 2024 12:11:41 +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 30C6E3858C52 for ; Thu, 29 Feb 2024 12:10:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 30C6E3858C52 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 30C6E3858C52 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=1709208665; cv=none; b=oU5ENZMMKVl8T5siEJWlm0DXu1pAFxx7DD120EJdrFfusAMUPyXNQbQCMv0z7XjIpuZbv0+pPVXsQjDIMIqAMTU5nVHjN4impepYhjBedVSv2N26hArU3geJQmSG7UjB1cP5Id182bcB2LjHnaXAZtAhS0G5ikr3ppEDVadJf+U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709208665; c=relaxed/simple; bh=OoeXFjptslBO/0awDdnYv190mMU70F4/0GUiNBnBXtA=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=IgDEqzk4QI7o7j5EKAK3MqDTnco3uzRjEbC5GVnKEJBaUkin5iSjJZIw7ueaU0XnvhZfwc73apSlCHxGSQLVqBlsc4hPDtIzJCm8FgcI6NnG1M7zRNfTVmXQzU8oJTpLpjlyDuFwOmWwlkjV9npa+IS9FWS1ytKWCNRpeh2g9+U= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709208655; 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=8DDiQGvQaPkQ98pQ79aEBX/AckQUyESi/TBmFeW/X2w=; b=dAZYALarnDbMMMnnfRawMSvdIeSNgbpQRb1+IxxiwdOsMjCqFnZhMMp/H0KiA0LujgnHEs bt8JfhOYeIcFgUdJxNXPKIKMNkA6L46JhsJpreP+jrKM1mIUF8Jd7jUdLTvWv7qEjmPswX i2k40U61guIVQXp+7nyZpakoSTD+yhU= 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-101-GbB2gAZWOsiheffvsz_0UA-1; Thu, 29 Feb 2024 07:10:54 -0500 X-MC-Unique: GbB2gAZWOsiheffvsz_0UA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 EC09A10B7263 for ; Thu, 29 Feb 2024 12:10:53 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B08C21121312; Thu, 29 Feb 2024 12:10:53 +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 41TCAp4N1804827 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 29 Feb 2024 13:10:51 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 41TCApvb1804826; Thu, 29 Feb 2024 13:10:51 +0100 Date: Thu, 29 Feb 2024 13:10:50 +0100 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] dwarf2out: Don't move variable sized aggregates to comdat [PR114015] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.5 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: 1792235223629015050 X-GMAIL-MSGID: 1792235223629015050 Hi! The following testcase ICEs, because we decide to move that struct { char a[n]; } DW_TAG_structure_type into .debug_types section / DW_UT_type DWARF5 unit, but refer from there to a DW_TAG_variable (created artificially for the array bounds). Even with non-bitint, I think it is just wrong to use .debug_types section / DW_UT_type for something that uses DW_OP_fbreg and similar in it, things clearly dependent on a particular function. In most cases, is_nested_in_subprogram (die) check results in such aggregates not being moved, but in the function parameter type case that is not the case. The following patch fixes it by returning false from should_move_die_to_comdat for non-constant sized aggregate types, i.e. when either we gave up on adding DW_AT_byte_size for it because it wasn't expressable, or when it is something non-constant (location description, reference, ...). Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2024-02-29 Jakub Jelinek PR debug/114015 * dwarf2out.cc (should_move_die_to_comdat): Return false for aggregates without DW_AT_byte_size attribute or with non-constant DW_AT_byte_size. * gcc.dg/debug/dwarf2/pr114015.c: New test. Jakub --- gcc/dwarf2out.cc.jj 2024-02-17 01:14:48.157790666 +0100 +++ gcc/dwarf2out.cc 2024-02-28 17:11:44.259252850 +0100 @@ -8215,6 +8215,15 @@ should_move_die_to_comdat (dw_die_ref di || is_nested_in_subprogram (die) || contains_subprogram_definition (die)) return false; + if (die->die_tag != DW_TAG_enumeration_type) + { + /* Don't move non-constant size aggregates. */ + dw_attr_node *sz = get_AT (die, DW_AT_byte_size); + if (sz == NULL + || (AT_class (sz) != dw_val_class_unsigned_const + && AT_class (sz) != dw_val_class_unsigned_const_implicit)) + return false; + } return true; case DW_TAG_array_type: case DW_TAG_interface_type: --- gcc/testsuite/gcc.dg/debug/dwarf2/pr114015.c.jj 2024-02-28 17:22:33.206221495 +0100 +++ gcc/testsuite/gcc.dg/debug/dwarf2/pr114015.c 2024-02-28 17:21:49.357831730 +0100 @@ -0,0 +1,14 @@ +/* PR debug/114015 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-g -fvar-tracking-assignments -fdebug-types-section -w" } */ + +#if __BITINT_MAXWIDTH__ >= 236 +typedef _BitInt(236) B; +#else +typedef _BitInt(63) B; +#endif + +int +foo (B n, struct { char a[n]; } o) +{ +}