]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Remove impossible speculation in ipa_polymorphic_call_context::possible_dynamic_type_...
authorJan Hubicka <hubicka@ucw.cz>
Tue, 27 Jan 2026 18:18:13 +0000 (19:18 +0100)
committerJan Hubicka <hubicka@ucw.cz>
Tue, 27 Jan 2026 18:20:34 +0000 (19:20 +0100)
This patch makes ipa-cp dataflow monotone by making sure we do not use speculation that
was proved to be impossible earlier.

gcc/ChangeLog:

PR ipa/123619
* ipa-polymorphic-call.cc
(ipa_polymorphic_call_context::possible_dynamic_type_change): Remove impossible
speuculation.

gcc/ipa-polymorphic-call.cc

index 243a2f13cdc8dff23e3ac199f2db4ba7c02da1b7..5e53c217e33cee0db0b9c5a2a641ffa02f56dacb 100644 (file)
@@ -2363,7 +2363,18 @@ ipa_polymorphic_call_context::possible_dynamic_type_change (bool in_poly_cdtor,
                                                            tree otr_type)
 {
   if (dynamic)
-    make_speculative (otr_type);
+    {
+      /* See if existing speculation was inconsistent before type change.
+        If so drop it first, so we do not lose track about it being
+        impossible.  */
+      if (speculative_outer_type
+         && !speculation_consistent_p (speculative_outer_type,
+                                       speculative_offset,
+                                       speculative_maybe_derived_type,
+                                       otr_type))
+       clear_speculation ();
+      make_speculative (otr_type);
+    }
   else if (in_poly_cdtor)
     maybe_in_construction = true;
 }