From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [IPv6:2001:67c:2050::465:102]) by sourceware.org (Postfix) with ESMTPS id 2336E393D01A for ; Fri, 30 Jul 2021 11:01:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2336E393D01A Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4Gbkwr2PzszQk3L; Fri, 30 Jul 2021 13:01:32 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter02.heinlein-hosting.de (spamfilter02.heinlein-hosting.de [80.241.56.116]) (amavisd-new, port 10030) with ESMTP id fPs5CLGcLxcu; Fri, 30 Jul 2021 13:01:29 +0200 (CEST) From: Iain Buclaw To: gcc-patches@gcc.gnu.org Subject: [committed 10/12] d: Don't generate a PREDICT_EXPR when assert contracts are turned off. Date: Fri, 30 Jul 2021 13:01:09 +0200 Message-Id: <20210730110111.569140-10-ibuclaw@gdcproject.org> In-Reply-To: <20210730110111.569140-1-ibuclaw@gdcproject.org> References: <20210730110111.569140-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 9FA8D1838 X-Rspamd-UID: 689ed4 X-Spam-Status: No, score=-15.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Fri, 30 Jul 2021 11:01:34 -0000 This expression is just discarded by add_stmt, so never reaches the middle-end. gcc/d/ChangeLog: * expr.cc (ExprVisitor::visit (AssertExp *)): Don't generate PREDICT_EXPR. --- gcc/d/expr.cc | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/gcc/d/expr.cc b/gcc/d/expr.cc index 76c1e613e77..73e0abeaa43 100644 --- a/gcc/d/expr.cc +++ b/gcc/d/expr.cc @@ -2085,15 +2085,9 @@ public: } else { - /* Assert contracts are turned off, if the contract condition has no - side effects can still use it as a predicate for the optimizer. */ - if (TREE_SIDE_EFFECTS (arg)) - { - this->result_ = void_node; - return; - } - - assert_fail = build_predict_expr (PRED_NORETURN, NOT_TAKEN); + /* Assert contracts are turned off. */ + this->result_ = void_node; + return; } /* Build condition that we are asserting in this contract. */ -- 2.30.2