This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [ipa-branch] Devirtualization - enhanced patch


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]