http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59883
Bug ID: 59883 Summary: Missed C++ front-end devirtualizations Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hubicka at gcc dot gnu.org I believe the following testcase: struct A { virtual int foo (void) {return foo();} }; struct B { struct A a; }; struct A a[7]; int test(void) { return a[3].foo(); } int test2(struct B *b) { return b->a.foo(); } ought to get devirtualized by C++ FE based on the fact that the object is contained within an structure or array. (this is related to PR46507) In the following testcase: namespace { struct A { virtual int foo (void) {return 42;} }; } int test(void) { struct A a, *b=&a; return b->foo(); } We can now probably use ipa-devirt's type inheritance graph to work out right away that A is a final class. And finally: struct A { virtual int foo (void) {return foo();} }; IMO allows devirtualization of self recursive functions