http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45791
--- Comment #5 from Jan Hubicka <hubicka at gcc dot gnu.org> 2010-09-25
22:17:41 UTC ---
Another testcase where we devirtualize via folding is:
// { dg-do assemble }
// { dg-options "-g -O2" }
// Copyright (C) 1999 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 21 Nov 1999 <[email protected]>
// This causes assember relocation errors
struct X
{
virtual ~X () {}
};
struct Y
{
Y (){};
};
void foo ()
{
X *x = new X;
x->~X ();
Y ys[2];
}
compiled with -O2 we get
x_3 = operator new (8);
# DEBUG this => x_3
x_3->_vptr.X = &_ZTV1X[2];
# DEBUG x => x_3
D.2142_7 = (int (*__vtbl_ptr_type) (void)) __comp_dtor ;
OBJ_TYPE_REF(D.2142_7;x_3->0) (x_3);
that gets folded only in ccp3. We need FRE to fold:
x_3->_vptr.X = &_ZTV1X[2];
# DEBUG x => x_3
D.2141_6 = &_ZTV1X[2];
D.2142_7 = *D.2141_6;
OBJ_TYPE_REF(D.2142_7;x_3->0) (x_3);
into
x_3 = operator new (8);
# DEBUG this => x_3
x_3->_vptr.X = &_ZTV1X[2];
# DEBUG x => x_3
D.2141_6 = x_3->_vptr.X;
D.2142_7 = *D.2141_6;
OBJ_TYPE_REF(D.2142_7;x_3->0) (x_3);