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] Incorrect integer constants in tree dump files


To print HOST_WIDE_INTs, dump_generic_node uses a hard-coded %x format
string.  This patch fixes it to include the HOST_WIDE_INT_PRINT length
modifier.

The same line also has a typo.  HOST_BITS_PER_INT is used for the
width of HWI instead of HOST_BITS_PER_WIDE_INT.

I also changed the output to prefix the number with 0x to make it
obvious whether the number is a hexadecimal number (for !host_integerp
numbers) or decimal (for host_integerp numbers).

Because of this last change I needed to update some tests.
i686-pc-linux-gnu native compiler has 32-bit HWI so I hope I have
gotten all effected tests fixed.

Bootrapped and regression tested on i686-pc-linux-gnu, regression
tested on mipsisa64-elf.

OK to install?

Adam

	* tree-pretty-print.c (dump_generic_node) <INTEGER_CST>: Use
	HOST_WIDE_INT_PRINT to print high and low parts.  Use
	HOST_BITS_PER_WIDE_INT for the width of HOST_WIDE_INT.  When
	printing a hexadecimal number prefix it with 0x.


	* gcc.dg/fold-mod-1.c: Match the leading 0x for the
	hexadecimal value.
	* gcc.dg/tree-prof/val-prof-2.c: Likewise.
	* gcc.dg/pr14796-2.c: Likewise.

Index: tree-pretty-print.c
===================================================================
--- tree-pretty-print.c	(revision 114148)
+++ tree-pretty-print.c	(working copy)
@@ -730,7 +730,9 @@ dump_generic_node (pretty_printer *buffe
 	  {
 	    static char format[10]; /* "%x%09999x\0" */
 	    if (!format[0])
-	      sprintf (format, "%%x%%0%dx", HOST_BITS_PER_INT / 4);
+	      sprintf (format, "0x%%" HOST_WIDE_INT_PRINT "x"
+		       "%%0%d" HOST_WIDE_INT_PRINT "x",
+		       HOST_BITS_PER_WIDE_INT / 4);
 	    sprintf (pp_buffer (buffer)->digit_buffer, format,
 		     TREE_INT_CST_HIGH (val),
 		     TREE_INT_CST_LOW (val));
Index: testsuite/gcc.dg/pr14796-2.c
===================================================================
--- testsuite/gcc.dg/pr14796-2.c	(revision 114148)
+++ testsuite/gcc.dg/pr14796-2.c	(working copy)
@@ -19,5 +19,5 @@ long long j (long long c) {
 }
 /* { dg-final { scan-tree-dump-times "= 0" 2 "gimple" } } */
 /* { dg-final { scan-tree-dump "b >> 31" "gimple" } } */
-/* { dg-final { scan-tree-dump "c & -(34359738368|800000000)" "gimple" } } */
+/* { dg-final { scan-tree-dump "c & -(34359738368|0x800000000)" "gimple" } } */
 /* { dg-final { cleanup-tree-dump "gimple" } } */
Index: testsuite/gcc.dg/tree-prof/val-prof-2.c
===================================================================
--- testsuite/gcc.dg/tree-prof/val-prof-2.c	(revision 114148)
+++ testsuite/gcc.dg/tree-prof/val-prof-2.c	(working copy)
@@ -26,7 +26,7 @@ main ()
 /* { dg-final-use { scan-tree-dump "Mod power of 2 transformation on insn" "tree_profile"} } */
 /* This is part of code checking that n is power of 2, so we are sure that the transformation
    didn't get optimized out.  */
-/* { dg-final-use { scan-tree-dump "n \\+ ffff" "optimized"} } */
+/* { dg-final-use { scan-tree-dump "n \\+ 0xffff" "optimized"} } */
 /* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */
 /* { dg-final-use { cleanup-tree-dump "optimized" } } */
 /* { dg-final-use { cleanup-tree-dump "tree_profile" } } */
Index: testsuite/gcc.dg/fold-mod-1.c
===================================================================
--- testsuite/gcc.dg/fold-mod-1.c	(revision 114148)
+++ testsuite/gcc.dg/fold-mod-1.c	(working copy)
@@ -21,6 +21,6 @@ unsigned int k (unsigned int d) {
 	return d % 8;
 }
 
-/* { dg-final { scan-tree-dump "a % (4294967288|0fffffff8)" "gimple" } } */
+/* { dg-final { scan-tree-dump "a % (4294967288|0x0fffffff8)" "gimple" } } */
 /* { dg-final { scan-tree-dump-times " & 7" 3 "gimple" } } */
 /* { dg-final { cleanup-tree-dump "gimple" } } */


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