This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix -fdump-ipa-all -dv (PR middle-end/37858)


Hi!

ipa and simple ipa passes don't have cfun set, as they operate on whole
cgraph.  execute_one_pass even asserts that early:
  /* IPA passes are executed on whole program, so cfun should be NULL.
     Other passes need function context set.  */
  if (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS)
    gcc_assert (!cfun && !current_function_decl);
  else
    gcc_assert (cfun && current_function_decl);
Most of the places in execute_one_pass check cfun != NULL before
dereferencing it, one place tests again
pass->type != SIMPLE_IPA_PASS && pass->type != IPA_PASS
and one place below, which ICEs during -fdump-ipa-all -dv, fails
to do this check.  Given that most places just test cfun
and it is tiny bit cheaper test, I've committed following fix
as obvious to trunk.

2008-11-03  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/37858
	* passes.c (execute_one_pass): Don't look at cfun->curr_properties
	for ipa and simple ipa passes.

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

--- gcc/passes.c.jj	2008-10-23 13:21:41.000000000 +0200
+++ gcc/passes.c	2008-11-03 09:25:35.000000000 +0100
@@ -1289,6 +1289,7 @@ execute_one_pass (struct opt_pass *pass)
   if (initializing_dump
       && dump_file
       && graph_dump_format != no_graph
+      && cfun
       && (cfun->curr_properties & (PROP_cfg | PROP_rtl))
 	  == (PROP_cfg | PROP_rtl))
     {
--- gcc/testsuite/gcc.dg/pr37858.c.jj	2008-11-03 09:28:27.000000000 +0100
+++ gcc/testsuite/gcc.dg/pr37858.c	2008-11-03 09:29:12.000000000 +0100
@@ -0,0 +1,11 @@
+/* PR middle-end/37858 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-early_local_cleanups -dv" } */
+
+int
+main (void)
+{
+  return 0;
+}
+
+/* { dg-final { cleanup-ipa-dump "early_local_cleanups" } } */

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]