[llvm-bugs] [Bug 27589] New: large position independent x86 code

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Apr 30 11:19:08 PDT 2016


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: unassignedbugs at nondot.org
          Reporter: rafael.espindola at gmail.com
                CC: hans at chromium.org, llvm-bugs at lists.llvm.org
    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 at GOT(%eax), %eax
       ret

which is 19 bytes.


gcc produces

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

        .section       
.text.__x86.get_pc_thunk.ax,"axG", at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160430/990ff349/attachment.html>


More information about the llvm-bugs mailing list