From patchwork Wed Sep 22 11:32:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 45284 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0C15A385843E for ; Wed, 22 Sep 2021 11:33:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0C15A385843E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1632310436; bh=Muu6CE5AQbctIijRroI2o2VLtQsJU3pJ6Z2HaN3p0GA=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Z0Ofsp2zXb1S2rwsrw3njqTFoSO7iXO81hNWuwcfSF89ovYw7+m4NleRCbQ2PDyU+ LqVsC4/Gx+e50t3BgRYqlg5gNbQydkXOpWBb0QiyLPbHl37aSBwSprsY2t/9r3InWe DOGoaaInlVX14Ry0zHZt3BEboh4ksw2+3teZGgWY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 6851A3858401 for ; Wed, 22 Sep 2021 11:32:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6851A3858401 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-289-hOUSzw_ePXayyzJZiatkGw-1; Wed, 22 Sep 2021 07:32:28 -0400 X-MC-Unique: hOUSzw_ePXayyzJZiatkGw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 22A3818125C0 for ; Wed, 22 Sep 2021 11:32:27 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.193.251]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2332B10016FF; Wed, 22 Sep 2021 11:32:21 +0000 (UTC) Received: from abulafia.quesejoda.com (localhost [127.0.0.1]) by abulafia.quesejoda.com (8.16.1/8.15.2) with ESMTPS id 18MBWJqB482996 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 22 Sep 2021 13:32:19 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.16.1/8.16.1/Submit) id 18MBWJMX482995; Wed, 22 Sep 2021 13:32:19 +0200 To: Andrew MacLeod Subject: [COMMITTED] Check for BB before calling register_outgoing_edges. Date: Wed, 22 Sep 2021 13:32:08 +0200 Message-Id: <20210922113207.482939-2-aldyh@redhat.com> In-Reply-To: <20210922113207.482939-1-aldyh@redhat.com> References: <20210922113207.482939-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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-Patchwork-Original-From: Aldy Hernandez via Gcc-patches From: Aldy Hernandez Reply-To: Aldy Hernandez Cc: GCC patches Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" We may be asked to fold an artificial statement not in the CFG. Since there are no outgoing edges from those, avoid calling register_outgoing_edges. Tested on x86-64 Linux. gcc/ChangeLog: * gimple-range-fold.cc (fold_using_range::range_of_range_op): Move check for non-empty BB here. (fur_source::register_outgoing_edges): ...from here. --- gcc/gimple-range-fold.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc index d7fa0f2c86e..1da1befa9a2 100644 --- a/gcc/gimple-range-fold.cc +++ b/gcc/gimple-range-fold.cc @@ -650,7 +650,9 @@ fold_using_range::range_of_range_op (irange &r, gimple *s, fur_source &src) src.register_relation (s, rel, lhs, op2); } } - else if (is_a (s)) + // Check for an existing BB, as we maybe asked to fold an + // artificial statement not in the CFG. + else if (is_a (s) && gimple_bb (s)) { basic_block bb = gimple_bb (s); edge e0 = EDGE_SUCC (bb, 0); @@ -1404,10 +1406,6 @@ fur_source::register_outgoing_edges (gcond *s, irange &lhs_range, edge e0, edge range_operator *handler; basic_block bb = gimple_bb (s); - // We may get asked to fold an artificial statement not in the CFG. - if (!bb) - return; - if (e0) { // If this edge is never taken, ignore it.