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]

[lto]: patch to fix up the processing of flags and line numbers.


Most of this patch is really code sent to me 6 months ago by Alon and
lost in my massive mail archives.  However, the patch came right at the
time that danny was redoing the lto branch from scratch because it had
been too rotten do to lack of regular merging.  Alon's  patch fixes a
design flaw of mine where i assumed that flags were only 1 bit wide. 
The patch is different from his original patch because things have
changed. 

The rest of the patch is cleaning up how line numbers are handled when
USE_MAPPED_LOCATION has been set.  This code has not yet been fully
tested. 


2007-11-08  Alon Dayan <alond@il.ibm.com>
        Kenneth Zadeck <zadeck@naturalbridge.com>

         * lto-function-out.c: (output_tree_flags): Use expanded
location for exprs.
    (output_tree_flags, lto_debug_tree_flags):
    Macro add flags of size>1.
         * lto-tree-flags.def: Likewise.

2007-11-08 Alon Dayan  <alond@il.ibm.com>
       Kenneth Zadeck <zadeck@naturalbridge.com>

     * lto-read.c (process_flags, lto_static_init_local):
     read flags of VAR_DECL and FUNCTION_DECL of size>1.
     change global array num_flags_for_code to flags_length_for_code.
     (set_line_info): Make decls work in USE_MAPPED_LOCATION mode.
   


committed as revision 129933.

kenny
Index: lto-tree-flags.def
===================================================================
--- lto-tree-flags.def	(revision 129932)
+++ lto-tree-flags.def	(working copy)
@@ -325,7 +325,7 @@
       ADD_EXPR_FLAG (static_flag)
       ADD_EXPR_FLAG (public_flag)
       ADD_EXPR_FLAG (nothrow_flag)
-      ADD_VIS_FLAG (visibility)
+      ADD_VIS_FLAG_SIZE (visibility, 2)
       ADD_VIS_FLAG (one_only)
       ADD_VIS_FLAG (comdat_flag)
       ADD_VIS_FLAG (weak_flag)
@@ -737,14 +737,15 @@
       ADD_DECL_FLAG (decl_flag_2)
       ADD_DECL_FLAG (decl_flag_3)
       ADD_DECL_FLAG (gimple_reg_flag)
-      ADD_VIS_FLAG (visibility)
+      ADD_VIS_FLAG_SIZE (visibility, 2)
       ADD_VIS_FLAG (one_only)
       ADD_VIS_FLAG (comdat_flag)
       ADD_VIS_FLAG (weak_flag)
       ADD_VIS_FLAG (dllimport_flag)
       ADD_VIS_FLAG (hard_register)
       ADD_VIS_FLAG (init_priority_p)
-      ADD_VIS_FLAG (tls_model)
+      ADD_VIS_FLAG_SIZE (tls_model, 3)
+      ADD_VIS_FLAG (thread_local)
       ADD_VIS_FLAG (in_text_section)
       ADD_VIS_FLAG (common_flag)
       ADD_VIS_FLAG (seen_in_bind_expr)
Index: lto-function-out.c
===================================================================
--- lto-function-out.c	(revision 129932)
+++ lto-function-out.c	(working copy)
@@ -794,6 +794,8 @@ output_tree_flags (struct output_block *
       { flags <<= 1; if (expr->decl_common. flag_name ) flags |= 1; }
 #define ADD_VIS_FLAG(flag_name)  \
       { flags <<= 1; if (expr->decl_with_vis. flag_name ) flags |= 1; }
+#define ADD_VIS_FLAG_SIZE(flag_name,size)					\
+      { flags <<= size; if (expr->decl_with_vis. flag_name ) flags |= expr->decl_with_vis. flag_name; }
 #define ADD_FUNC_FLAG(flag_name) \
       { flags <<= 1; if (expr->function_decl. flag_name ) flags |= 1; }
 #define END_EXPR_CASE(class)      break;
@@ -815,6 +817,7 @@ output_tree_flags (struct output_block *
 #undef ADD_EXPR_FLAG
 #undef ADD_DECL_FLAG
 #undef ADD_VIS_FLAG
+#undef ADD_VIS_FLAG_SIZE
 #undef ADD_FUNC_FLAG
 #undef END_EXPR_CASE
 #undef END_EXPR_SWITCH
@@ -831,16 +834,21 @@ output_tree_flags (struct output_block *
 	    {
 	      if (EXPR_HAS_LOCATION (expr))
 		{
-		  current_file = EXPR_FILENAME (expr);
-		  current_line = EXPR_LINENO (expr);
+		  expanded_location xloc 
+		    = expand_location (EXPR_LOCATION (expr));
+
+		  current_file = xloc.file;
+		  current_line = xloc.line;
 #ifdef USE_MAPPED_LOCATION
-		/* This will blow up because i cannot find the function
-		   that i would have expected to have the name
-		   expr_col.  */ 
-		  current_col = ????
+		  current_col = xloc.column;
 #endif
 		}
 	    }
+
+	  /* We use force_loc here because we only want to put out the
+	     line number when we are writing the top level list of var
+	     and parm decls, not when we access them inside a
+	     function.  */
 	  else if (force_loc && DECL_P (expr))
 	    {
 	      expanded_location xloc 
@@ -2405,6 +2413,8 @@ lto_debug_tree_flags (struct lto_debug_c
   { if (flags >> CLEAROUT) lto_debug_token (context, " " # flag_name ); flags <<= 1; }
 #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; }
 #define ADD_FUNC_FLAG(flag_name) \
   { if (flags >> CLEAROUT) lto_debug_token (context, " " # flag_name ); flags <<= 1; }
 #define END_EXPR_CASE(class)      break;
Index: lto/lto-read.c
===================================================================
--- lto/lto-read.c	(revision 129932)
+++ lto/lto-read.c	(working copy)
@@ -57,7 +57,7 @@ Boston, MA 02110-1301, USA.  */
 static enum tree_code tag_to_expr[LTO_last_tag];
 
 /* The number of flags that are defined for each tree code.  */
-static int num_flags_for_code[NUM_TREE_CODES];
+static int flags_length_for_code[NUM_TREE_CODES];
 
 struct data_in
 {
@@ -381,7 +381,7 @@ process_tree_flags (tree expr, unsigned 
   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 - num_flags_for_code[code];
+  flags <<= HOST_BITS_PER_WIDE_INT - flags_length_for_code[code];
 
 #define START_CLASS_SWITCH()              \
   {                                       \
@@ -409,6 +409,8 @@ process_tree_flags (tree expr, unsigned 
   { expr->decl_common. flag_name = flags >> CLEAROUT; flags <<= 1; }
 #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; }
 #define ADD_FUNC_FLAG(flag_name) \
   { expr->function_decl. flag_name = (flags >> CLEAROUT); flags <<= 1; }
 #define END_EXPR_CASE(class)      break;
@@ -430,6 +432,7 @@ process_tree_flags (tree expr, unsigned 
 #undef ADD_EXPR_FLAG
 #undef ADD_DECL_FLAG
 #undef ADD_VIS_FLAG
+#undef ADD_VIS_FLAG_SIZE
 #undef ADD_FUNC_FLAG
 #undef END_EXPR_CASE
 #undef END_EXPR_SWITCH
@@ -526,9 +529,7 @@ set_line_info (struct data_in *data_in, 
   if (data_in->current_file)
     {
 #ifdef USE_MAPPED_LOCATION
-  
-
-
+      LINEMAP_POSITION_FOR_COLUMN (DECL_SOURCE_LOCATION (node), line_table, data_in->current_col);
 #else
       if (EXPR_P (node))
 	  annotate_with_file_line (node, 
@@ -1660,7 +1661,7 @@ lto_static_init_local (void)
 #undef TREE_SINGLE_MECHANICAL_TRUE
 #undef TREE_SINGLE_MECHANICAL_FALSE
 #undef SET_NAME
-  /* Initialize num_flags_for_code.  */
+  /* Initialize flags_length_for_code.  */
 
 
 #define START_CLASS_SWITCH()                  \
@@ -1669,13 +1670,13 @@ lto_static_init_local (void)
     for (code=0; code<NUM_TREE_CODES; code++) \
       {                                       \
 	/* The LTO_SOURCE_LOC_BITS leaves room for file and line number for exprs.  */ \
-        num_flags_for_code[code] = LTO_SOURCE_LOC_BITS; \
+        flags_length_for_code[code] = LTO_SOURCE_LOC_BITS; \
                                               \
         switch (TREE_CODE_CLASS (code))       \
           {
 
 #define START_CLASS_CASE(class)    case class:
-#define ADD_CLASS_FLAG(flag_name)    num_flags_for_code[code]++;
+#define ADD_CLASS_FLAG(flag_name)    flags_length_for_code[code]++;
 #define END_CLASS_CASE(class)      break;
 #define END_CLASS_SWITCH()                    \
           default:                            \
@@ -1689,10 +1690,11 @@ lto_static_init_local (void)
         switch (code)			      \
           {
 #define START_EXPR_CASE(code)    case code:
-#define ADD_EXPR_FLAG(flag_name)    num_flags_for_code[code]++;
-#define ADD_DECL_FLAG(flag_name)    num_flags_for_code[code]++;
-#define ADD_VIS_FLAG(flag_name)     num_flags_for_code[code]++;
-#define ADD_FUNC_FLAG(flag_name)    num_flags_for_code[code]++;
+#define ADD_EXPR_FLAG(flag_name)           flags_length_for_code[code]++;
+#define ADD_DECL_FLAG(flag_name)           flags_length_for_code[code]++;
+#define ADD_VIS_FLAG(flag_name)            flags_length_for_code[code]++;
+#define ADD_VIS_FLAG_SIZE(flag_name,size)  flags_length_for_code[code] += size;
+#define ADD_FUNC_FLAG(flag_name)           flags_length_for_code[code]++;
 #define END_EXPR_CASE(class)      break;
 #define END_EXPR_SWITCH()                     \
           default:                            \
@@ -1715,6 +1717,7 @@ lto_static_init_local (void)
 #undef ADD_EXPR_FLAG
 #undef ADD_DECL_FLAG
 #undef ADD_VIS_FLAG
+#undef ADD_VIS_FLAG_SIZE
 #undef ADD_FUNC_FLAG
 #undef END_EXPR_CASE
 #undef END_EXPR_SWITCH

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