[ipa-branch] Devirtualization - enhanced patch
Mircea Namolaru
NAMOLARU@il.ibm.com
Wed Nov 23 17:57:00 GMT 2005
Even if your examples don't break the devirtualization code,
they are interesting pointing to potential problems.
The second example shows indeed objects created may not be
detected by the current analysis that is looking for
constructors. In your example the classes created have no
virtual tables, hence not relevant for devirtualization.
They have a very simple constructor that don't appear at
gimple level. But if you add in your example a virtual
function (the method "f" was added in class fred in your
example, see below) the code correctly detects that the
classes "bar" and "foo" are created. I think that all the
classes requiring a virtual table have the constructors
appearing at gimple level, and in this case the
instantiated classes relevant for devirtualization
(or targets of virtual calls) are correctly detected.
I will add checks that the above assumption about the
constructors is indeed fulfilled.
class fred
{
public:
int a;
virtual int f () { return 1}; // added in the example
};
class foo : public fred
{
public:
int b;
};
class bar : public foo
{
public:
foo c;
};
static bar arr[5];
In the first example the classes have again no virtual
table and very simple constructors. This time the
constructors are inlined by early inlining and not seen
by devirtualization code. Even if early inlining will not
inline more complicated constructors, it seems better
to place the devirtualization before early inlining (it
is already placed before the inlining as it is supposed
to help it).
So thanks, and any other tests/comments are more
then welcomed.
Mircea
More information about the Gcc-patches
mailing list