From patchwork Mon Jan 9 10:52:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 40792 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2085853wrt; Mon, 9 Jan 2023 02:53:25 -0800 (PST) X-Google-Smtp-Source: AMrXdXuaJqsi9NhmiPIG6GMAmX2w/uMnI+JIxAPZD+VnwobAxDsGBFxU5y9ZOB2abpxoNqrejXwO X-Received: by 2002:a05:6402:b14:b0:498:21b3:aeaf with SMTP id bm20-20020a0564020b1400b0049821b3aeafmr6337872edb.1.1673261605360; Mon, 09 Jan 2023 02:53:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673261605; cv=none; d=google.com; s=arc-20160816; b=N3FprkI6Ruopwll5oZ7Gvkc8q49hykGwqwwXna0wm+ptAKO35lRrKvRQkD7s1tu8MZ EHmnZFJfEp3rUUfycU/p8hoFJQ8bgagKB26h2ZsCnxhfSfcMx2EE4xCIUDW1W99HoUYw r2MXnd1+oymJzBGXVQc0cEUCOzTi+ax41imtG9GejVRIhyxKHnzTcB0y0QkwGz21Kbfq 2zPGrYoOrTjwYTonVx+ukJTfDt2bSCT4Vw/Sh6xjyDA1S7HbEPkhjuKQj+HEu/uqLeky 4cv5PyhZjg8Wlg+1GavZHoMt79/sTZlCJS2EIY452zek4AY3alCmlctV4p6RJUbAROHI xisQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding:cc :content-language:to:subject:from:user-agent:mime-version:date :message-id:dkim-signature:dkim-signature:dmarc-filter:delivered-to; bh=nIgc5fxHaJURXEZoECUfELCydnpfWNKbllgHh6Y0C7s=; b=o131WF3xSS8VcDTXcE4YO3OZJyErjWl/DX86M+Bq/Z136sZMnK7i2JN42HATjFDoaf VLYehNsBY2Gq8TEYOWgDW2iM6YAEZAhmNmhZY5yvwUt9b3PG4RHxZ7ixYeGwx5L9RDVT XSY8vxvAWrcBCe+4GoxksSATtLZwI38bH6Oy4e3CjYCpEcWQNCYyM0r+sjipC8rejF6a IMJ+hvptHQn3bA4yPLrOQ4Ik00I2OPc7XALcVE36xsu249lGEJb1PkD1lY0KunNHT7h5 9au/3D0GAOVsSpWnZIQjxSXRs2Owh+OO+nUSkVdLWCZ59oH97P6s0ogUyL50bZpwAh0e /XMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=RCmAm2ho; dkim=neutral (no key) header.i=@gcc.gnu.org header.s=susede2_ed25519; 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" Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id n6-20020a056402514600b00487205f3103si8673986edd.324.2023.01.09.02.53.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jan 2023 02:53:25 -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.cz header.s=susede2_rsa header.b=RCmAm2ho; dkim=neutral (no key) header.i=@gcc.gnu.org header.s=susede2_ed25519; 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 173E83858D38 for ; Mon, 9 Jan 2023 10:53:21 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 0CF713858D37 for ; Mon, 9 Jan 2023 10:52:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0CF713858D37 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=suse.cz 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-out2.suse.de (Postfix) with ESMTPS id 8B9A6768C8; Mon, 9 Jan 2023 10:52:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1673261575; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nIgc5fxHaJURXEZoECUfELCydnpfWNKbllgHh6Y0C7s=; b=RCmAm2hoyfeoikWDLs0mqVTjslJ2PkS6CD6uIsqtT9t9PXjrOGwh/4Pu6Ny0bH66VGta0a 1dOCDDl4LN+T5036yRx0Hb+3KyFj0TRXpg7va0eNVPIaVjL2IOQjmxhYn9Z4HlBXUI/UJf gb/ije6+EL2VKbst1Ese7VTJ3klP5cA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1673261575; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nIgc5fxHaJURXEZoECUfELCydnpfWNKbllgHh6Y0C7s=; b=9rJissLpTpulqVFSF1wkl2MqWqU7NtSo6PEGGC4z9QmzQyq/GB8y/E8uI1KlJkbiMbSzLJ cxOW4btxa9gfA+Ag== 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 79AAD134AD; Mon, 9 Jan 2023 10:52:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Vp60HAfyu2NpKwAAMHmgww (envelope-from ); Mon, 09 Jan 2023 10:52:55 +0000 Message-ID: <7cb85a5f-98c7-a398-d7ec-40a170039830@suse.cz> Date: Mon, 9 Jan 2023 11:52:55 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH] hash: do not insert deleted value to a hash_set To: gcc-patches@gcc.gnu.org Content-Language: en-US Cc: Alexandre Oliva 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_SOFTFAIL, 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 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: , 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?1754541960610723994?= X-GMAIL-MSGID: =?utf-8?q?1754541960610723994?= Hi. After the new hash_set checking code, we face an issue where deleted value is added to a hash_set. Fix it. Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Ready to be installed? Thanks, Martin PR lto/108330 gcc/ChangeLog: * lto-cgraph.cc (compute_ltrans_boundary): Do not insert NULL (deleleted value) to a hash_set. gcc/testsuite/ChangeLog: * g++.dg/ipa/pr108830.C: New test. --- gcc/lto-cgraph.cc | 3 ++- gcc/testsuite/g++.dg/ipa/pr108830.C | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/ipa/pr108830.C diff --git a/gcc/lto-cgraph.cc b/gcc/lto-cgraph.cc index eef5ea1d061..805c7855eb3 100644 --- a/gcc/lto-cgraph.cc +++ b/gcc/lto-cgraph.cc @@ -918,7 +918,8 @@ compute_ltrans_boundary (lto_symtab_encoder_t in_encoder) vec targets = possible_polymorphic_call_targets (edge, &final, &cache_token); - if (!reachable_call_targets.add (cache_token)) + if (cache_token != NULL + && !reachable_call_targets.add (cache_token)) { for (i = 0; i < targets.length (); i++) { diff --git a/gcc/testsuite/g++.dg/ipa/pr108830.C b/gcc/testsuite/g++.dg/ipa/pr108830.C new file mode 100644 index 00000000000..96656f67e4f --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr108830.C @@ -0,0 +1,20 @@ +// PR lto/108330 +// { dg-do compile } + +class A { + virtual unsigned long m_fn1() const; + virtual int &m_fn2(unsigned long) const; +}; +class C : A { +public: + int &m_fn2(unsigned long) const; + unsigned long m_fn1() const; +}; +class B { + void m_fn3(const A &, const int &, const C &, int &) const; +}; +void B::m_fn3(const A &, const int &, const C &, int &) const { + C &a(a); + for (long b = 0; a.m_fn1(); b++) + a.m_fn2(0); +}