From 2a3e49aaaafabed2113c746c6363d6250de418a2 Mon Sep 17 00:00:00 2001
From: rakdver <rakdver@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Sun, 4 Feb 2007 23:51:28 +0000
Subject: [PATCH] 	* cfgcleanup.c (try_optimize_cfg): Avoid removing
 ENTRY_BLOCK_PTR.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@121584 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog    | 6 +++++-
 gcc/cfgcleanup.c | 6 ++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index acb109e29ede..f458ac7b176f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,7 @@
+2007-02-04  Zdenek Dvorak <dvorakz@suse.cz>
+
+	* cfgcleanup.c (try_optimize_cfg): Avoid removing ENTRY_BLOCK_PTR.
+
 2007-02-04  Zdenek Dvorak <dvorakz@suse.cz>
 
 	* cfgloopmanip.c (loop_delete_branch_edge): Removed.
@@ -43,7 +47,7 @@
 	* passes.c (init_optimization_passes): Reindent.
 
 2007-02-04  Jan Hubicka  <jh@suse.cz>
-            Eric Botcazou  <ebotcazou@adacore.com>
+	    Eric Botcazou  <ebotcazou@adacore.com>
 
 	* tree-optimize.c (has_abnormal_outgoing_edge_p): Move to...
 	(execute_fixup_cfg): Break out the abnormal goto code.
diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c
index 7c5b745a6506..ee5c69bd2e6a 100644
--- a/gcc/cfgcleanup.c
+++ b/gcc/cfgcleanup.c
@@ -1992,7 +1992,7 @@ try_optimize_cfg (int mode)
 	      bool changed_here = false;
 
 	      /* Delete trivially dead basic blocks.  */
-	      while (EDGE_COUNT (b->preds) == 0)
+	      if (EDGE_COUNT (b->preds) == 0)
 		{
 		  c = b->prev_bb;
 		  if (dump_file)
@@ -2002,7 +2002,9 @@ try_optimize_cfg (int mode)
 		  delete_basic_block (b);
 		  if (!(mode & CLEANUP_CFGLAYOUT))
 		    changed = true;
-		  b = c;
+		  /* Avoid trying to remove ENTRY_BLOCK_PTR.  */
+		  b = (c == ENTRY_BLOCK_PTR ? c->next_bb : c);
+		  continue;
 		}
 
 	      /* Remove code labels no longer used.  */
-- 
GitLab