Hi Richard,

Thanks you for your reply.
And sorry for not responding in time.

The reason why the ctor_for_folding was not used here before is that the 
variable here is read-only, and  ctor_for_folding would return error_mark_node.
If I want to keep the size check for array, I had to skip the check of 
ctor_for_folding , and use get_constructor () directly.
I think you're right, the boundary warning here is indeed not critical.
Your fix works for me fine.

Thanks,
Zekun

> -----Original Message-----
> From: Richard Biener [mailto:richard.guent...@gmail.com]
> Sent: 2020年4月29日 16:48
> To: lizekun (A) <lizek...@huawei.com>
> Cc: gcc-patches@gcc.gnu.org
> Subject: Re: [PATCH]use vnode->get_constructor () to get intial in
> lto[PR94822]
> 
> On Wed, Apr 29, 2020 at 8:44 AM Richard Biener
> <richard.guent...@gmail.com> wrote:
> >
> > On Wed, Apr 29, 2020 at 6:04 AM lizekun (A) <lizek...@huawei.com>
> wrote:
> > >
> > > Hi,
> > >
> > > This ICE appears because gcc will stream it to the function_body
> > > section when processing the variable with the initial value of the
> > > constructor type, and the error_mark_node to the decls section. When
> recompiling, the value obtained with DECL_INITIAL will be error_mark.
> > >
> > > This patch use vnode->get_constructor () to get intial in lto.
> > >
> > > Bootstrap and tested on aarch64 Linux platform.
> >
> > You should use ctor_for_folding to get all the magic correct.  Note
> > that this function returns error_mark_node if there is no usable
> > initializer, NULL if there is zero-init and sth else for the actual
> > initializer.  You can use
> >
> >   if (tree init = ctor_for_folding (base))
> >     if (init && init != error_mark_node)
> >       {
> > ...
> >       }
> >
> > Not to mention this whole function is a red herring ...:/
> 
> So I tested this and ctor_for_folding is too strict but we also do not stream
> ctors not usable for folding but to the LTRANS unit that is responsible for 
> the
> variable output.
> 
> So instead I am simply testing an additional != error_mark_node check.
> The size, if "important", should be resolved before LTO.
> 
> Richard.
> 
> > Thanks,
> > Richard.
> >
> > >
> > > Best regulars,
> > > Zekun
> > >
> > >
> > > gcc:
> > > +2020-04-29  Li Zekun  <lizek...@huawei.com>
> > > +
> > > +       PR  lto/94822
> > > +       * tree.c: use vnode->get_constructor () to get intial in lto
> > >
> > > gcc/testsuite:
> > > +2020-04-29  Li Zekun  <lizek...@huawei.com>
> > > +
> > > +       PR  lto/94822
> > > +       * gcc.dg/lto/pr94822.h: New test.
> > > +       * gcc.dg/lto/pr94822_0.c: New test.
> > > +       * gcc.dg/lto/pr94822_1.c: New test.

Reply via email to