> 
> 
> On 3/11/24 4:38 PM, Eric Botcazou wrote:
> > Hi,
> > 
> > this is a regression present on all active branches: the attached Ada 
> > testcase
> > triggers an assertion failure when compiled with -O2 -gnatp -flto:
> > 
> >    /* Initialize the static chain.  */
> >    p = DECL_STRUCT_FUNCTION (fn)->static_chain_decl;
> >    gcc_assert (fn != current_function_decl);
> >    if (p)
> >      {
> >        /* No static chain?  Seems like a bug in tree-nested.cc.  */
> >        gcc_assert (static_chain);                                  <--- here
> > 
> >        setup_one_parameter (id, p, static_chain, fn, bb, &vars);
> >      }
> > 
> > The problem is that the ICF pass identifies two functions, one of which has 
> > a
> > static chain but the other does not.  The proposed fix is just to prevent 
> > this
> > identification from occurring.
> > 
> > Tested on x86-64/Linux, OK for all active branches?
> > 
> > 
> > 2024-03-11  Eric Botcazou  <ebotca...@adacore.com>
> > 
> >     PR ipa/113996
> >     * ipa-icf.h (sem_function): Add static_chain_present member.
> >     * ipa-icf.cc (sem_function::get_hash): Hash it.
> >     (sem_function::equals_wpa): Compare it.
> >     (sem_function::equals_private): Likewise.
> >     (sem_function::init): Initialize it.
> > 
> > 
> > 2024-03-11  Eric Botcazou  <ebotca...@adacore.com>
> > 
> >     * gnat.dg/lto27.adb: New test.
> OK.
Patch is still OK, but ipa-ICF will only identify the functions if
static chain is unused. Perhaps just picking the winning candidate to be
version without static chain and making ipa-inline to not ICE when calls
with static chain lands to function with no static chain would help us
to optimize better.

Also IPA-SRA can optimize out unused static chains and ipa-prop can
propagate across them.

Honza
> jeff
> 

Reply via email to