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

            Bug ID: 64317
           Summary: [5 Regression] Ineffective allocation of PIC base
                    register
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: izamyatin at gmail dot com
                CC: vmakarov at redhat dot com
            Target: i686

Created attachment 34285
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34285&action=edit
Reproducer

For the attached test compiled with -O2  -m32 -fPIE -pie  after r218059 we
generate 

    call    __x86.get_pc_thunk.ax
    addl    $_GLOBAL_OFFSET_TABLE_, %eax
    subl    $28, %esp
    .cfi_def_cfa_offset 48
    movl    48(%esp), %edi
    movl    %eax, 12(%esp)            <--- PIC reg spill
    testl    %edi, %edi
    je    .L8
    movl    12(%esp), %eax            <--- PIC reg fill
    xorl    %esi, %esi
    movl    c@GOT(%eax), %ebp
    .p2align 4,,10
    .p2align 3
.L4:
    movl    12(%esp), %ebx            <--- PIC reg fill
    addl    $1, %esi
    call    bar@PLT

while for r218058 there is no spill and only reg-reg fill:

    call    __x86.get_pc_thunk.di
    addl    $_GLOBAL_OFFSET_TABLE_, %edi
    subl    $12, %esp
    .cfi_def_cfa_offset 32
    movl    32(%esp), %eax
    testl    %eax, %eax
    je    .L8
    movl    c@GOT(%edi), %ebp
    xorl    %esi, %esi
    .p2align 4,,10
    .p2align 3
.L4:
    movl    %edi, %ebx
    addl    $1, %esi
    call    bar@PLT

Reply via email to