This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Save strings in NOTE_LINE_NUMBER notes.


If RTL inlining is in use, and debugging is on, and you manage just
the right combination of events, it matters that the string in a
NOTE_LINE_NUMBER isn't saved properly.  This fixes it.  I can't manage
to trigger this code on HEAD (it's now much much harder to invoke the
RTL inliner), so no testcase.

Bootstrapped & tested on powerpc-darwin, with gcac checking.

-- 
- Geoffrey Keating <geoffk at apple dot com>

===File ~/patches/gcc-notelinenumberggc.patch===============
2003-03-18  Geoffrey Keating  <geoffk at apple dot com>

	* gengtype.c: Include rtl.h.
	(enum rtx_code): Don't define.
	(rtx_format): Make declaration match rtl.h.
	(rtx_next_new): Rename from rtx_next to avoid conflict.  Change all
	users.
	(adjust_field_rtx_def): Describe strings in NOTE_LINE_NUMBER notes.
	* Makefile.in (gengtype.o): Update dependencies.

Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.1021
diff -u -p -u -p -r1.1021 Makefile.in
--- Makefile.in	17 Mar 2003 05:47:52 -0000	1.1021
+++ Makefile.in	18 Mar 2003 20:00:57 -0000
@@ -2188,7 +2188,7 @@ gengtype$(build_exeext) : gengtype.o gen
 	 gengtype.o gengtype-lex.o gengtype-yacc.o $(BUILD_LIBS)
 
 gengtype.o : gengtype.c gengtype.h $(BCONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H) \
-  real.h rtl.def gtyp-gen.h
+  real.h $(RTL_BASE_H) gtyp-gen.h
 	$(BUILD_CC) -c $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(INCLUDES) \
 	  $(srcdir)/gengtype.c $(OUTPUT_OPTION)
 
Index: gengtype.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gengtype.c,v
retrieving revision 1.27
diff -u -p -u -p -r1.27 gengtype.c
--- gengtype.c	31 Jan 2003 01:42:34 -0000	1.27
+++ gengtype.c	18 Mar 2003 20:00:57 -0000
@@ -25,6 +25,10 @@ Software Foundation, 59 Temple Place - S
 #include "gengtype.h"
 #include "gtyp-gen.h"
 
+#define NO_GENRTL_H
+#include "rtl.h"
+#undef abort
+
 /* Nonzero iff an error has occurred.  */
 static int hit_error = 0;
 
@@ -347,22 +351,15 @@ note_variable (s, t, o, pos)
   variables = n;
 }
 
-enum rtx_code {
-#define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS)   ENUM ,
-#include "rtl.def"
-#undef DEF_RTL_EXPR
-    NUM_RTX_CODE
-};
-
 /* We really don't care how long a CONST_DOUBLE is.  */
 #define CONST_DOUBLE_FORMAT "ww"
-static const char * const rtx_format[NUM_RTX_CODE] = {
+const char * const rtx_format[NUM_RTX_CODE] = {
 #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS)   FORMAT ,
 #include "rtl.def"
 #undef DEF_RTL_EXPR
 };
 
-static int rtx_next[NUM_RTX_CODE];
+static int rtx_next_new[NUM_RTX_CODE];
 
 /* Generate the contents of the rtx_next array.  This really doesn't belong
    in gengtype at all, but it's needed for adjust_field_rtx_def.  */
@@ -375,15 +372,15 @@ gen_rtx_next ()
     {
       int k;
       
-      rtx_next[i] = -1;
+      rtx_next_new[i] = -1;
       if (strncmp (rtx_format[i], "iuu", 3) == 0)
-	rtx_next[i] = 2;
+	rtx_next_new[i] = 2;
       else if (i == COND_EXEC || i == SET || i == EXPR_LIST || i == INSN_LIST)
-	rtx_next[i] = 1;
+	rtx_next_new[i] = 1;
       else 
 	for (k = strlen (rtx_format[i]) - 1; k >= 0; k--)
 	  if (rtx_format[i][k] == 'e' || rtx_format[i][k] == 'u')
-	    rtx_next[i] = k;
+	    rtx_next_new[i] = k;
     }
 }
 
@@ -397,12 +394,12 @@ write_rtx_next ()
   oprintf (f, "\n/* Used to implement the RTX_NEXT macro.  */\n");
   oprintf (f, "const unsigned char rtx_next[NUM_RTX_CODE] = {\n");
   for (i = 0; i < NUM_RTX_CODE; i++)
-    if (rtx_next[i] == -1)
+    if (rtx_next_new[i] == -1)
       oprintf (f, "  0,\n");
     else
       oprintf (f, 
 	       "  offsetof (struct rtx_def, fld) + %d * sizeof (rtunion),\n",
-	       rtx_next[i]);
+	       rtx_next_new[i]);
   oprintf (f, "};\n");
 }
 
@@ -451,28 +448,47 @@ adjust_field_rtx_def (t, opt)
   {
     pair_p note_flds = NULL;
     int c;
-    
-    for (c = 0; c < 3; c++)
+
+    for (c = NOTE_INSN_BIAS; c <= NOTE_INSN_MAX; c++)
       {
 	pair_p old_note_flds = note_flds;
 	
 	note_flds = xmalloc (sizeof (*note_flds));
 	note_flds->line.file = __FILE__;
 	note_flds->line.line = __LINE__;
-	note_flds->name = "rttree";
-	note_flds->type = tree_tp;
 	note_flds->opt = xmalloc (sizeof (*note_flds->opt));
 	note_flds->opt->next = nodot;
 	note_flds->opt->name = "tag";
+	note_flds->opt->info = xasprintf ("%d", c);
 	note_flds->next = old_note_flds;
+
+	switch (c)
+	  {
+	    /* NOTE_INSN_MAX is used as the default field for line
+	       number notes.  */
+	  case NOTE_INSN_MAX:
+	    note_flds->opt->name = "default";
+	    note_flds->name = "rtstr";
+	    note_flds->type = &string_type;
+	    break;
+
+	  case NOTE_INSN_BLOCK_BEG:
+	  case NOTE_INSN_BLOCK_END:
+	    note_flds->name = "rttree";
+	    note_flds->type = tree_tp;
+	    break;
+	    
+	  case NOTE_INSN_EXPECTED_VALUE:
+	    note_flds->name = "rtx";
+	    note_flds->type = rtx_tp;
+	    break;
+
+	  default:
+	    note_flds->name = "rtint";
+	    note_flds->type = scalar_tp;
+	    break;
+	  }
       }
-    
-    note_flds->type = rtx_tp;
-    note_flds->name = "rtx";
-    note_flds->opt->info = "NOTE_INSN_EXPECTED_VALUE";
-    note_flds->next->opt->info = "NOTE_INSN_BLOCK_BEG";
-    note_flds->next->next->opt->info = "NOTE_INSN_BLOCK_END";
-    
     new_structure ("rtx_def_note_subunion", 1, &lexer_line, note_flds, NULL);
   }
   
============================================================


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]