https://llvm.org/bugs/show_bug.cgi?id=27589

            Bug ID: 27589
           Summary: large position independent x86 code
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

When compiling

extern int a;
int *f() {
  return &a;
}

Clang generates the following for finding the current ip address:

f:
        calll   .L0$pb
.L0$pb:
        popl    %eax
.Ltmp0:
        addl    $_GLOBAL_OFFSET_TABLE_+(.Ltmp0-.L0$pb), %eax
        movl    a@GOT(%eax), %eax
       ret

which is 19 bytes.


gcc produces

f:
        call    __x86.get_pc_thunk.ax
        addl    $_GLOBAL_OFFSET_TABLE_, %eax
        movl    a@GOT(%eax), %eax
        ret

        .section       
.text.__x86.get_pc_thunk.ax,"axG",@progbits,__x86.get_pc_thunk.ax,comdat
        .globl  __x86.get_pc_thunk.ax
        .hidden __x86.get_pc_thunk.ax
__x86.get_pc_thunk.ax:
        movl    (%esp), %eax
        ret

While the total code is now 21 bytes, f is 17 bytes and __x86.get_pc_thunk.ax
will be merged by the linker.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to