On Sat, 14 Mar 2020, Jakub Jelinek wrote: > Hi! > > The following testcase fails with -fcompare-debug. The problem is that > bar is marked as address_taken only with -g and not without. > I've tracked it down to insert_init_stmt calling gimple_regimplify_operands > even on DEBUG_STMTs. That function will just insert normal stmts before > the DEBUG_STMT if the DEBUG_STMT operand isn't gimple val or invariant. > While DCE will turn those statements into debug temporaries, it can cause > differences in SSA_NAMEs and more importantly, the ipa references are > generated from those before the DCE happens. > On the testcase, the DEBUG_STMT value is (int)bar. > > We could generate DEBUG_STMTs with debug temporaries instead, but I fail to > see the reason to do that, DEBUG_STMTs allow other expressions and all we > want to ensure is that the expressions aren't too large (arbitrarily > complex), but during inlining/function versioning I don't see why something > would queue a DEBUG_STMT with arbitrarily complex expressions in there. > > So, this patch just doesn't regimplify DEBUG_STMTs. Bootstrapped/regtested > on x86_64-linux and i686-linux, ok for trunk?
OK. Thanks, Richard. > 2020-03-14 Jakub Jelinek <ja...@redhat.com> > > PR debug/94167 > * tree-inline.c (insert_init_stmt): Don't gimple_regimplify_operands > DEBUG_STMTs. > > * gcc.dg/pr94167.c: New test. > > --- gcc/tree-inline.c.jj 2020-03-04 12:58:35.033528551 +0100 > +++ gcc/tree-inline.c 2020-03-13 16:19:04.129493354 +0100 > @@ -3361,10 +3361,10 @@ insert_init_stmt (copy_body_data *id, ba > gimple_assign_set_rhs1 (init_stmt, rhs); > } > gsi_insert_after (&si, init_stmt, GSI_NEW_STMT); > - gimple_regimplify_operands (init_stmt, &si); > - > if (!is_gimple_debug (init_stmt)) > { > + gimple_regimplify_operands (init_stmt, &si); > + > tree def = gimple_assign_lhs (init_stmt); > insert_init_debug_bind (id, bb, def, def, init_stmt); > } > --- gcc/testsuite/gcc.dg/pr94167.c.jj 2020-03-13 16:33:34.046632902 +0100 > +++ gcc/testsuite/gcc.dg/pr94167.c 2020-03-13 16:33:08.353012748 +0100 > @@ -0,0 +1,33 @@ > +/* PR debug/94167 */ > +/* { dg-do compile } */ > +/* { dg-options "-O2 -fcompare-debug" } */ > + > +struct S { int g, h; signed char i; int j; signed char k; int l[4]; } a, c; > +struct T { signed char g; } e; > +int *b, d; > +static void foo (); > + > +void > +bar (void) > +{ > + while (d) > + { > + int k; > + struct T f[3]; > + foo (bar, a); > + for (k = 0;; k++) > + f[k] = e; > + } > +} > + > +static inline void > +foo (int x, struct S y, struct T z) > +{ > + for (z.g = 2; z.g; z.g--) > + { > + c = a = y; > + *b |= 6; > + if (y.g) > + break; > + } > +} > > Jakub > > -- Richard Biener <rguent...@suse.de> SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)