This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] use symbol_ref flags for rs6000


That when it is a local direct call, in the example it on gcc 3.4 before the original patch went in:
.data
.align 2
_thunk.0:
.long 1317011488
.space 16
.text
.align 2
.globl _main
_main:
mflr r2
stw r31,-4(r1)
stw r2,8(r1)
stwu r1,-80(r1)
bl _thunk.0
addi r1,r1,80
lwz r2,8(r1)
lwz r31,-4(r1)
mtlr r2
blr


This is direct jump, not going through a dyld stub which is what you are think of, if the variable is extern then it slow and has to go through a stub (the only reason why it is slower is because it has to load each time the address for the function for a call and get where the current pc is).

int main()
{
        extern int thunk[5];
        ((int (*)(void))thunk) ();
}

This produces the call to the stub (without -mdynamic-no-pic):
.text
        .align 2
        .globl _main
_main:
        mflr r2
        stw r31,-4(r1)
        stw r2,8(r1)
        stwu r1,-80(r1)
        bl L_thunk$stub
        addi r1,r1,80
        lwz r2,8(r1)
        lwz r31,-4(r1)
        mtlr r2
        blr
.data
.section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
        .align 2
L_thunk$stub:
        .indirect_symbol _thunk
        mflr r0
        bcl 20,31,L0$_thunk
L0$_thunk:
        mflr r11
        addis r11,r11,ha16(L_thunk$lazy_ptr-L0$_thunk)
        mtlr r0
        lwzu r12,lo16(L_thunk$lazy_ptr-L0$_thunk)(r11)
        mtctr r12
        bctr
.data
.lazy_symbol_pointer
L_thunk$lazy_ptr:
        .indirect_symbol _thunk
        .long dyld_stub_binding_helper


Thanks, Andrew Pinski


On Thursday, May 1, 2003, at 18:30 US/Eastern, David Edelsohn wrote:


Andrew Pinski writes:

Andrew> The only problem with this on darwin, it is okay to call the static int
Andrew> so that will become a regression.


	Regession in what sense?  I have heard that calling function
pointer on Darwin actually is faster.

David




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]