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

--- Comment #2 from huangpei at loongson dot cn <huangpei at loongson dot cn> 
---
my colleague Xu Chenghua (xucheng...@loongson.cn) add a patch to address this

--------------------
diff --git a/src/gcc/config/mips/mips-protos.h
b/src/gcc/config/mips/mips-protos.h
index aba1f8222..253c5b6f5 100644
--- a/src/gcc/config/mips/mips-protos.h
+++ b/src/gcc/config/mips/mips-protos.h
@@ -394,4 +394,6 @@ extern void mips_expand_vec_cond_expr (machine_mode,
machine_mode, rtx *);
 /* Routines implemented in mips-d.c  */
 extern void mips_d_target_versions (void);

+extern void mips_declare_function_name (FILE *, const char *, tree);
+
 #endif /* ! GCC_MIPS_PROTOS_H */
diff --git a/src/gcc/config/mips/mips.c b/src/gcc/config/mips/mips.c
index de69400d1..f94028e55 100644
--- a/src/gcc/config/mips/mips.c
+++ b/src/gcc/config/mips/mips.c
@@ -12002,6 +12002,23 @@ mips_output_cplocal (void)
     output_asm_insn (".cplocal %+", 0);
 }

+/* Implement ASM_DECLARE_FUNCTION_NAME. */
+
+void mips_declare_function_name(FILE *stream ATTRIBUTE_UNUSED,
+                               const char *name, tree fndecl ATTRIBUTE_UNUSED)
+{
+
+  /* Get the function name the same way that toplev.c does before calling
+     assemble_start_function.  This is needed so that the name used here
+     exactly matches the name used in ASM_DECLARE_FUNCTION_NAME.  */
+  //fnname = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0);
+  mips_start_function_definition (name, TARGET_MIPS16);
+
+  //ASM_OUTPUT_TYPE_DIRECTIVE (stream, name, "function");
+  //ASM_OUTPUT_LABEL (stream, name);
+}
+
+
 /* Implement TARGET_OUTPUT_FUNCTION_PROLOGUE.  */

 static void
@@ -12016,12 +12033,6 @@ mips_output_function_prologue (FILE *file)
       && crtl->args.info.fp_code != 0)
     mips16_build_function_stub ();

-  /* Get the function name the same way that toplev.c does before calling
-     assemble_start_function.  This is needed so that the name used here
-     exactly matches the name used in ASM_DECLARE_FUNCTION_NAME.  */
-  fnname = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0);
-  mips_start_function_definition (fnname, TARGET_MIPS16);
-
   /* Output MIPS-specific frame information.  */
   if (!flag_inhibit_size_directive)
     {
diff --git a/src/gcc/config/mips/mips.h b/src/gcc/config/mips/mips.h
index dccfae52c..cb8ab602a 100644
--- a/src/gcc/config/mips/mips.h
+++ b/src/gcc/config/mips/mips.h
@@ -2955,7 +2955,8 @@ while (0)
    is not declared before the .ent directive elsewhere.  */

 #undef ASM_DECLARE_FUNCTION_NAME
-#define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL)
+#define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL) \
+  mips_declare_function_name(STREAM,NAME,DECL)

 /* This is how to store into the string LABEL
    the symbol_ref name of an internal numbered label where
diff --git a/src/gcc/targhooks.c b/src/gcc/targhooks.c
index fafcc6c51..9a6baaf4b 100644
--- a/src/gcc/targhooks.c
+++ b/src/gcc/targhooks.c
@@ -1806,7 +1806,7 @@ default_print_patchable_function_entry (FILE *file,

   unsigned i;
   for (i = 0; i < patch_area_size; ++i)
-    fprintf (file, "\t%s\n", nop_templ);
+    output_asm_insn (nop_templ, NULL);
 }

 bool

--------------------------

With this and fix for bug 93242, -fpatchable-function-entry works on linux
kernel 5.10

Reply via email to