From patchwork Tue Jan 23 10:15:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 190826 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2553:b0:103:945f:af90 with SMTP id p19csp234832dyi; Tue, 23 Jan 2024 02:16:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IHxr8aU0XL032N97peJxRDsDMzm42HYopIIIIBDnLrCCOWSfNtuUJ1SazToTOkREi8+5CQv X-Received: by 2002:a05:6830:151a:b0:6dd:e425:8fec with SMTP id k26-20020a056830151a00b006dde4258fecmr5591311otp.34.1706004966154; Tue, 23 Jan 2024 02:16:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706004966; cv=pass; d=google.com; s=arc-20160816; b=bsG7mKFob8bioKHrsB3Sn7dewUWNCXLppj+0PWBXZj0PZEiW6gzg7CdNGnbaVjzmTF qVikP9wBg7bJ/kcRuuv4Hw+IzFhHApaw/tBGSrHijPXwGKMFHs4IOzo40oMixK5Kwefi jVh3hw/d9USxlOl5hPbO3tXBpIObh84ItF5UJgLNNklpQdJb9VWNY5J3+x7T8trebiTr s2HmepN+lhydf1EZg/J0HfBvahr7pfAGufbQBO3wQrv8Vkm75epKtNlTyaF49WrhumiF pGUu3g3ofmVhebSxgsaQvkJQoTfrcvC/O2mpKBT9xMWoslz2kTutdRCeGYrICM0/A0Nj EfTw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:message-id:mime-version:subject :to:from:date:dkim-signature:dkim-signature:dkim-signature :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=3skM1E/J3OVvzQzTAA9KufglEdvm2krXiOSgP3u3MEk=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=03ftnxt0gVjRGpAsyWGeu6EWGRJJe+n0cHD1MsCTC7z+MDSGWQPIu3G55v1M5MfCRz Q6RRjT/4vL3BOxa0wuXqex0RK5l/wSvN6ef2zYrcDGHrTz9iTAxtvdpc8/naTuSspBhG qQKxpsAgmUUz6igiBmxuPpvzFP9KHnNZyBt0XhOhYJZ+nT6DpkA8MkfRULXUPK7Ucbi/ ANq1LnefdD+0/g/cMNTxfzoKNudzm2J1jZZVgcvnoV5mkJvI+cRDQ5SWA4OG+0EfN9DO MALadAvdSA8P31X0LtAhI+CmIo+csDSl2SqeUZh1F+sU0fBO9IdVvBpHizOFrHkmZtcb DNnw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=IZXoZPJh; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=IZXoZPJh; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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=suse.de Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id o9-20020a05622a008900b0042a35cc88b4si5955524qtw.54.2024.01.23.02.16.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 02:16:06 -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=@suse.de header.s=susede2_rsa header.b=IZXoZPJh; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=IZXoZPJh; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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=suse.de Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D247238582A2 for ; Tue, 23 Jan 2024 10:16:05 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id 1375E3858C50 for ; Tue, 23 Jan 2024 10:15:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1375E3858C50 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1375E3858C50 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706004912; cv=none; b=xQQm2pDcU4dOKCXloX0d4kLZxFWl4pTzmQ248SNlxsX/pkUgvuGk3b6AIO/clcwbYFpOjPPS4scbERwY54JOFzC2A0VeO2zMUVuWqn2nB0Ss+LAqmaErS59LHea2w/ONAt13p/Yjqjl1YQNW+ApBTCrLkYkWn6yrYD7GsgwY7RI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706004912; c=relaxed/simple; bh=Z6tu02l543gIJVLsDIaYNPvs2xJ0x1WSt07Ho5iNxrk=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version:Message-Id; b=RpKIAhwDXAZOv0yprLo/8DZX/VEl4hwzoWJUa38LJEohqz6hSWjJHMJY6J+/vtGSVDwVGgJO+zbXdV+fGMATCeD8EUR5Q11+MnMhTwFHWYFQvX2P1r7DR7Xrs40iB19eFf0yb8G5ZD/twylqMoT6fw5NegXkXgVws4nysGdD0wc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 9992322177 for ; Tue, 23 Jan 2024 10:15:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706004908; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=3skM1E/J3OVvzQzTAA9KufglEdvm2krXiOSgP3u3MEk=; b=IZXoZPJhvKEepV1DPvInC/kbOeF5lY4L6e5fZaZdbO1osPuQsL9L4yqoDehKKCAASt9n+z 12Wi1LVhBinOTcj+AcENftgZ8R7iCuoNd1n6Cu0ZmgIRJNJ/l8ZWz+OFct7hgYIXLVmC4r Gof2ghaYEo8qjPyn2FjVDURF/kKyGyE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706004908; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=3skM1E/J3OVvzQzTAA9KufglEdvm2krXiOSgP3u3MEk=; b=h9nJ3HqjaozYBZipvJYfjicz5OaVsLwHczc/qA3L/kTdfh8/PeIfzoyUIfRc7y24C1jvSl vzS389F0bXyc6DCw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706004908; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=3skM1E/J3OVvzQzTAA9KufglEdvm2krXiOSgP3u3MEk=; b=IZXoZPJhvKEepV1DPvInC/kbOeF5lY4L6e5fZaZdbO1osPuQsL9L4yqoDehKKCAASt9n+z 12Wi1LVhBinOTcj+AcENftgZ8R7iCuoNd1n6Cu0ZmgIRJNJ/l8ZWz+OFct7hgYIXLVmC4r Gof2ghaYEo8qjPyn2FjVDURF/kKyGyE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706004908; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=3skM1E/J3OVvzQzTAA9KufglEdvm2krXiOSgP3u3MEk=; b=h9nJ3HqjaozYBZipvJYfjicz5OaVsLwHczc/qA3L/kTdfh8/PeIfzoyUIfRc7y24C1jvSl vzS389F0bXyc6DCw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 7B47013786 for ; Tue, 23 Jan 2024 10:15:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id LSLsG6yRr2U5FQAAD6G6ig (envelope-from ) for ; Tue, 23 Jan 2024 10:15:08 +0000 Date: Tue, 23 Jan 2024 11:15:08 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] debug/107058 - gracefully handle unexpected DIE contexts MIME-Version: 1.0 Message-Id: <20240123101508.7B47013786@imap1.dmz-prg2.suse.org> Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=IZXoZPJh; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=h9nJ3Hqj X-Spamd-Result: default: False [-5.31 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; DWL_DNSWL_MED(-2.00)[suse.de:dkim]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[gcc-patches@gcc.gnu.org]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 9992322177 X-Spam-Level: X-Spam-Score: -5.31 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788875863441171525 X-GMAIL-MSGID: 1788875863441171525 While the bug is persisting that LTO streaming picks up a CONST_DECL from an attribute argument on a VAR_DECL which with -fdebug-type-section refers to a DIE in a type unit we can handle this gracefully, at least with -fno-checking. Do so. The C++ frontend nevetheless should resolve the CONST_DECL attribute argument to a constant. LTO bootstrapped and tested on x86_64-unknown-linux-gnu, pushed to trunk. PR debug/107058 * dwarf2out.cc (dwarf2out_die_ref_for_decl): Gracefully handle unexpected but bogus DIE contexts when not checking enabled. * c-c++-common/pr107058.c: New testcase. --- gcc/dwarf2out.cc | 15 +++++++++++---- gcc/testsuite/c-c++-common/pr107058.c | 7 +++++++ 2 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/c-c++-common/pr107058.c diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc index 0b8a3002292..2b723210f34 100644 --- a/gcc/dwarf2out.cc +++ b/gcc/dwarf2out.cc @@ -6061,10 +6061,17 @@ dwarf2out_die_ref_for_decl (tree decl, const char **sym, die = die->die_parent; /* For the containing CU DIE we compute a die_symbol in compute_comp_unit_symbol. */ - gcc_assert (die->die_tag == DW_TAG_compile_unit - && die->die_id.die_symbol != NULL); - *sym = die->die_id.die_symbol; - return true; + if (die->die_tag == DW_TAG_compile_unit) + { + gcc_assert (die->die_id.die_symbol != NULL); + *sym = die->die_id.die_symbol; + return true; + } + /* While we can gracefully handle running into say a type unit + we don't really want and consider this a bug. */ + if (flag_checking) + gcc_unreachable (); + return false; } /* Add a reference of kind ATTR_KIND to a DIE at SYMBOL + OFFSET to DIE. */ diff --git a/gcc/testsuite/c-c++-common/pr107058.c b/gcc/testsuite/c-c++-common/pr107058.c new file mode 100644 index 00000000000..5e625d6a6af --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr107058.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target lto } */ +/* { dg-options "-g -fdebug-types-section -flto -fno-checking" } */ + +/* We should handle the C++ FE issue gracefully with -fno-checking. */ + +#include "pr50459.c"