https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63874

            Bug ID: 63874
           Summary: vtable address generation goes through memory
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
            Target: aarch64

Take:
struct a
{
  virtual void f(void);
  virtual ~a();
};
struct b : a
{
  virtual void f(void);
  virtual ~b();
};
void b::f(void){}
b::~b(void){}

Currently b::~b() produces:
_ZN1bD2Ev:
.LFB2:
    .cfi_startproc
    ldr    x1, .LC0
    str    x1, [x0]
    b    _ZN1aD2Ev
    .cfi_endproc

This really should be:
_ZN1bD2Ev:
.LFB1:
    .cfi_startproc
    adrp    x1, _ZTV1b+16
    add    x1, x1, :lo12:_ZTV1b+16
    str    x1, [x0]
    b    _ZN1aD2Ev

Which is produced if I don't have a definition of b::f() in the same TU causing
the vtable not to be defined weak in this TU.

Reply via email to