]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/13376 (Incorrect dumps of RTL for passes that use current_function_name)
authorSteven Bosscher <stevenb@suse.de>
Tue, 13 Jan 2004 01:58:45 +0000 (01:58 +0000)
committerSteven Bosscher <steven@gcc.gnu.org>
Tue, 13 Jan 2004 01:58:45 +0000 (01:58 +0000)
PR c++/13376
* function.h (struct function): Kill `name' field.
(current_function_name): Make it an extern function.
* function.c (current_function_name): New function.
* graph.c: Update all uses of current_function_name.
* gcse.c: Likewise.
* config/alpha/alpha.c, config/avr/avr.c, config/c4x/c4x.c,
config/mips/mips.c, config/pdp11/pdp11.c: Likewise.
* config/ip2k/ip2k.c (function_prologue): Use MAIN_NAME_P
instead of a strcmp with "main".

From-SVN: r75784

gcc/ChangeLog
gcc/config/alpha/alpha.c
gcc/config/avr/avr.c
gcc/config/c4x/c4x.c
gcc/config/ip2k/ip2k.c
gcc/config/mips/mips.c
gcc/config/pdp11/pdp11.c
gcc/function.c
gcc/function.h
gcc/gcse.c
gcc/graph.c

index 043b8fafcf60d8fafd3646d67445f3e1a31a8300..ee83e98ffe00af7ea2a045c15eb868a9621aa246 100644 (file)
@@ -1,3 +1,16 @@
+2004-01-13  Steven Bosscher  <stevenb@suse.de>
+
+       PR c++/13376
+       * function.h (struct function): Kill `name' field.
+       (current_function_name): Make it an extern function.
+       * function.c (current_function_name): New function.
+       * graph.c: Update all uses of current_function_name.
+       * gcse.c: Likewise.
+       * config/alpha/alpha.c, config/avr/avr.c, config/c4x/c4x.c,
+       config/mips/mips.c, config/pdp11/pdp11.c: Likewise.
+       * config/ip2k/ip2k.c (function_prologue): Use MAIN_NAME_P
+       instead of a strcmp with "main".
+
 2004-01-13  Jan Hubicka  <jh@suse.cz>
 
        * c-decl.c (diagnose_mismatched_decls):  Fix warning calls.
index 87408d6f5f7b348e5c69f2356b32c4f6d61193da..e25ece23030f6917a14d71c9ac76458014f33434 100644 (file)
@@ -9739,7 +9739,7 @@ unicosmk_add_call_info_word (rtx x)
   ++machine->ciw_count;
 
   return GEN_INT (machine->ciw_count
-                 + strlen (current_function_name)/8 + 5);
+                 + strlen (current_function_name ())/8 + 5);
 }
 
 static char unicosmk_section_buf[100];
index 6ec10ba493e4f8149ae6fe45012336426eb0c7c0..198c56895d345578ae18db0deb3a8d3e971ad5f0 100644 (file)
@@ -662,13 +662,14 @@ avr_output_function_prologue (FILE *file, HOST_WIDE_INT size)
     }
   else if (minimize && (frame_pointer_needed || live_seq > 6)) 
     {
+      const char *cfun_name = current_function_name ();
       fprintf (file, ("\t"
                      AS1 (ldi, r26) ",lo8(" HOST_WIDE_INT_PRINT_DEC ")" CR_TAB
                      AS1 (ldi, r27) ",hi8(" HOST_WIDE_INT_PRINT_DEC ")" CR_TAB), size, size);
 
       fprintf (file, (AS2 (ldi, r30, pm_lo8(.L_%s_body)) CR_TAB
-                     AS2 (ldi, r31, pm_hi8(.L_%s_body)) CR_TAB)
-              ,current_function_name, current_function_name);
+                     AS2 (ldi, r31, pm_hi8(.L_%s_body)) CR_TAB),
+              cfun_name, cfun_name);
       
       prologue_size += 4;
       
@@ -684,7 +685,7 @@ avr_output_function_prologue (FILE *file, HOST_WIDE_INT size)
                   (18 - live_seq) * 2);
          ++prologue_size;
        }
-      fprintf (file, ".L_%s_body:\n", current_function_name);
+      fprintf (file, ".L_%s_body:\n", cfun_name);
     }
   else
     {
@@ -871,7 +872,7 @@ avr_output_function_epilogue (FILE *file, HOST_WIDE_INT size)
 
  out:
   fprintf (file, "/* epilogue end (size=%d) */\n", epilogue_size);
-  fprintf (file, "/* function %s size %d (%d) */\n", current_function_name,
+  fprintf (file, "/* function %s size %d (%d) */\n", current_function_name (),
           prologue_size + function_size + epilogue_size, function_size);
   commands_in_file += prologue_size + function_size + epilogue_size;
   commands_in_prologues += prologue_size;
index 9eaa87194d216cefedb7ab16c6dc900eb329c23b..28e13359f940021027d4563b809685c4840a6b9b 100644 (file)
@@ -791,18 +791,20 @@ c4x_naked_function_p (void)
 int
 c4x_interrupt_function_p (void)
 {
+  const char *cfun_name;
   if (lookup_attribute ("interrupt",
                        TYPE_ATTRIBUTES (TREE_TYPE (current_function_decl))))
     return 1;
 
   /* Look for TI style c_intnn.  */
-  return current_function_name[0] == 'c'
-    && current_function_name[1] == '_'
-    && current_function_name[2] == 'i'
-    && current_function_name[3] == 'n' 
-    && current_function_name[4] == 't'
-    && ISDIGIT (current_function_name[5])
-    && ISDIGIT (current_function_name[6]);
+  cfun_name = current_function_name ();
+  return cfun_name[0] == 'c'
+    && cfun_name[1] == '_'
+    && cfun_name[2] == 'i'
+    && cfun_name[3] == 'n' 
+    && cfun_name[4] == 't'
+    && ISDIGIT (cfun_name[5])
+    && ISDIGIT (cfun_name[6]);
 }
 
 void
@@ -846,7 +848,7 @@ c4x_expand_prologue (void)
             storage!  */
          if (size > 32767)
            error ("ISR %s requires %d words of local vars, max is 32767",
-                  current_function_name, size);
+                  current_function_name (), size);
 
          insn = emit_insn (gen_addqi3 (gen_rtx_REG (QImode, SP_REGNO),
                                        gen_rtx_REG (QImode, SP_REGNO),
index cb73b39234b016ab2c1ec362f23b9bf970766b6b..6f32c43d07c1e3f8343e3a9243145ef914b15bb3 100644 (file)
@@ -202,7 +202,7 @@ function_prologue (FILE *file, HOST_WIDE_INT size)
     }
 
   leaf_func_p = leaf_function_p ();
-  main_p = ! strcmp ("main", current_function_name);
+  main_p = MAIN_NAME_P (DECL_NAME (current_function_decl));
 
   /* For now, we compute all these facts about the function, but don't
      take any action based on the information.  */
index 66bc05344fba78299169aaa95a14d6cedb90df5d..477f98964aa61651c3c9f304890ae1d889421b15 100644 (file)
@@ -7659,7 +7659,7 @@ build_mips16_function_stub (FILE *file)
                         build_function_type (void_type_node, NULL_TREE));
   DECL_SECTION_NAME (stubdecl) = build_string (strlen (secname), secname);
 
-  fprintf (file, "\t# Stub function for %s (", current_function_name);
+  fprintf (file, "\t# Stub function for %s (", current_function_name ());
   need_comma = 0;
   for (f = (unsigned int) current_function_args_info.fp_code; f != 0; f >>= 2)
     {
index 02565432cda80035cf96850fbeeba1076d4e30fc..049b541a4ac3b5132febd85f9c008c5fed1dfe29 100644 (file)
@@ -148,7 +148,8 @@ pdp11_output_function_prologue (FILE *stream, HOST_WIDE_INT size)
     int via_ac = -1;
 
     fprintf (stream,
-            "\n\t;     /* function prologue %s*/\n", current_function_name);
+            "\n\t;     /* function prologue %s*/\n",
+            current_function_name ());
 
     /* if we are outputting code for main, 
        the switch FPU to right mode if TARGET_FPU */
index 30ede39ef0222d1f0273c77e6197298eec9308dc..02f095a19b3bfb83cf479b231f73bdd24f36c1f5 100644 (file)
@@ -6408,8 +6408,6 @@ allocate_struct_function (tree fndecl)
   DECL_SAVED_INSNS (fndecl) = cfun;
   cfun->decl = fndecl;
 
-  current_function_name = (*lang_hooks.decl_printable_name) (fndecl, 2);
-
   result = DECL_RESULT (fndecl);
   if (aggregate_value_p (result, fndecl))
     {
@@ -8070,4 +8068,11 @@ init_function_once (void)
   VARRAY_INT_INIT (sibcall_epilogue, 0, "sibcall_epilogue");
 }
 
+/* Returns the name of the current function.  */
+const char *
+current_function_name (void)
+{
+  return (*lang_hooks.decl_printable_name) (cfun->decl, 2);
+}
+
 #include "gt-function.h"
index 89a1465ad0a8abaffa374a7d17f7ae55316b67fa..088fbbb53205e90d651b6f0a3830e72f2b49f1e8 100644 (file)
@@ -183,9 +183,6 @@ struct function GTY(())
 
   /* For function.c.  */
 
-  /* Name of this function.  */
-  const char *name;
-
   /* Points to the FUNCTION_DECL of this function.  */
   tree decl;
 
@@ -534,7 +531,6 @@ extern int virtuals_instantiated;
 extern int trampolines_created;
 
 /* For backward compatibility... eventually these should all go away.  */
-#define current_function_name (cfun->name)
 #define current_function_pops_args (cfun->pops_args)
 #define current_function_returns_struct (cfun->returns_struct)
 #define current_function_returns_pcc_struct (cfun->returns_pcc_struct)
@@ -638,6 +634,9 @@ extern rtx get_arg_pointer_save_area (struct function *);
 
 extern void init_virtual_regs (struct emit_status *);
 
+/* Returns the name of the current function.  */
+extern const char *current_function_name (void);
+
 /* Called once, at initialization, to initialize function.c.  */
 extern void init_function_once (void);
 
index 55f6d1bed720b26e87fd2034068760a9057e4fe3..f3656c19d47c853e9e9861d1991593fc9dc26c53 100644 (file)
@@ -855,7 +855,7 @@ gcse_main (rtx f, FILE *file)
   if (file)
     {
       fprintf (file, "GCSE of %s: %d basic blocks, ",
-              current_function_name, n_basic_blocks);
+              current_function_name (), n_basic_blocks);
       fprintf (file, "%d pass%s, %d bytes\n\n",
               pass, pass > 1 ? "es" : "", max_pass_bytes);
     }
@@ -3614,7 +3614,7 @@ one_classic_gcse_pass (int pass)
     {
       fprintf (gcse_file, "\n");
       fprintf (gcse_file, "GCSE of %s, pass %d: %d bytes needed, %d substs,",
-              current_function_name, pass, bytes_used, gcse_subst_count);
+              current_function_name (), pass, bytes_used, gcse_subst_count);
       fprintf (gcse_file, "%d insns created\n", gcse_create_count);
     }
 
@@ -4686,7 +4686,7 @@ one_cprop_pass (int pass, int cprop_jumps, int bypass_jumps)
   if (gcse_file)
     {
       fprintf (gcse_file, "CPROP of %s, pass %d: %d bytes needed, ",
-              current_function_name, pass, bytes_used);
+              current_function_name (), pass, bytes_used);
       fprintf (gcse_file, "%d const props, %d copy props\n\n",
               const_prop_count, copy_prop_count);
     }
@@ -5788,7 +5788,7 @@ one_pre_gcse_pass (int pass)
   if (gcse_file)
     {
       fprintf (gcse_file, "\nPRE GCSE of %s, pass %d: %d bytes needed, ",
-              current_function_name, pass, bytes_used);
+              current_function_name (), pass, bytes_used);
       fprintf (gcse_file, "%d substs, %d insns created\n",
               gcse_subst_count, gcse_create_count);
     }
@@ -8017,7 +8017,7 @@ bypass_jumps (FILE *file)
   if (file)
     {
       fprintf (file, "BYPASS of %s: %d basic blocks, ",
-              current_function_name, n_basic_blocks);
+              current_function_name (), n_basic_blocks);
       fprintf (file, "%d bytes\n\n", bytes_used);
     }
 
index d82dd917ce9ee712c0a7a5d1a184333bae3590c5..26c866d8291a953041abedc90fd00dfab3b0c86c 100644 (file)
@@ -55,7 +55,7 @@ start_fct (FILE *fp)
     case vcg:
       fprintf (fp, "\
 graph: { title: \"%s\"\nfolding: 1\nhidden: 2\nnode: { title: \"%s.0\" }\n",
-              current_function_name, current_function_name);
+              current_function_name (), current_function_name ());
       break;
     case no_graph:
       break;
@@ -71,7 +71,7 @@ start_bb (FILE *fp, int bb)
       fprintf (fp, "\
 graph: {\ntitle: \"%s.BB%d\"\nfolding: 1\ncolor: lightblue\n\
 label: \"basic block %d",
-              current_function_name, bb, bb);
+              current_function_name (), bb, bb);
       break;
     case no_graph:
       break;
@@ -113,8 +113,8 @@ node_data (FILE *fp, rtx tmp_rtx)
        case vcg:
          fprintf (fp, "\
 edge: { sourcename: \"%s.0\" targetname: \"%s.%d\" }\n",
-                  current_function_name,
-                  current_function_name, XINT (tmp_rtx, 0));
+                  current_function_name (),
+                  current_function_name (), XINT (tmp_rtx, 0));
          break;
        case no_graph:
          break;
@@ -126,7 +126,7 @@ edge: { sourcename: \"%s.0\" targetname: \"%s.%d\" }\n",
     case vcg:
       fprintf (fp, "node: {\n  title: \"%s.%d\"\n  color: %s\n  \
 label: \"%s %d\n",
-              current_function_name, XINT (tmp_rtx, 0),
+              current_function_name (), XINT (tmp_rtx, 0),
               GET_CODE (tmp_rtx) == NOTE ? "lightgrey"
               : GET_CODE (tmp_rtx) == INSN ? "green"
               : GET_CODE (tmp_rtx) == JUMP_INSN ? "darkgreen"
@@ -178,8 +178,8 @@ draw_edge (FILE *fp, int from, int to, int bb_edge, int class)
        color = "color: green ";
       fprintf (fp,
               "edge: { sourcename: \"%s.%d\" targetname: \"%s.%d\" %s",
-              current_function_name, from,
-              current_function_name, to, color);
+              current_function_name (), from,
+              current_function_name (), to, color);
       if (class)
        fprintf (fp, "class: %d ", class);
       fputs ("}\n", fp);
@@ -209,7 +209,7 @@ end_fct (FILE *fp)
     {
     case vcg:
       fprintf (fp, "node: { title: \"%s.999999\" label: \"END\" }\n}\n",
-              current_function_name);
+              current_function_name ());
       break;
     case no_graph:
       break;