ipa: Meet same speculative and certain polymorphic contexts (PR123629)

PR 123629 is a somewhat complicated situation.  IPA-CP clones for a
known speculative polymorphic context in a situation when a caller
bringing the known context has itself already been cloned, and now we
can determine that the context coming from that clone is not
speculative (but otherwise the same).  This confuses the meet function
of contexts which gives up and returns a useless context, which in
turn triggers an assert because the value we originally cloned for is
nowhere to be found in the data structures which describe what we know
about the function clone.

This patch changes the meet function so that it can deal with this
situation.  When one of the contexts does not have a certain
component, the other one is moved to the speculative one.

gcc/ChangeLog:

2026-02-23  Martin Jambor  <mjambor@suse.cz>

	PR ipa/123629
	* ipa-polymorphic-call.cc
	(ipa_polymorphic_call_context::meet_with): When an outer context is
	NULL, call make_speculative on the other one.
This commit is contained in:
Martin Jambor
2026-02-27 11:58:01 +01:00
committed by Martin Jambor
parent cd13223e77
commit 654026083a

View File

@@ -2482,12 +2482,14 @@ ipa_polymorphic_call_context::meet_with (ipa_polymorphic_call_context ctx,
updated = true;
}
/* If call is known to be invalid, we are done. */
/* If a certain context is known to be invalid, we can move to comparing
speculation. Because the second context might be a certain one which can
be met with the speculation of the first, make it speculative. */
if (!outer_type)
;
ctx.make_speculative ();
else if (!ctx.outer_type)
{
clear_outer_type ();
make_speculative ();
updated = true;
}
/* If types are known to be same, merging is quite easy. */