This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [ipa-branch] Devirtualization - enhanced patch
- From: Daniel Berlin <dberlin at dberlin dot org>
- To: Mircea Namolaru <NAMOLARU at il dot ibm dot com>
- Cc: gcc-patches at gcc dot gnu dot org, hubicka at ucw dot cz, jh at suse dot cz
- Date: Mon, 21 Nov 2005 09:49:41 -0500
- Subject: Re: [ipa-branch] Devirtualization - enhanced patch
- References: <OFF93B7822.368B7234-ONC22570C0.003265B0-422570C0.003822AC@il.ibm.com>
On Mon, 2005-11-21 at 12:08 +0200, Mircea Namolaru wrote:
> > It is possible in our IR, to make an indirect call to a constructor,
> even if it
> > is not legal at the C++ level.
> >
> > and in fact, we do so in initialization and destruction of global
> objects,
> > and other places (IE we have arrays of pointers to constructors that are
>
> > called, etc).
>
> As I said detecting all the classes instantiated ensures the correctness
> of
> the algorithm. If the current analysis doesn't do this it should be fixed.
>
> It will be very helpful if you could be more specific about the cases
> where
> in your opinion the analysis is broken.
There are a number of places, but okay, let's start simple.
Given where you've placed the pass, the following simple testcase will
never have foo or fred marked as TYPE_OBJ_CREATED, but both are created
(one directly by bar's constructor, both indirectly by being
subclasses).
-----------------------------------------------------------
class fred
{
public:
inline fred() __attribute__ ((always_inline))
{
g = 9;
}
int g;
};
class foo : public fred
{
public:
inline foo() __attribute__ ((always_inline))
{
a = 5;
}
int a;
};
class bar : public foo
{
public:
inline bar() __attribute__ ((always_inline))
{
f = 5;
}
int f;
foo b;
};
static bar arr[5];
--------------------------------------------------------
In the next testcase, you will claim no objects are instantiated, and
yet, we really instantiate 5 bar's directly. This is true no matter
where you move the pass.
---------------------------------------------------------------------
class fred
{
public:
int a;
};
class foo : public fred
{
public:
int b;
};
class bar : public foo
{
public:
foo c;
};
static bar arr[5];
-----------------------------------------------------------------------
--Dan