From bd015d378330fc78f85d28ed8c094837e23baca8 Mon Sep 17 00:00:00 2001
From: Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
Date: Sat, 24 Feb 2001 13:15:55 +0000
Subject: [PATCH] tree.h (BLOCK_DEAD): New macro.

	* tree.h (BLOCK_DEAD): New macro.
	(struct tree_block): New flag, dead_flag.
	* print-tree.c (print_node, case 'b'): Print missing fields.
	* emit-rtl.c (remove_unnecessary_notes): Set BLOCK_DEAD.
	* function.c (identify_blocks): Enable test for misplaced notes.
	(all_blocks): Skip BLOCK_DEAD blocks.
	* integrate.c (integrate_decl_tree): Likewise.

From-SVN: r40039
---
 gcc/ChangeLog    |  8 ++++++++
 gcc/emit-rtl.c   |  1 +
 gcc/function.c   | 32 ++++++++++++++++----------------
 gcc/integrate.c  | 11 ++++++-----
 gcc/print-tree.c |  8 ++++++++
 gcc/tree.h       |  7 ++++++-
 6 files changed, 45 insertions(+), 22 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index eb5f49f294c..00ce4bd4348 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,13 @@
 Sat Feb 24 06:45:21 2001  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
 
+	* tree.h (BLOCK_DEAD): New macro.
+	(struct tree_block): New flag, dead_flag.
+	* print-tree.c (print_node, case 'b'): Print missing fields.
+	* emit-rtl.c (remove_unnecessary_notes): Set BLOCK_DEAD.
+	* function.c (identify_blocks): Enable test for misplaced notes.
+	(all_blocks): Skip BLOCK_DEAD blocks.
+	* integrate.c (integrate_decl_tree): Likewise.
+
 	* errors.c (internal_error, trim_filename): New functions.
 	(fancy_abort): Call internal_error.
 	* errors.h (internal_error, trim_filename): New declarations.
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index 96fea2ccf27..a7a9115325d 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -2881,6 +2881,7 @@ remove_unnecessary_notes ()
 
 		  if (debug_ignore_block (NOTE_BLOCK (insn)))
 		    {
+		      BLOCK_DEAD (NOTE_BLOCK (insn)) = 1;
 		      remove_insn (prev);
 		      remove_insn (insn);
 		    }
diff --git a/gcc/function.c b/gcc/function.c
index a1c2d3389d0..58f3f6d374d 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -5740,8 +5740,7 @@ identify_blocks ()
 					 block_stack);
 
   /* If we didn't use all of the subblocks, we've misplaced block notes.  */
-  /* ??? This appears to happen all the time.  Latent bugs elsewhere?  */
-  if (0 && last_block_vector != block_vector + n_blocks)
+  if (last_block_vector != block_vector + n_blocks)
     abort ();
 
   free (block_vector);
@@ -5947,27 +5946,28 @@ blocks_nreverse (t)
    blocks.  */
 
 static int
-all_blocks (block, vector)
-     tree block;
+all_blocks (blocks, vector)
+     tree blocks;
      tree *vector;
 {
   int n_blocks = 0;
+  tree block;
 
-  while (block)
-    {
-      TREE_ASM_WRITTEN (block) = 0;
+  for (block = blocks; block != 0; block = TREE_CHAIN (block))
+    if (!BLOCK_DEAD (block))
+      {
+	TREE_ASM_WRITTEN (block) = 0;
 
-      /* Record this block.  */
-      if (vector)
-	vector[n_blocks] = block;
+	/* Record this block.  */
+	if (vector)
+	  vector[n_blocks] = block;
 
-      ++n_blocks;
+	++n_blocks;
 
-      /* Record the subblocks, and their subblocks...  */
-      n_blocks += all_blocks (BLOCK_SUBBLOCKS (block),
-			      vector ? vector + n_blocks : 0);
-      block = BLOCK_CHAIN (block);
-    }
+	/* Record the subblocks, and their subblocks...  */
+	n_blocks += all_blocks (BLOCK_SUBBLOCKS (block),
+				vector ? vector + n_blocks : 0);
+      }
 
   return n_blocks;
 }
diff --git a/gcc/integrate.c b/gcc/integrate.c
index 270a9c5a115..23f3590b4f3 100644
--- a/gcc/integrate.c
+++ b/gcc/integrate.c
@@ -1684,11 +1684,12 @@ integrate_decl_tree (let, map)
 
   next = &BLOCK_SUBBLOCKS (new_block);
   for (t = BLOCK_SUBBLOCKS (let); t; t = BLOCK_CHAIN (t))
-    {
-      *next = integrate_decl_tree (t, map);
-      BLOCK_SUPERCONTEXT (*next) = new_block;
-      next = &BLOCK_CHAIN (*next);
-    }
+    if (!BLOCK_DEAD (t))
+      {
+	*next = integrate_decl_tree (t, map);
+	BLOCK_SUPERCONTEXT (*next) = new_block;
+	next = &BLOCK_CHAIN (*next);
+      }
 
   TREE_USED (new_block) = TREE_USED (let);
   BLOCK_ABSTRACT_ORIGIN (new_block) = let;
diff --git a/gcc/print-tree.c b/gcc/print-tree.c
index 3bbea3f52f0..7e49ee0f949 100644
--- a/gcc/print-tree.c
+++ b/gcc/print-tree.c
@@ -584,6 +584,14 @@ print_node (file, prefix, node, indent)
       break;
 
     case 'b':
+      if (BLOCK_ABSTRACT (node))
+	fprintf (file, " abstract");
+      if (BLOCK_HANDLER_BLOCK (node))
+	fprintf (file, " handler-block");
+      if (BLOCK_DEAD (node))
+	fprintf (file, " dead");
+      fprintf (file, " block-number %d", BLOCK_NUMBER (node));
+
       print_node (file, "vars", BLOCK_VARS (node), indent + 4);
       print_node (file, "supercontext", BLOCK_SUPERCONTEXT (node), indent + 4);
       print_node (file, "subblocks", BLOCK_SUBBLOCKS (node), indent + 4);
diff --git a/gcc/tree.h b/gcc/tree.h
index 3d2e38416f1..45252ddc561 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -829,6 +829,10 @@ struct tree_exp
    listed in the BLOCK_VARS slot.  */
 #define BLOCK_HANDLER_BLOCK(NODE) (BLOCK_CHECK (NODE)->block.handler_block_flag)
 
+/* Nonzero means the block was deleted as dead and should not be copied
+   when a function is inlined.  */
+#define BLOCK_DEAD(NODE) (BLOCK_CHECK (NODE)->block.dead_flag)
+
 /* An index number for this block.  These values are not guaranteed to
    be unique across functions -- whether or not they are depends on
    the debugging output format in use.  */
@@ -840,7 +844,8 @@ struct tree_block
 
   unsigned handler_block_flag : 1;
   unsigned abstract_flag : 1;
-  unsigned block_num : 30;
+  unsigned dead_flag : 1;
+  unsigned block_num : 29;
 
   union tree_node *vars;
   union tree_node *subblocks;
-- 
2.30.2