Hi,
this patch workarounds ICE in gimple_static_chain_flags.  I added a
sanity check that the nested function is never considered interposable
because such situation makes no sense: nested functions have no static
API and can not be safely merged across translation units.
It turns out however that this triggers for Ada and also for Fortran if
LTO partitioning separates nested function from its origin.  The secon
is bug in binds_to_current_def_p which I was fixing some time ago but it
seems that the patch got lost :(

So I will dig it out and fix the situation property however to unbreak
periodic testers I am silencing the ICE for now (at expense of missed
optimization)

Honza

gcc/ChangeLog:

2021-11-04  Jan Hubicka  <hubi...@ucw.cz>

        PR ipa/103058
        * gimple.c (gimple_call_static_chain_flags): Handle case when
        nested function does not bind locally.

diff --git a/gcc/gimple.c b/gcc/gimple.c
index 76768c19c8e..7a578f5113e 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -1666,7 +1666,18 @@ gimple_call_static_chain_flags (const gcall *stmt)
          int modref_flags = summary->static_chain_flags;
 
          /* We have possibly optimized out load.  Be conservative here.  */
-         gcc_checking_assert (node->binds_to_current_def_p ());
+         if (!node->binds_to_current_def_p ())
+           {
+             if ((modref_flags & EAF_UNUSED) && !(flags & EAF_UNUSED))
+               {
+                 modref_flags &= ~EAF_UNUSED;
+                 modref_flags |= EAF_NOESCAPE;
+               }
+             if ((modref_flags & EAF_NOREAD) && !(flags & EAF_NOREAD))
+               modref_flags &= ~EAF_NOREAD;
+             if ((modref_flags & EAF_DIRECT) && !(flags & EAF_DIRECT))
+               modref_flags &= ~EAF_DIRECT;
+           }
          if (dbg_cnt (ipa_mod_ref_pta))
            flags |= modref_flags;
        }

Reply via email to