re PR middle-end/56231 (warning traces have bogus line information when using LTO)
authorRichard Biener <rguenther@suse.de>
Fri, 8 Feb 2013 12:55:13 +0000 (12:55 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 8 Feb 2013 12:55:13 +0000 (12:55 +0000)
2013-02-08  Richard Biener  <rguenther@suse.de>

PR lto/56231
* lto-streamer.h (struct data_in): Remove current_file, current_line
and current_col members.
* lto-streamer-out.c (lto_output_location): Stream changed bits
en-block for efficiency.
* lto-streamer-in.c (clear_line_info): Remove.
(lto_input_location): Cache current file, line and column
globally via local statics.  Read changed bits en-block.
(input_function): Do not call clear_line_info.
(lto_read_body): Likewise.
(lto_input_toplevel_asms): Likewise.

lto/
* lto-lang.c (lto_init): Do not enter a dummy file.

From-SVN: r195884

gcc/ChangeLog
gcc/lto-streamer-in.c
gcc/lto-streamer-out.c
gcc/lto-streamer.h
gcc/lto/ChangeLog
gcc/lto/lto-lang.c

index d54c1c0f6c662a0bbe579fcc833ce2a99bcd5cf4..d7b0e643b7f85eb37eee21c80fbb08a7f7635f8c 100644 (file)
@@ -1,3 +1,17 @@
+2013-02-08  Richard Biener  <rguenther@suse.de>
+
+       PR lto/56231
+       * lto-streamer.h (struct data_in): Remove current_file, current_line
+       and current_col members.
+       * lto-streamer-out.c (lto_output_location): Stream changed bits
+       en-block for efficiency.
+       * lto-streamer-in.c (clear_line_info): Remove.
+       (lto_input_location): Cache current file, line and column
+       globally via local statics.  Read changed bits en-block.
+       (input_function): Do not call clear_line_info.
+       (lto_read_body): Likewise.
+       (lto_input_toplevel_asms): Likewise.
+
 2013-02-08  Michael Matz  <matz@suse.de>
 
        PR tree-optimization/52448
index fe9dd22c24c2e04b1037c7d43e709576060b995d..f3a08884b53e2c9029c543be2befd847c8631e39 100644 (file)
@@ -123,58 +123,48 @@ canon_file_name (const char *string)
 }
 
 
-/* Clear the line info stored in DATA_IN.  */
-
-static void
-clear_line_info (struct data_in *data_in)
-{
-  if (data_in->current_file)
-    linemap_add (line_table, LC_LEAVE, false, NULL, 0);
-  data_in->current_file = NULL;
-  data_in->current_line = 0;
-  data_in->current_col = 0;
-}
-
-
 /* Read a location bitpack from input block IB.  */
 
 location_t
 lto_input_location (struct bitpack_d *bp, struct data_in *data_in)
 {
+  static const char *current_file;
+  static int current_line;
+  static int current_col;
   bool file_change, line_change, column_change;
   unsigned len;
-  bool prev_file = data_in->current_file != NULL;
+  bool prev_file = current_file != NULL;
 
   if (bp_unpack_value (bp, 1))
     return UNKNOWN_LOCATION;
 
   file_change = bp_unpack_value (bp, 1);
+  line_change = bp_unpack_value (bp, 1);
+  column_change = bp_unpack_value (bp, 1);
+
   if (file_change)
-    data_in->current_file = canon_file_name
-                             (string_for_index (data_in,
-                                                bp_unpack_var_len_unsigned (bp),
-                                                &len));
+    current_file = canon_file_name
+                    (string_for_index (data_in,
+                                       bp_unpack_var_len_unsigned (bp),
+                                       &len));
 
-  line_change = bp_unpack_value (bp, 1);
   if (line_change)
-    data_in->current_line = bp_unpack_var_len_unsigned (bp);
+    current_line = bp_unpack_var_len_unsigned (bp);
 
-  column_change = bp_unpack_value (bp, 1);
   if (column_change)
-    data_in->current_col = bp_unpack_var_len_unsigned (bp);
+    current_col = bp_unpack_var_len_unsigned (bp);
 
   if (file_change)
     {
       if (prev_file)
        linemap_add (line_table, LC_LEAVE, false, NULL, 0);
 
-      linemap_add (line_table, LC_ENTER, false, data_in->current_file,
-                  data_in->current_line);
+      linemap_add (line_table, LC_ENTER, false, current_file, current_line);
     }
   else if (line_change)
-    linemap_line_start (line_table, data_in->current_line, data_in->current_col);
+    linemap_line_start (line_table, current_line, current_col);
 
-  return linemap_position_for_column (line_table, data_in->current_col);
+  return linemap_position_for_column (line_table, current_col);
 }
 
 
@@ -806,7 +796,6 @@ input_function (tree fn_decl, struct data_in *data_in,
 
   fn = DECL_STRUCT_FUNCTION (fn_decl);
   tag = streamer_read_record_start (ib);
-  clear_line_info (data_in);
 
   gimple_register_cfg_hooks ();
   lto_tag_check (tag, LTO_function);
@@ -987,7 +976,6 @@ lto_read_body (struct lto_file_decl_data *file_data, tree fn_decl,
       pop_cfun ();
     }
 
-  clear_line_info (data_in);
   lto_data_in_delete (data_in);
 }
 
@@ -1137,7 +1125,6 @@ lto_input_toplevel_asms (struct lto_file_decl_data *file_data, int order_base)
        symtab_order = node->order + 1;
     }
 
-  clear_line_info (data_in);
   lto_data_in_delete (data_in);
 
   lto_free_section_data (file_data, LTO_section_asm, NULL, data, len);
index f97f1e228cea7c02b555f52c1d733d22873904ca..f8207c8e02249f4e29803ce42f1066bcb365ae13 100644 (file)
@@ -162,6 +162,9 @@ lto_output_location (struct output_block *ob, struct bitpack_d *bp,
   xloc = expand_location (loc);
 
   bp_pack_value (bp, ob->current_file != xloc.file, 1);
+  bp_pack_value (bp, ob->current_line != xloc.line, 1);
+  bp_pack_value (bp, ob->current_col != xloc.column, 1);
+
   if (ob->current_file != xloc.file)
     bp_pack_var_len_unsigned (bp,
                              streamer_string_index (ob, xloc.file,
@@ -169,12 +172,10 @@ lto_output_location (struct output_block *ob, struct bitpack_d *bp,
                                                     true));
   ob->current_file = xloc.file;
 
-  bp_pack_value (bp, ob->current_line != xloc.line, 1);
   if (ob->current_line != xloc.line)
     bp_pack_var_len_unsigned (bp, xloc.line);
   ob->current_line = xloc.line;
 
-  bp_pack_value (bp, ob->current_col != xloc.column, 1);
   if (ob->current_col != xloc.column)
     bp_pack_var_len_unsigned (bp, xloc.column);
   ob->current_col = xloc.column;
index 4e4a4e956e9ffe70a6999006706caae9f09d678b..919e304e107d7326d63218e020a5b86daad8f660 100644 (file)
@@ -691,10 +691,6 @@ struct data_in
   /* Number of unnamed labels.  */
   unsigned int num_unnamed_labels;
 
-  const char *current_file;
-  int current_line;
-  int current_col;
-
   /* Maps each reference number to the resolution done by the linker. */
   vec<ld_plugin_symbol_resolution_t> globals_resolution;
 
index 6743f2f680ae0a49916f13c3779b6a79b0fe7255..e3530da973e3d30fb8664111babad7e6dd2bf3e4 100644 (file)
@@ -1,3 +1,8 @@
+2013-02-08  Richard Biener  <rguenther@suse.de>
+
+       PR lto/56231
+       * lto-lang.c (lto_init): Do not enter a dummy file.
+
 2013-02-07  Uros Bizjak  <ubizjak@gmail.com>
 
        PR bootstrap/56227
index b2919ee1aee8436ecb3b044a20f44a83b2472419..87a756d57639bb83095764f40f16b39688772e69 100644 (file)
@@ -1156,9 +1156,6 @@ lto_init (void)
   /* We need to generate LTO if running in WPA mode.  */
   flag_generate_lto = flag_wpa;
 
-  /* Initialize libcpp line maps for gcc_assert to work.  */
-  linemap_add (line_table, LC_ENTER, 0, NULL, 0);
-
   /* Create the basic integer types.  */
   build_common_tree_nodes (flag_signed_char, /*short_double=*/false);