From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 62E713858402; Wed, 15 Dec 2021 10:00:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 62E713858402 From: "huangpei at loongson dot cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/99217] [MIPS] wrong function entry with -fpatchable-function-entry Date: Wed, 15 Dec 2021 10:00:05 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: huangpei at loongson dot cn X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc attachments.created Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Dec 2021 10:00:05 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99217 huangpei at loongson dot cn changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |huangpei at loongson dot cn --- Comment #6 from huangpei at loongson dot cn --- Created attachment 52005 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D52005&action=3Dedit fix -fpatch-function-entry on MIPS Patch 0001 fix -fpatchable-function-entry on non-MIPS16, but it cause=20 compiling b.c (see previous comment) with duplicate __fn_stub_f* in asm out= put in MIPS16 Patch 0002 remove the duplicate __fn_stub_f* by filter __fn_stub_ in=20 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=20 separates asm generation of f from its stub by delay "mips16_build_function_stub" till "mips_output_function_epilogue", and no e= rror 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=3D32 .module oddspreg .abicalls .text .align 2 .globl f .set mips16 .set nomicromips .ent f .type f, @function f: .frame $17,8,$31 # vars=3D 0, regs=3D 1/0, args=3D 0= , gp=3D 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 =3D f .text .size f, .-f !!! .size should be not be here .ident "GCC: (GNU) 8.3.0" +. with -fpatchable-functione-entry=3D3, asm output of b.c like this, .section .mdebug.abi32 .previous .nan legacy .module fp=3D32 .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=3D 0, regs=3D 1/0, args=3D 0= , gp=3D 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 =3D f .text .size f, .-f .ident "GCC: (GNU) 8.3.0"=