Avoid using unavailable objects in jt_state.

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.
This commit is contained in:
Aldy Hernandez 2021-09-03 12:02:30 +02:00
parent b237eb9dfd
commit 2fcfc03459

View File

@ -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)