diff mbox

Fix PR 44915 - ensure indirect inlining is never run at -O0

Message ID 20100723125734.GB28683@virgil.arch.suse.de
State New
Headers show

Commit Message

Martin Jambor July 23, 2010, 12:57 p.m. UTC
H,

this is a quick workaround for PR 44915.  The problem is that if user
specifically requests indirect inlining at the command line when not
optimizing, we segfault because virtual operands are not there when we
expect them.

I understand that a proper fix would be to disable IPA passes at -O0
but at the moment I feel I should work on more serious problems
instead.

Bootstrapped and tested on x86_64-linux.  OK for trunk?

Thanks,

Martin


2010-07-23  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/44915
	* ipa-cp.c (cgraph_gate_cp): Also check that optimize is true.
	* ipa-inline.c (cgraph_mark_inline_edge): Likewise.
	(analyze_function): Likewise.

	* testsuite/g++.dg/torture/pr44915.C: New test.

Comments

Richard Biener July 23, 2010, 12:59 p.m. UTC | #1
On Fri, Jul 23, 2010 at 2:57 PM, Martin Jambor <mjambor@suse.cz> wrote:
> H,
>
> this is a quick workaround for PR 44915.  The problem is that if user
> specifically requests indirect inlining at the command line when not
> optimizing, we segfault because virtual operands are not there when we
> expect them.
>
> I understand that a proper fix would be to disable IPA passes at -O0
> but at the moment I feel I should work on more serious problems
> instead.
>
> Bootstrapped and tested on x86_64-linux.  OK for trunk?

Ok.

Thanks,
Richard.

> Thanks,
>
> Martin
>
>
> 2010-07-23  Martin Jambor  <mjambor@suse.cz>
>
>        PR tree-optimization/44915
>        * ipa-cp.c (cgraph_gate_cp): Also check that optimize is true.
>        * ipa-inline.c (cgraph_mark_inline_edge): Likewise.
>        (analyze_function): Likewise.
>
>        * testsuite/g++.dg/torture/pr44915.C: New test.
>
> Index: icln/gcc/ipa-cp.c
> ===================================================================
> --- icln.orig/gcc/ipa-cp.c
> +++ icln/gcc/ipa-cp.c
> @@ -1278,7 +1278,9 @@ ipcp_read_summary (void)
>  static bool
>  cgraph_gate_cp (void)
>  {
> -  return flag_ipa_cp;
> +  /* FIXME: We should remove the optimize check after we ensure we never run
> +     IPA passes when not optimizng.  */
> +  return flag_ipa_cp && optimize;
>  }
>
>  struct ipa_opt_pass_d pass_ipa_cp =
> Index: icln/gcc/ipa-inline.c
> ===================================================================
> --- icln.orig/gcc/ipa-inline.c
> +++ icln/gcc/ipa-inline.c
> @@ -334,7 +334,9 @@ cgraph_mark_inline_edge (struct cgraph_e
>     overall_size += new_size - old_size;
>   ncalls_inlined++;
>
> -  if (flag_indirect_inlining)
> +  /* FIXME: We should remove the optimize check after we ensure we never run
> +     IPA passes when not optimizng.  */
> +  if (flag_indirect_inlining && optimize)
>     return ipa_propagate_indirect_call_infos (curr, new_edges);
>   else
>     return false;
> @@ -2085,7 +2087,9 @@ analyze_function (struct cgraph_node *no
>   current_function_decl = node->decl;
>
>   compute_inline_parameters (node);
> -  if (flag_indirect_inlining)
> +  /* FIXME: We should remove the optimize check after we ensure we never run
> +     IPA passes when not optimizng.  */
> +  if (flag_indirect_inlining && optimize)
>     inline_indirect_intraprocedural_analysis (node);
>
>   current_function_decl = NULL;
> Index: icln/gcc/testsuite/g++.dg/torture/pr44915.C
> ===================================================================
> --- /dev/null
> +++ icln/gcc/testsuite/g++.dg/torture/pr44915.C
> @@ -0,0 +1,13 @@
> +/* { dg-do compile }  */
> +/* { dg-options "-findirect-inlining" } */
> +
> +struct A;
> +
> +typedef void (A::*f_ptr) ();
> +
> +void dummy (f_ptr) { }
> +
> +void call_dummy (f_ptr cb)
> +{
> +  dummy (cb);
> +}
>
diff mbox

Patch

Index: icln/gcc/ipa-cp.c
===================================================================
--- icln.orig/gcc/ipa-cp.c
+++ icln/gcc/ipa-cp.c
@@ -1278,7 +1278,9 @@  ipcp_read_summary (void)
 static bool
 cgraph_gate_cp (void)
 {
-  return flag_ipa_cp;
+  /* FIXME: We should remove the optimize check after we ensure we never run
+     IPA passes when not optimizng.  */
+  return flag_ipa_cp && optimize;
 }
 
 struct ipa_opt_pass_d pass_ipa_cp =
Index: icln/gcc/ipa-inline.c
===================================================================
--- icln.orig/gcc/ipa-inline.c
+++ icln/gcc/ipa-inline.c
@@ -334,7 +334,9 @@  cgraph_mark_inline_edge (struct cgraph_e
     overall_size += new_size - old_size;
   ncalls_inlined++;
 
-  if (flag_indirect_inlining)
+  /* FIXME: We should remove the optimize check after we ensure we never run
+     IPA passes when not optimizng.  */
+  if (flag_indirect_inlining && optimize)
     return ipa_propagate_indirect_call_infos (curr, new_edges);
   else
     return false;
@@ -2085,7 +2087,9 @@  analyze_function (struct cgraph_node *no
   current_function_decl = node->decl;
 
   compute_inline_parameters (node);
-  if (flag_indirect_inlining)
+  /* FIXME: We should remove the optimize check after we ensure we never run
+     IPA passes when not optimizng.  */
+  if (flag_indirect_inlining && optimize)
     inline_indirect_intraprocedural_analysis (node);
 
   current_function_decl = NULL;
Index: icln/gcc/testsuite/g++.dg/torture/pr44915.C
===================================================================
--- /dev/null
+++ icln/gcc/testsuite/g++.dg/torture/pr44915.C
@@ -0,0 +1,13 @@ 
+/* { dg-do compile }  */
+/* { dg-options "-findirect-inlining" } */
+
+struct A;
+
+typedef void (A::*f_ptr) ();
+
+void dummy (f_ptr) { }
+
+void call_dummy (f_ptr cb)
+{
+  dummy (cb);
+}