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

huangpei at loongson dot cn <huangpei at loongson dot cn> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |huangpei at loongson dot cn

--- Comment #6 from huangpei at loongson dot cn <huangpei at loongson dot cn> 
---
Created attachment 52005
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52005&action=edit
fix -fpatch-function-entry on MIPS

Patch 0001 fix -fpatchable-function-entry on non-MIPS16, but it cause 
compiling b.c (see previous comment) with duplicate __fn_stub_f* in asm output
in MIPS16

Patch 0002 remove the duplicate __fn_stub_f* by filter __fn_stub_ in 
ASM_DECLARE_FUNCTION_NAME. However, implenmenting ASM_DECLARE_FUNCTION_NAME
cause asm generation of function f interleave with __fn_stub_f, which cause
error even without -fpatchable-function-entry on MIPS16. Patch 0002 
separates asm generation of f from its stub by delay
"mips16_build_function_stub" till "mips_output_function_epilogue", and no error
on MIPS16 without -fpatchable-function-entry.

But it is not perfect.

+. without -fpatchable-function-entry, asm  output of b.c like this

        .file   1 "b.c"
        .section .mdebug.abi32
        .previous
        .nan    legacy
        .module fp=32
        .module oddspreg
        .abicalls
        .text
        .align  2
        .globl  f
        .set    mips16
        .set    nomicromips
        .ent    f
        .type   f, @function
f:
        .frame  $17,8,$31               # vars= 0, regs= 1/0, args= 0, gp= 0
        .mask   0x00020000,-4
        .fmask  0x00000000,0
        save    8,$17
        move    $17,$sp
        sw      $4,8($17)
        sw      $5,12($17)
        .set    noreorder
        nop
        .set    reorder
        move    $sp,$17
        restore 8,$17
        jr      $31
        .end    f
        !!!! .size f, .-f  should be here
        # Stub function for f (float, float)
        .section        .mips16.fn.f,"ax",@progbits
        .align  2
        .set    nomips16
        .set    nomicromips
        .ent    __fn_stub_f
        .type   __fn_stub_f, @function
__fn_stub_f:
        .set    noreorder
        .cpload $25
        .set    reorder
        .reloc  0,R_MIPS_NONE,f
        la      $25,__fn_local_f
        mfc1    $4,$f12
        mfc1    $5,$f14
        jr      $25
        .end    __fn_stub_f
        __fn_local_f = f
        .text
        .size   f, .-f          !!! .size should be not be here
        .ident  "GCC: (GNU) 8.3.0"

+. with -fpatchable-functione-entry=3, asm output of b.c like this,

       .section .mdebug.abi32
        .previous
        .nan    legacy
        .module fp=32
        .module oddspreg
        .abicalls
        .text
        .align  2
        .globl  f
        .set    mips16
        .set    nomicromips
        .ent    f
        .type   f, @function
f:
        .section        __patchable_function_entries,"a",@progbits
        .4byte  $LPFE1
        .text
!!! f should not be patched with nop, since this is the first entry from
caller's point
$LPFE1:
        .set    noreorder
        nop
        .set    reorder
        .set    noreorder
        nop
        .set    reorder
        .set    noreorder
        nop
        .set    reorder
        .frame  $17,8,$31               # vars= 0, regs= 1/0, args= 0, gp= 0
        .mask   0x00020000,-4
        .fmask  0x00000000,0
        save    8,$17
        move    $17,$sp
        sw      $4,8($17)
        sw      $5,12($17)
        .set    noreorder
        nop
        .set    reorder
        move    $sp,$17
        restore 8,$17
        jr      $31
        .end    f
        # Stub function for f (float, float)
        .section        .mips16.fn.f,"ax",@progbits
        .align  2
        .section        __patchable_function_entries
        .4byte  $LPFE2
        .section        .mips16.fn.f
$LPFE2:
        .set    noreorder
        nop
        .set    reorder
        .set    noreorder
        nop
        .set    reorder
        .set    noreorder
        nop
        .set    reorder
        .set    nomips16
        .set    nomicromips
        .ent    __fn_stub_f
        .type   __fn_stub_f, @function
__fn_stub_f:
        .set    noreorder
        .cpload $25
        .set    reorder
        .reloc  0,R_MIPS_NONE,f
        la      $25,__fn_local_f
        mfc1    $4,$f12
        mfc1    $5,$f14
        jr      $25
        .end    __fn_stub_f
        __fn_local_f = f
        .text
        .size   f, .-f
        .ident  "GCC: (GNU) 8.3.0"

Reply via email to