public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, PR 48195] Move around ipa_check_create_node_params and ipa_check_create_edge_args
@ 2011-03-29 11:52 Martin Jambor
  2011-04-11 10:34 ` Jan Hubicka
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Jambor @ 2011-03-29 11:52 UTC (permalink / raw)
  To: GCC Patches; +Cc: Jan Hubicka

Hi,

PR 48195 happens because analyze_node in ipa-inline can be called from
add_new_function hook and thus bypass calls for
ipa_check_create_node_params and ipa_check_create_edge_args in
inline_generate_summary.  The two functions are required to reallocate
info arrays if necessary before calling ipa_analyze_node.

This revealed the whole setup is rather fragile so I moved the
reallocation functions directly to ipa_analyze_node.  This means the
node count is checked each time we analyze a node but the overhead
should be tiny and we'll avoid issues like this.

The other caller of ipa_analyze_node is ipa-cp so I removed the now
unnecessary calls in ipcp_generate_summary too.  This in turn revealed
that ipcp_driver lacks these calls (which has always been basically a
hidden bug ever since we made ipa-cp a proper IPA pass) so I added it
there.

Bootstrapped and tested on x86_64-linux on both trunk and 4.6 branch
without any issues.  OK for both?

Thanks,

Martin


Index: src/gcc/ipa-cp.c
===================================================================
--- src.orig/gcc/ipa-cp.c
+++ src/gcc/ipa-cp.c
@@ -1516,6 +1516,8 @@ ipcp_driver (void)
         ipa_print_all_params (dump_file);
       ipa_print_all_jump_functions (dump_file);
     }
+  ipa_check_create_node_params ();
+  ipa_check_create_edge_args ();
   /* 2. Do the interprocedural propagation.  */
   ipcp_iterate_stage ();
   /* 3. Insert the constants found to the functions.  */
@@ -1543,8 +1545,6 @@ ipcp_generate_summary (void)
 
   if (dump_file)
     fprintf (dump_file, "\nIPA constant propagation start:\n");
-  ipa_check_create_node_params ();
-  ipa_check_create_edge_args ();
   ipa_register_cgraph_hooks ();
 
   for (node = cgraph_nodes; node; node = node->next)
Index: src/gcc/ipa-inline.c
===================================================================
--- src.orig/gcc/ipa-inline.c
+++ src/gcc/ipa-inline.c
@@ -2091,11 +2091,7 @@ inline_generate_summary (void)
       cgraph_add_function_insertion_hook (&add_new_function, NULL);
 
   if (flag_indirect_inlining)
-    {
-      ipa_register_cgraph_hooks ();
-      ipa_check_create_node_params ();
-      ipa_check_create_edge_args ();
-    }
+    ipa_register_cgraph_hooks ();
 
   for (node = cgraph_nodes; node; node = node->next)
     if (node->analyzed)
Index: src/gcc/ipa-prop.c
===================================================================
--- src.orig/gcc/ipa-prop.c
+++ src/gcc/ipa-prop.c
@@ -1522,10 +1522,13 @@ ipa_analyze_params_uses (struct cgraph_n
 void
 ipa_analyze_node (struct cgraph_node *node)
 {
-  struct ipa_node_params *info = IPA_NODE_REF (node);
+  struct ipa_node_params *info;
   struct param_analysis_info *parms_info;
   int i, param_count;
 
+  ipa_check_create_node_params ();
+  ipa_check_create_edge_args ();
+  info = IPA_NODE_REF (node);
   push_cfun (DECL_STRUCT_FUNCTION (node->decl));
   current_function_decl = node->decl;
   ipa_initialize_node_params (node);
Index: src/gcc/testsuite/gcc.dg/ipa/pr48195.c
===================================================================
--- /dev/null
+++ src/gcc/testsuite/gcc.dg/ipa/pr48195.c
@@ -0,0 +1,24 @@
+/* { dg-do link } */
+/* { dg-options "-O2 -flto --param partial-inlining-entry-probability=101" } */
+
+extern void abort(void);
+
+int i;
+
+void __attribute__ ((constructor))
+c2 ()
+{
+  if (i)
+    abort ();
+}
+
+void __attribute__ ((destructor))
+d1 ()
+{
+  if (i)
+    abort ();
+}
+
+void main ()
+{
+}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH, PR 48195] Move around ipa_check_create_node_params and ipa_check_create_edge_args
  2011-03-29 11:52 [PATCH, PR 48195] Move around ipa_check_create_node_params and ipa_check_create_edge_args Martin Jambor
@ 2011-04-11 10:34 ` Jan Hubicka
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Hubicka @ 2011-04-11 10:34 UTC (permalink / raw)
  To: GCC Patches, Jan Hubicka

> Bootstrapped and tested on x86_64-linux on both trunk and 4.6 branch
> without any issues.  OK for both?

OK, please add changelog ;)
I always wondered why we do the resizing in such a convoluted way.

Honza
> 
> Thanks,
> 
> Martin
> 
> 
> Index: src/gcc/ipa-cp.c
> ===================================================================
> --- src.orig/gcc/ipa-cp.c
> +++ src/gcc/ipa-cp.c
> @@ -1516,6 +1516,8 @@ ipcp_driver (void)
>          ipa_print_all_params (dump_file);
>        ipa_print_all_jump_functions (dump_file);
>      }
> +  ipa_check_create_node_params ();
> +  ipa_check_create_edge_args ();
>    /* 2. Do the interprocedural propagation.  */
>    ipcp_iterate_stage ();
>    /* 3. Insert the constants found to the functions.  */
> @@ -1543,8 +1545,6 @@ ipcp_generate_summary (void)
>  
>    if (dump_file)
>      fprintf (dump_file, "\nIPA constant propagation start:\n");
> -  ipa_check_create_node_params ();
> -  ipa_check_create_edge_args ();
>    ipa_register_cgraph_hooks ();
>  
>    for (node = cgraph_nodes; node; node = node->next)
> Index: src/gcc/ipa-inline.c
> ===================================================================
> --- src.orig/gcc/ipa-inline.c
> +++ src/gcc/ipa-inline.c
> @@ -2091,11 +2091,7 @@ inline_generate_summary (void)
>        cgraph_add_function_insertion_hook (&add_new_function, NULL);
>  
>    if (flag_indirect_inlining)
> -    {
> -      ipa_register_cgraph_hooks ();
> -      ipa_check_create_node_params ();
> -      ipa_check_create_edge_args ();
> -    }
> +    ipa_register_cgraph_hooks ();
>  
>    for (node = cgraph_nodes; node; node = node->next)
>      if (node->analyzed)
> Index: src/gcc/ipa-prop.c
> ===================================================================
> --- src.orig/gcc/ipa-prop.c
> +++ src/gcc/ipa-prop.c
> @@ -1522,10 +1522,13 @@ ipa_analyze_params_uses (struct cgraph_n
>  void
>  ipa_analyze_node (struct cgraph_node *node)
>  {
> -  struct ipa_node_params *info = IPA_NODE_REF (node);
> +  struct ipa_node_params *info;
>    struct param_analysis_info *parms_info;
>    int i, param_count;
>  
> +  ipa_check_create_node_params ();
> +  ipa_check_create_edge_args ();
> +  info = IPA_NODE_REF (node);
>    push_cfun (DECL_STRUCT_FUNCTION (node->decl));
>    current_function_decl = node->decl;
>    ipa_initialize_node_params (node);
> Index: src/gcc/testsuite/gcc.dg/ipa/pr48195.c
> ===================================================================
> --- /dev/null
> +++ src/gcc/testsuite/gcc.dg/ipa/pr48195.c
> @@ -0,0 +1,24 @@
> +/* { dg-do link } */
> +/* { dg-options "-O2 -flto --param partial-inlining-entry-probability=101" } */
> +
> +extern void abort(void);
> +
> +int i;
> +
> +void __attribute__ ((constructor))
> +c2 ()
> +{
> +  if (i)
> +    abort ();
> +}
> +
> +void __attribute__ ((destructor))
> +d1 ()
> +{
> +  if (i)
> +    abort ();
> +}
> +
> +void main ()
> +{
> +}

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-04-11 10:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-29 11:52 [PATCH, PR 48195] Move around ipa_check_create_node_params and ipa_check_create_edge_args Martin Jambor
2011-04-11 10:34 ` Jan Hubicka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).