http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59031

            Bug ID: 59031
           Summary: vtable lookup not optimized away
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eraman at google dot com
                CC: jason at redhat dot com

Created attachment 31175
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31175&action=edit
Proposed patch

The fix to PR c++/11750 at r193504 caused a regression in the following code at
-O0:

class B {
 public:
  virtual int add (int a, int b) {return a+ b;}
};

class D : public B {
};

int foo (int a, int b) {
  D d;
  return d.add(a, b);
}

The call d.add(a, b) used to generate a direct call to B::add, but now
generates an indirect call. At -O2, FRE could devirtualize this in some
situations but not always. The attached patch fixes this case and bootstraps
fine. Is this a reasonable fix?

Reply via email to