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]

Patch for warnings in new register allocator code (ra-*.c)


The patch below fixes these warnings:

 > ra-build.c:1072: warning: traditional C rejects automatic aggregate initialization
 > ra-build.c:1829:33: warning: traditional C rejects the "U" suffix
 > ra-build.c:1874:29: warning: traditional C rejects the "U" suffix
 > ra-build.c:2193: warning: `check_conflict_numbers' defined but not used
 > ra-build.c:2226: warning: unused variable `d'
 > ra-debug.c:718: warning: traditional C rejects string concatenation
 > ra-debug.c:874: warning: traditional C rejects string concatenation
 > ra-debug.c:927: warning: traditional C rejects automatic aggregate initialization
 > ra-debug.c:928: warning: traditional C rejects automatic aggregate initialization
 > ra-debug.c:929: warning: traditional C rejects automatic aggregate initialization
 > ra-debug.c:930: warning: traditional C rejects automatic aggregate initialization
 > ra-debug.c:931: warning: traditional C rejects automatic aggregate initialization
 > ra-debug.c:989: warning: int format, different type arg (arg 5)
 > ra-debug.c:991: warning: int format, different type arg (arg 5)
 > ra-debug.c:993: warning: int format, different type arg (arg 5)
 > ra-debug.c:995: warning: int format, different type arg (arg 5)
 > ra-debug.c:997: warning: int format, different type arg (arg 5)
 > ra-rewrite.c:1954: warning: traditional C rejects string concatenation
 > ra-rewrite.c:1956: warning: traditional C rejects string concatenation
 > ra-rewrite.c:1958: warning: traditional C rejects string concatenation
 > ra-rewrite.c:1961: warning: traditional C rejects string concatenation
 > ra-rewrite.c:1963: warning: traditional C rejects string concatenation
 > ra-rewrite.c:669: warning: traditional C rejects automatic aggregate initialization

Note: I added new hwint.h macros for HWI formatting widths on values
assumed to be an integer but which were really HWI.  See
ra-debug.c:dump_static_insn_cost.  We already use the asterisk
specifier in a bunch of places so there shouldn't be a question of
portability to any platforms actually in use.

Bootstrapped on sparc-sun-solaris2.7 --disable-checking --disable-nls.
Ok to install?

		Thanks,
		--Kaveh


2002-07-18  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* hwint.h (HOST_WIDE_INT_PRINT_DEC_SPACE,
	HOST_WIDE_INT_PRINT_UNSIGNED_SPACE,
	HOST_WIDEST_INT_PRINT_DEC_SPACE, HOST_WIDEST_INT_PRINT_DEC_SPACE):
	New formatting macros.

	* ra-build.c (check_conflict_numbers): Hide unused function.
	(livethrough_conflicts_bb): Avoid automatic aggregate
	initialization.
	(parts_to_webs_1): Avoid `U' integer constant modifier.
	(conflicts_between_webs): Wrap a variable in the macro controlling
	its usage.
	* ra-debug.c (ra_debug_msg): Use VA_OPEN/VA_CLOSE.
	(dump_igraph, dump_graph_cost): Avoid string concatenation
	(dump_static_insn_cost): Avoid automatic aggregate
	initialization.  Avoid string concatenation
	* ra-rewrite.c (insert_stores): Avoid automatic aggregate
	initialization.
	(dump_cost): Avoid string concatenation

diff -rup orig/egcc-CVS20020717/gcc/hwint.h egcc-CVS20020717/gcc/hwint.h
--- orig/egcc-CVS20020717/gcc/hwint.h	Mon Dec 10 07:30:29 2001
+++ egcc-CVS20020717/gcc/hwint.h	Thu Jul 18 10:17:42 2002
@@ -72,11 +72,14 @@
 #ifndef HOST_WIDE_INT_PRINT_DEC
 # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
 #  define HOST_WIDE_INT_PRINT_DEC "%d"
+#  define HOST_WIDE_INT_PRINT_DEC_SPACE "% *d"
 # else
 #  if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
 #   define HOST_WIDE_INT_PRINT_DEC "%ld"
+#   define HOST_WIDE_INT_PRINT_DEC_SPACE "% *ld"
 #  else
 #   define HOST_WIDE_INT_PRINT_DEC "%lld"
+#   define HOST_WIDE_INT_PRINT_DEC_SPACE "% *lld"
 #  endif
 # endif
 #endif /* ! HOST_WIDE_INT_PRINT_DEC */
@@ -84,11 +87,14 @@
 #ifndef HOST_WIDE_INT_PRINT_UNSIGNED
 # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
 #  define HOST_WIDE_INT_PRINT_UNSIGNED "%u"
+#  define HOST_WIDE_INT_PRINT_UNSIGNED_SPACE "% *u"
 # else
 #  if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
 #   define HOST_WIDE_INT_PRINT_UNSIGNED "%lu"
+#   define HOST_WIDE_INT_PRINT_UNSIGNED_SPACE "% *lu"
 #  else
 #   define HOST_WIDE_INT_PRINT_UNSIGNED "%llu"
+#   define HOST_WIDE_INT_PRINT_UNSIGNED_SPACE "% *llu"
 #  endif
 # endif
 #endif /* ! HOST_WIDE_INT_PRINT_UNSIGNED */
@@ -139,13 +145,17 @@
 #   define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER_LONGLONG
 #   define HOST_WIDEST_INT long long
 #   define HOST_WIDEST_INT_PRINT_DEC "%lld"
+#   define HOST_WIDEST_INT_PRINT_DEC_SPACE "% *lld"
 #   define HOST_WIDEST_INT_PRINT_UNSIGNED "%llu"
+#   define HOST_WIDEST_INT_PRINT_UNSIGNED_SPACE "% *llu"
 #   define HOST_WIDEST_INT_PRINT_HEX "0x%llx"
 #  else
 #   define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER_LONG
 #   define HOST_WIDEST_INT long
 #   define HOST_WIDEST_INT_PRINT_DEC "%ld"
+#   define HOST_WIDEST_INT_PRINT_DEC_SPACE "% *ld"
 #   define HOST_WIDEST_INT_PRINT_UNSIGNED "%lu"
+#   define HOST_WIDEST_INT_PRINT_UNSIGNED_SPACE "% *lu"
 #   define HOST_WIDEST_INT_PRINT_HEX "0x%lx"
 # endif /* long long wider than long */
 #endif /* ! HOST_WIDEST_INT */
diff -rup orig/egcc-CVS20020717/gcc/ra-build.c egcc-CVS20020717/gcc/ra-build.c
--- orig/egcc-CVS20020717/gcc/ra-build.c	Tue Jul 16 10:03:52 2002
+++ egcc-CVS20020717/gcc/ra-build.c	Thu Jul 18 09:59:38 2002
@@ -101,7 +101,9 @@ static unsigned int parts_to_webs_1 PARA
 					     struct df_link *));
 static void parts_to_webs PARAMS ((struct df *));
 static void reset_conflicts PARAMS ((void));
+#if 0
 static void check_conflict_numbers PARAMS ((void));
+#endif
 static void conflicts_between_webs PARAMS ((struct df *));
 static void remember_web_was_spilled PARAMS ((struct web *));
 static void detect_spill_temps PARAMS ((void));
@@ -1069,8 +1071,10 @@ livethrough_conflicts_bb (bb)
     {
       if (INSN_P (insn))
 	{
-	  struct ra_insn_info info = insn_df[INSN_UID (insn)];
 	  unsigned int n;
+	  struct ra_insn_info info;
+
+	  info = insn_df[INSN_UID (insn)];
 	  for (n = 0; n < info.num_defs; n++)
 	    bitmap_set_bit (all_defs, DF_REF_ID (info.defs[n]));
 	  if (TEST_BIT (insns_with_deaths, INSN_UID (insn)))
@@ -1826,7 +1830,7 @@ parts_to_webs_1 (df, copy_webs, all_refs
       if (! wp->uplink)
 	{
 	  /* If we have a web part root, create a new web.  */
-	  unsigned int newid = ~0U;
+	  unsigned int newid = ~(unsigned)0;
 	  unsigned int old_web = 0;
 
 	  /* In the first pass, there are no old webs, so unconditionally
@@ -1871,7 +1875,7 @@ parts_to_webs_1 (df, copy_webs, all_refs
 		    }
 		}
 	      /* The id is zeroed in init_one_web().  */
-	      if (newid == ~0U)
+	      if (newid == ~(unsigned)0)
 		newid = web->id;
 	      if (old_web)
 		reinit_one_web (web, GET_CODE (reg) == SUBREG
@@ -2188,6 +2192,7 @@ reset_conflicts ()
 /* For each web check it's num_conflicts member against that
    number, as calculated from scratch from all neighbors.  */
 
+#if 0
 static void
 check_conflict_numbers ()
 {
@@ -2204,6 +2209,7 @@ check_conflict_numbers ()
 	abort ();
     }
 }
+#endif
 
 /* Convert the conflicts between web parts to conflicts between full webs.
 
@@ -2223,7 +2229,9 @@ conflicts_between_webs (df)
      struct df *df;
 {
   unsigned int i;
+#ifdef STACK_REGS
   struct dlist *d;
+#endif
   bitmap ignore_defs = BITMAP_XMALLOC ();
   unsigned int have_ignored;
   unsigned int *pass_cache = (unsigned int *) xcalloc (num_webs, sizeof (int));
diff -rup orig/egcc-CVS20020717/gcc/ra-debug.c egcc-CVS20020717/gcc/ra-debug.c
--- orig/egcc-CVS20020717/gcc/ra-debug.c	Mon Jul 15 10:07:05 2002
+++ egcc-CVS20020717/gcc/ra-debug.c	Thu Jul 18 11:14:26 2002
@@ -47,22 +47,12 @@ static const char *const reg_class_names
 void
 ra_debug_msg VPARAMS ((unsigned int level, const char *format, ...))
 {
-#ifndef ANSI_PROTOTYPES
-  int level;
-  const char *format;
-#endif
-  va_list ap;
+  VA_OPEN (ap, format);
+  VA_FIXEDARG (ap, unsigned int, level);
+  VA_FIXEDARG (ap, const char *, format);
   if ((debug_new_regalloc & level) != 0 && rtl_dump_file != NULL)
-    {
-      VA_START (ap, format);
-
-#ifndef ANSI_PROTOTYPES
-      format = va_arg (ap, const char *);
-#endif
-
-      vfprintf (rtl_dump_file, format, ap);
-      va_end (ap);
-    }
+    vfprintf (rtl_dump_file, format, ap);
+  VA_CLOSE (ap);
 }
 
 
@@ -714,10 +704,10 @@ dump_igraph (df)
 	  ra_debug_msg (DUMP_WEBS, " sub %d", SUBREG_BYTE (web->orig_x));
 	  ra_debug_msg (DUMP_WEBS, " par %d", find_web_for_subweb (web)->id);
 	}
-      ra_debug_msg (DUMP_WEBS, " +%d (span %d, cost "
-		 HOST_WIDE_INT_PRINT_DEC ") (%s)",
-	         web->add_hardregs, web->span_deaths, web->spill_cost,
-	         reg_class_names[web->regclass]);
+      ra_debug_msg (DUMP_WEBS, " +%d (span %d, cost ",
+		    web->add_hardregs, web->span_deaths);
+      ra_debug_msg (DUMP_WEBS, HOST_WIDE_INT_PRINT_DEC, web->spill_cost);
+      ra_debug_msg (DUMP_WEBS, ") (%s)", reg_class_names[web->regclass]);
       if (web->spill_temp == 1)
 	ra_debug_msg (DUMP_WEBS, " (spilltemp)");
       else if (web->spill_temp == 2)
@@ -860,7 +850,6 @@ dump_graph_cost (level, msg)
 {
   unsigned int i;
   unsigned HOST_WIDE_INT cost;
-#define LU HOST_WIDE_INT_PRINT_UNSIGNED
   if (!rtl_dump_file || (debug_new_regalloc & level) == 0)
     return;
 
@@ -871,9 +860,9 @@ dump_graph_cost (level, msg)
       if (alias (web)->type == SPILLED)
 	cost += web->orig_spill_cost;
     }
-  ra_debug_msg (level, " spill cost of graph (%s) = " LU "\n",
-	     msg ? msg : "", cost);
-#undef LU
+  ra_debug_msg (level, " spill cost of graph (%s) = ", msg ? msg : "");
+  ra_debug_msg (level, HOST_WIDE_INT_PRINT_UNSIGNED, cost);
+  ra_debug_msg (level, "\n");
 }
 
 /* Dump the color assignment per web, the coalesced and spilled webs.  */
@@ -924,12 +913,13 @@ dump_static_insn_cost (file, message, pr
       unsigned HOST_WIDE_INT cost;
       unsigned int count;
     };
-  struct cost load = {0, 0};
-  struct cost store = {0, 0};
-  struct cost regcopy = {0, 0};
-  struct cost selfcopy = {0, 0};
-  struct cost overall = {0, 0};
   basic_block bb;
+  struct cost load, store, regcopy, selfcopy, overall;
+  memset (&load, 0, sizeof(load));
+  memset (&store, 0, sizeof(store));
+  memset (&regcopy, 0, sizeof(regcopy));
+  memset (&selfcopy, 0, sizeof(selfcopy));
+  memset (&overall, 0, sizeof(overall));
 
   if (!file)
     return;
@@ -985,16 +975,21 @@ dump_static_insn_cost (file, message, pr
   if (!prefix)
     prefix = "";
   fprintf (file, "static insn cost %s\n", message ? message : "");
-  fprintf (file, "  %soverall:\tnum=%6d\tcost=%8d\n", prefix, overall.count,
-	   overall.cost);
-  fprintf (file, "  %sloads:\tnum=%6d\tcost=%8d\n", prefix, load.count,
-	   load.cost);
-  fprintf (file, "  %sstores:\tnum=%6d\tcost=%8d\n", prefix,
-	   store.count, store.cost);
-  fprintf (file, "  %sregcopy:\tnum=%6d\tcost=%8d\n", prefix, regcopy.count,
-	   regcopy.cost);
-  fprintf (file, "  %sselfcpy:\tnum=%6d\tcost=%8d\n", prefix, selfcopy.count,
-	   selfcopy.cost);
+  fprintf (file, "  %soverall:\tnum=%6d\tcost=", prefix, overall.count);
+  fprintf (file, HOST_WIDE_INT_PRINT_DEC_SPACE, 8, overall.cost);
+  fprintf (file, "\n");
+  fprintf (file, "  %sloads:\tnum=%6d\tcost=", prefix, load.count);
+  fprintf (file, HOST_WIDE_INT_PRINT_DEC_SPACE, 8, load.cost);
+  fprintf (file, "\n");
+  fprintf (file, "  %sstores:\tnum=%6d\tcost=", prefix, store.count);
+  fprintf (file, HOST_WIDE_INT_PRINT_DEC_SPACE, 8, store.cost);
+  fprintf (file, "\n");
+  fprintf (file, "  %sregcopy:\tnum=%6d\tcost=", prefix, regcopy.count);
+  fprintf (file, HOST_WIDE_INT_PRINT_DEC_SPACE, 8, regcopy.cost);
+  fprintf (file, "\n");
+  fprintf (file, "  %sselfcpy:\tnum=%6d\tcost=", prefix, selfcopy.count);
+  fprintf (file, HOST_WIDE_INT_PRINT_DEC_SPACE, 8, selfcopy.cost);
+  fprintf (file, "\n");
 }
 
 /* Returns nonzero, if WEB1 and WEB2 have some possible
diff -rup orig/egcc-CVS20020717/gcc/ra-rewrite.c egcc-CVS20020717/gcc/ra-rewrite.c
--- orig/egcc-CVS20020717/gcc/ra-rewrite.c	Tue Jul 16 10:03:52 2002
+++ egcc-CVS20020717/gcc/ra-rewrite.c	Thu Jul 18 10:57:50 2002
@@ -666,9 +666,11 @@ insert_stores (new_deaths)
       if (uid < insn_df_max_uid)
 	{
 	  unsigned int n;
-	  struct ra_insn_info info = insn_df[uid];
 	  rtx following = NEXT_INSN (insn);
 	  basic_block bb = BLOCK_FOR_INSN (insn);
+	  struct ra_insn_info info;
+
+	  info = insn_df[uid];
 	  for (n = 0; n < info.num_defs; n++)
 	    {
 	      struct web *web = def2web[DF_REF_ID (info.defs[n])];
@@ -1949,20 +1951,18 @@ void
 dump_cost (level)
      unsigned int level;
 {
-#define LU HOST_WIDE_INT_PRINT_UNSIGNED
   ra_debug_msg (level, "Instructions for spilling\n added:\n");
-  ra_debug_msg (level, "  loads =%d cost=" LU "\n", emitted_spill_loads,
-	     spill_load_cost);
-  ra_debug_msg (level, "  stores=%d cost=" LU "\n", emitted_spill_stores,
-	     spill_store_cost);
-  ra_debug_msg (level, "  remat =%d cost=" LU "\n", emitted_remat,
-	     spill_remat_cost);
-  ra_debug_msg (level, " removed:\n");
-  ra_debug_msg (level, "  moves =%d cost=" LU "\n", deleted_move_insns,
-	     deleted_move_cost);
-  ra_debug_msg (level, "  others=%d cost=" LU "\n", deleted_def_insns,
-	     deleted_def_cost);
-#undef LU
+  ra_debug_msg (level, "  loads =%d cost=", emitted_spill_loads);
+  ra_debug_msg (level, HOST_WIDE_INT_PRINT_UNSIGNED, spill_load_cost);
+  ra_debug_msg (level, "\n  stores=%d cost=", emitted_spill_stores);
+  ra_debug_msg (level, HOST_WIDE_INT_PRINT_UNSIGNED, spill_store_cost);
+  ra_debug_msg (level, "\n  remat =%d cost=", emitted_remat);
+  ra_debug_msg (level, HOST_WIDE_INT_PRINT_UNSIGNED, spill_remat_cost);
+  ra_debug_msg (level, "\n removed:\n  moves =%d cost=", deleted_move_insns);
+  ra_debug_msg (level, HOST_WIDE_INT_PRINT_UNSIGNED, deleted_move_cost);
+  ra_debug_msg (level, "\n  others=%d cost=", deleted_def_insns);
+  ra_debug_msg (level, HOST_WIDE_INT_PRINT_UNSIGNED, deleted_def_cost);
+  ra_debug_msg (level, "\n");
 }
 
 /* Initialization of the rewrite phase.  */


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