From 88768989be6c79c43bd3166c87eaa877b867957c Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Tue, 2 May 2017 15:12:13 +0200
Subject: [PATCH] Remove LTO_STREAMER_DEBUG (PR lto/79489).

gcc/ChangeLog:

2017-05-02  Martin Liska  <mliska@suse.cz>

	PR lto/79489.
	* lto-streamer-in.c (lto_read_tree_1): Remove
	LTO_STREAMER_DEBUG.
	* lto-streamer.c (struct tree_hash_entry): Likewise.
	(struct tree_entry_hasher): Likewise.
	(tree_entry_hasher::hash): Likewise.
	(tree_entry_hasher::equal): Likewise.
	(lto_streamer_init): Likewise.
	(lto_orig_address_map): Likewise.
	(lto_orig_address_get): Likewise.
	(lto_orig_address_remove): Likewise.
	* lto-streamer.h: Likewise.
	* tree-streamer-in.c (streamer_alloc_tree): Likewise.
	* tree-streamer-out.c (streamer_write_tree_header): Likewise.
---
 gcc/lto-streamer-in.c   |  6 ----
 gcc/lto-streamer.c      | 92 -------------------------------------------------
 gcc/lto-streamer.h      | 13 -------
 gcc/tree-streamer-in.c  | 20 -----------
 gcc/tree-streamer-out.c | 10 ------
 5 files changed, 141 deletions(-)

diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c
index 515aa532ce6..6da217d5589 100644
--- a/gcc/lto-streamer-in.c
+++ b/gcc/lto-streamer-in.c
@@ -1337,12 +1337,6 @@ lto_read_tree_1 (struct lto_input_block *ib, struct data_in *data_in, tree expr)
       && TREE_CODE (expr) != FUNCTION_DECL
       && TREE_CODE (expr) != TRANSLATION_UNIT_DECL)
     DECL_INITIAL (expr) = stream_read_tree (ib, data_in);
-
-#ifdef LTO_STREAMER_DEBUG
-  /* Remove the mapping to RESULT's original address set by
-     streamer_alloc_tree.  */
-  lto_orig_address_remove (expr);
-#endif
 }
 
 /* Read the physical representation of a tree node with tag TAG from
diff --git a/gcc/lto-streamer.c b/gcc/lto-streamer.c
index 04d733024d8..74fe0e259bf 100644
--- a/gcc/lto-streamer.c
+++ b/gcc/lto-streamer.c
@@ -257,35 +257,6 @@ print_lto_report (const char *s)
 	     lto_section_name[i], lto_stats.section_size[i]);
 }
 
-
-#ifdef LTO_STREAMER_DEBUG
-struct tree_hash_entry
-{
-  tree key;
-  intptr_t value;
-};
-
-struct tree_entry_hasher : nofree_ptr_hash <tree_hash_entry>
-{
-  static inline hashval_t hash (const tree_hash_entry *);
-  static inline bool equal (const tree_hash_entry *, const tree_hash_entry *);
-};
-
-inline hashval_t
-tree_entry_hasher::hash (const tree_hash_entry *e)
-{
-  return htab_hash_pointer (e->key);
-}
-
-inline bool
-tree_entry_hasher::equal (const tree_hash_entry *e1, const tree_hash_entry *e2)
-{
-  return (e1->key == e2->key);
-}
-
-static hash_table<tree_entry_hasher> *tree_htab;
-#endif
-
 /* Initialization common to the LTO reader and writer.  */
 
 void
@@ -297,10 +268,6 @@ lto_streamer_init (void)
      handle it.  */
   if (flag_checking)
     streamer_check_handled_ts_structures ();
-
-#ifdef LTO_STREAMER_DEBUG
-  tree_htab = new hash_table<tree_entry_hasher> (31);
-#endif
 }
 
 
@@ -314,65 +281,6 @@ gate_lto_out (void)
 	  && !seen_error ());
 }
 
-
-#ifdef LTO_STREAMER_DEBUG
-/* Add a mapping between T and ORIG_T, which is the numeric value of
-   the original address of T as it was seen by the LTO writer.  This
-   mapping is useful when debugging streaming problems.  A debugging
-   session can be started on both reader and writer using ORIG_T
-   as a breakpoint value in both sessions.
-
-   Note that this mapping is transient and only valid while T is
-   being reconstructed.  Once T is fully built, the mapping is
-   removed.  */
-
-void
-lto_orig_address_map (tree t, intptr_t orig_t)
-{
-  struct tree_hash_entry ent;
-  struct tree_hash_entry **slot;
-
-  ent.key = t;
-  ent.value = orig_t;
-  slot = tree_htab->find_slot (&ent, INSERT);
-  gcc_assert (!*slot);
-  *slot = XNEW (struct tree_hash_entry);
-  **slot = ent;
-}
-
-
-/* Get the original address of T as it was seen by the writer.  This
-   is only valid while T is being reconstructed.  */
-
-intptr_t
-lto_orig_address_get (tree t)
-{
-  struct tree_hash_entry ent;
-  struct tree_hash_entry **slot;
-
-  ent.key = t;
-  slot = tree_htab->find_slot (&ent, NO_INSERT);
-  return (slot ? (*slot)->value : 0);
-}
-
-
-/* Clear the mapping of T to its original address.  */
-
-void
-lto_orig_address_remove (tree t)
-{
-  struct tree_hash_entry ent;
-  struct tree_hash_entry **slot;
-
-  ent.key = t;
-  slot = tree_htab->find_slot (&ent, NO_INSERT);
-  gcc_assert (slot);
-  free (*slot);
-  tree_htab->clear_slot (slot);
-}
-#endif
-
-
 /* Check that the version MAJOR.MINOR is the correct version number.  */
 
 void
diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h
index 854bcd2d75e..9ab3007a9df 100644
--- a/gcc/lto-streamer.h
+++ b/gcc/lto-streamer.h
@@ -27,14 +27,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "gcov-io.h"
 #include "diagnostic.h"
 
-/* Define when debugging the LTO streamer.  This causes the writer
-   to output the numeric value for the memory address of the tree node
-   being emitted.  When debugging a problem in the reader, check the
-   original address that the writer was emitting using lto_orig_address_get.
-   With this value, set a breakpoint in the writer (e.g., lto_output_tree)
-   to trace how the faulty node is being emitted.  */
-/* #define LTO_STREAMER_DEBUG	1  */
-
 /* The encoding for a function consists of the following sections:
 
    1)    The header.
@@ -836,11 +828,6 @@ extern char *lto_get_section_name (int, const char *, struct lto_file_decl_data
 extern void print_lto_report (const char *);
 extern void lto_streamer_init (void);
 extern bool gate_lto_out (void);
-#ifdef LTO_STREAMER_DEBUG
-extern void lto_orig_address_map (tree, intptr_t);
-extern intptr_t lto_orig_address_get (tree);
-extern void lto_orig_address_remove (tree);
-#endif
 extern void lto_check_version (int, int, const char *);
 extern void lto_streamer_hooks_init (void);
 
diff --git a/gcc/tree-streamer-in.c b/gcc/tree-streamer-in.c
index f0099c05032..7f7ea7f90ab 100644
--- a/gcc/tree-streamer-in.c
+++ b/gcc/tree-streamer-in.c
@@ -566,20 +566,9 @@ streamer_alloc_tree (struct lto_input_block *ib, struct data_in *data_in,
 {
   enum tree_code code;
   tree result;
-#ifdef LTO_STREAMER_DEBUG
-  HOST_WIDE_INT orig_address_in_writer;
-#endif
 
   result = NULL_TREE;
 
-#ifdef LTO_STREAMER_DEBUG
-  /* Read the word representing the memory address for the tree
-     as it was written by the writer.  This is useful when
-     debugging differences between the writer and reader.  */
-  orig_address_in_writer = streamer_read_hwi (ib);
-  gcc_assert ((intptr_t) orig_address_in_writer == orig_address_in_writer);
-#endif
-
   code = lto_tag_to_tree_code (tag);
 
   /* We should never see an SSA_NAME tree.  Only the version numbers of
@@ -630,15 +619,6 @@ streamer_alloc_tree (struct lto_input_block *ib, struct data_in *data_in,
       result = make_node (code);
     }
 
-#ifdef LTO_STREAMER_DEBUG
-  /* Store the original address of the tree as seen by the writer
-     in RESULT's aux field.  This is useful when debugging streaming
-     problems.  This way, a debugging session can be started on
-     both writer and reader with a breakpoint using this address
-     value in both.  */
-  lto_orig_address_map (result, (intptr_t) orig_address_in_writer);
-#endif
-
   return result;
 }
 
diff --git a/gcc/tree-streamer-out.c b/gcc/tree-streamer-out.c
index 5cf90449341..05239fb7c25 100644
--- a/gcc/tree-streamer-out.c
+++ b/gcc/tree-streamer-out.c
@@ -952,16 +952,6 @@ streamer_write_tree_header (struct output_block *ob, tree expr)
   tag = lto_tree_code_to_tag (code);
   streamer_write_record_start (ob, tag);
 
-  /* The following will cause bootstrap miscomparisons.  Enable with care.  */
-#ifdef LTO_STREAMER_DEBUG
-  /* This is used mainly for debugging purposes.  When the reader
-     and the writer do not agree on a streamed node, the pointer
-     value for EXPR can be used to track down the differences in
-     the debugger.  */
-  gcc_assert ((HOST_WIDE_INT) (intptr_t) expr == (intptr_t) expr);
-  streamer_write_hwi (ob, (HOST_WIDE_INT) (intptr_t) expr);
-#endif
-
   /* The text in strings and identifiers are completely emitted in
      the header.  */
   if (CODE_CONTAINS_STRUCT (code, TS_STRING))
-- 
2.12.2

