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



Steven Bosscher <steven at gcc dot gnu.org> changed:



           What    |Removed                     |Added

----------------------------------------------------------------------------

           Keywords|                            |missed-optimization

             Status|UNCONFIRMED                 |NEW

   Last reconfirmed|                            |2013-02-25

            Summary|Generate one fewer          |[4.6/4.7/4.8 Regression]

                   |relocation when calling a   |Generate one fewer

                   |checked weakref function    |relocation when calling a

                   |                            |checked weakref function

     Ever Confirmed|0                           |1



--- Comment #2 from Steven Bosscher <steven at gcc dot gnu.org> 2013-02-25 
22:22:11 UTC ---

Slightly modified test case to avoid the relatively new weakref attribute:



int f() __attribute__((weak));  /* weakref(("foo")) */

void g() 

{ 

    int (*ptr)() = f; 

    if (ptr) 

        ptr(); 

}



GCC 4.8 r196182 (ignoring cfi stuff) with "-O2 -fPIC":

g:

        cmpq    $0, f@GOTPCREL(%rip)

        je      .L1

        xorl    %eax, %eax

        jmp     f@PLT

.L1:

        ret



GCC 4.1.3, GCC 4.4.7 and GCC 4.6.3 produce the same code as above.





GCC 3.4.6 with "-O2 -fPIC":

g:

    movq    f@GOTPCREL(%rip), %rdx

    testq    %rdx, %rdx

    je    .L1

    xorl    %eax, %eax

    movq    %rdx, %r11

    jmp    *%r11

    .p2align 4,,7

.L1:

    rep ; ret





Arguably GCC4 produces better code, but GCC 3.4.6 re-uses the address

loaded in the register.  I think that is the right thing to do, too.



So, marking as a regression.

Reply via email to