Patchwork [committed] Fix ipa local noreturn discovery (PR tree-optimization/46233)

login
register
mail settings
Submitter Jakub Jelinek
Date Nov. 4, 2010, 6:49 p.m.
Message ID <20101104184907.GY29412@tyan-ft48-01.lab.bos.redhat.com>
Download mbox | patch
Permalink /patch/70156/
State New
Headers show

Comments

Jakub Jelinek - Nov. 4, 2010, 6:49 p.m.
Hi!

analyze_function in ipa-pure-const.c calls loop_optimizer_finalize
which in turn calls verify_flow_info.  When we do NORETURN discovery before
analyze_function, if the current function recurses to itself the cfg is
invalid and thus ICEs during verification.  While we could
fixup_noreturn_call in that case, I don't think doing it before
analyze_function buys us much, unless we also perform a cfg cleanup, because
otherwise, while bbs will be properly split after noreturn calls, the
following bbs will not be removed and so will still affect const/pure
discovery.

Fixed thusly, approved by Richard in the PR, committed to trunk after
bootstrapping/regtesting on x86_64-linux and i686-linux.

2010-11-04  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/46233
	* ipa-pure-const.c (local_pure_const): Do noreturn discovery
	after calling analyze_function, not before.

	* gcc.dg/pr46233.c: New test.


	Jakub

Patch

--- gcc/ipa-pure-const.c.jj	2010-11-01 09:07:22.000000000 +0100
+++ gcc/ipa-pure-const.c	2010-11-04 11:14:17.000000000 +0100
@@ -1571,7 +1571,9 @@  local_pure_const (void)
       && skip)
     return 0;
 
-  /* First do NORETURN discovery.  */
+  l = analyze_function (node, false);
+
+  /* Do NORETURN discovery.  */
   if (!skip && !TREE_THIS_VOLATILE (current_function_decl)
       && EDGE_COUNT (EXIT_BLOCK_PTR->preds) == 0)
     {
@@ -1587,7 +1589,6 @@  local_pure_const (void)
 
       changed = true;
     }
-  l = analyze_function (node, false);
 
   switch (l->pure_const_state)
     {
--- gcc/testsuite/gcc.dg/pr46233.c.jj	2010-11-04 11:05:05.000000000 +0100
+++ gcc/testsuite/gcc.dg/pr46233.c	2010-11-04 11:04:09.000000000 +0100
@@ -0,0 +1,11 @@ 
+/* PR tree-optimization/46233 */
+/* { dg-do compile } */
+/* { dg-options "-O -fno-tree-dce" } */
+
+int
+foo ()
+{
+  int i = 0;
+  while (1)
+    i += foo ();
+}