re PR middle-end/28071 (A file that can not be compiled in reasonable time/space)
authorJan Hubicka <jh@suse.cz>
Mon, 24 Jul 2006 11:27:53 +0000 (13:27 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Mon, 24 Jul 2006 11:27:53 +0000 (11:27 +0000)
PR rtl-optimization/28071
* tree-cfg.c (tree_split_block): Do not allocate new stmt_list nodes.
* tree-iterator.c (tsi_split_statement_list_before): Do not crash when
splitting before first stmt.

From-SVN: r115713

gcc/ChangeLog
gcc/tree-cfg.c
gcc/tree-iterator.c

index 2151f0a6c37c000ee04f2e8d4bbbd77b38210952..b03da442bc809a1b7aadd4a6084f3b5b4b33c255 100644 (file)
@@ -1,3 +1,10 @@
+2006-07-24  Jan Hubicka  <jh@suse.cz>
+
+       PR rtl-optimization/28071
+       * tree-cfg.c (tree_split_block): Do not allocate new stmt_list nodes.
+       * tree-iterator.c (tsi_split_statement_list_before): Do not crash when
+       splitting before first stmt.
+
 2006-07-24  Jan Hubicka  <jh@suse.cz>
 
        PR rtl-optimization/28071
index 82adabda06313dec2b777796670919794ea0947d..ced78077047469d912da02f14ac3ff63cf2d002d 100644 (file)
@@ -4158,7 +4158,8 @@ tree_redirect_edge_and_branch_force (edge e, basic_block dest)
 static basic_block
 tree_split_block (basic_block bb, void *stmt)
 {
-  block_stmt_iterator bsi, bsi_tgt;
+  block_stmt_iterator bsi;
+  tree_stmt_iterator tsi_tgt;
   tree act;
   basic_block new_bb;
   edge e;
@@ -4192,13 +4193,17 @@ tree_split_block (basic_block bb, void *stmt)
        }
     }
 
-  bsi_tgt = bsi_start (new_bb);
-  while (!bsi_end_p (bsi))
-    {
-      act = bsi_stmt (bsi);
-      bsi_remove (&bsi, false);
-      bsi_insert_after (&bsi_tgt, act, BSI_NEW_STMT);
-    }
+  if (bsi_end_p (bsi))
+    return new_bb;
+
+  /* Split the statement list - avoid re-creating new containers as this
+     brings ugly quadratic memory consumption in the inliner.  
+     (We are still quadratic since we need to update stmt BB pointers,
+     sadly.)  */
+  new_bb->stmt_list = tsi_split_statement_list_before (&bsi.tsi);
+  for (tsi_tgt = tsi_start (new_bb->stmt_list);
+       !tsi_end_p (tsi_tgt); tsi_next (&tsi_tgt))
+    set_bb_for_stmt (tsi_stmt (tsi_tgt), new_bb);
 
   return new_bb;
 }
index ad2b47ea8cd4d8c8a7999a75a7b7b244b3ab3d9f..77e2345e4c23db5c0f17158d28c2cd8f27af0f15 100644 (file)
@@ -289,7 +289,8 @@ tsi_split_statement_list_before (tree_stmt_iterator *i)
   STATEMENT_LIST_TAIL (new_sl) = STATEMENT_LIST_TAIL (old_sl);
   STATEMENT_LIST_TAIL (old_sl) = prev;
   cur->prev = NULL;
-  prev->next = NULL;
+  if (prev)
+    prev->next = NULL;
 
   return new_sl;
 }