On Mon, 2 May 2022, Jakub Jelinek wrote:

> On Fri, Apr 29, 2022 at 01:23:46PM +0200, Richard Biener wrote:
> > On Fri, 29 Apr 2022, Jakub Jelinek wrote:
> > 
> > > On Fri, Apr 29, 2022 at 01:11:31PM +0200, Jakub Jelinek via Gcc-patches 
> > > wrote:
> > > > Depends.  DECL_IN_CONSTANT_POOL decls can appear 2 ways, through
> > > > tree_output_constant_def which does create a varpool node for them
> > > > and is generally invoked during GIMPLE passes or so, and using
> > > > output_constant_def, which is called during expansion or later and 
> > > > doesn't
> > > > have varpool nodes created unless say alias.cc creates those for them.
> > > 
> > > Oh, and one thing I forgot.  The constant pool decls can be put into 
> > > section
> > > anchors, so it is essential that we handle DECL_IN_CONSTANT_POOL decls
> > > there and don't just punt on those.
> > 
> > Ah, OK - that makes sense (maybe we should create varpool nodes at the
> > point we associate them with anchors, or alternatively use the varpool
> > node of the anchor?).
> 
> I've bootstrapped/regtested the following on x86_64-linux and i686-linux,
> then bootstrapped with the patch reverted, reapplied the patch and did make
> cc1plus in stage3.  The debug section sizes are identical, .debug_info and
> .debug_loc is identical too, so I think we don't lose any debug info through
> it.
> 
> Ok for trunk?

OK.

Richard.

> 2022-05-02  Jakub Jelinek  <ja...@redhat.com>
> 
>       PR debug/105415
>       * cfgexpand.cc (expand_debug_expr): Don't make_decl_rtl_for_debug
>       if there is no symtab node for the VAR_DECL.
> 
>       * gcc.dg/pr105415.c: New test.
> 
> --- gcc/cfgexpand.cc.jj       2022-03-09 19:54:17.112284770 +0100
> +++ gcc/cfgexpand.cc  2022-04-29 12:33:32.585363999 +0200
> @@ -4565,7 +4565,8 @@ expand_debug_expr (tree exp)
>             || !DECL_NAME (exp)
>             || DECL_HARD_REGISTER (exp)
>             || DECL_IN_CONSTANT_POOL (exp)
> -           || mode == VOIDmode)
> +           || mode == VOIDmode
> +           || symtab_node::get (exp) == NULL)
>           return NULL;
>  
>         op0 = make_decl_rtl_for_debug (exp);
> --- gcc/testsuite/gcc.dg/pr105415.c.jj        2022-04-28 12:26:13.174302870 
> +0200
> +++ gcc/testsuite/gcc.dg/pr105415.c   2022-04-28 12:25:36.770809149 +0200
> @@ -0,0 +1,26 @@
> +/* PR debug/105415 */
> +/* { dg-do compile } */
> +/* { dg-require-effective-target pthread } */
> +/* { dg-options "-O2 -ftree-parallelize-loops=2 -fcompare-debug" } */
> +
> +int m;
> +static int n;
> +
> +void
> +foo (void)
> +{
> +  int s = 0;
> +
> +  while (m < 1)
> +    {
> +      s += n;
> +      ++m;
> +    }
> +}
> +
> +void
> +bar (int *arr, int i)
> +{
> +  while (i < 1)
> +    arr[i++] = 1;
> +}
> 
> 
>       Jakub
> 
> 

-- 
Richard Biener <rguent...@suse.de>
SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg,
Germany; GF: Ivo Totev; HRB 36809 (AG Nuernberg)

Reply via email to