On Wed, 11 Feb 2015, Jakub Jelinek wrote: > Hi! > > This patch fixes a thinko in -fsection-anchors alias handling code > Honza added in r211357. Usually for aliases we don't create > SYMBOL_REF_HAS_BLOCK_INFO_P, but in the following testcase we do, > because the rtl is created through notice_global_symbol already > when the symbol wasn't an alias, only later optimizations made it into > an alias. The thinko is that DECL_RTL of the alias target would be > SYMBOL_REF, I think that can't ever happen, usually the DECL_RTL would > be a MEM with SYMBOL_REF operand.
Yeah, indeed. > I've bootstrapped/regtested this on > {x86_64,i686,ppc64,ppc64le,aarch64,armv7hl,s390,s390x}-linux without > regressions, so I hope the assertion this way is safe, if not, we'd > need to avoid turning a symbol into an alias somewhere much earlier. > > Ok for trunk? Ok. Thanks, Richard. > 2015-02-11 Jakub Jelinek <ja...@redhat.com> > > PR middle-end/65003 > * varasm.c (place_block_symbol): Assert that DECL_RTL of the > ultimate alias is MEM with SYMBOL_REF satisfying > SYMBOL_REF_HAS_BLOCK_INFO_P as its operand. Don't pass the MEM > to place_block_symbol, but instead pass the SYMBOL_REF operand of it. > > * g++.dg/opt/pr65003.C: New test. > > --- gcc/varasm.c.jj 2015-02-04 15:24:20.000000000 +0100 > +++ gcc/varasm.c 2015-02-10 15:37:55.872609142 +0100 > @@ -7180,6 +7180,10 @@ place_block_symbol (rtx symbol) > { > rtx target = DECL_RTL (snode->ultimate_alias_target ()->decl); > > + gcc_assert (MEM_P (target) > + && GET_CODE (XEXP (target, 0)) == SYMBOL_REF > + && SYMBOL_REF_HAS_BLOCK_INFO_P (XEXP (target, 0))); > + target = XEXP (target, 0); > place_block_symbol (target); > SYMBOL_REF_BLOCK_OFFSET (symbol) = SYMBOL_REF_BLOCK_OFFSET (target); > return; > --- gcc/testsuite/g++.dg/opt/pr65003.C.jj 2015-02-10 15:50:44.240734029 > +0100 > +++ gcc/testsuite/g++.dg/opt/pr65003.C 2015-02-10 15:50:39.468814055 > +0100 > @@ -0,0 +1,31 @@ > +// PR middle-end/65003 > +// { dg-do compile } > +// { dg-options "-O2" } > +// { dg-additional-options "-fpic" { target fpic } } > + > +struct A > +{ > + void operator= (A &); > + A (); > +}; > +struct B > +{ > + A b; > +}; > +struct C > +{ > + virtual bool foo (int &, bool) const; > +}; > +struct D : virtual C > +{ > + bool foo (int &, bool) const; > + B e; > +}; > +struct F : D > +{ > + F (int &, const int &, const A &); > + bool foo (int &, bool) const; > +}; > +bool D::foo (int &, bool) const {} > +F::F (int &, const int &, const A &) {} > +bool F::foo (int &, bool) const {} > > Jakub > > -- Richard Biener <rguent...@suse.de> SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu, Graham Norton HRB 21284 (AG Nuernberg)