From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 5A068384B13A for ; Fri, 3 Sep 2021 13:50:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5A068384B13A 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-8-ofHWVy_IM9WyVfY2E2RPiQ-1; Fri, 03 Sep 2021 09:50:57 -0400 X-MC-Unique: ofHWVy_IM9WyVfY2E2RPiQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F1A8C18BA2AB; Fri, 3 Sep 2021 13:50:08 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.194.61]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 819435D9D3; Fri, 3 Sep 2021 13:50:08 +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 183Do5L0734474 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 3 Sep 2021 15:50:06 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.16.1/8.16.1/Submit) id 183Do5dm734473; Fri, 3 Sep 2021 15:50:05 +0200 From: Aldy Hernandez To: GCC patches Subject: [COMMITTED] Avoid using unavailable objects in jt_state. Date: Fri, 3 Sep 2021 15:49:53 +0200 Message-Id: <20210903134951.734347-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" X-Spam-Status: No, score=-13.2 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-List-Received-Date: Fri, 03 Sep 2021 13:51:03 -0000 [Jeff: I'm going to go out on a limb here and commit this under the obvious rule. If I am overstepping my obvious powers, please let me know.] The jump threading state is about to get more interesting, and it may get with a ranger or with the const_copies/etc helpers. This patch makes sure we have an object before we attempt to call push_marker or pop_to_marker. Tested on x86-64 Linux. gcc/ChangeLog: * tree-ssa-threadedge.c (jt_state::push): Only call methods for which objects are available. (jt_state::pop): Same. (jt_state::register_equiv): Same. (jt_state::register_equivs_on_edge): Same. --- gcc/tree-ssa-threadedge.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c index 8a485125ff5..e57f6d3e39c 100644 --- a/gcc/tree-ssa-threadedge.c +++ b/gcc/tree-ssa-threadedge.c @@ -1323,8 +1323,10 @@ jt_state::jt_state (const_and_copies *copies, void jt_state::push (edge) { - m_copies->push_marker (); - m_exprs->push_marker (); + if (m_copies) + m_copies->push_marker (); + if (m_exprs) + m_exprs->push_marker (); if (m_evrp) m_evrp->push_marker (); } @@ -1334,8 +1336,10 @@ jt_state::push (edge) void jt_state::pop () { - m_copies->pop_to_marker (); - m_exprs->pop_to_marker (); + if (m_copies) + m_copies->pop_to_marker (); + if (m_exprs) + m_exprs->pop_to_marker (); if (m_evrp) m_evrp->pop_to_marker (); } @@ -1346,7 +1350,8 @@ jt_state::pop () void jt_state::register_equiv (tree dst, tree src, bool update_range) { - m_copies->record_const_or_copy (dst, src); + if (m_copies) + m_copies->record_const_or_copy (dst, src); /* If requested, update the value range associated with DST, using the range from SRC. */ @@ -1396,7 +1401,8 @@ jt_state::record_ranges_from_stmt (gimple *stmt, bool temporary) void jt_state::register_equivs_on_edge (edge e) { - record_temporary_equivalences (e, m_copies, m_exprs); + if (m_copies && m_exprs) + record_temporary_equivalences (e, m_copies, m_exprs); } jump_threader_simplifier::jump_threader_simplifier (vr_values *v) -- 2.31.1