On Sun, 15 Jan 2012, Jakub Jelinek wrote: > Hi! > > The recent changes in tree_function_versioning broke the following > testcase. If DECL_RESULT exists, but has void type, then we used to > remap_decl it before, but now we don't, so in this case the same RESULT_DECL > is used in two different functions, which upsets ipa-pta, but could upset > other code too. > > Fixed by calling remap_decl again for void type. Bootstrapped/regtested > on x86_64-linux and i686-linux (on x86_64 including ada). Ok for trunk?
Ok. Thanks, Richard. > 2012-01-15 Jakub Jelinek <ja...@redhat.com> > > PR tree-optimization/51865 > * tree-inline.c (tree_function_versioning): Call remap_decl > on DECL_RESULT whenever it has VOID_TYPE_P type. > > * gcc.dg/pr51865.c: New test. > > --- gcc/tree-inline.c.jj 2012-01-13 21:47:35.000000000 +0100 > +++ gcc/tree-inline.c 2012-01-15 20:00:00.350918475 +0100 > @@ -5201,9 +5201,9 @@ tree_function_versioning (tree old_decl, > /* Add local vars. */ > add_local_variables (DECL_STRUCT_FUNCTION (old_decl), cfun, &id, false); > > - if (VOID_TYPE_P (TREE_TYPE (DECL_RESULT (old_decl)))) > + if (DECL_RESULT (old_decl) == NULL_TREE) > ; > - else if (skip_return) > + else if (skip_return && !VOID_TYPE_P (TREE_TYPE (DECL_RESULT (old_decl)))) > { > DECL_RESULT (new_decl) > = build_decl (DECL_SOURCE_LOCATION (DECL_RESULT (old_decl)), > --- gcc/testsuite/gcc.dg/pr51865.c.jj 2012-01-15 20:09:00.035734459 +0100 > +++ gcc/testsuite/gcc.dg/pr51865.c 2012-01-15 20:08:42.000000000 +0100 > @@ -0,0 +1,25 @@ > +/* PR tree-optimization/51865 */ > +/* { dg-do compile } */ > +/* { dg-options "-O2 -fipa-pta" } */ > + > +void fn (const char *, const char *) __attribute__ ((__noreturn__)); > +int var; > + > +inline void > +foo (void) > +{ > + if (__builtin_expect (var != 0, 0)) > + fn ("a", "b"); > +}; > + > +void > +bar (void) > +{ > + foo (); > +}; > + > +void > +baz (void) > +{ > + foo (); > +}; > > Jakub > > -- Richard Guenther <rguent...@suse.de> SUSE / SUSE Labs SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer