From patchwork Mon Aug 8 09:13:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 428 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:20da:b0:2d3:3019:e567 with SMTP id n26csp1727675pxc; Mon, 8 Aug 2022 02:13:52 -0700 (PDT) X-Google-Smtp-Source: AA6agR4qVZ4Bp9gmvOuzXxkpwYnW9jkzIMVZgvxwtiPXglKsv8sqXOOzDPbKZ2WFmlVAJ/FHouJy X-Received: by 2002:a17:907:7b83:b0:730:8649:9836 with SMTP id ne3-20020a1709077b8300b0073086499836mr13120698ejc.0.1659950032380; Mon, 08 Aug 2022 02:13:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659950032; cv=none; d=google.com; s=arc-20160816; b=TIZsnYGkFv6V2Ptr4Ds8m4J1Ji/iORQdXJcEOOVFZ8XaXehvsq3U6Ccb8Lo3Yt0FAs HAU2aujLZNyMiYGsAyGIBI2ug1xE80VdrH/YfXEuaxubauD5hr2FA25bf+gqviiT8Tyt /G+twlYTcnwXf5Je3SX4m92X00m5IZmF1Z7X40ia4wCqMEA+jNEsUHasPDGeU3Wq2BzT t1z4W05jiDLedFJ6ZsvOdah4steDlzGq8bVEdtD0vPPZCwDkXa0mvyHqtmvNS/oP6IYF eeZTYuh/1usjlT/A40YP0f+Q4WBTADBvWprwf8rIOCbfvPUQgP7iUmKdEzl83QJqIgyl BJSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:message-id :mime-version:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=nh/t5EsInKK5z+9I/B61NXo4FcnCvW4qzPz/kFfUiYU=; b=b5/lBV0Tz34K+yTalzl+JXL5mbwRU36vraclFbyLQ7DOFhNqWqF01OuXJRRZb80k51 /2Rg2Rsj27ZTzXQBRwL4cSs0jZK2LqwnnCP0VPaM5N5rYbBfXAvqtLyQv8IaTcMgSS2z sptmKK6fnh4sXwOEt4Bb7yU4GcJDriySAmlRPjdNHeh7mygmaQYZE61GdI1pVfVcjaIp 3eX4rIExm70tEA2+UTcU9JPO8t3G/7r1tgedr5QsXzBISNN3X+IcYQkQYrjzHwb4kHi/ mjIowc00jnxWlH5ku63+aZIwvsPElCpeaJUATRUZyZ5xZykg/cqpbg4H/7gqpZfQl2nB F0bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=VcdN0LtV; 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=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id f12-20020a056402354c00b0043cdfee4b1fsi6153357edd.383.2022.08.08.02.13.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Aug 2022 02:13:52 -0700 (PDT) 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=@gcc.gnu.org header.s=default header.b=VcdN0LtV; 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6BE4D385703F for ; Mon, 8 Aug 2022 09:13:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6BE4D385703F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1659950028; bh=nh/t5EsInKK5z+9I/B61NXo4FcnCvW4qzPz/kFfUiYU=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=VcdN0LtVPQqasgmi0lumPF3SKYMcpDfBye9hiS2S0y/PWfowYGzGzM+8xi/a0tC3N PcVmUus7PCWqqpXBhUxny+JpOqUSXorkYIwXgKgtZlki5XTji0BV9kL/fQG2KHx010 jCB6FMFbFJRWTusB92leDiJhLFau21+rzfxrQ59Y= 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 [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id D67663858285 for ; Mon, 8 Aug 2022 09:13:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D67663858285 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id AD23637307 for ; Mon, 8 Aug 2022 09:13:02 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9476113AB3 for ; Mon, 8 Aug 2022 09:13:02 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id p3P2Ip7T8GLbZQAAMHmgww (envelope-from ) for ; Mon, 08 Aug 2022 09:13:02 +0000 Date: Mon, 8 Aug 2022 11:13:02 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] lto/106540 - fix LTO tree input wrt dwarf2out_register_external_die MIME-Version: 1.0 Message-Id: <20220808091302.9476113AB3@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-12.0 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.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" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1740583765089583672?= X-GMAIL-MSGID: =?utf-8?q?1740583765089583672?= I've revisited the earlier two workarounds for dwarf2out_register_external_die getting duplicate entries. It turns out that r11-525-g03d90a20a1afcb added dref_queue pruning to lto_input_tree but decl reading uses that to stream in DECL_INITIAL even when in the middle of SCC streaming. When that SCC then gets thrown away we can end up with debug nodes registered which isn't supposed to happen. The following adjusts the DECL_INITIAL streaming to go the in-SCC way, using lto_input_tree_1, since no SCCs are expected at this point, just refs. LTO bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR lto/106540 PR lto/106334 * dwarf2out.cc (dwarf2out_register_external_die): Restore original assert. * lto-streamer-in.cc (lto_read_tree_1): Use lto_input_tree_1 to input DECL_INITIAL, avoiding to commit drefs. --- gcc/dwarf2out.cc | 7 +------ gcc/lto-streamer-in.cc | 7 +++++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc index cfea9cf6451..e3920c898f5 100644 --- a/gcc/dwarf2out.cc +++ b/gcc/dwarf2out.cc @@ -6069,12 +6069,7 @@ dwarf2out_register_external_die (tree decl, const char *sym, if (!external_die_map) external_die_map = hash_map::create_ggc (1000); - /* When we do tree merging during WPA or with -flto-partition=none we - can end up re-using GC memory as there's currently no way to unregister - external DIEs. Ideally we'd register them only after merging finished - but allowing override here is easiest. See PR106334. */ - gcc_checking_assert (!(in_lto_p && !flag_wpa) - || !external_die_map->get (decl)); + gcc_checking_assert (!external_die_map->get (decl)); sym_off_pair p = { IDENTIFIER_POINTER (get_identifier (sym)), off }; external_die_map->put (decl, p); } diff --git a/gcc/lto-streamer-in.cc b/gcc/lto-streamer-in.cc index fe5a4e7fe1d..a7dad70363f 100644 --- a/gcc/lto-streamer-in.cc +++ b/gcc/lto-streamer-in.cc @@ -1699,11 +1699,14 @@ lto_read_tree_1 (class lto_input_block *ib, class data_in *data_in, tree expr) /* Read all the pointer fields in EXPR. */ streamer_read_tree_body (ib, data_in, expr); - /* Read any LTO-specific data not read by the tree streamer. */ + /* Read any LTO-specific data not read by the tree streamer. Do not use + stream_read_tree here since that flushes the dref_queue in mids of + SCC reading. */ if (DECL_P (expr) && TREE_CODE (expr) != FUNCTION_DECL && TREE_CODE (expr) != TRANSLATION_UNIT_DECL) - DECL_INITIAL (expr) = stream_read_tree (ib, data_in); + DECL_INITIAL (expr) + = lto_input_tree_1 (ib, data_in, streamer_read_record_start (ib), 0); /* Stream references to early generated DIEs. Keep in sync with the trees handled in dwarf2out_register_external_die. */