public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [LTO][PATCH] Fix missing tree flags bug.
@ 2007-11-10 14:10 Doug Kwan (關振德)
  2007-11-10 23:51 ` Kenneth Zadeck
  2007-11-13 20:28 ` Diego Novillo
  0 siblings, 2 replies; 3+ messages in thread
From: Doug Kwan (關振德) @ 2007-11-10 14:10 UTC (permalink / raw)
  To: gcc-patches, Diego Novillo

[-- Attachment #1: Type: text/plain, Size: 219 bytes --]

Hi,

    Could someone review and approve this patch? It fixes a problem
where the first 5 bits of tree flags of a VAR_DECL node got dropped on
host that has 32-bit HOST_WIDE_INT.  I tested it on i686-linux-gnu.

-Doug

[-- Attachment #2: patch-tree-flags.txt --]
[-- Type: text/plain, Size: 9421 bytes --]

2007-11-09  Doug Kwan  <dougkwan@google.com>

	Fix flags encoding size bug.

	* lto-function-out.c (output_widest_uint_uleb128_stream,
	output_widest_uint_uleb128): New functions. 
	(output_tree_flags):  Use lto_flags_type instead of unsigned
	HOST_WIDE_INT.  Call output_widest_unint_uleb128 instead of
	output_uleb128.
	(lto_debug_tree_flags):  Replace HOST_BITS_PER_WIDE_INT with
	BITS_PER_LTO_FLAGS_TYPE as appropriate.
	* lto-tags.h (lto_flags_type) New type.  (BITS_PER_LTO_FLAGS_TYPES)
	New macro.  (lto_debug_tree_flags):  Change prototype to use
	lto_flags_type.

	lto/
	* lto-read.c (input_widest_uint_uleb128): New function.
	(input_tree_flags, process_tree_flags, input_line_info,
	input_expr_operand, input_local_var, input_phi, input_ssa_names):
	Change to use lto_flags_type and BITS_PER_LTO_FLAGS_TYPES instead of
	unsigned HOST_WIDE_INT and HOST_BITS_PER_WIDE_INT.
	(lto_static_init_local): Add code to assert that lto_flags_type is
	wide enough.

Index: gcc/lto-function-out.c
===================================================================
--- gcc/lto-function-out.c	(revision 130057)
+++ gcc/lto-function-out.c	(working copy)
@@ -561,6 +561,30 @@ output_uleb128_stream (struct output_str
 
 }
 
+/* Identical to output_uleb128_stream above except using unsigned 
+   HOST_WIDEST_INT type.  For efficiency on host where unsigned HOST_WIDEST_INT
+   is not native, we only use this if we know that HOST_WIDE_INT is not wide
+   enough.  */
+
+static void
+output_widest_uint_uleb128_stream (struct output_stream *obs,
+				   unsigned HOST_WIDEST_INT work)
+{
+  LTO_DEBUG_WIDE ("U", work);
+  do
+    {
+      unsigned int byte = (work & 0x7f);
+      work >>= 7;
+      if (work != 0)
+	/* More bytes to follow.  */
+	byte |= 0x80;
+
+      output_1_stream (obs, byte);
+    }
+  while (work != 0);
+
+}
+
 
 /* Output an unsigned LEB128 quantity to OB->main_stream.  */
 
@@ -570,6 +594,14 @@ output_uleb128 (struct output_block *ob,
   output_uleb128_stream (ob->main_stream, work);
 }
 
+/* HOST_WIDEST_INT version of the above. */
+
+static void
+output_widest_uint_uleb128 (struct output_block *ob,
+			    unsigned HOST_WIDEST_INT work)
+{
+  output_widest_uint_uleb128_stream (ob->main_stream, work);
+}
 
 /* Output a signed LEB128 quantity.  */
 
@@ -760,7 +792,7 @@ output_tree_flags (struct output_block *
 		   tree expr, 
 		   bool force_loc)
 {
-  unsigned HOST_WIDE_INT flags = 0;
+  lto_flags_type flags = 0;
   const char *file_to_write = NULL;
   int line_to_write = -1;
 
@@ -888,7 +920,7 @@ output_tree_flags (struct output_block *
 	}
 
       LTO_DEBUG_TOKEN ("flags");
-      output_uleb128 (ob, flags);
+      output_widest_uint_uleb128 (ob, flags);
       LTO_DEBUG_TREE_FLAGS (code, flags);
 
       if (file_to_write)
@@ -2385,9 +2417,9 @@ debug_out_fun (struct lto_debug_context 
 void 
 lto_debug_tree_flags (struct lto_debug_context *context, 
 		      enum tree_code code, 
-		      unsigned HOST_WIDE_INT flags)
+		      lto_flags_type flags)
 {
-#define CLEAROUT (HOST_BITS_PER_WIDE_INT - 1)
+#define CLEAROUT (BITS_PER_LTO_FLAGS_TYPE - 1)
 
 #define START_CLASS_SWITCH()              \
   {                                       \
@@ -2416,7 +2448,7 @@ lto_debug_tree_flags (struct lto_debug_c
 #define ADD_VIS_FLAG(flag_name)  \
   { if (flags >> CLEAROUT) lto_debug_token (context, " " # flag_name ); flags <<= 1; }
 #define ADD_VIS_FLAG_SIZE(flag_name,size)					\
-  { if (flags >> (HOST_BITS_PER_WIDE_INT - size)) lto_debug_token (context, " " # flag_name ); flags <<= size; }
+  { if (flags >> (BITS_PER_LTO_FLAGS_TYPE - size)) lto_debug_token (context, " " # flag_name ); flags <<= size; }
 #define ADD_FUNC_FLAG(flag_name) \
   { if (flags >> CLEAROUT) lto_debug_token (context, " " # flag_name ); flags <<= 1; }
 #define END_EXPR_CASE(class)      break;
Index: gcc/lto-tags.h
===================================================================
--- gcc/lto-tags.h	(revision 130057)
+++ gcc/lto-tags.h	(working copy)
@@ -527,6 +527,10 @@ struct lto_debug_context
   void * main_data;
 };
 
+/* The var_decl tree code has more than 32 bits in flags.  On some host,
+   HOST_WIDE_INT is not wide enough.  */
+typedef unsigned HOST_WIDEST_INT 	lto_flags_type;
+#define	BITS_PER_LTO_FLAGS_TYPE		HOST_BITS_PER_WIDEST_INT
 
 /* Serialize out a file, line (and if USE_MAPPED_LOCATION was set) a
    column.  */
@@ -549,7 +553,7 @@ extern void lto_debug_indent_token (stru
 extern void lto_debug_integer (struct lto_debug_context *, const char *, HOST_WIDE_INT, HOST_WIDE_INT);
 extern void lto_debug_string (struct lto_debug_context *, const char *, int);
 extern void lto_debug_token (struct lto_debug_context *, const char *);
-extern void lto_debug_tree_flags (struct lto_debug_context *, enum tree_code, unsigned HOST_WIDE_INT);
+extern void lto_debug_tree_flags (struct lto_debug_context *, enum tree_code, lto_flags_type);
 extern void lto_debug_undent (struct lto_debug_context *);
 extern void lto_debug_wide (struct lto_debug_context *, const char *, HOST_WIDE_INT);
 
Index: gcc/lto/lto-read.c
===================================================================
--- gcc/lto/lto-read.c	(revision 130057)
+++ gcc/lto/lto-read.c	(working copy)
@@ -177,6 +177,27 @@ input_uleb128 (struct input_block *ib)
     }
 }
 
+/* HOST_WIDEST_INT version of the above.  */
+
+static unsigned HOST_WIDEST_INT 
+input_widest_uint_uleb128 (struct input_block *ib)
+{
+  unsigned HOST_WIDEST_INT result = 0;
+  int shift = 0;
+  unsigned HOST_WIDEST_INT byte;
+
+  while (true)
+    {
+      byte = input_1_unsigned (ib);
+      result |= (byte & 0x7f) << shift;
+      shift += 7;
+      if ((byte & 0x80) == 0)
+	{
+	  LTO_DEBUG_WIDE ("U", result);
+	  return result;
+	}
+    }
+}
 
 /* Read an SLEB128 Number of IB.  */
 
@@ -351,20 +372,20 @@ get_type_ref (struct data_in *data_in, s
 }
 
 /* Set all of the FLAGS for NODE.  */
-#define CLEAROUT (HOST_BITS_PER_WIDE_INT - 1)
+#define CLEAROUT (BITS_PER_LTO_FLAGS_TYPE - 1)
 
 
 /* Read the tree flags for CODE from IB.  */
 
-static unsigned HOST_WIDE_INT 
+static lto_flags_type
 input_tree_flags (struct input_block *ib, enum tree_code code, bool force)
 {
-  unsigned HOST_WIDE_INT flags;
+  lto_flags_type flags;
 
   if (force || TEST_BIT (lto_flags_needed_for, code))
     {
       LTO_DEBUG_TOKEN ("flags");
-      flags = input_uleb128 (ib);
+      flags = input_widest_uint_uleb128 (ib);
       LTO_DEBUG_TREE_FLAGS (code, flags);
     }
   else
@@ -376,12 +397,12 @@ input_tree_flags (struct input_block *ib
 /* Set all of the flag bits inside EXPR by unpacking FLAGS.  */
 
 static void
-process_tree_flags (tree expr, unsigned HOST_WIDE_INT flags)
+process_tree_flags (tree expr, lto_flags_type flags)
 {
   enum tree_code code = TREE_CODE (expr);
   /* Shift the flags up so that the first flag is at the top of the
      flag word.  */
-  flags <<= HOST_BITS_PER_WIDE_INT - flags_length_for_code[code];
+  flags <<= BITS_PER_LTO_FLAGS_TYPE - flags_length_for_code[code];
 
 #define START_CLASS_SWITCH()              \
   {                                       \
@@ -410,7 +431,7 @@ process_tree_flags (tree expr, unsigned 
 #define ADD_VIS_FLAG(flag_name)  \
   { expr->decl_with_vis. flag_name = (flags >> CLEAROUT); flags <<= 1; }
 #define ADD_VIS_FLAG_SIZE(flag_name,size)					\
-  { expr->decl_with_vis. flag_name = (flags >> (HOST_BITS_PER_WIDE_INT - size)); flags <<= size; }
+  { expr->decl_with_vis. flag_name = (flags >> (BITS_PER_LTO_FLAGS_TYPE - size)); flags <<= size; }
 #define ADD_FUNC_FLAG(flag_name) \
   { expr->function_decl. flag_name = (flags >> CLEAROUT); flags <<= 1; }
 #define END_EXPR_CASE(class)      break;
@@ -475,7 +496,7 @@ canon_file_name (const char *string)
 
 static void 
 input_line_info (struct input_block *ib, struct data_in *data_in, 
-		 unsigned HOST_WIDE_INT flags)
+		 lto_flags_type flags)
 {
 #ifdef USE_MAPPED_LOCATION  
   if (flags & LTO_SOURCE_FILE)
@@ -569,7 +590,7 @@ input_expr_operand (struct input_block *
 {
   enum tree_code code = tag_to_expr[tag];
   tree type = NULL_TREE;
-  unsigned HOST_WIDE_INT flags;
+  lto_flags_type flags;
   gcc_assert (code);
   tree result = NULL_TREE;
   
@@ -1227,7 +1248,7 @@ input_local_var (struct input_block *ib,
   unsigned int name_index;
   tree name;
   tree type;
-  unsigned HOST_WIDE_INT flags;
+  lto_flags_type flags;
   tree result;
   tree context;
 
@@ -1464,7 +1485,7 @@ static tree
 input_phi (struct input_block *ib, basic_block bb, 
 	   struct data_in *data_in, struct function *fn)
 {
-  unsigned HOST_WIDE_INT flags = input_tree_flags (ib, PHI_NODE, false);
+  lto_flags_type flags = input_tree_flags (ib, PHI_NODE, false);
 
   tree phi_result = VEC_index (tree, SSANAMES (fn), input_uleb128 (ib));
   int len = EDGE_COUNT (bb->preds);
@@ -1517,7 +1538,7 @@ input_ssa_names (struct input_block *ib,
     {
       tree ssa_name;
       tree name;
-      unsigned HOST_WIDE_INT flags;
+      lto_flags_type flags;
 
       /* Skip over the elements that had been freed.  */
       while (VEC_length (tree, SSANAMES (fn)) < i)
@@ -1722,6 +1743,13 @@ lto_static_init_local (void)
 #undef END_EXPR_CASE
 #undef END_EXPR_SWITCH
 
+  /* Verify that lto_flags_type is wide enough.  */
+  {
+    int code;
+    for (code=0; code<NUM_TREE_CODES; code++)
+      gcc_assert (flags_length_for_code[code] <= BITS_PER_LTO_FLAGS_TYPE);
+  }
+  
   lto_static_init ();
   tree_register_cfg_hooks ();
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [LTO][PATCH] Fix missing tree flags bug.
  2007-11-10 14:10 [LTO][PATCH] Fix missing tree flags bug Doug Kwan (關振德)
@ 2007-11-10 23:51 ` Kenneth Zadeck
  2007-11-13 20:28 ` Diego Novillo
  1 sibling, 0 replies; 3+ messages in thread
From: Kenneth Zadeck @ 2007-11-10 23:51 UTC (permalink / raw)
  To: gcc-patches, dougkwan

Doug,


[12:11]	<zadeck>	richi_ is HOST_WIDEST_INT at least 64 bits on all platforms
[12:11]	<zadeck>	?
[12:18]	<richi_>	zadeck: no
[12:19]	<richi_>	see the comment in hwint.h
[13:14]	<zadeck>	the comments in this file say that long long is defined to be 64 bits but that there are still some machines that do not define this. is that still true?
[13:15]	<zadeck>	s/defined to be 64 bits/defined to be 64 bits by c99/
[13:15]	<richi_>	I don't think C99 says long long is 64bits
[13:16]	<richi_>	(also we can't use C99 but only C89)
[13:17]	<zadeck>	i was looking on line 27 of the file
[13:17]	<richi_>	interesting ;)
[13:18]	<richi_>	right, is says so.
[13:18]	<richi_>	so long long needs to be >=64bits
[13:18]	<richi_>	for C99
[13:20]	<zadeck>	i am trying to deal with http://gcc.gnu.org/ml/gcc-patches/2007-11/msg00551.html. This is really a bug, it needs to be fixed, but from what you are saying, he has not really fixed this in a portable way.
[13:20]	<zadeck>	not that the code that i wrote that he is replacing is correct, you understand
[13:22]	<richi_>	I see. So you have >32bits worth of flags in a single bitfield?
[13:22]	<zadeck>	yes
[13:22]	<richi_>	can't you split it?
[13:22]	<zadeck>	it would be a mess
[13:24]	<zadeck>	i assume that int64_t is not guaranteed to be there either?
[13:24]	<richi_>	ok, so I'd use HOST_WIDEST_INT then.
[13:24]	<richi_>	right
[13:24]	<richi_>	or wait - we generate stdint at least
[13:24]	<richi_>	but if HOST_WIDEST_INT can be not 64bit int64_t might not exist, too
[13:27]	<zadeck>	so what is your conclusion?
[13:27]	<richi_>	hwint.h should be fixed and we should drop host support for hosts that do not have a 64bit integer type ;)
[13:28]	<zadeck>	i guess i will accept the patch
[13:28]	<richi_>	yes
[13:28]	<richi_>	I think it's reasonable


This patch appears to be fine.  
I do not have any 32 bit machines anymore which is why i missed this.

Also, if you cc the lto patches to me directly, i will review them
quicker.  I am sometimes slow to read the lists.

Kenny

> Hi,
> 
>     Could someone review and approve this patch? It fixes a problem
> where the first 5 bits of tree flags of a VAR_DECL node got dropped on
> host that has 32-bit HOST_WIDE_INT.  I tested it on i686-linux-gnu.
> 
> -Doug

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [LTO][PATCH] Fix missing tree flags bug.
  2007-11-10 14:10 [LTO][PATCH] Fix missing tree flags bug Doug Kwan (關振德)
  2007-11-10 23:51 ` Kenneth Zadeck
@ 2007-11-13 20:28 ` Diego Novillo
  1 sibling, 0 replies; 3+ messages in thread
From: Diego Novillo @ 2007-11-13 20:28 UTC (permalink / raw)
  To: "Doug Kwan (Ãö®¶¼w)"; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 388 bytes --]

Doug Kwan (Ãö®¶¼w) wrote:

>     Could someone review and approve this patch? It fixes a problem
> where the first 5 bits of tree flags of a VAR_DECL node got dropped on
> host that has 32-bit HOST_WIDE_INT.  I tested it on i686-linux-gnu.

Committed with a couple of minor formatting fixes and added an extra 
compile-time check for the width of BITS_PER_LTO_FLAGS_TYPES.



Diego.

[-- Attachment #2: 20071113-widest-int-for-flags.diff.txt --]
[-- Type: text/plain, Size: 9680 bytes --]

2007-11-13  Diego Novillo  <dnovillo@google.com>

	* lto-tags.h: Call #error if BITS_PER_LTO_FLAGS_TYPE is
	not wide enough.

2007-11-13  Doug Kwan  <dougkwan@google.com>

	* lto-function-out.c (output_widest_uint_uleb128_stream,
	output_widest_uint_uleb128): New functions. 
	(output_tree_flags): Use lto_flags_type instead of unsigned
	HOST_WIDE_INT.  Call output_widest_unint_uleb128 instead of
	output_uleb128.
	(lto_debug_tree_flags): Replace HOST_BITS_PER_WIDE_INT with
	BITS_PER_LTO_FLAGS_TYPE as appropriate.
	* lto-tags.h (lto_flags_type): New type.
	(BITS_PER_LTO_FLAGS_TYPES): New macro.
	(lto_debug_tree_flags): Change prototype to use
	lto_flags_type.

lto/ChangeLog

	* lto-read.c (input_widest_uint_uleb128): New function.
	(input_tree_flags, process_tree_flags, input_line_info,
	input_expr_operand, input_local_var, input_phi, input_ssa_names):
	Change to use lto_flags_type and BITS_PER_LTO_FLAGS_TYPES instead of
	unsigned HOST_WIDE_INT and HOST_BITS_PER_WIDE_INT.
	(lto_static_init_local): Add code to assert that lto_flags_type is
	wide enough.

Index: lto-function-out.c
===================================================================
--- lto-function-out.c	(revision 130144)
+++ lto-function-out.c	(working copy)
@@ -558,7 +558,29 @@ output_uleb128_stream (struct output_str
       output_1_stream (obs, byte);
     }
   while (work != 0);
+}
+
+/* Identical to output_uleb128_stream above except using unsigned 
+   HOST_WIDEST_INT type.  For efficiency on host where unsigned HOST_WIDEST_INT
+   is not native, we only use this if we know that HOST_WIDE_INT is not wide
+   enough.  */
 
+static void
+output_widest_uint_uleb128_stream (struct output_stream *obs,
+				   unsigned HOST_WIDEST_INT work)
+{
+  LTO_DEBUG_WIDE ("U", work);
+  do
+    {
+      unsigned int byte = (work & 0x7f);
+      work >>= 7;
+      if (work != 0)
+	/* More bytes to follow.  */
+	byte |= 0x80;
+
+      output_1_stream (obs, byte);
+    }
+  while (work != 0);
 }
 
 
@@ -570,6 +592,15 @@ output_uleb128 (struct output_block *ob,
   output_uleb128_stream (ob->main_stream, work);
 }
 
+/* HOST_WIDEST_INT version of output_uleb128.  OB and WORK are as in
+   output_uleb128. */
+
+static void
+output_widest_uint_uleb128 (struct output_block *ob,
+			    unsigned HOST_WIDEST_INT work)
+{
+  output_widest_uint_uleb128_stream (ob->main_stream, work);
+}
 
 /* Output a signed LEB128 quantity.  */
 
@@ -761,7 +792,7 @@ output_tree_flags (struct output_block *
 		   tree expr, 
 		   bool force_loc)
 {
-  unsigned HOST_WIDE_INT flags = 0;
+  lto_flags_type flags = 0;
   const char *file_to_write = NULL;
   int line_to_write = -1;
 
@@ -890,7 +921,7 @@ output_tree_flags (struct output_block *
 	}
 
       LTO_DEBUG_TOKEN ("flags");
-      output_uleb128 (ob, flags);
+      output_widest_uint_uleb128 (ob, flags);
       LTO_DEBUG_TREE_FLAGS (code, flags);
 
       if (file_to_write)
@@ -2389,9 +2420,9 @@ debug_out_fun (struct lto_debug_context 
 void 
 lto_debug_tree_flags (struct lto_debug_context *context, 
 		      enum tree_code code, 
-		      unsigned HOST_WIDE_INT flags)
+		      lto_flags_type flags)
 {
-#define CLEAROUT (HOST_BITS_PER_WIDE_INT - 1)
+#define CLEAROUT (BITS_PER_LTO_FLAGS_TYPE - 1)
 
 #define START_CLASS_SWITCH()              \
   {                                       \
@@ -2420,7 +2451,7 @@ lto_debug_tree_flags (struct lto_debug_c
 #define ADD_VIS_FLAG(flag_name)  \
   { if (flags >> CLEAROUT) lto_debug_token (context, " " # flag_name ); flags <<= 1; }
 #define ADD_VIS_FLAG_SIZE(flag_name,size)					\
-  { if (flags >> (HOST_BITS_PER_WIDE_INT - size)) lto_debug_token (context, " " # flag_name ); flags <<= size; }
+  { if (flags >> (BITS_PER_LTO_FLAGS_TYPE - size)) lto_debug_token (context, " " # flag_name ); flags <<= size; }
 #define END_EXPR_CASE(class)      break;
 #define END_EXPR_SWITCH()                 \
     default:                              \
Index: lto-tags.h
===================================================================
--- lto-tags.h	(revision 130144)
+++ lto-tags.h	(working copy)
@@ -526,6 +526,14 @@ struct lto_debug_context
   void * main_data;
 };
 
+/* The VAR_DECL tree code has more than 32 bits in flags.  On some hosts,
+   HOST_WIDE_INT is not wide enough.  */
+typedef unsigned HOST_WIDEST_INT 	lto_flags_type;
+#define	BITS_PER_LTO_FLAGS_TYPE		HOST_BITS_PER_WIDEST_INT
+
+#if BITS_PER_LTO_FLAGS_TYPE <= 32
+#  error "Your host should support integer types wider than 32 bits."
+#endif
 
 /* The serialization plan is that when any of the current file, line,
    or col change (from the state last serialized), we write the
@@ -551,7 +559,7 @@ extern void lto_debug_indent_token (stru
 extern void lto_debug_integer (struct lto_debug_context *, const char *, HOST_WIDE_INT, HOST_WIDE_INT);
 extern void lto_debug_string (struct lto_debug_context *, const char *, int);
 extern void lto_debug_token (struct lto_debug_context *, const char *);
-extern void lto_debug_tree_flags (struct lto_debug_context *, enum tree_code, unsigned HOST_WIDE_INT);
+extern void lto_debug_tree_flags (struct lto_debug_context *, enum tree_code, lto_flags_type);
 extern void lto_debug_undent (struct lto_debug_context *);
 extern void lto_debug_wide (struct lto_debug_context *, const char *, HOST_WIDE_INT);
 
Index: lto/lto-read.c
===================================================================
--- lto/lto-read.c	(revision 130144)
+++ lto/lto-read.c	(working copy)
@@ -178,6 +178,27 @@ input_uleb128 (struct input_block *ib)
     }
 }
 
+/* HOST_WIDEST_INT version of input_uleb128.  IB is as in input_uleb128.  */
+
+static unsigned HOST_WIDEST_INT 
+input_widest_uint_uleb128 (struct input_block *ib)
+{
+  unsigned HOST_WIDEST_INT result = 0;
+  int shift = 0;
+  unsigned HOST_WIDEST_INT byte;
+
+  while (true)
+    {
+      byte = input_1_unsigned (ib);
+      result |= (byte & 0x7f) << shift;
+      shift += 7;
+      if ((byte & 0x80) == 0)
+	{
+	  LTO_DEBUG_WIDE ("U", result);
+	  return result;
+	}
+    }
+}
 
 /* Read an SLEB128 Number of IB.  */
 
@@ -352,20 +373,20 @@ get_type_ref (struct data_in *data_in, s
 }
 
 /* Set all of the FLAGS for NODE.  */
-#define CLEAROUT (HOST_BITS_PER_WIDE_INT - 1)
+#define CLEAROUT (BITS_PER_LTO_FLAGS_TYPE - 1)
 
 
 /* Read the tree flags for CODE from IB.  */
 
-static unsigned HOST_WIDE_INT 
+static lto_flags_type
 input_tree_flags (struct input_block *ib, enum tree_code code, bool force)
 {
-  unsigned HOST_WIDE_INT flags;
+  lto_flags_type flags;
 
   if (force || TEST_BIT (lto_flags_needed_for, code))
     {
       LTO_DEBUG_TOKEN ("flags");
-      flags = input_uleb128 (ib);
+      flags = input_widest_uint_uleb128 (ib);
       LTO_DEBUG_TREE_FLAGS (code, flags);
     }
   else
@@ -377,12 +398,12 @@ input_tree_flags (struct input_block *ib
 /* Set all of the flag bits inside EXPR by unpacking FLAGS.  */
 
 static void
-process_tree_flags (tree expr, unsigned HOST_WIDE_INT flags)
+process_tree_flags (tree expr, lto_flags_type flags)
 {
   enum tree_code code = TREE_CODE (expr);
   /* Shift the flags up so that the first flag is at the top of the
      flag word.  */
-  flags <<= HOST_BITS_PER_WIDE_INT - flags_length_for_code[code];
+  flags <<= BITS_PER_LTO_FLAGS_TYPE - flags_length_for_code[code];
 
 #define START_CLASS_SWITCH()              \
   {                                       \
@@ -411,7 +432,7 @@ process_tree_flags (tree expr, unsigned 
 #define ADD_VIS_FLAG(flag_name)  \
   { expr->decl_with_vis. flag_name = (flags >> CLEAROUT); flags <<= 1; }
 #define ADD_VIS_FLAG_SIZE(flag_name,size)					\
-  { expr->decl_with_vis. flag_name = (flags >> (HOST_BITS_PER_WIDE_INT - size)); flags <<= size; }
+  { expr->decl_with_vis. flag_name = (flags >> (BITS_PER_LTO_FLAGS_TYPE - size)); flags <<= size; }
 #define END_EXPR_CASE(class)      break;
 #define END_EXPR_SWITCH()                 \
     default:                              \
@@ -473,7 +494,7 @@ canon_file_name (const char *string)
 
 static void 
 input_line_info (struct input_block *ib, struct data_in *data_in, 
-		 unsigned HOST_WIDE_INT flags)
+		 lto_flags_type flags)
 {
 #ifdef USE_MAPPED_LOCATION  
   if (flags & LTO_SOURCE_FILE)
@@ -576,7 +597,7 @@ input_expr_operand (struct input_block *
 {
   enum tree_code code = tag_to_expr[tag];
   tree type = NULL_TREE;
-  unsigned HOST_WIDE_INT flags;
+  lto_flags_type flags;
   gcc_assert (code);
   tree result = NULL_TREE;
   
@@ -1233,7 +1254,7 @@ input_local_var (struct input_block *ib,
   unsigned int name_index;
   tree name;
   tree type;
-  unsigned HOST_WIDE_INT flags;
+  lto_flags_type flags;
   tree result;
   tree context;
 
@@ -1470,7 +1491,7 @@ static tree
 input_phi (struct input_block *ib, basic_block bb, 
 	   struct data_in *data_in, struct function *fn)
 {
-  unsigned HOST_WIDE_INT flags = input_tree_flags (ib, PHI_NODE, false);
+  lto_flags_type flags = input_tree_flags (ib, PHI_NODE, false);
 
   tree phi_result = VEC_index (tree, SSANAMES (fn), input_uleb128 (ib));
   int len = EDGE_COUNT (bb->preds);
@@ -1523,7 +1544,7 @@ input_ssa_names (struct input_block *ib,
     {
       tree ssa_name;
       tree name;
-      unsigned HOST_WIDE_INT flags;
+      lto_flags_type flags;
 
       /* Skip over the elements that had been freed.  */
       while (VEC_length (tree, SSANAMES (fn)) < i)
@@ -1726,6 +1747,13 @@ lto_static_init_local (void)
 #undef END_EXPR_CASE
 #undef END_EXPR_SWITCH
 
+  /* Verify that lto_flags_type is wide enough.  */
+  {
+    int code;
+    for (code = 0; code < NUM_TREE_CODES; code++)
+      gcc_assert (flags_length_for_code[code] <= BITS_PER_LTO_FLAGS_TYPE);
+  }
+  
   lto_static_init ();
   tree_register_cfg_hooks ();
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-11-13 19:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-10 14:10 [LTO][PATCH] Fix missing tree flags bug Doug Kwan (關振德)
2007-11-10 23:51 ` Kenneth Zadeck
2007-11-13 20:28 ` Diego Novillo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).