RFA: Fix PR middle-end/46314

Joern Rennecke amylaar@spamcop.net
Fri Nov 5 18:22:00 GMT 2010


This instroduces a new target hook as a wrapper around
ASM_GENERATE_INTERNAL_LABEL, and makes the C++ and java
front ends use it.

bootstrapped / regtested on i686-pc-linux-gnu.

-------------- next part --------------
2010-11-05  Joern Rennecke  <amylaar@spamcop.net>

	PR middle-end/46314
gcc:
	* target.def (generate_internal_label): New asm_out hook.
	* output.h (default_generate_internal_label): Declare.
	* varasm.c (default_generate_internal_label): Define.
gcc/cp:
	* method.c (make_alias_for_thunk):
	Use targetm.asm_out.generate_internal_label.
gcc/java:
	* class.c: Include target.h.
	(make_local_function_alias):
	Use targetm.asm_out.generate_internal_label.
	* expr.c (lookup_label, generate_name): Likewise.

Index: target.def
===================================================================
--- target.def	(revision 166360)
+++ target.def	(working copy)
@@ -200,6 +200,14 @@ DEFHOOKPOD
  be called afterward.",
  bool, true)
 
+/* Generate an internal label.
+   For now this is just a wrapper for ASM_GENERATE_INTERNAL_LABEL.  */
+DEFHOOK_UNDOC
+(generate_internal_label,
+ "",
+ void, (char *buf, const char *prefix, unsigned long labelno),
+ default_generate_internal_label)
+
 /* Output an internal label.  */
 DEFHOOK
 (internal_label,
Index: output.h
===================================================================
--- output.h	(revision 166360)
+++ output.h	(working copy)
@@ -627,6 +627,8 @@ extern void default_globalize_label (FIL
 extern void default_globalize_decl_name (FILE *, tree);
 extern void default_emit_unwind_label (FILE *, tree, int, int);
 extern void default_emit_except_table_label (FILE *);
+extern void default_generate_internal_label (char *, const char *,
+					     unsigned long);
 extern void default_internal_label (FILE *, const char *, unsigned long);
 extern void default_asm_declare_constant_name (FILE *, const char *,
 					       const_tree, HOST_WIDE_INT);
Index: varasm.c
===================================================================
--- varasm.c	(revision 166360)
+++ varasm.c	(working copy)
@@ -6611,6 +6611,16 @@ default_emit_except_table_label (FILE * 
    the class of label and LABELNO is the number within the class.  */
 
 void
+default_generate_internal_label (char *buf, const char *prefix,
+				 unsigned long labelno)
+{
+  ASM_GENERATE_INTERNAL_LABEL (buf, prefix, labelno);
+}
+
+/* This is how to output an internal numbered label where PREFIX is
+   the class of label and LABELNO is the number within the class.  */
+
+void
 default_internal_label (FILE *stream, const char *prefix,
 			unsigned long labelno)
 {
Index: cp/method.c
===================================================================
--- cp/method.c	(revision 166360)
+++ cp/method.c	(working copy)
@@ -252,7 +252,7 @@ make_alias_for_thunk (tree function)
   tree alias;
   char buf[256];
 
-  ASM_GENERATE_INTERNAL_LABEL (buf, "LTHUNK", thunk_labelno);
+  targetm.asm_out.generate_internal_label (buf, "LTHUNK", thunk_labelno);
   thunk_labelno++;
 
   alias = make_alias_for (function, get_identifier (buf));
Index: java/class.c
===================================================================
--- java/class.c	(revision 166360)
+++ java/class.c	(working copy)
@@ -43,6 +43,7 @@ The Free Software Foundation is independ
 #include "tree-iterator.h"
 #include "vecprim.h"
 #include "tm.h"         /* FIXME: For gcc_obstack_init from defaults.h.  */
+#include "target.h"
 
 /* DOS brain-damage */
 #ifndef O_BINARY
@@ -1399,7 +1400,7 @@ make_local_function_alias (tree method)
   *name = 'L';
   strcpy (name + 1, method_name);
 
-  ASM_GENERATE_INTERNAL_LABEL (buf, name, alias_labelno++);  
+  targetm.asm_out.generate_internal_label (buf, name, alias_labelno++);  
   alias = build_decl (input_location,
 		      FUNCTION_DECL, get_identifier (buf),
 		      TREE_TYPE (method));
Index: java/expr.c
===================================================================
--- java/expr.c	(revision 166360)
+++ java/expr.c	(working copy)
@@ -1763,7 +1763,8 @@ lookup_label (int pc)
   char buf[32];
   if (pc > highest_label_pc_this_method)
     highest_label_pc_this_method = pc;
-  ASM_GENERATE_INTERNAL_LABEL(buf, "LJpc=", start_label_pc_this_method + pc);
+  targetm.asm_out.generate_internal_label (buf, "LJpc=",
+					   start_label_pc_this_method + pc);
   name = get_identifier (buf);
   if (IDENTIFIER_LOCAL_VALUE (name))
     return IDENTIFIER_LOCAL_VALUE (name);
@@ -1783,7 +1784,7 @@ generate_name (void)
 {
   static int l_number = 0;
   char buff [32];
-  ASM_GENERATE_INTERNAL_LABEL(buff, "LJv", l_number);
+  targetm.asm_out.generate_internal_label (buff, "LJv", l_number);
   l_number++;
   return get_identifier (buff);
 }


More information about the Gcc-patches mailing list