From patchwork Tue Dec 27 04:17:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 36763 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1218379wrt; Mon, 26 Dec 2022 20:18:01 -0800 (PST) X-Google-Smtp-Source: AMrXdXs32sYwiN++o/IulBgd2EXuDV1BCFycy+in6EWHbnf10OQ1zeMtj95um2DdOOElLh2gM8z3 X-Received: by 2002:aa7:cf94:0:b0:47b:16f5:61dc with SMTP id z20-20020aa7cf94000000b0047b16f561dcmr17632224edx.37.1672114681904; Mon, 26 Dec 2022 20:18:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672114681; cv=none; d=google.com; s=arc-20160816; b=BF0vCvizIUfnkkKM7+2Y5uj4AYHKrKoZ115KdWlUXnsHMwmwco1saAbwW3QUhWfjUD Axgvl7ys8qd28VvDpRUZxOaCtJGIdVm0BQ6CWsSlhFMFogbBqnN8g826mubt88b/jjPe u365dhpzqPLwuvvxDysa9BP5QI07v21UgXniJn0t4vH+DWu8YlkRl3EJ/xa6dQ+fyXCn yXjAeQh83KcO+vS2Zrui6tIMsFwHnOtmutbs89ZnajWHHQOwyMzXPNstf86P/I1C5Qwu D6iT9k7EVmQ7qku8K9H3z0IJmwzm9SAFcb86dhuPMd7bcBMdswV4YGenhyF1Hl9cipqN +FqQ== 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:mime-version :user-agent:message-id:in-reply-to:date:references:organization :subject:to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=OfNllI4GrBohry2jwd8P10zjUvrD9Wb28lEW84qMX28=; b=T7qXMDzdjV/Ll6mWARcucnHrfcPSIpHAyeyrm5P79NRnfu00tliwCTbxn4p+jkQq4O HA9OfMtEXcOAURFyfrVziS6jbh6eDoa4YdAq2bryK/Y+EJ++6iK6Shmz8vqPz/puwzxJ YswH0FXJ9t8UE1iyHAxog3TvqNWCLSWeIoSLuWLKUEcT6VCs4rrT9cO+KJwKG4opvhk4 rIkrJictFarf1ORA96hWPkXUOTSu8TIfY+dRSQL5F5Vt48o4HNogdYLtOHhvBNaU9kYs UvHEftCoWm3CRY77viwgEBWnj5fhoww9THm/sYu4pFIYGze2jX9EdjJ6S3QttRSDXScE 7ZLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=GTQGnRWy; 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=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id s24-20020aa7d798000000b00486a1eddd65si1363849edq.125.2022.12.26.20.18.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Dec 2022 20:18:01 -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=@gcc.gnu.org header.s=default header.b=GTQGnRWy; 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DDEE33858C1F for ; Tue, 27 Dec 2022 04:18:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DDEE33858C1F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672114680; bh=OfNllI4GrBohry2jwd8P10zjUvrD9Wb28lEW84qMX28=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=GTQGnRWylzWnO6OIodcZW0ZzWHcm/rQvzmpIMRhEhB7ajr95rzNvrifb+GwGtyNw1 13G8qpqs0OKSid8ksp2n5XpmEq2Aog/RYsO0niEcQLyalG7nMQE2euxleHN41Gkf2J C1CNrLCoDUAO4WbQ1fQhZkWI1ChQDz6VhDGDjLSg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [IPv6:2620:20:4000:0:a9e:1ff:fe9b:1d1]) by sourceware.org (Postfix) with ESMTPS id C83F53858D38 for ; Tue, 27 Dec 2022 04:17:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C83F53858D38 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 90F4F1162A6; Mon, 26 Dec 2022 23:17:17 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id pzSwmPrT6DlK; Mon, 26 Dec 2022 23:17:17 -0500 (EST) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id 3139D11628F; Mon, 26 Dec 2022 23:17:17 -0500 (EST) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 2BR4HARn711938 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 27 Dec 2022 01:17:10 -0300 To: gcc-patches@gcc.gnu.org Subject: [01/13] scoped tables: insert before further lookups Organization: Free thinker, does not speak for AdaCore References: Date: Tue, 27 Dec 2022 01:17:10 -0300 In-Reply-To: (Alexandre Oliva's message of "Tue, 27 Dec 2022 01:07:35 -0300") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, 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: , X-Patchwork-Original-From: Alexandre Oliva via Gcc-patches From: Alexandre Oliva Reply-To: Alexandre Oliva 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?1753339324690249844?= X-GMAIL-MSGID: =?utf-8?q?1753339324690249844?= Avoid hash table lookups between requesting an insert and storing the inserted value in avail_exprs_stack. Lookups before the insert is completed could fail to find double-hashed elements. Regstrapped on x86_64-linux-gnu. Ok to install? for gcc/ChangeLog * tree-ssa-scopedtables.cc (avail_exprs_stack::lookup_avail_expr): Finish hash table insertion before further lookups. --- gcc/tree-ssa-scopedtables.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gcc/tree-ssa-scopedtables.cc b/gcc/tree-ssa-scopedtables.cc index 6d203ef89ecef..3e6e129e7d5d3 100644 --- a/gcc/tree-ssa-scopedtables.cc +++ b/gcc/tree-ssa-scopedtables.cc @@ -259,11 +259,6 @@ avail_exprs_stack::lookup_avail_expr (gimple *stmt, bool insert, bool tbaa_p, } else if (*slot == NULL) { - /* If we did not find the expression in the hash table, we may still - be able to produce a result for some expressions. */ - tree retval = avail_exprs_stack::simplify_binary_operation (stmt, - element); - /* We have, in effect, allocated *SLOT for ELEMENT at this point. We must initialize *SLOT to a real entry, even if we found a way to prove ELEMENT was a constant after not finding ELEMENT @@ -277,6 +272,11 @@ avail_exprs_stack::lookup_avail_expr (gimple *stmt, bool insert, bool tbaa_p, class expr_hash_elt *element2 = new expr_hash_elt (element); *slot = element2; + /* If we did not find the expression in the hash table, we may still + be able to produce a result for some expressions. */ + tree retval = avail_exprs_stack::simplify_binary_operation (stmt, + element); + record_expr (element2, NULL, '2'); return retval; } From patchwork Tue Dec 27 04:18:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 36764 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1218724wrt; Mon, 26 Dec 2022 20:19:31 -0800 (PST) X-Google-Smtp-Source: AMrXdXvfD5IFUj2tLWv40YDlAkbXvSkmrlzjAS1LQIOvMndoRqjvwtcf8w2k6sx7e/uMVx/Yw9Ns X-Received: by 2002:a50:d616:0:b0:47c:6ed2:43d1 with SMTP id x22-20020a50d616000000b0047c6ed243d1mr18000195edi.30.1672114771452; Mon, 26 Dec 2022 20:19:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672114771; cv=none; d=google.com; s=arc-20160816; b=V7Cx3qgFIZIX1xaWutj1QKVl2D2u9uPWkpU1Q28E0P/hhXhk1HwSRHlgsB0AQSEKPW XV16VpaAxclyUQCBi8IvUi6v7SAZcSvrrxljcD0Mj653e1A3bFlzwB+Gc96Tzv34MIAd YFtaOh41Nl+/vu8jWNIzK2uS3JaMAMuW5TXADVgTEXZpNWQzJ0wBqBLIBnYj+oH1aafS I4l+GzBVHRz1BfbE1u5BHATyf1d2lwb0IeWfwMoCQc7WdY/FpOz1znzJ3alfMx6bDAcS DUOjlT9zHHdd1Ux366JFJy8iim0HnwcmWK/5lAfj3poNC3oxtLiikUJSK+NcRnyeSCGE B0RA== 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:mime-version :user-agent:message-id:in-reply-to:date:references:organization :subject:to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=xV/uII29uJfJXwyu7cgG7Q4wBxJopBsMwWqh3W2YNOo=; b=HsZoLmGoOpizelOIT5oMxfFOh9sSUk97xeLXEV+Wzd7YU6kKutAorHfilAjCG3hkd1 g044a7D6Wx/n91ZOS8KVh59/6YWdOXSoAN6YpfXve1351bqYEcJgUL+NODBX1wNfqr77 9pjSBjoO8xwlg0bYczsQOwqEvvhGUPn2RxTqwrSDKnF1aba52xi37F0i1PyfVrcRXuT4 TQm7+r2CFBbhTxPs8CQb/hrUXNlZDXy9cCErxEksGZyPBy+SubQ+dISkXxzZqokhNN1p a/eZHdnv+HGF+CfoUV7uSx9F3b/Ukxmg7n1aRISt4IsG1hRhEyap8sjABQU+FFGNMd2d sKzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=WlWEa9OK; 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 n11-20020aa7c44b000000b00467238595easi9444663edr.369.2022.12.26.20.19.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Dec 2022 20:19:31 -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=@gcc.gnu.org header.s=default header.b=WlWEa9OK; 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 3AC493858421 for ; Tue, 27 Dec 2022 04:19:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3AC493858421 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672114770; bh=xV/uII29uJfJXwyu7cgG7Q4wBxJopBsMwWqh3W2YNOo=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=WlWEa9OKXeF1tqQ1MzLtC1GSb8sm/TmgyATMkHRzUK8FXsRn6h9Zv7XBJ3wxG5zUn uZgDQD7LaeG2gyCkLIz3uQFbouITUD94sis6jNzPK0JzL0THy+FHaAQSgRkQp9eAUS M7jE+hoAuqUAQYjuQtQOqC6fFaS8XzSNxEIFgiJ0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTPS id 8B4EF3858D32 for ; Tue, 27 Dec 2022 04:18:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8B4EF3858D32 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 611981162A6; Mon, 26 Dec 2022 23:18:48 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id O+e0kaffoMUW; Mon, 26 Dec 2022 23:18:48 -0500 (EST) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id 01B4511628F; Mon, 26 Dec 2022 23:18:47 -0500 (EST) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 2BR4IbF6712009 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 27 Dec 2022 01:18:38 -0300 To: gcc-patches@gcc.gnu.org Subject: [02/13] varpool: do not add NULL vnodes to referenced Organization: Free thinker, does not speak for AdaCore References: Date: Tue, 27 Dec 2022 01:18:37 -0300 In-Reply-To: (Alexandre Oliva's message of "Tue, 27 Dec 2022 01:07:35 -0300") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, 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: , X-Patchwork-Original-From: Alexandre Oliva via Gcc-patches From: Alexandre Oliva Reply-To: Alexandre Oliva 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?1753339418285918929?= X-GMAIL-MSGID: =?utf-8?q?1753339418285918929?= Avoid adding NULL vnodes to referenced tables. Regstrapped on x86_64-linux-gnu. Ok to install? for gcc/ChangeLog * varpool.c (symbol_table::remove_unreferenced_decls): Do not add NULL vnodes to referenced table. --- gcc/varpool.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gcc/varpool.cc b/gcc/varpool.cc index bfd17f1250cc0..ccbd6e50f4b01 100644 --- a/gcc/varpool.cc +++ b/gcc/varpool.cc @@ -680,10 +680,12 @@ symbol_table::remove_unreferenced_decls (void) enqueue_node (vnode, &first); else { - referenced.add (vnode); + if (vnode) + referenced.add (vnode); while (vnode && vnode->alias && vnode->definition) { vnode = vnode->get_alias_target (); + gcc_checking_assert (vnode); referenced.add (vnode); } } From patchwork Tue Dec 27 04:19:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 36765 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1218976wrt; Mon, 26 Dec 2022 20:20:38 -0800 (PST) X-Google-Smtp-Source: AMrXdXsJawyuq0kTy3It9LTeRzAhxwp8xf8JCkhB+BjmhJTDgvVus5lRFecVOt709yHyaPjzw+i+ X-Received: by 2002:a17:906:f250:b0:7c1:528:bc02 with SMTP id gy16-20020a170906f25000b007c10528bc02mr17517073ejb.41.1672114838112; Mon, 26 Dec 2022 20:20:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672114838; cv=none; d=google.com; s=arc-20160816; b=ZvuaVAejTa0mMeelqq4hsiITlUgF5HnkM5HEsExjPjr14v4rihYjRKr2EBt4aPRx89 BbXdP5CJbwTBEnd9dAysfFW9G+P3t+WIrxrADVpAP6rw1xlR10g0Zlwzxcvr2Z6szrUl HDRqZIiyts2MSH3jj5/9YMppJEBq6iWgAFcsiJY1QYnbDuc3UcW1pfG063disPEzheOd WRKfewaHSeIuvoBhAFRg5OeIDGeTDHPsqcqbi4jsQyyJwso8o58Bq3+du8iyJJ5VlwkG xZksCf3KY7rB2cE2abAp/7+pH7tndK5t4o3xmQ+9nSlla0DacnCZ3vmP43IhNZhZfl6c PQZA== 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:mime-version :user-agent:message-id:in-reply-to:date:references:organization :subject:to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=/PgCft1l4EDdjOvRkxQTxgtYwaE0wX7X55ujfEfrbLU=; b=zsnPDI2XJCHQ0hGyvJK1l/sV8UYKhboerEc3PM/Xlj9J97SvZ1y9FdF4oNiAP/1DHj 0Q7na5rHRM2E/oV7TYrM3XLHLyD+BrwFBhwBHMWXC7nberKnwKMAzwcLQ/AvcJ7JA5Ku Wr0zDlnRhfmrYDDbB59KOCPV5vmcDW2+JNbXgYwTLpdgIF7EYvLwU6dIvu3z0IpdNleo 0x+4+dUpaP7eraBCwAeEr6N3aX8pQVRm1ZY9PceZUNH0nq3iZ8xw4py05wz1qeSMa9V6 AGgwYBhxfMKUDvbNJPmdApJbL+rydzGdXDbyii/fLXbfObD3IjPOkMqqhpaa5bwVlkgQ SbXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=U1e2CSTB; 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=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id jg14-20020a170907970e00b007c1651709e3si10705985ejc.177.2022.12.26.20.20.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Dec 2022 20:20:38 -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=@gcc.gnu.org header.s=default header.b=U1e2CSTB; 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1EAAD385843A for ; Tue, 27 Dec 2022 04:20:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1EAAD385843A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672114837; bh=/PgCft1l4EDdjOvRkxQTxgtYwaE0wX7X55ujfEfrbLU=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=U1e2CSTBrm8k8S2iTMQYSjBCxqfw8W+eKIX1zOy/MmrAH9SPlFvUDf3Ye3eE/yZB7 C3f2W08Cqp4tUXgvgjWvsps+d5WL1gWv+kbYfyt15lGMj2MA0oNXvN0JzUq+ycwsvc h0cZWR/g0MY6SLVmrtcz0gMllgAmICGuGk8s03Hc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTPS id B47C13858422 for ; Tue, 27 Dec 2022 04:19:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B47C13858422 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 8A2121162A6; Mon, 26 Dec 2022 23:19:54 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id EZjwON2FBhZ2; Mon, 26 Dec 2022 23:19:54 -0500 (EST) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id 2AE7711628F; Mon, 26 Dec 2022 23:19:54 -0500 (EST) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 2BR4Jl83712025 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 27 Dec 2022 01:19:47 -0300 To: gcc-patches@gcc.gnu.org Subject: [03/13] tree-inline decl_map: skip mapping NULL to itself Organization: Free thinker, does not speak for AdaCore References: Date: Tue, 27 Dec 2022 01:19:47 -0300 In-Reply-To: (Alexandre Oliva's message of "Tue, 27 Dec 2022 01:07:35 -0300") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, 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: , X-Patchwork-Original-From: Alexandre Oliva via Gcc-patches From: Alexandre Oliva Reply-To: Alexandre Oliva 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?1753339488790141702?= X-GMAIL-MSGID: =?utf-8?q?1753339488790141702?= Mapping a NULL key is no use, skip it. Regstrapped on x86_64-linux-gnu. Ok to install? for gcc/ChangeLog * tree-inline.cc (insert_decl_map): Skip mapping a NULL decl as value to itself. --- gcc/tree-inline.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/tree-inline.cc b/gcc/tree-inline.cc index c6c86af6c4ea9..bfea1cc11822e 100644 --- a/gcc/tree-inline.cc +++ b/gcc/tree-inline.cc @@ -148,7 +148,7 @@ insert_decl_map (copy_body_data *id, tree key, tree value) /* Always insert an identity map as well. If we see this same new node again, we won't want to duplicate it a second time. */ - if (key != value) + if (key != value && value) id->decl_map->put (value, value); } From patchwork Tue Dec 27 04:21:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 36766 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1219358wrt; Mon, 26 Dec 2022 20:22:42 -0800 (PST) X-Google-Smtp-Source: AMrXdXvaiBg4NbNTy69EEho8+jcGdISEpCCt2XomWJX3MA3yeb3xhFmS1HZ8uZA3IHAoaTOFMhYy X-Received: by 2002:a17:906:5e04:b0:7c0:e803:4ebb with SMTP id n4-20020a1709065e0400b007c0e8034ebbmr16798961eju.70.1672114962687; Mon, 26 Dec 2022 20:22:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672114962; cv=none; d=google.com; s=arc-20160816; b=BxLfO5TdH9Gu9YOo7QAfq2TeiWqw1gINeYmdo9AOPcA4meRGoP3/O7WTT5XvRL47Z8 r4W99HX/Ii3m1vUWy2eWkZHM6yKFeOL6c1qhAjJhFPK1r932qp8t0cFLuTkhmgJ//dkY F2H5Ggvv5LrQ9S3n7hDbfh0e0FU+BNGxh1xKwtVbvHFefd98Z/IQvf3yr2gIvXTIZi2o iY/RveE0RtlixjIiS0OhLbXJOWIipA7STft1X4mq2+DHBAbR/w4HEFnCMkyud9aDguZy OLCRvLTUFwWlndZu4A/lYncVLlLC8lgi3fRgAcph9nTwfiJUSfM1VsTiJFHmVM5xAjHN nyHA== 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:mime-version :user-agent:message-id:in-reply-to:date:references:organization :subject:cc:to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=Yqz7XHYk96kgrRslQ3Yex/UqpsmoYrYKDvsEqHaiLSs=; b=OHQKZGkYmc3EjbJQ8c+1ZLJJqGXaUcUExA6S56SND1bXRag8/zYTL35bSPTGJg9bcx sbCPve99zTprCiAuZ3rAMSfbkvZKpSGrhbg9EgKkaivIYNRt9/fA0VBfQmeJxTiWwK8s b7lulvQLRNRxRWVMj/qYgzjwF4q5GM9CduNPJWzrENfKbkA+plDmC9TQvUxks4+Ypjov UEO1Iwo1jrTE1B4jCOrciijr0iPPHxIQVeXuZq2aBdb104psqK2vhMUXeBfxXsiNJyMP OXx2YVNvYz51TiNfS+8+WLdgAQe4cupLou2v0lJ9Tp62bYqCyiYhBMe2ocHYRE9Kn1oq LdGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="MDqX/VKC"; 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 o22-20020a170906975600b007ae8d01144dsi11016298ejy.717.2022.12.26.20.22.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Dec 2022 20:22:42 -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=@gcc.gnu.org header.s=default header.b="MDqX/VKC"; 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 7C15F3858418 for ; Tue, 27 Dec 2022 04:22:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7C15F3858418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672114961; bh=Yqz7XHYk96kgrRslQ3Yex/UqpsmoYrYKDvsEqHaiLSs=; h=To:Cc:Subject:References:Date:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=MDqX/VKCs6B1GSGaJgXjmr0fRw9iA/ef/ooAeLb5ltsVQqidO5NoN31J45soNFJ+F 1WXJpvijmnrG69j5r9i/KXv9G5p86y073zfk82Cqvinw+un7DWqgxQClarL/E0SIuF PqvC1kFKOXoNSCZJbFeR2O4OLjJ0yvGe/mrdltPQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [IPv6:2620:20:4000:0:a9e:1ff:fe9b:1d1]) by sourceware.org (Postfix) with ESMTPS id E83CA3858D32 for ; Tue, 27 Dec 2022 04:21:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E83CA3858D32 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id BD1EE1162A6; Mon, 26 Dec 2022 23:21:58 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id ZI-WUsrdkY8U; Mon, 26 Dec 2022 23:21:58 -0500 (EST) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id 5E83411628F; Mon, 26 Dec 2022 23:21:58 -0500 (EST) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 2BR4Lo0W712080 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 27 Dec 2022 01:21:50 -0300 To: gcc-patches@gcc.gnu.org Cc: Jason Merrill , Nathan Sidwell Subject: [04/13] [C++] constraint: insert norm entry once Organization: Free thinker, does not speak for AdaCore References: Date: Tue, 27 Dec 2022 01:21:50 -0300 In-Reply-To: (Alexandre Oliva's message of "Tue, 27 Dec 2022 01:07:35 -0300") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, 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: , X-Patchwork-Original-From: Alexandre Oliva via Gcc-patches From: Alexandre Oliva Reply-To: Alexandre Oliva 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?1753339619164195095?= X-GMAIL-MSGID: =?utf-8?q?1753339619164195095?= Use NO_INSERT to test whether inserting should be attempted. Regstrapped on x86_64-linux-gnu. Ok to install? for gcc/cp/ChangeLog * constraint.cc (normalize_concept_check): Use NO_INSERT for pre-insertion check. --- gcc/cp/constraint.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index 37eae03afdb73..f28f96ada463e 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -777,14 +777,16 @@ normalize_concept_check (tree check, tree args, norm_info info) norm_entry entry = {tmpl, targs, NULL_TREE}; norm_entry **slot = nullptr; hashval_t hash = 0; + bool insert = false; if (!info.generate_diagnostics ()) { /* Cache the normal form of the substituted concept-id (when not diagnosing). */ hash = norm_hasher::hash (&entry); - slot = norm_cache->find_slot_with_hash (&entry, hash, INSERT); - if (*slot) + slot = norm_cache->find_slot_with_hash (&entry, hash, NO_INSERT); + if (slot) return (*slot)->norm; + insert = true; } /* The concept may have been ill-formed. */ @@ -794,7 +796,7 @@ normalize_concept_check (tree check, tree args, norm_info info) info.update_context (check, args); tree norm = normalize_expression (def, targs, info); - if (slot) + if (insert) { /* Recompute SLOT since norm_cache may have been expanded during the recursive call. */ From patchwork Tue Dec 27 04:22:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 36767 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1219572wrt; Mon, 26 Dec 2022 20:23:38 -0800 (PST) X-Google-Smtp-Source: AMrXdXvC/4SJVS2oUEAzYAqePiqrWevVzykejZLOk5UTkGph9x9TNjXBLIWEeBf3jfjPhVPrp9K1 X-Received: by 2002:a05:6402:104d:b0:486:ac69:b9e4 with SMTP id e13-20020a056402104d00b00486ac69b9e4mr1442888edu.4.1672115018846; Mon, 26 Dec 2022 20:23:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672115018; cv=none; d=google.com; s=arc-20160816; b=P1dHWR2GEq3OfSfEL65pnyEHfVZy6mFvT8JKZoOdNh58iBM7LkDP4lpKO63i3YxQ1T dz2P3BVNhfTFffWZW0+0E8OOsKTL2YhxsN7/oeiTzeXmT9YfGg7qc8bRXQXn7Bcbct0G qHUh9mm6Nk6cv3yGiI8xvP3oZbZNBTKq+2HTz65AvC/hDxgx/wHyJzLEURMpZwEokP3f GMy4201/wK++omfAN9de9Sz0Iel1oiZcnoBm6x+OrPOh1TRobd/cAGejGo7jslys7Ov6 LlOpnKX95JXQk9MBfqijwbDO3w1XsB7XIG5lXVjZWu1K/nYuuLWlTWjCWtfJpzE/IqoL uUrw== 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:mime-version :user-agent:message-id:in-reply-to:date:references:organization :subject:to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=HjgLGbTwZlo/mdqI6jJwSYzhxqZ9P9dfpykfpRfmxro=; b=KO8CX50CfYChhMglCw0F6qYxF8H22lYtRAy/B73f6Pm/pbbHJe9aWiKy4eOzeALLtC xHj1SbWCJwNofq6D6UhqUgkkCJ59zfVUVmLGXyJUZ47hsc40b5eSUOz36l9AMCdEep9W hMpRUqmulCZ7+Q+D2ygpXi37JPehZarmOCwT/PYuPOObb0eV+1graheXO3OnKaLwoDD0 iS2wCrJva694+DQJE1+NVPlg6oeL+Q2AYAT47IEV73PU3cEtX+hoepjjd6KYfndyNKkK V7rrrP3hqXops0KAKpFszJ3hpzdazEZvU8J6PYaGlE09e7qK43iL6wNkvKfF7S4o6ZJn sOug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Fyrzl8Yd; 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=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id b23-20020aa7cd17000000b00461c3758704si8955116edw.36.2022.12.26.20.23.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Dec 2022 20:23:38 -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=@gcc.gnu.org header.s=default header.b=Fyrzl8Yd; 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D22FE3858C2D for ; Tue, 27 Dec 2022 04:23:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D22FE3858C2D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672115017; bh=HjgLGbTwZlo/mdqI6jJwSYzhxqZ9P9dfpykfpRfmxro=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Fyrzl8Ydy7IC0GyhC+FPLSZG1Rb6bxTm1CnTUHCgI6wLPeie5X0Mod76j/WZwKHRx jTLl+pEzUXGSt8eEkwO6U9Vm1W5iDp0oKqlHNpR42ut3onVuME1wJcl7FEr60dcQU8 rQHBQdOTIzzpJqoVx0yQnJ81hDrBiu/mE2Nvy8GY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [IPv6:2620:20:4000:0:a9e:1ff:fe9b:1d1]) by sourceware.org (Postfix) with ESMTPS id 1CACB3858416 for ; Tue, 27 Dec 2022 04:22:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1CACB3858416 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id D71A21162AC; Mon, 26 Dec 2022 23:22:36 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id cLbmacll-P3P; Mon, 26 Dec 2022 23:22:36 -0500 (EST) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id 9EAB01162AB; Mon, 26 Dec 2022 23:22:36 -0500 (EST) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 2BR4MSad712153 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 27 Dec 2022 01:22:28 -0300 To: gcc-patches@gcc.gnu.org Subject: [05/13] ssa-loop-niter: skip caching of null operands Organization: Free thinker, does not speak for AdaCore References: Date: Tue, 27 Dec 2022 01:22:28 -0300 In-Reply-To: (Alexandre Oliva's message of "Tue, 27 Dec 2022 01:07:35 -0300") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, 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: , X-Patchwork-Original-From: Alexandre Oliva via Gcc-patches From: Alexandre Oliva Reply-To: Alexandre Oliva 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?1753339678323714773?= X-GMAIL-MSGID: =?utf-8?q?1753339678323714773?= When a TREE_OPERAND is NULL, do not cache it. Regstrapped on x86_64-linux-gnu. Ok to install? for gcc/ChangeLog * tree-ssa-loop-niter.cc (expand_simple_operands): Refrain from caching NULL TREE_OPERANDs. --- gcc/tree-ssa-loop-niter.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gcc/tree-ssa-loop-niter.cc b/gcc/tree-ssa-loop-niter.cc index fece876099c16..17645648326e8 100644 --- a/gcc/tree-ssa-loop-niter.cc +++ b/gcc/tree-ssa-loop-niter.cc @@ -2325,6 +2325,8 @@ expand_simple_operations (tree expr, tree stop, hash_map &cache) for (i = 0; i < n; i++) { e = TREE_OPERAND (expr, i); + if (!e) + continue; /* SCEV analysis feeds us with a proper expression graph matching the SSA graph. Avoid turning it into a tree here, thus handle tree sharing From patchwork Tue Dec 27 04:23:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 36769 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1220457wrt; Mon, 26 Dec 2022 20:28:22 -0800 (PST) X-Google-Smtp-Source: AMrXdXvkWshKKjx+9oeXHme2A8CpMgqEj0CU3RCwlG1JZsPWGyt2Msnphg53AY9l1TOud4sptxN5 X-Received: by 2002:a50:fe0e:0:b0:46f:9507:36bc with SMTP id f14-20020a50fe0e000000b0046f950736bcmr23021254edt.16.1672115301934; Mon, 26 Dec 2022 20:28:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672115301; cv=none; d=google.com; s=arc-20160816; b=X7xzIgMHNwG8NRSrdNChCWnMsjscPNKq83+5cTq5oV9jGsz+Ig7BKRJj62X0j5NCWQ y2rmv94kfF77w7rtDYPyQEZPCESal8AcLFhF19l1fs06WO0edyASLjA+2qyc947jyOCI YbmJpoXk2DX6IJpNWRZXV1c46D9ScUIrB2kA6uH8CIBCX/F0K3KebMbMV/Ki88QIfzOs YuIOaNOEH8LDawSVs23WHxIx+Rc2GY7JznYqhniQbohl6hIag0W7Omkj11Mb+bTeVAPg 5yWC2VVwUbhMDslzLvIKswyloFaeu+uq6UCUOzGCtY2iB9lpqiAEO29mGJife16vAvRv iGSg== 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:mime-version :user-agent:message-id:in-reply-to:date:references:organization :subject:to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=ICanSbrAIBRMKeEwo2aMRWmhuZdx7zWOKpQJ6LQJkjg=; b=kuTXQ+9XDfWtMcsTqd2Eg9wFibhv9X3a42KCInDwjl8bbxG1JL5VBHEUcIzVi8cUxv d8fQEs5ZISUo7cGRx2wbwB0wThDh8KsKVO+3QkREGecQLd0yMTpUcwENH+VSajnfzxRv 5XLd8jKOczhehKTLp+f83PF9HZXvW1C7ShIyCZ5KNWl2M4y/6YHDjBLuxGDVa+G4MOF1 ObBZII2UpzksvJE9vZ/OWPoOjEHFx37Tz9QnrMBFsh5m0bjjq71Q4E3RFZTYRMjoaM+B yHgncDOVgZsK0IQz4uFxLiXHJm0rJ7nMhYbxnog9o6zV310gJRdp18l2lVpOXZi+6ypJ tubQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=npj5Tepm; 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 d21-20020a056402079500b004700a51c22asi9421805edy.420.2022.12.26.20.28.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Dec 2022 20:28:21 -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=@gcc.gnu.org header.s=default header.b=npj5Tepm; 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 BB9CE3858416 for ; Tue, 27 Dec 2022 04:28:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BB9CE3858416 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672115300; bh=ICanSbrAIBRMKeEwo2aMRWmhuZdx7zWOKpQJ6LQJkjg=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=npj5TepmE25AMZBsbc9Iq/5JQM+HkAOCtKGxCVm9jX6O3uJSbnALsiwGjzaizqZxF mhxT5cByNpq+zqPBL7E8531kR4FMaoJzuNGU3UxRRa7UXOvOQ1mYZDtfJGk/5bST6y dg6aw9oXSbtXm7mCGCi2vAos5Td3ibtY3r6ZkOew= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTPS id BF0C33858D32 for ; Tue, 27 Dec 2022 04:27:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BF0C33858D32 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 854D31162AC; Mon, 26 Dec 2022 23:27:38 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 9DaWA6Dd0eZ5; Mon, 26 Dec 2022 23:27:38 -0500 (EST) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id 4D0571162AB; Mon, 26 Dec 2022 23:27:38 -0500 (EST) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 2BR4NMXR712163 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 27 Dec 2022 01:23:22 -0300 To: gcc-patches@gcc.gnu.org Subject: [06/13] tree-inline decl_map: skip mapping result's NULL default def Organization: Free thinker, does not speak for AdaCore References: Date: Tue, 27 Dec 2022 01:23:22 -0300 In-Reply-To: (Alexandre Oliva's message of "Tue, 27 Dec 2022 01:07:35 -0300") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, 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: , X-Patchwork-Original-From: Alexandre Oliva via Gcc-patches From: Alexandre Oliva Reply-To: Alexandre Oliva 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?1753339975119526802?= X-GMAIL-MSGID: =?utf-8?q?1753339975119526802?= If a result doesn't have a default def, don't attempt to remap it. Regstrapped on x86_64-linux-gnu. Ok to install? for gcc/ChangeLog * tree-inline.cc (declare_return_variable): Don't remap NULL default def of result. --- gcc/tree-inline.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gcc/tree-inline.cc b/gcc/tree-inline.cc index bfea1cc11822e..4556256dc32b1 100644 --- a/gcc/tree-inline.cc +++ b/gcc/tree-inline.cc @@ -3851,10 +3851,11 @@ declare_return_variable (copy_body_data *id, tree return_slot, tree modify_dest, it's default_def SSA_NAME. */ if (gimple_in_ssa_p (id->src_cfun) && is_gimple_reg (result)) - { - temp = make_ssa_name (temp); - insert_decl_map (id, ssa_default_def (id->src_cfun, result), temp); - } + if (tree default_def = ssa_default_def (id->src_cfun, result)) + { + temp = make_ssa_name (temp); + insert_decl_map (id, default_def, temp); + } insert_init_stmt (id, entry_bb, gimple_build_assign (temp, var)); } else From patchwork Tue Dec 27 04:24:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 36768 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1219866wrt; Mon, 26 Dec 2022 20:25:09 -0800 (PST) X-Google-Smtp-Source: AMrXdXtw5tbCDOWQt78+xEH5vhymIpDArHSZEcuZYEG5PMYxuA+ojLT1G6aEBeI9xsxYD8Xod5Uz X-Received: by 2002:a17:907:7da1:b0:7c0:d6b6:1ee9 with SMTP id oz33-20020a1709077da100b007c0d6b61ee9mr20173090ejc.11.1672115108945; Mon, 26 Dec 2022 20:25:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672115108; cv=none; d=google.com; s=arc-20160816; b=aSN90TyzQRYkDcybTYAge0s53HRsx1AXXbB/ILlQUpGGd5B3O9/C10fALshbzXYa6v yNKdl6DwizqjrwaRXdqiI4uezduEULnrWbEM+oUpC+yZGWRFyP58Xt9G7gdILXfA2Wj+ at4gkb8vr91HUq6jv/gcAsP81q47kiNvdCZUc7Dh6xj2io0pJvkVesrqbns1XjOqNbse mezwsBiX1g3mYqivmu1cQiuSQGT9geqcHjzgXLeShpWzkHcwaWP4r0wrck3EccZ8wZaZ gq6SJ/O555KVY3YM40V44F3it6xTz38Wc9kNOdNzQWqMn64bS421O7nI1qaTlq9xK47F F6ow== 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:mime-version :user-agent:message-id:in-reply-to:date:references:organization :subject:to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=rUtBeNzUuCxSRz2rrUo14KS99/91mJRJ/SsIDlDURqc=; b=maL1eXkuQO0EXNTFDHsO8JoNmB7d74O8AxHu8wEB5EWtyFXU6wWEnnM+uQ8KAmEego PeLsK3+iLtuFTiwgt0aDVPIDNSa7unMTYZbjOP66UVRLMqaEKyYTZIvbddfSZZuqPpcg oGqdLeaTgdPUaMl1HSELZzczvsKo+WM91mPPasNe999x04LvnoZpD70tqKfZOakZnfd+ 5GTBcGBnM502K4lQ1zL1+BdtX0ypP2PU3mgaR71Zseio2XV42NG4j1vbGCZDQPBTYrMy AtpD5lWWfyHNQWAZ8/zthJYAwDm47OmHkdOkwEH8IULBIX9WnYwTMXsXBp39RXoyjxQH jB2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=AanYDbSX; 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=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id q8-20020a50cc88000000b0047039339346si10017205edi.550.2022.12.26.20.25.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Dec 2022 20:25:08 -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=@gcc.gnu.org header.s=default header.b=AanYDbSX; 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 067403858C1F for ; Tue, 27 Dec 2022 04:25:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 067403858C1F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672115108; bh=rUtBeNzUuCxSRz2rrUo14KS99/91mJRJ/SsIDlDURqc=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=AanYDbSXBS4GCQbFD9MK0uOG4YFn4i4AjZPyqp6aFbRLothA6RStKASXH8l6xXiao 3z6OE3sapCBlqXV/EvMdsojhz+k8/1Lclh1vsYPgkbOed9ct8TYrrbDJBglAJjrYuc 5WZ7NvPcX7dueA2QJ3VUtWeRNX3tt3pbj5B4cq60= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTPS id 1AC7C3858D32 for ; Tue, 27 Dec 2022 04:24:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1AC7C3858D32 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id E3F361162AC; Mon, 26 Dec 2022 23:24:24 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 4vPr7Z8F8lnN; Mon, 26 Dec 2022 23:24:24 -0500 (EST) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id 978801162AB; Mon, 26 Dec 2022 23:24:23 -0500 (EST) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 2BR4OFS9712192 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 27 Dec 2022 01:24:16 -0300 To: gcc-patches@gcc.gnu.org Subject: [07/13] postreload-gcse: no insert on mere lookup Organization: Free thinker, does not speak for AdaCore References: Date: Tue, 27 Dec 2022 01:24:15 -0300 In-Reply-To: (Alexandre Oliva's message of "Tue, 27 Dec 2022 01:07:35 -0300") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, 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: , X-Patchwork-Original-From: Alexandre Oliva via Gcc-patches From: Alexandre Oliva Reply-To: Alexandre Oliva 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?1753339772562959612?= X-GMAIL-MSGID: =?utf-8?q?1753339772562959612?= lookup_expr_in_table is not used for insertions, but it mistakenly used INSERT rather than NO_INSERT. Regstrapped on x86_64-linux-gnu. Ok to install? for gcc/ChangeLog * postreload-gcse.cc (lookup_expr_in_table): Use NO_INSERT. --- gcc/postreload-gcse.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/postreload-gcse.cc b/gcc/postreload-gcse.cc index 1c795b43ca36b..2818f54dedd29 100644 --- a/gcc/postreload-gcse.cc +++ b/gcc/postreload-gcse.cc @@ -447,7 +447,7 @@ lookup_expr_in_table (rtx pat) tmp_expr->hash = hash; tmp_expr->avail_occr = NULL; - slot = expr_table->find_slot_with_hash (tmp_expr, hash, INSERT); + slot = expr_table->find_slot_with_hash (tmp_expr, hash, NO_INSERT); obstack_free (&expr_obstack, tmp_expr); if (!slot) From patchwork Tue Dec 27 04:28:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 36770 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1220736wrt; Mon, 26 Dec 2022 20:29:37 -0800 (PST) X-Google-Smtp-Source: AMrXdXsAxUy9A4evr76o/6KjBeiYOO5aeVyrIz3EhB25kLR445YI2ehEb9Yy83ABQgY2VkJ3lJMr X-Received: by 2002:a17:907:76fc:b0:7c0:edb6:e55f with SMTP id kg28-20020a17090776fc00b007c0edb6e55fmr17684667ejc.37.1672115377412; Mon, 26 Dec 2022 20:29:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672115377; cv=none; d=google.com; s=arc-20160816; b=wOunZDcUVrnuOJxK90cU6ki7e8WE1lSj9ECnS7hMEbluM2XXfpI5Xk3dK4r4uzAnkK 84AOkIwx7Yp+HMaBAoljzvJrICGAmh1xj0tP77HYijrRK9tThamM+MESyZul1kF8SrOk L7f8YbZneIGm6AQK237AK+Vgpx68aHuzVUJE5K8AED8I4eFJNZwYo+1+GIo6aC6i0VW0 1sySE3dtDiolGuPY4EQjAHawLVqiO/SIxl1pDH8Om01kogymOmm2msoP9FtCOC2LUIjP bJrwMGswFj/+5Geoo2MGOra/g/wuKe4IWwB0sw6rm5I8jez/cnSWKVSjtrOXaKshqOHP 4BMA== 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:mime-version :user-agent:message-id:in-reply-to:date:references:organization :subject:to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=hjoyAQbe1zLl3l1oJ07seSAUO6IgUyS/uxBV91i8J2A=; b=v90tMj2uyscaiMuLMrpFcXiWuSlScBsrYQejxROMCdSPiYtOVHpcL6ToWI6Fcl0DS+ 49gL+RRH+wHqXKlYk1e/9dEdxqbzL9lPribc+mikxf72b2FVfHRd2imlG0UL3fkRNd60 fv/wEvTTnf1mfaG+IvW5bSxYfsWTdwLaATPtncGJtQ4BeTkzp+0CHkhyvpOwAX5nBWkM L4uHaDIYTbQv61yQLi5I9dAbrhJ5WhYCPhnnbTjaW/Ncebyi5NS+Fg3J1zR+pHM1xz91 9ZxVoxZPuFRnZrItycrlc3uoLufdZ/5nEi525Hgsee1AiNerfzIceVcdp18H3ZxTM/ab ygJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=wz9W8PiO; 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=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id f8-20020a056402354800b004614acc0706si11427280edd.250.2022.12.26.20.29.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Dec 2022 20:29:37 -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=@gcc.gnu.org header.s=default header.b=wz9W8PiO; 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7848C3858C2B for ; Tue, 27 Dec 2022 04:29:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7848C3858C2B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672115376; bh=hjoyAQbe1zLl3l1oJ07seSAUO6IgUyS/uxBV91i8J2A=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=wz9W8PiOBq2/JIaA2K+CWst6ZHugdXq7xyHQycJQ70p9MWtz5uSiyuy0deV1Vje8Q guE7r7UoV2E7DslaBgkpGMImck1Sp+FoDTQ/M6DSWH3iAqMRQhhPYJ2TozgH7/gNoj GSw6+evpw6V0HLXLyu8B3SPVUtrdxpD+mZhThXkI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [IPv6:2620:20:4000:0:a9e:1ff:fe9b:1d1]) by sourceware.org (Postfix) with ESMTPS id CC82C3858D32 for ; Tue, 27 Dec 2022 04:28:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CC82C3858D32 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 9D8631162AC; Mon, 26 Dec 2022 23:28:53 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id V7C4PA5fthID; Mon, 26 Dec 2022 23:28:53 -0500 (EST) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id 3EC301162AB; Mon, 26 Dec 2022 23:28:53 -0500 (EST) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 2BR4SjDK712351 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 27 Dec 2022 01:28:45 -0300 To: gcc-patches@gcc.gnu.org Subject: [08/13] tm: complete tm_restart insertion Organization: Free thinker, does not speak for AdaCore References: Date: Tue, 27 Dec 2022 01:28:45 -0300 In-Reply-To: (Alexandre Oliva's message of "Tue, 27 Dec 2022 01:07:35 -0300") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, 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: , X-Patchwork-Original-From: Alexandre Oliva via Gcc-patches From: Alexandre Oliva Reply-To: Alexandre Oliva 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?1753340054144598932?= X-GMAIL-MSGID: =?utf-8?q?1753340054144598932?= Insertion of a tm_restart_node in tm_restart failed to record the newly-allocated node in the hash table. Regstrapped on x86_64-linux-gnu. Ok to install? for gcc/ChangeLog * trans-mem.cc (split_bb_make_tm_edge): Record new node in tm_restart. --- gcc/trans-mem.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/trans-mem.cc b/gcc/trans-mem.cc index 131dce05476ac..cbd1b891266fd 100644 --- a/gcc/trans-mem.cc +++ b/gcc/trans-mem.cc @@ -3215,7 +3215,7 @@ split_bb_make_tm_edge (gimple *stmt, basic_block dest_bb, struct tm_restart_node *n = *slot; if (n == NULL) { - n = ggc_alloc (); + *slot = n = ggc_alloc (); *n = dummy; } else From patchwork Tue Dec 27 04:30:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 36771 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1221058wrt; Mon, 26 Dec 2022 20:31:02 -0800 (PST) X-Google-Smtp-Source: AMrXdXut+RUEgfuXUmDrvGUGso9d4+7beO3wHJyNySje9RUJ0z+fmggTRcQLDeM4exfMc5ALXDya X-Received: by 2002:a05:6402:cb4:b0:483:6d73:ad02 with SMTP id cn20-20020a0564020cb400b004836d73ad02mr11245639edb.35.1672115462645; Mon, 26 Dec 2022 20:31:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672115462; cv=none; d=google.com; s=arc-20160816; b=xQybu9U6RIFDENfEaJdrEmUjttIDXjfvGtCXlADwXtm7iWVRa3uI8F5li7/FCCGY1V FjfnTDZm1zsBjJFY7xi13yAo2Y7fhbsf0v5cgEOq5aEbD1vPGvbifQl6PjGcupNNUW4x OBHOjZFGSVGRAtGq8mqOlPgfHHlNENsq+P1Tf/tJ2hbYhM7eRaikWuQa0S2cwjSoOYlY 3fXykMceUfihnh+3fPLhlsCAZ5ZXm2vtfwZ13frG1MJw5FEThjJzeejlPno6PmPFed2Q pfOP9Xun6TZ71ZCCPcSwypkNCkelGvXvOB7gxipNLrbMPlyADM4M6nZadUhtBzDK41Wp 6xYw== 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:mime-version :user-agent:message-id:in-reply-to:date:references:organization :subject:cc:to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=3TwQNnw9AuDlFblj0lK4GThcGK41glUKVXhzbrpRfkI=; b=OtRGAHx6WPYkgdpHQEuttYkQfF47m0GWoXy8kHqK4WLhGb/v/VqxjtA0N/Iz5hzKLF Nj1tnQ6A4ujAzDhCAAwBcbI0+9CbbULghEhhjn/CK64xxULihy/7jg+KkRDWbxA7IkaN p/w4WSJpqpvfeuSaS/S152mx+evsKQBwM4gQUfs+14mK2grwpga13sW1uSXuRxheMzY3 OarbkmqQ2CINoEsn9V46utrGcsAUpvKWmmHSfTfrLr2LKaqtVOV3s6ltNR4kPIruk4i4 /CnumPJPUKBSMfKMPWYfNRmOIMXPiQGm/SgVzaof2CdEcTpvda7UKSdiCjuk+B80+R4e 18KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=s48MBo7W; 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=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id b10-20020a056402084a00b0047df36b44f5si11211841edz.582.2022.12.26.20.31.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Dec 2022 20:31:02 -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=@gcc.gnu.org header.s=default header.b=s48MBo7W; 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A24333858C2D for ; Tue, 27 Dec 2022 04:31:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A24333858C2D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672115461; bh=3TwQNnw9AuDlFblj0lK4GThcGK41glUKVXhzbrpRfkI=; h=To:Cc:Subject:References:Date:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=s48MBo7WL0u4g1wWVNYY0aw7Nca5IEOhZs/u9lE5EJaGnvfWZ8W6rxsoBsZ7DRP9X mi57Ju2q26d/yNUbM3cO87zsf0vSokKSvedd0nFNs3iqdqMUJT/odWM+IMYotuvX6s z/aO+v86BAYOX7ehCtFy5F5PQXwUIPRVousll5VQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTPS id AA2693858D3C for ; Tue, 27 Dec 2022 04:30:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AA2693858D3C Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 7DC3D1162A6; Mon, 26 Dec 2022 23:30:09 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id x8Tbz2gYLg1O; Mon, 26 Dec 2022 23:30:09 -0500 (EST) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id 1CFB811628F; Mon, 26 Dec 2022 23:30:08 -0500 (EST) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 2BR4U0lW712370 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 27 Dec 2022 01:30:00 -0300 To: gcc-patches@gcc.gnu.org Cc: Jason Merrill , Nathan Sidwell Subject: [09/13] [C++] constexpr: request insert iff depth is ok Organization: Free thinker, does not speak for AdaCore References: Date: Tue, 27 Dec 2022 01:30:00 -0300 In-Reply-To: (Alexandre Oliva's message of "Tue, 27 Dec 2022 01:07:35 -0300") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, 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: , X-Patchwork-Original-From: Alexandre Oliva via Gcc-patches From: Alexandre Oliva Reply-To: Alexandre Oliva 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?1753340142938792238?= X-GMAIL-MSGID: =?utf-8?q?1753340142938792238?= cxx_eval_call_expression requests an INSERT even in cases when it would later decide not to insert. This could break double-hashing chains. Arrange for it to use NO_INSERT when the insertion would not be completed. Regstrapped on x86_64-linux-gnu. Ok to install? for gcc/cp/ChangeLog * constexpr.cc (cxx_eval_call_expression): Do not request an INSERT that would not be completed. --- gcc/cp/constexpr.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc index d99c49bdbe282..6d20ffa2cdeb6 100644 --- a/gcc/cp/constexpr.cc +++ b/gcc/cp/constexpr.cc @@ -3000,13 +3000,15 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, /* If we have seen this call before, we are done. */ maybe_initialize_constexpr_call_table (); + bool insert = depth_ok < constexpr_cache_depth; constexpr_call **slot - = constexpr_call_table->find_slot (&new_call, INSERT); - entry = *slot; + = constexpr_call_table->find_slot (&new_call, + insert ? INSERT : NO_INSERT); + entry = slot ? *slot : NULL; if (entry == NULL) { /* Only cache up to constexpr_cache_depth to limit memory use. */ - if (depth_ok < constexpr_cache_depth) + if (insert) { /* We need to keep a pointer to the entry, not just the slot, as the slot can move during evaluation of the body. */ From patchwork Tue Dec 27 04:35:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 36772 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1222408wrt; Mon, 26 Dec 2022 20:36:36 -0800 (PST) X-Google-Smtp-Source: AMrXdXuwhb63eWe3z3HGWjJhGAqTAR0rrM9Pi9mLvUiAcfKUQ7NYeKED5C9xBuk7teQYRWKyXczL X-Received: by 2002:a17:906:724b:b0:7c1:7669:629 with SMTP id n11-20020a170906724b00b007c176690629mr17341497ejk.49.1672115796873; Mon, 26 Dec 2022 20:36:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672115796; cv=none; d=google.com; s=arc-20160816; b=XP2UvPmkZSX7CweVWg+KWnxZ9E3ILszeR3VG7iB9y7cCq2/JZ2z9zPeJwibs9ffOUr SyLJF19hqb+vXkV2XPNn6ilEMlpEWwgrN1iQN34BnSSNvCf1Tb5hwY4LqVVtELldGP+V fyuCP9SrDYTd/rrbmFLpyldmV+KI6Gli4Z1J0yzvhLAmcCrhG0S6CENN/nKCFqFIQWA1 yZqkG+XKVU6u3ANaO3bFIn/w+sWGtrKbwXUdUR9hFuqbKY2n4LRyEuY3FtKBP1yGeJKr 0yQiuTus1s8rdZPyGS1Bd3Pv7lemG03tpU9X34jCVlbn7Juh5S67Eub+OGGe5LzyPmpz 9qZg== 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:mime-version :user-agent:message-id:in-reply-to:date:references:organization :subject:cc:to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=iAJcLChQMbxrg1h0EkXdm7nMJF9Nfav1QypwnGoURj0=; b=tQSvJRqHgFfgwjMWut20niWfOz90c5MxJqFFqZQXpPVGDuURdDMn6wC7HfhcVlnGF0 wSVW9eKAgq5+9xAGXN7H6VtZNYth/6szRu7pqqGoOiRx62wdVN0u2BprxGdcmxtAgnfb 9CIi9iq7ruTxUJHpoy5QawuR55wlAE0mM/tSc0te/t5euLfmnTczNnq7G5ZHZA+7JR0M bxuiwY8blhecPetnlzerLhPn4e/9pyXIFnqgniFEZEq5drwPT6/s9m7ibBuasemZl99T 9WW8wKcxu5jc3bvxYDgg0xj+bnRDm+sCabfBEAdTdpBzh3ikjSpYUf79fWwAnQp0I9V5 4tFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=dRDqxK1U; 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=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id gn12-20020a1709070d0c00b007ae26c753edsi11310140ejc.52.2022.12.26.20.36.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Dec 2022 20:36:36 -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=@gcc.gnu.org header.s=default header.b=dRDqxK1U; 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BCEA53858412 for ; Tue, 27 Dec 2022 04:36:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BCEA53858412 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672115795; bh=iAJcLChQMbxrg1h0EkXdm7nMJF9Nfav1QypwnGoURj0=; h=To:Cc:Subject:References:Date:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=dRDqxK1Ui3XOeBFWMetmqy7YgV/VwK/9nfSqGPx8ISKtBFY67vQ5Zl7SJoufiwA6M QqaqJu/wUd3Ggjjn9zwbqlhi5tsi3UpQ8E5hz7DaV2+wpQTv+lj3c1IoJXB772yxTa 9McCTxUyTlbqnhi0KfTGTGbx8c6NJBYtJB/XFE6U= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTPS id AC7D03858D32 for ; Tue, 27 Dec 2022 04:35:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AC7D03858D32 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 74C2B1162AB; Mon, 26 Dec 2022 23:35:53 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id FFiPhLlJGumF; Mon, 26 Dec 2022 23:35:53 -0500 (EST) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id 2292F11628F; Mon, 26 Dec 2022 23:35:52 -0500 (EST) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 2BR4ZjLR712560 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 27 Dec 2022 01:35:45 -0300 To: gcc-patches@gcc.gnu.org Cc: Richard Biener Subject: [10/13] lto: drop dummy partition mapping Organization: Free thinker, does not speak for AdaCore References: Date: Tue, 27 Dec 2022 01:35:45 -0300 In-Reply-To: (Alexandre Oliva's message of "Tue, 27 Dec 2022 01:07:35 -0300") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, 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: , X-Patchwork-Original-From: Alexandre Oliva via Gcc-patches From: Alexandre Oliva Reply-To: Alexandre Oliva 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?1753340493733181806?= X-GMAIL-MSGID: =?utf-8?q?1753340493733181806?= When adding a catch-all partition, we map NULL to it. That mapping is ineffective and unnecessary. Drop it. Regstrapped on x86_64-linux-gnu. Ok to install? for gcc/lto/ChangeLog * lto-partition.cc (lto_1_to_1_map): Drop NULL partition mapping. --- gcc/lto/lto-partition.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/gcc/lto/lto-partition.cc b/gcc/lto/lto-partition.cc index ebb9c3abe128c..654d67f272e92 100644 --- a/gcc/lto/lto-partition.cc +++ b/gcc/lto/lto-partition.cc @@ -333,7 +333,6 @@ lto_1_to_1_map (void) else { partition = new_partition (""); - pmap.put (NULL, partition); npartitions++; } From patchwork Tue Dec 27 04:38:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 36773 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1222880wrt; Mon, 26 Dec 2022 20:38:53 -0800 (PST) X-Google-Smtp-Source: AMrXdXulZ/JyCTeavuLukg7DH9K8NnwPEpvj3bAPnJbV7U4JsZn9XBW8gI1xcY2wpUqNXvKyPOgr X-Received: by 2002:a17:906:b7c4:b0:7c0:dac7:36dc with SMTP id fy4-20020a170906b7c400b007c0dac736dcmr21252128ejb.46.1672115933828; Mon, 26 Dec 2022 20:38:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672115933; cv=none; d=google.com; s=arc-20160816; b=j5UO6aMKDg37SQduFujfNQXus1WvaqeqSFwZvXwGdPQqa4pzqdsnD3oQQ7Ibbs9JMX p5WWQQj0dADafiT6ijcxKrUWIjLWUTQRuoNKpohezZJDYvk6mq/9ZY0F06r+h4eWlT7/ 70kbwGyV5iksfKF/dsBi8qr0TIq8lV8HcYyyGxJaFVYCrXAhMCOlXZ8x4hIPC4NhkwdV icy6pAl3HGptgibnqZ/bp8uvV2ui8VCkviWGOfZPc5YOj1xCfzDTPnkskqhoifaowiuk ve5ktxHM4DiruN7Ii8lSDTJXUVezq5eNwFxKZnstGxYXQNL3wsxWZjyvBSPxTJalUrO/ 2Qyg== 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:mime-version :user-agent:message-id:in-reply-to:date:references:organization :subject:cc:to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=IqDf9XnWor5jBjPURYaKN1705DwEV5dkarxbLVHfpl4=; b=gZYwTbfYfz6XoQL74EDOMdb94e45v0m+jjyx5UC+5K4SQwPdh85QlEP6eO1rAc6ylg JEPnEEpm5Ue64seA3l+/1PyDW4u2hjzgllWaczrq/s41enVThzbFU+nS9NKG7TZcaDPR 4oL2v//e6lhXciJuovDRYjsN2jpqgX/WS/85oMNWU7+/F8aKb4S7rzDwAWExsBDo0qPW V4tHNr3lIcNvUVc5SoINALRDm5378m3CwodfkvDDh09t9PmfsWKp5fmcsbzzSCN58rLQ XC0SW4atY8wIolM+dNstkGuaPvH8iI+WVjhmYUHqgJsz4xKFAe9ssU5MQUaZJf/Pb0ew cFyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=SRKfmJOi; 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=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id gn19-20020a1709070d1300b00817f6980923si9655913ejc.343.2022.12.26.20.38.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Dec 2022 20:38:53 -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=@gcc.gnu.org header.s=default header.b=SRKfmJOi; 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CDCEF385840D for ; Tue, 27 Dec 2022 04:38:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CDCEF385840D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672115932; bh=IqDf9XnWor5jBjPURYaKN1705DwEV5dkarxbLVHfpl4=; h=To:Cc:Subject:References:Date:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=SRKfmJOigo6d+CkkXWJokAxWox6KEk3okLxOWrYxjiA94+Y6bej04P0stJxTS54Jn rfEuDRpl+ueOfKM045Jzf4+LwdXUL6kpZCmAsNO3u7XlTWY6jN71Vr9uD7JdmpLF9K CPvHW/1glGE3L4V4pAPdGyqCxDCrA+DFnjh0DB0U= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTPS id 78C243858D32 for ; Tue, 27 Dec 2022 04:38:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 78C243858D32 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 4E2E71162A6; Mon, 26 Dec 2022 23:38:10 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id RRpX8B4dncfr; Mon, 26 Dec 2022 23:38:10 -0500 (EST) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id E609C11628F; Mon, 26 Dec 2022 23:38:09 -0500 (EST) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 2BR4c0pp712593 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 27 Dec 2022 01:38:00 -0300 To: gcc-patches@gcc.gnu.org Cc: Arnaud Charlet , Eric Botcazou , Marc =?utf-8?b?UG91bGhpw6hz?= , Pierre-Marie de Rodat Subject: [11/13] ada: don't map NULL decl to locus Organization: Free thinker, does not speak for AdaCore References: Date: Tue, 27 Dec 2022 01:38:00 -0300 In-Reply-To: (Alexandre Oliva's message of "Tue, 27 Dec 2022 01:07:35 -0300") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, 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: , X-Patchwork-Original-From: Alexandre Oliva via Gcc-patches From: Alexandre Oliva Reply-To: Alexandre Oliva 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?1753340637600077168?= X-GMAIL-MSGID: =?utf-8?q?1753340637600077168?= When decl is NULL, don't record its mapping in the decl_to_instance_map. Regstrapped on x86_64-linux-gnu. Ok to install? for gcc/ada/ChangeLog * gcc-interface/trans.cc (Sloc_to_locus): Don't map NULL decl. --- gcc/ada/gcc-interface/trans.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc index 59332f93614a9..6579ad11cc284 100644 --- a/gcc/ada/gcc-interface/trans.cc +++ b/gcc/ada/gcc-interface/trans.cc @@ -10564,7 +10564,7 @@ Sloc_to_locus (Source_Ptr Sloc, location_t *locus, bool clear_column, *locus = linemap_position_for_line_and_column (line_table, map, line, column); - if (file_map && file_map[file - 1].Instance) + if (decl && file_map && file_map[file - 1].Instance) decl_to_instance_map->put (decl, file_map[file - 1].Instance); return true; From patchwork Tue Dec 27 04:38:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 36774 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1223033wrt; Mon, 26 Dec 2022 20:39:41 -0800 (PST) X-Google-Smtp-Source: AMrXdXvRuVSs9wUDyXHXaQ6xKOweszf+F9CT50vpkiiXF5+XZqpZh/m5WSlBdgKvyKOvz5RA+kD7 X-Received: by 2002:a17:906:850c:b0:7c0:f44d:984 with SMTP id i12-20020a170906850c00b007c0f44d0984mr24249867ejx.74.1672115981150; Mon, 26 Dec 2022 20:39:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672115981; cv=none; d=google.com; s=arc-20160816; b=PV01vwwTSmRr0jVJzfTgAuQnHfr5BYeHCZgzMlR7di/TZuUqDnLSAnjJ36mrQ5aE+n 87zYnMj6Z3869v+UKfvByWTiMfRWT/Xk3fljENoaLGCFBtj8aPwZ8f2TN7EmNU9n7lW+ fayM3+RUGgG7wTHWzWeV16asvjySkfCL1/YnORXgxQ3LMHKhroPiOKiU5XudbC/tPtNc DO9boNJzWdTkAWZAjEKcqW/Y3B41QoqrIAfovxErNrMDUoKdAKyDjiCxcGQ2F3akeOrv jDoPw8yGYvOYeGGLZ3shdIsAkwuMfUj7/OMVfjLMk9LRlC7QY2ZSqw9GlH6kuqizNfPu Bvew== 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:mime-version :user-agent:message-id:in-reply-to:date:references:organization :subject:to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=o20KEfavBdD7EgRqu/jaVa/R2gJHcJBkbuTDAJUqoYM=; b=q75SQYVMGERxRfeOxbdj/aLm4BtLRs6On2F4DuiJqSfqj0WswWWqGiG2h2LNShQYIf Wzpy8uIrjQqE5ZO9GMRxp9+14E32vSUYvR/dz5DIwfYHNwSEXyJCMdES7axi0NdvP4M+ IdRz4tSqmi7cxhTFosjdVfFSBziDAnovUim1njZwXBaB69C54zD6bq9+FW1HNLDyaxts qe9UYIwg11rdne7w4zjmJWRty/ZdFzdP71DOYEDYmSv6KOtwihP1KPS6qU09ZFZTTYWy tjofl+S56P/jLlGR8xDz74CMi57YXqKlxS/CT0tx9IqtzoJIapmxqyyo8aAS8Tmsypcl kuYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=O3tN+NrC; 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=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id w16-20020a05640234d000b0046b953601besi11225854edc.29.2022.12.26.20.39.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Dec 2022 20:39: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=@gcc.gnu.org header.s=default header.b=O3tN+NrC; 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3AD543858D3C for ; Tue, 27 Dec 2022 04:39:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3AD543858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672115980; bh=o20KEfavBdD7EgRqu/jaVa/R2gJHcJBkbuTDAJUqoYM=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=O3tN+NrCyq5BYnGeQJNJZKGASpzg0z6olK+ZDOE0IQaIu2T/qifnbjwfB3aSIl/lh UJryfOL95p8fzzI+MqPN5wZzJ7Fp65Nxz/HULFW+Hocn2Ls7+0DxuiTZhXpsBy2O21 HklFm1wdmxpiKxEp6hqG/SfskO2WzNyOvkLUkgkw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTPS id DBB98385840D for ; Tue, 27 Dec 2022 04:38:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DBB98385840D Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id AEDC71162A6; Mon, 26 Dec 2022 23:38:58 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Nw9ZoLWITYvo; Mon, 26 Dec 2022 23:38:58 -0500 (EST) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id 73A1A11628F; Mon, 26 Dec 2022 23:38:58 -0500 (EST) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 2BR4coML712622 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 27 Dec 2022 01:38:50 -0300 To: gcc-patches@gcc.gnu.org Subject: [12/13] hash set: reject attempts to add empty values Organization: Free thinker, does not speak for AdaCore References: Date: Tue, 27 Dec 2022 01:38:50 -0300 In-Reply-To: (Alexandre Oliva's message of "Tue, 27 Dec 2022 01:07:35 -0300") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, 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: , X-Patchwork-Original-From: Alexandre Oliva via Gcc-patches From: Alexandre Oliva Reply-To: Alexandre Oliva 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?1753340687173820276?= X-GMAIL-MSGID: =?utf-8?q?1753340687173820276?= Check, after adding a key to a hash set, that the entry does not look empty. Regstrapped on x86_64-linux-gnu. Ok to install? for gcc/ChangeLog * hash-set.h (add): Check that the inserted entry does not look empty. --- gcc/hash-set.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gcc/hash-set.h b/gcc/hash-set.h index 76fa7f394561e..a98121a060eed 100644 --- a/gcc/hash-set.h +++ b/gcc/hash-set.h @@ -58,7 +58,11 @@ public: Key *e = m_table.find_slot_with_hash (k, Traits::hash (k), INSERT); bool existed = !Traits::is_empty (*e); if (!existed) - new (e) Key (k); + { + new (e) Key (k); + // Catch attempts to insert e.g. a NULL pointer. + gcc_checking_assert (!Traits::is_empty (*e)); + } return existed; } From patchwork Tue Dec 27 04:39:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 36775 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1223154wrt; Mon, 26 Dec 2022 20:40:23 -0800 (PST) X-Google-Smtp-Source: AMrXdXsCoADPwMe/JKgB3kkySexnRc2cuAJkpklYbZk66186AbKYbw0k0TtrQFZvol4whMHH4mzE X-Received: by 2002:a17:907:7da4:b0:78d:f455:b5dc with SMTP id oz36-20020a1709077da400b0078df455b5dcmr19923293ejc.28.1672116023051; Mon, 26 Dec 2022 20:40:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672116023; cv=none; d=google.com; s=arc-20160816; b=bE6RCh7BhDunkmzP7XZvHJB/NXlPzloSIIbM5tk9gnAd4YiDVrKiSPIyXEAdlrr62S v67wyhlOrqOQmJAc7MwDKMVnJDPlLqV8D1SP55OudC/mFZv7q7Uq242xh83JowmGtbLP 8+4kVrIgAo8Aa4R16OjcdM++j7G/R0n/kSu8uYzLpdomZAfJMKHTyBZ41nrdjhZoQLmi jIwKH2/aLQx0HHrVdyT15paR9/XRV5lS51Bby94FBlc22HPL/SNZGkZ0nL11hvdPIkN8 Ovj/L0Hm6EZcTzRSW5Wi2fl+7GxRz2LEEOc/4iYMxM5TrWFk0VxA6M0JXQWcl8LXr3Vt b45A== 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:mime-version :user-agent:message-id:in-reply-to:date:references:organization :subject:to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=QfuLFqacFOLfzmRv/gdCEZF7xCNP+kn61CNo/gKr2WE=; b=eefRP0A4hXvPPjO6CZmkOsXi8O7WRvzGPRp1bIYE29IIST0w2SX+gx3gdAXNxzk22e QdVFZ8XvkY0dFgZwYiZzL1xaXLT0+fkw/U7LwZGge9j4PyTBjDApYnn3xudIsqEVplDZ zd0Xx+K/V/u5aa8gBbL0kf+w93FWoY6BjDmrN/NWnVwVDEPtaZ/7InXO7jph5yhASVpF 6/Nifnm8eBTw36APU4rr+R1xeLkxLA3VOEy8FlakUHsFpeb5g9ErOgODHNHUwBcbrjNc IKvUrCQJIAO9aljJdUfx8jG1Nuj9yJqxK4tnRs9d6d5MBbPADxXaVO+bzo2NO0rx6THc lzGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=HnFh48n1; 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=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id fj3-20020a1709069c8300b0084b9ac8f8a3si6743384ejc.836.2022.12.26.20.40.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Dec 2022 20:40:23 -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=@gcc.gnu.org header.s=default header.b=HnFh48n1; 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1FDFC3858410 for ; Tue, 27 Dec 2022 04:40:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1FDFC3858410 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672116022; bh=QfuLFqacFOLfzmRv/gdCEZF7xCNP+kn61CNo/gKr2WE=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=HnFh48n1ykpBFBt9OOdhm8qpi/l22OyG4TupnIdiJrMmCBsa+uWQzQQLLzmFR3YnT KFQLsJK3hM2GfOT7+skkCZzw6DYu8CeCrq2J2q7TpTXg+sqshHd0EqiOGUVIwfuGVo 0d6b28GquT0Po9xci/bJtxLBOZVvNhRYCXaUoPHo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTPS id 0B6933858C27 for ; Tue, 27 Dec 2022 04:39:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0B6933858C27 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id D31D61162A6; Mon, 26 Dec 2022 23:39:39 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id lzd7Cq5YcRbW; Mon, 26 Dec 2022 23:39:39 -0500 (EST) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id 9B38711628F; Mon, 26 Dec 2022 23:39:39 -0500 (EST) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 2BR4dUtv712633 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 27 Dec 2022 01:39:30 -0300 To: gcc-patches@gcc.gnu.org Subject: [13/13] hash-map: reject empty-looking insertions Organization: Free thinker, does not speak for AdaCore References: Date: Tue, 27 Dec 2022 01:39:30 -0300 In-Reply-To: (Alexandre Oliva's message of "Tue, 27 Dec 2022 01:07:35 -0300") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, 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: , X-Patchwork-Original-From: Alexandre Oliva via Gcc-patches From: Alexandre Oliva Reply-To: Alexandre Oliva 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?1753340731232655215?= X-GMAIL-MSGID: =?utf-8?q?1753340731232655215?= Check, after inserting entries, that they don't look empty. Regstrapped on x86_64-linux-gnu. Ok to install? for gcc/ChangeLog * hash-map.h (put, get_or_insert): Check that entry does not look empty after insertion. --- gcc/hash-map.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gcc/hash-map.h b/gcc/hash-map.h index 457967f4bf1ae..63fa21cf37c5b 100644 --- a/gcc/hash-map.h +++ b/gcc/hash-map.h @@ -169,11 +169,12 @@ public: { hash_entry *e = m_table.find_slot_with_hash (k, Traits::hash (k), INSERT); - bool ins = hash_entry::is_empty (*e); + bool ins = Traits::is_empty (*e); if (ins) { e->m_key = k; new ((void *) &e->m_value) Value (v); + gcc_checking_assert (!Traits::is_empty (*e)); } else e->m_value = v; @@ -203,6 +204,7 @@ public: { e->m_key = k; new ((void *)&e->m_value) Value (); + gcc_checking_assert (!Traits::is_empty (*e)); } if (existed != NULL) From patchwork Wed Dec 28 12:30:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 37185 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1866525wrt; Wed, 28 Dec 2022 04:31:40 -0800 (PST) X-Google-Smtp-Source: AMrXdXuyo7Ulvh9RwWyWtddZ1VQZXLr+R4ylAzJeypw85BhtqlnIAY6JjgCVOCPlFLHl0pcg55wA X-Received: by 2002:a05:6402:206c:b0:474:47ce:eea0 with SMTP id bd12-20020a056402206c00b0047447ceeea0mr20331975edb.11.1672230700441; Wed, 28 Dec 2022 04:31:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672230700; cv=none; d=google.com; s=arc-20160816; b=ALowL3hLb/6NJDpUpKcGLhxFnQOFRQBASZeCHS5ypdvE8OOn2o7GYsq5Bm4SRmr4ao 9PO4nIkUcLuxLwTV6kIcdunRtZ9G3bB4DBFZtXiaiNes+ndcydCCIdqhNdMomV3gI48Y 1RGcWstbOJyDOdX71vETCWIQXf3DzK2HAe0i/oK1uM6hTXqs9WGlhW9nL6co2cR3zqs1 XIfEfVZCWhhqsYC1HlDbM4qT/nYjrMtEZHpvzFxszUf1brbjqrR26rCfH/eqWL1GdyjQ 9c2B9yB+ajaUHOlu0njc8T5x1A+RU3DX+sWJvPTjw6FF/VU/JjSh4kFFM7bbQKbxMIPO dRtg== 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:mime-version :user-agent:message-id:in-reply-to:date:references:organization :subject:to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=n5PwsATnwOwKcK9D/ZbQbe0pPPk3pau4khzaLYqHyVQ=; b=srG/Td5i/x9HvU5GdpbaW88BED7p+Zmsl3Az0MCTb0mKDNHXccZt9CfyncdiBhaat9 V0HaB1vb4MelmzUKy/4FeNj10s0YK5KLgm6QqSkfboiUBT7VGKqG5+dJGXeXHV8zRQOO sDPaHgJ62KnInKHvUbDIE2c1ns+JhQQZO30xg095TKvrYyAmHKZLFS2RdbvQxVi251Cc oDyLRAFcMuIIEQeyPf6TOOOvhChmRLuctT3PHrLXu/YnVXJRb44In+Wu03ki3vSJLU8l vOOW5DjkcVxxK3DCWJjRO8EPGuGoaVDfd0PoyFkrkTykyMXyBBDy714BLvNma3O2+LZl 1vZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Fx8D2uyZ; 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 x9-20020aa7d6c9000000b0046351fa4ae2si12098062edr.99.2022.12.28.04.31.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Dec 2022 04:31:40 -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=@gcc.gnu.org header.s=default header.b=Fx8D2uyZ; 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 3B6BA3858C3A for ; Wed, 28 Dec 2022 12:31:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3B6BA3858C3A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672230699; bh=n5PwsATnwOwKcK9D/ZbQbe0pPPk3pau4khzaLYqHyVQ=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Fx8D2uyZSIGpeQEI9E8uMExzQHn5/BUe0+AqsoRAigTmCG+GS4p4ZdOEy0jYhbTrG Xf5aRNd7ib/tWabzuKwW8JAk5rF4dapWzm2RCR0i9oRmyQgttgrTLIuuGXD1HOdPPL P5ARZU7TLGKJSKZ8M/AaEbzuMZSfHYPLFDBmbycs= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [IPv6:2620:20:4000:0:a9e:1ff:fe9b:1d1]) by sourceware.org (Postfix) with ESMTPS id D59E73858D33 for ; Wed, 28 Dec 2022 12:30:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D59E73858D33 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id BAE0B116312; Wed, 28 Dec 2022 07:30:47 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id V4i0L8UAU2Uy; Wed, 28 Dec 2022 07:30:47 -0500 (EST) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id 8899E116304; Wed, 28 Dec 2022 07:30:47 -0500 (EST) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 2BSCUdbC743553 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 28 Dec 2022 09:30:41 -0300 To: gcc-patches@gcc.gnu.org Subject: [14/17] parloops: don't request insert that won't be completed Organization: Free thinker, does not speak for AdaCore References: Date: Wed, 28 Dec 2022 09:30:39 -0300 In-Reply-To: (Alexandre Oliva's message of "Tue, 27 Dec 2022 01:07:35 -0300") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, 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: , X-Patchwork-Original-From: Alexandre Oliva via Gcc-patches From: Alexandre Oliva Reply-To: Alexandre Oliva 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?1753460978831134981?= X-GMAIL-MSGID: =?utf-8?q?1753460978831134981?= In take_address_of, we may refrain from completing a decl_address INSERT if gsi is NULL, so dnn't even ask for an INSERT in this case. Regstrapped on x86_64-linux-gnu. Ok to install? for gcc/ChangeLog * tree-parloops.cc (take_address_of): Skip INSERT if !gsi. --- gcc/tree-parloops.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gcc/tree-parloops.cc b/gcc/tree-parloops.cc index e680d97dd0497..b829ba7b873b6 100644 --- a/gcc/tree-parloops.cc +++ b/gcc/tree-parloops.cc @@ -1221,8 +1221,11 @@ take_address_of (tree obj, tree type, edge entry, uid = DECL_UID (TREE_OPERAND (TREE_OPERAND (*var_p, 0), 0)); int_tree_map elt; elt.uid = uid; - int_tree_map *slot = decl_address->find_slot (elt, INSERT); - if (!slot->to) + int_tree_map *slot = decl_address->find_slot (elt, + gsi == NULL + ? NO_INSERT + : INSERT); + if (!slot || !slot->to) { if (gsi == NULL) return NULL; From patchwork Wed Dec 28 12:32:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 37189 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1867448wrt; Wed, 28 Dec 2022 04:33:52 -0800 (PST) X-Google-Smtp-Source: AMrXdXuyuatLfeu/LsIlBaczaay8VPB6JuOLi18lp1ejGbJ9k130FxIuyWkUDUvujVp4gJoPk4AD X-Received: by 2002:a17:906:a2d6:b0:7c0:bf7c:19f4 with SMTP id by22-20020a170906a2d600b007c0bf7c19f4mr20186536ejb.74.1672230832212; Wed, 28 Dec 2022 04:33:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672230832; cv=none; d=google.com; s=arc-20160816; b=FETPajfxJEoEgzLyY6qEhB2No6Q2yfN3ouyH8a8XLHidxUmEPBQIJWyj3iNimaym52 84u9/jqdYjc1EwyMtvTyxdMbf2gSQn3hbF1lHEWP0Ua13wkRH2zTQkDEE/Iw3hkQPQ4i /bThn/T1OnG6xZmEvC1OvN98m0TTA7C8+takulhVnDSbJTTfq5/bJpM1uycEw9XwHLCa IzSQZX8W/PS7rm1CwBXAfZ4/rMH+SMLHiC8Wf9/2aC4oPc3UhRUOsBiROmnyuaan2xKv OPfLnh9LoL1EWCd0FUYAU2/rzoPHEytQP/xSiV9WsTP3PNHo76Alh5pn302FMIcrWStL n+4w== 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:mime-version :user-agent:message-id:in-reply-to:date:references:organization :subject:cc:to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=ManF7Tb7kpzpON2PUf0kBDZF9qXlXsJANibs3IpZkDg=; b=Iyxs77js90SmRUITaU9K0wH7VHTGQ8HbDbTnU5fbzMC3Oj+yIt2egEvD+fxq2KkVhv L3Hx1aZzB4yiuiJMAKwg+40USssmVLdYVsn5TVlROOub1QCEs5I29BQfhobkKkLLZfxq xvN6wfhYWUT6XmH1FssiIFx/8ckx1Xg/COz3PhlHwPk0WGo+vblug6zn1eqUU1NPrpVb IlcRF7VYfVWRUht+lFP905GRwn6wxr1OuzPhtNMbuixsdAgizgYaiKOmZbJWnCabpGw7 2mSOo8M9YVnpFy/Z7iJ5yoxzXYkJ+mHwIkECBDMipAJbvg6ts8thdh+W/1K6yQV/w1az LXag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=MaESk8e7; 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=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id xi9-20020a170906dac900b007c4f75345e7si13147009ejb.458.2022.12.28.04.33.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Dec 2022 04:33:52 -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=@gcc.gnu.org header.s=default header.b=MaESk8e7; 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 31D903858D35 for ; Wed, 28 Dec 2022 12:33:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 31D903858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672230831; bh=ManF7Tb7kpzpON2PUf0kBDZF9qXlXsJANibs3IpZkDg=; h=To:Cc:Subject:References:Date:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=MaESk8e7jbqvMsTFD9emnrU+qnPksPOh9P5iVw6rBqcRxLqk2PjlTMCGc/Ff6AgPa WHrq4pbrSjW/7P9RWWCSxhd74xNzxuno+bVRiW74kZ1ibXRnzRmFeDGwTu/iJEqGAg s9y6P55IMn2m34PLWoYZcuxsHnadFqKiNdpKcOqg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [IPv6:2620:20:4000:0:a9e:1ff:fe9b:1d1]) by sourceware.org (Postfix) with ESMTPS id 379033858D33 for ; Wed, 28 Dec 2022 12:33:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 379033858D33 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 07903116316; Wed, 28 Dec 2022 07:33:00 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id KEJ2LGTJ+gFU; Wed, 28 Dec 2022 07:32:59 -0500 (EST) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id C8688116312; Wed, 28 Dec 2022 07:32:59 -0500 (EST) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 2BSCWq86743588 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 28 Dec 2022 09:32:53 -0300 To: David Malcolm Cc: gcc-patches@gcc.gnu.org Subject: [15/17] prevent hash set/map insertion of deleted entries Organization: Free thinker, does not speak for AdaCore References: <613b4501636146942775f23cfa8035f9eb7b84d3.camel@redhat.com> Date: Wed, 28 Dec 2022 09:32:52 -0300 In-Reply-To: <613b4501636146942775f23cfa8035f9eb7b84d3.camel@redhat.com> (David Malcolm's message of "Tue, 27 Dec 2022 12:53:18 -0500") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, 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: , X-Patchwork-Original-From: Alexandre Oliva via Gcc-patches From: Alexandre Oliva Reply-To: Alexandre Oliva 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?1753461117474198492?= X-GMAIL-MSGID: =?utf-8?q?1753461117474198492?= On Dec 27, 2022, David Malcolm wrote: > Would it make sense to also add assertions that such entries aren't > Traits::is_deleted? (both for hash_map and hash_set) Yeah, I guess so. I've come up with something for hash-table proper too, coming up in 17/17. Just like the recently-added checks for empty entries, add checks for deleted entries as well. This didn't catch any problems, but it might prevent future accidents. Suggested by David Malcolm. Regstrapped on x86_64-linux-gnu. Ok to install? for gcc/ChangeLog * hash-map.h (put, get_or_insert): Check that added entry doesn't look deleted either. & hash-set.h (add): Likewise. --- gcc/hash-map.h | 8 +++++--- gcc/hash-set.h | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/gcc/hash-map.h b/gcc/hash-map.h index 63fa21cf37c5b..e6ca9cf5e6429 100644 --- a/gcc/hash-map.h +++ b/gcc/hash-map.h @@ -173,8 +173,9 @@ public: if (ins) { e->m_key = k; - new ((void *) &e->m_value) Value (v); - gcc_checking_assert (!Traits::is_empty (*e)); + new ((void *)&e->m_value) Value (v); + gcc_checking_assert (!Traits::is_empty (*e) + && !Traits::is_deleted (*e)); } else e->m_value = v; @@ -204,7 +205,8 @@ public: { e->m_key = k; new ((void *)&e->m_value) Value (); - gcc_checking_assert (!Traits::is_empty (*e)); + gcc_checking_assert (!Traits::is_empty (*e) + && !Traits::is_deleted (*e)); } if (existed != NULL) diff --git a/gcc/hash-set.h b/gcc/hash-set.h index a98121a060eed..08e1851d5118d 100644 --- a/gcc/hash-set.h +++ b/gcc/hash-set.h @@ -61,7 +61,8 @@ public: { new (e) Key (k); // Catch attempts to insert e.g. a NULL pointer. - gcc_checking_assert (!Traits::is_empty (*e)); + gcc_checking_assert (!Traits::is_empty (*e) + && !Traits::is_deleted (*e)); } return existed; From patchwork Wed Dec 28 12:46:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 37192 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1872625wrt; Wed, 28 Dec 2022 04:47:16 -0800 (PST) X-Google-Smtp-Source: AMrXdXtaRcQB7j8KeNRetxt8EyzfpafJLdOFrMWqeP83KuS+yj94sKt4CWrNCe6WXhkh+jEmKThI X-Received: by 2002:a17:906:345a:b0:7c0:eb33:892a with SMTP id d26-20020a170906345a00b007c0eb33892amr19417948ejb.77.1672231636768; Wed, 28 Dec 2022 04:47:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672231636; cv=none; d=google.com; s=arc-20160816; b=P/Yjs6Y00VLUS9bqRhQbVeeGsFF6DFgCknNwaTt7muqv1VeKwSZxvq89CwIi2tFKd3 5HtOiNoqQQitQ6uvFv6D6Rjo6PBWcOQZNArlXlbS3LKYEIpGnyEQh7UXswzP/89BYWAY +yi0shzcx+Q56NTCwA9hx+ejlBcgtboCzVlBfzhP2SHRHcXQr2b45WL5uxjEdw6x1Ax9 GU5Anmhu7MGvE2m3R4azw9bj/odN0iR8F8NFPwXYBiWaS+GME4Qf4leRijqfKzDDmHR0 QjEplU3yD5XqBrU2ULMbEhvFMdFnuYZzvrtr14YBwiejOElWUc5tZbTqSVymwAdUyK2o 1G1Q== 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 :content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:organization:subject:cc:to:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=SznVbtpk0UZCxzIlwNSbUWfWRmg8LH5ID5puFhQOCYs=; b=lqUV1yyBX3yHO576cISMz0mXJfJhHYnmp+/2ppsUCOajN7T0EtgdqfdFWyic5JuD6/ louiHOlWmR9OJaCeN+J56X0HXBl8DDtVsiDPwqqLV5HctN9ZO1zyQc1my9sCnDPNKDdq +gtvs99otBpAxszqfr8nO0w3WWFewv14U4stXjqEk+JVv5vId4xYUnva0meZoHhbe5GX 6Pz1Z0z8BDvULVqWflhV3x+G/E00pJ/IvGdyikjwa/bJc1YSa4AajiUxqJY4RSju7A3Z hvp1FgJQE+LAbBnXe6ZHJSlMfd1ZNBVqvxoFcJdvfUgZN6hLF7ljQ9Z+85vz8EZZApYL 2wbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="O/+LXSSe"; 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 dt12-20020a170907728c00b00817f698091csi13208080ejc.301.2022.12.28.04.47.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Dec 2022 04:47:16 -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=@gcc.gnu.org header.s=default header.b="O/+LXSSe"; 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 8FDE33858D3C for ; Wed, 28 Dec 2022 12:47:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8FDE33858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672231635; bh=SznVbtpk0UZCxzIlwNSbUWfWRmg8LH5ID5puFhQOCYs=; h=To:Cc:Subject:References:Date:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=O/+LXSSekLka5MCb3+v3Cn3X132WU6MM5Guxx0xiuNnFzPnYAfaGOPfWLfrzaRoW9 nFSvvpSQEUK8db52HtU7J78ep/4wxfIVdSStB6Q/PgZq4zIUhkq7MCRC5UR1cuxBFy Epf0yD5xjwYN3VsdnXH0VGD9mgNTgaGzsjccn6us= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [IPv6:2620:20:4000:0:a9e:1ff:fe9b:1d1]) by sourceware.org (Postfix) with ESMTPS id 5AB113858D33 for ; Wed, 28 Dec 2022 12:46:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5AB113858D33 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 21287116304; Wed, 28 Dec 2022 07:46:33 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id jqewHsGVlnxu; Wed, 28 Dec 2022 07:46:33 -0500 (EST) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id DD2D5116213; Wed, 28 Dec 2022 07:46:32 -0500 (EST) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 2BSCkLkR743977 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 28 Dec 2022 09:46:22 -0300 To: Martin =?utf-8?b?TGnFoWth?= Cc: gcc-patches@gcc.gnu.org Subject: [16/17] check hash table counts at expand Organization: Free thinker, does not speak for AdaCore References: Date: Wed, 28 Dec 2022 09:46:20 -0300 In-Reply-To: ("Martin \=\?utf-8\?Q\?Li\=C5\=A1ka\=22's\?\= message of "Wed, 28 Dec 2022 09:50:11 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, 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: , X-Patchwork-Original-From: Alexandre Oliva via Gcc-patches From: Alexandre Oliva Reply-To: Alexandre Oliva 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?1753461960831163573?= X-GMAIL-MSGID: =?utf-8?q?1753461960831163573?= On Dec 28, 2022, Martin Liška wrote: > I really like the verification code you added. It's quite similar to what > I added to hash-table.h: *nod* Prompted by your encouragement, I've combined the element count verification code with the verify() loop, and also added it to expand, where it can be done cheaply. Add cheap verification of element and deleted entry counts during expand and hash verify. Regstrapped on x86_64-linux-gnu. Ok to install? for gcc/ChangeLog * hash-table.h (expand): Check elements and deleted counts. (verify): Likewise. --- gcc/hash-table.h | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/gcc/hash-table.h b/gcc/hash-table.h index 53507daae26c3..f4bda6102323e 100644 --- a/gcc/hash-table.h +++ b/gcc/hash-table.h @@ -805,19 +805,28 @@ hash_table::expand () hash_table_usage ().release_instance_overhead (this, sizeof (value_type) * osize); + size_t n_deleted = m_n_deleted; + m_entries = nentries; m_size = nsize; m_size_prime_index = nindex; m_n_elements -= m_n_deleted; m_n_deleted = 0; + size_t n_elements = m_n_elements; + value_type *p = oentries; do { value_type &x = *p; - if (!is_empty (x) && !is_deleted (x)) + if (is_empty (x)) + ; + else if (is_deleted (x)) + n_deleted--; + else { + n_elements--; value_type *q = find_empty_slot_for_expand (Descriptor::hash (x)); new ((void*) q) value_type (std::move (x)); /* After the resources of 'x' have been moved to a new object at 'q', @@ -829,6 +838,8 @@ hash_table::expand () } while (p < olimit); + gcc_checking_assert (!n_elements && !n_deleted); + if (!m_ggc) Allocator ::data_free (oentries); else @@ -1018,8 +1029,9 @@ hash_table return &m_entries[index]; } -/* Verify that all existing elements in th hash table which are - equal to COMPARABLE have an equal HASH value provided as argument. */ +/* Verify that all existing elements in the hash table which are + equal to COMPARABLE have an equal HASH value provided as argument. + Also check that the hash table element counts are correct. */ template class Allocator> @@ -1027,14 +1039,23 @@ void hash_table ::verify (const compare_type &comparable, hashval_t hash) { + size_t n_elements = m_n_elements; + size_t n_deleted = m_n_deleted; for (size_t i = 0; i < MIN (hash_table_sanitize_eq_limit, m_size); i++) { value_type *entry = &m_entries[i]; - if (!is_empty (*entry) && !is_deleted (*entry) - && hash != Descriptor::hash (*entry) - && Descriptor::equal (*entry, comparable)) - hashtab_chk_error (); + if (!is_empty (*entry)) + { + n_elements--; + if (is_deleted (*entry)) + n_deleted--; + else if (hash != Descriptor::hash (*entry) + && Descriptor::equal (*entry, comparable)) + hashtab_chk_error (); + } } + if (hash_table_sanitize_eq_limit >= m_size) + gcc_checking_assert (!n_elements && !n_deleted); } /* This function deletes an element with the given COMPARABLE value From patchwork Wed Dec 28 12:50:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 37193 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1873841wrt; Wed, 28 Dec 2022 04:51:18 -0800 (PST) X-Google-Smtp-Source: AMrXdXtELOrsw3jNk+saL7l9GkxYyBDkqaSDGO2eJtAqDUPCvDxztUVRJ9XHvRARM1jrS3LvAaLB X-Received: by 2002:a05:6402:1819:b0:463:c960:7589 with SMTP id g25-20020a056402181900b00463c9607589mr20198656edy.40.1672231878627; Wed, 28 Dec 2022 04:51:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672231878; cv=none; d=google.com; s=arc-20160816; b=C7g7XkMn4fCKQBuroiPMcDy9yJ6LvVD374e4q/gj3vlNmLNmQ5133GuHNH6kDz59AI v4TpzUVlADTSkv1tjF4LXQKeT6vh+6oL4VrlG1A8zXHUiWpweiUHX9ONUzSZSo5U5Arn 6ilS5vLFwZuYqSjWGRJ7PFpkhreudmiHya/SX8hxqh2AgDkcRRrqsofb6WGKBbLPWxdt k7nZr5c7p/H2DHBiLSFObU8zm6sRIG2lgpxt0ZS1jaTheBWlWg6gb44rQgI7/fkZ8X3z SImUWVWoZC8Bd8l3cvR1Y3Mc0E4Agfa6JSUbTF1eRcVNWwTLZJuYsE9rILYVFJf4KH96 oLLw== 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:mime-version :user-agent:message-id:in-reply-to:date:references:organization :subject:to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=9AAKtjJuS6Nf76eh9BXvmE1MkZZ7t4J7QdWZmiYymXE=; b=F9ZqJqpOM2SNvXu0XxXwsa4ozuf3VoZG5OReQdn3jMBxubcdQNPQ0ezISubQOsEubA q0erX9iBfg4Yva9D5cY3ThZX55aiAwQnZNtsjbwHjGRfGI37Em5rZpDu2V6h5qzozcNL /fq2fKBlAU0hn3QkI9TJU+YKocZoMoGfU/CxhsSi0mgDkXmXnyB2Rvol00kw7AlLoE8n /FlN7hRXKW6DyeXCqw1KHLzKwdqWklpnw6VNpCs3lHwAgxIJi8NzgwkPd3amX1Av3pap 2f7yjVLAG6tYPXpJyBHcV1Jm8YAaIltmvGggrDVR8k/e42Nn4rLTdptcNH3D55bEJu7g qn8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ZOivGfFQ; 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 v18-20020a056402349200b0047b405e7746si14777235edc.1.2022.12.28.04.51.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Dec 2022 04:51:18 -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=@gcc.gnu.org header.s=default header.b=ZOivGfFQ; 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 E02563858D3C for ; Wed, 28 Dec 2022 12:51:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E02563858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672231876; bh=9AAKtjJuS6Nf76eh9BXvmE1MkZZ7t4J7QdWZmiYymXE=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=ZOivGfFQvzMAfE7kZTRw4yZOaz4Zbi870ttsaDujS+RZMV1TxqoJEegsLfp/9s7Be WbinoXwBp3LeRh7MzyhTnzfFGrz9QpsijzS5QX2VSbBODtP3u1c4snWGNvQpgatQJE hMgJeS7drpkFmUFa9p8inu1iFp+GCKQicp8X5H8E= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [IPv6:2620:20:4000:0:a9e:1ff:fe9b:1d1]) by sourceware.org (Postfix) with ESMTPS id 859EE3858D33 for ; Wed, 28 Dec 2022 12:50:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 859EE3858D33 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 598BF116316; Wed, 28 Dec 2022 07:50:34 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id z2OgpBsHNfKc; Wed, 28 Dec 2022 07:50:34 -0500 (EST) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id 061F4116312; Wed, 28 Dec 2022 07:50:33 -0500 (EST) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 2BSCoQ02744060 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 28 Dec 2022 09:50:26 -0300 To: gcc-patches@gcc.gnu.org Subject: [17/17] check hash table insertions Organization: Free thinker, does not speak for AdaCore References: Date: Wed, 28 Dec 2022 09:50:26 -0300 In-Reply-To: (Alexandre Oliva's message of "Tue, 27 Dec 2022 01:07:35 -0300") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, 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: , X-Patchwork-Original-From: Alexandre Oliva via Gcc-patches From: Alexandre Oliva Reply-To: Alexandre Oliva 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?1753462213858171829?= X-GMAIL-MSGID: =?utf-8?q?1753462213858171829?= On Dec 27, 2022, Alexandre Oliva wrote: > The number of bugs it revealed tells me that leaving callers in charge > of completing insertions is too error prone. I found this > verification code a bit too expensive to enable in general. Here's a relatively cheap, checking-only test to catch dangling inserts. I've noticed a number of potential problems in hash tables, of three kinds: insertion of entries that seem empty, dangling insertions, and lookups during insertions. These problems may all have the effect of replacing a deleted entry with one that seems empty, which may disconnect double-hashing chains involving that entry, and thus cause entries to go missing. This patch detects such problems by recording a pending insertion and checking that it's completed before other potentially-conflicting operations. The additional field is only introduced when checking is enabled. Regstrapped on x86_64-linux-gnu. Ok to install? for gcc/ChnageLog * hash-table.h (check_complete_insertion, check_insert_slot): New hash_table methods. (m_inserting_slot): New hash_table field. (begin, hash_table ctors, ~hash_table): Check previous insert. (expand, empty_slow, clear_slot, find_with_hash): Likewise. (remote_elt_with_hash, traverse_noresize): Likewise. (gt_pch_nx): Likewise. (find_slot_with_hash): Likewise. Record requested insert. --- gcc/hash-table.h | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 60 insertions(+), 3 deletions(-) diff --git a/gcc/hash-table.h b/gcc/hash-table.h index f4bda6102323e..33753d04b7bdb 100644 --- a/gcc/hash-table.h +++ b/gcc/hash-table.h @@ -495,6 +495,7 @@ public: { if (Lazy && m_entries == NULL) return iterator (); + check_complete_insertion (); iterator iter (m_entries, m_entries + m_size); iter.slide (); return iter; @@ -551,8 +552,39 @@ private: Descriptor::mark_empty (v); } +public: + void check_complete_insertion () const + { +#if CHECKING_P + if (!m_inserting_slot) + return; + + gcc_checking_assert (m_inserting_slot >= &m_entries[0] + && m_inserting_slot < &m_entries[m_size]); + + if (!is_empty (*m_inserting_slot)) + m_inserting_slot = NULL; + else + gcc_unreachable (); +#endif + } + +private: + value_type *check_insert_slot (value_type *ret) + { +#if CHECKING_P + gcc_checking_assert (is_empty (*ret)); + m_inserting_slot = ret; +#endif + return ret; + } + +#if CHECKING_P + mutable value_type *m_inserting_slot; +#endif + /* Table itself. */ - typename Descriptor::value_type *m_entries; + value_type *m_entries; size_t m_size; @@ -607,6 +639,9 @@ hash_table::hash_table (size_t size, bool ggc, ATTRIBUTE_UNUSED, mem_alloc_origin origin MEM_STAT_DECL) : +#if CHECKING_P + m_inserting_slot (0), +#endif m_n_elements (0), m_n_deleted (0), m_searches (0), m_collisions (0), m_ggc (ggc), m_sanitize_eq_and_hash (sanitize_eq_and_hash) #if GATHER_STATISTICS @@ -639,6 +674,9 @@ hash_table::hash_table (const hash_table &h, ATTRIBUTE_UNUSED, mem_alloc_origin origin MEM_STAT_DECL) : +#if CHECKING_P + m_inserting_slot (0), +#endif m_n_elements (h.m_n_elements), m_n_deleted (h.m_n_deleted), m_searches (0), m_collisions (0), m_ggc (ggc), m_sanitize_eq_and_hash (sanitize_eq_and_hash) @@ -646,6 +684,8 @@ hash_table::hash_table (const hash_table &h, , m_gather_mem_stats (gather_mem_stats) #endif { + h.check_complete_insertion (); + size_t size = h.m_size; if (m_gather_mem_stats) @@ -675,6 +715,8 @@ template class Allocator> hash_table::~hash_table () { + check_complete_insertion (); + if (!Lazy || m_entries) { for (size_t i = m_size - 1; i < m_size; i--) @@ -778,6 +820,8 @@ template::expand () { + check_complete_insertion (); + value_type *oentries = m_entries; unsigned int oindex = m_size_prime_index; size_t osize = size (); @@ -853,6 +897,8 @@ template::empty_slow () { + check_complete_insertion (); + size_t size = m_size; size_t nsize = size; value_type *entries = m_entries; @@ -901,6 +947,8 @@ template::clear_slot (value_type *slot) { + check_complete_insertion (); + gcc_checking_assert (!(slot < m_entries || slot >= m_entries + size () || is_empty (*slot) || is_deleted (*slot))); @@ -927,6 +975,8 @@ hash_table if (Lazy && m_entries == NULL) m_entries = alloc_entries (size); + check_complete_insertion (); + #if CHECKING_P if (m_sanitize_eq_and_hash) verify (comparable, hash); @@ -976,6 +1026,8 @@ hash_table } if (insert == INSERT && m_size * 3 <= m_n_elements * 4) expand (); + else + check_complete_insertion (); #if CHECKING_P if (m_sanitize_eq_and_hash) @@ -1022,11 +1074,11 @@ hash_table { m_n_deleted--; mark_empty (*first_deleted_slot); - return first_deleted_slot; + return check_insert_slot (first_deleted_slot); } m_n_elements++; - return &m_entries[index]; + return check_insert_slot (&m_entries[index]); } /* Verify that all existing elements in the hash table which are @@ -1068,6 +1120,8 @@ void hash_table ::remove_elt_with_hash (const compare_type &comparable, hashval_t hash) { + check_complete_insertion (); + value_type *slot = find_slot_with_hash (comparable, hash, NO_INSERT); if (slot == NULL) return; @@ -1094,6 +1148,8 @@ hash_table::traverse_noresize (Argument argument) if (Lazy && m_entries == NULL) return; + check_complete_insertion (); + value_type *slot = m_entries; value_type *limit = slot + size (); @@ -1210,6 +1266,7 @@ template static void gt_pch_nx (hash_table *h) { + h->check_complete_insertion (); bool success = gt_pch_note_object (h->m_entries, h, hashtab_entry_note_pointers); gcc_checking_assert (success);