[RFC PATCH, LTO] Linked list of stmt uids->stmts fixup hooks

View: New views
6 Messages — Rating Filter:   Alert me  

[RFC PATCH, LTO] Linked list of stmt uids->stmts fixup hooks

by Martin Jambor-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

while working on streaming of indirect inlinining information I
need to turn gimple stmt uids into gimple statements in the same way
this is done for call graph edges.  

I can either call a function in ipa-prop.c doing this directly from
input_function() in lto-streamer-in.c or add some generic simplisitc
infrastructure like what is in the patch below.  I simply added a
linked list of hooks that I envision will consist of static
structures, one per running IPA pass that needs this.

Alternatively, running fixup_call_stmt_edges() after IPA decisions are
made (and inlining decisions in particular).  So far I assumed it was
called before in non-wpa mode on purpose.

The patch is untested.  What do you think about this approach?

Thanks,

Martin

2009-11-03  Martin Jambor  <mjambor@...>

        * lto-streamer.h (struct lto_stmt_fixup_hook_list_element): New type.
        (lto_stmt_fixup_hook_list) Declare.

        * lto-streamer-in.c (input_function): Call all stmt fixup hooks in
        lto_stmt_fixup_hook_list.
        (lto_stmt_fixup_hook_list) New variable.

Index: icln/gcc/lto-streamer-in.c
===================================================================
--- icln.orig/gcc/lto-streamer-in.c
+++ icln/gcc/lto-streamer-in.c
@@ -59,6 +59,9 @@ struct string_slot
 /* The table to hold the file names.  */
 static htab_t file_name_hash_table;
 
+/* Linked list of pointers to stmt uids -> stmts fixup functions.  */
+struct lto_stmt_fixup_hook_list_element *lto_stmt_fixup_hook_list;
+
 
 /* Check that tag ACTUAL has one of the given values.  NUM_TAGS is the
    number of valid tag values to check.  */
@@ -1261,6 +1264,9 @@ input_function (tree fn_decl, struct dat
   gimple *stmts;
   basic_block bb;
   struct bitpack_d *bp;
+  struct cgraph_node *node;
+  struct lto_stmt_fixup_hook_list_element *fixup_hook;
+
 
   fn = DECL_STRUCT_FUNCTION (fn_decl);
   tag = input_record_start (ib);
@@ -1340,7 +1346,12 @@ input_function (tree fn_decl, struct dat
     gimple_set_body (fn_decl, bb_seq (ei_edge (ei)->dest));
   }
 
-  fixup_call_stmt_edges (cgraph_node (fn_decl), stmts);
+  node = cgraph_node (fn_decl);
+  fixup_call_stmt_edges (node, stmts);
+  for (fixup_hook = lto_stmt_fixup_hook_list;
+       fixup_hook;
+       fixup_hook = fixup_hook->next)
+    fixup_hook->hook (node, stmts);
 
   update_ssa (TODO_update_ssa_only_virtuals);
   free_dominance_info (CDI_DOMINATORS);
Index: icln/gcc/lto-streamer.h
===================================================================
--- icln.orig/gcc/lto-streamer.h
+++ icln/gcc/lto-streamer.h
@@ -689,6 +689,13 @@ struct data_in
   struct lto_streamer_cache_d *reader_cache;
 };
 
+/* Add-only linked list of functions that turn gimple statement uids into
+   gimple statements in IPA-pass info.  */
+struct lto_stmt_fixup_hook_list_element
+{
+  void (*hook)(struct cgraph_node *, gimple *);
+  struct lto_stmt_fixup_hook_list_element *next;
+};
 
 /* In lto-section-in.c  */
 extern struct lto_input_block * lto_create_simple_input_block (
@@ -803,6 +810,8 @@ extern void lto_check_version (int, int)
 
 
 /* In lto-streamer-in.c */
+extern struct lto_stmt_fixup_hook_list_element *lto_stmt_fixup_hook_list;
+
 extern void lto_input_cgraph (struct lto_file_decl_data *, const char *);
 extern void lto_init_reader (void);
 extern tree lto_input_tree (struct lto_input_block *, struct data_in *);


Re: [RFC PATCH, LTO] Linked list of stmt uids->stmts fixup hooks

by Richard Guenther-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, 3 Nov 2009, Martin Jambor wrote:

> Hi,
>
> while working on streaming of indirect inlinining information I
> need to turn gimple stmt uids into gimple statements in the same way
> this is done for call graph edges.  
>
> I can either call a function in ipa-prop.c doing this directly from
> input_function() in lto-streamer-in.c or add some generic simplisitc
> infrastructure like what is in the patch below.  I simply added a
> linked list of hooks that I envision will consist of static
> structures, one per running IPA pass that needs this.
>
> Alternatively, running fixup_call_stmt_edges() after IPA decisions are
> made (and inlining decisions in particular).  So far I assumed it was
> called before in non-wpa mode on purpose.
>
> The patch is untested.  What do you think about this approach?

Shouldn't this maybe be a IPA pass lto hook instead?

Richard.

> Thanks,
>
> Martin
>
> 2009-11-03  Martin Jambor  <mjambor@...>
>
> * lto-streamer.h (struct lto_stmt_fixup_hook_list_element): New type.
> (lto_stmt_fixup_hook_list) Declare.
>
> * lto-streamer-in.c (input_function): Call all stmt fixup hooks in
> lto_stmt_fixup_hook_list.
> (lto_stmt_fixup_hook_list) New variable.
>
> Index: icln/gcc/lto-streamer-in.c
> ===================================================================
> --- icln.orig/gcc/lto-streamer-in.c
> +++ icln/gcc/lto-streamer-in.c
> @@ -59,6 +59,9 @@ struct string_slot
>  /* The table to hold the file names.  */
>  static htab_t file_name_hash_table;
>  
> +/* Linked list of pointers to stmt uids -> stmts fixup functions.  */
> +struct lto_stmt_fixup_hook_list_element *lto_stmt_fixup_hook_list;
> +
>  
>  /* Check that tag ACTUAL has one of the given values.  NUM_TAGS is the
>     number of valid tag values to check.  */
> @@ -1261,6 +1264,9 @@ input_function (tree fn_decl, struct dat
>    gimple *stmts;
>    basic_block bb;
>    struct bitpack_d *bp;
> +  struct cgraph_node *node;
> +  struct lto_stmt_fixup_hook_list_element *fixup_hook;
> +
>  
>    fn = DECL_STRUCT_FUNCTION (fn_decl);
>    tag = input_record_start (ib);
> @@ -1340,7 +1346,12 @@ input_function (tree fn_decl, struct dat
>      gimple_set_body (fn_decl, bb_seq (ei_edge (ei)->dest));
>    }
>  
> -  fixup_call_stmt_edges (cgraph_node (fn_decl), stmts);
> +  node = cgraph_node (fn_decl);
> +  fixup_call_stmt_edges (node, stmts);
> +  for (fixup_hook = lto_stmt_fixup_hook_list;
> +       fixup_hook;
> +       fixup_hook = fixup_hook->next)
> +    fixup_hook->hook (node, stmts);
>  
>    update_ssa (TODO_update_ssa_only_virtuals);
>    free_dominance_info (CDI_DOMINATORS);
> Index: icln/gcc/lto-streamer.h
> ===================================================================
> --- icln.orig/gcc/lto-streamer.h
> +++ icln/gcc/lto-streamer.h
> @@ -689,6 +689,13 @@ struct data_in
>    struct lto_streamer_cache_d *reader_cache;
>  };
>  
> +/* Add-only linked list of functions that turn gimple statement uids into
> +   gimple statements in IPA-pass info.  */
> +struct lto_stmt_fixup_hook_list_element
> +{
> +  void (*hook)(struct cgraph_node *, gimple *);
> +  struct lto_stmt_fixup_hook_list_element *next;
> +};
>  
>  /* In lto-section-in.c  */
>  extern struct lto_input_block * lto_create_simple_input_block (
> @@ -803,6 +810,8 @@ extern void lto_check_version (int, int)
>  
>  
>  /* In lto-streamer-in.c */
> +extern struct lto_stmt_fixup_hook_list_element *lto_stmt_fixup_hook_list;
> +
>  extern void lto_input_cgraph (struct lto_file_decl_data *, const char *);
>  extern void lto_init_reader (void);
>  extern tree lto_input_tree (struct lto_input_block *, struct data_in *);
>
>

--
Richard Guenther <rguenther@...>
Novell / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 - GF: Markus Rex

Re: [RFC PATCH, LTO] Linked list of stmt uids->stmts fixup hooks

by Martin Jambor-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

On Wed, Nov 04, 2009 at 10:45:03AM +0100, Richard Guenther wrote:

> On Tue, 3 Nov 2009, Martin Jambor wrote:
>
> > Hi,
> >
> > while working on streaming of indirect inlinining information I
> > need to turn gimple stmt uids into gimple statements in the same way
> > this is done for call graph edges.  
> >
> > I can either call a function in ipa-prop.c doing this directly from
> > input_function() in lto-streamer-in.c or add some generic simplisitc
> > infrastructure like what is in the patch below.  I simply added a
> > linked list of hooks that I envision will consist of static
> > structures, one per running IPA pass that needs this.
> >
> > Alternatively, running fixup_call_stmt_edges() after IPA decisions are
> > made (and inlining decisions in particular).  So far I assumed it was
> > called before in non-wpa mode on purpose.
> >
> > The patch is untested.  What do you think about this approach?
>
> Shouldn't this maybe be a IPA pass lto hook instead?
>

I don't really care.  On one hand, if more IPA-passes need this (or
other fixups which could be bundled together into a big one) it would
certainly make sense.  On the other hand, I have written the first and
for the forseeable future the only user yesterday and even that one
will probably go away in 4.6 because (AFAIK) Honza plans to turn the
param call notes into special cgraph edges (with an unknown callee)
connected to the cgraph node directly.  That is a good idea as it will
enable us to put IPA information on it (jump functions etc) in the
usual way.

But I did not have the guts to make this change in stage 3 and
streaming the notes so far seems easy so I proposed this meanwhile.

Neverhteless, the bottom line is that I can turn this into an IPA-pass
standard hook if a maintainer decides that is a way to go.

Thanks,

Martin


> Richard.
>
> > Thanks,
> >
> > Martin
> >
> > 2009-11-03  Martin Jambor  <mjambor@...>
> >
> > * lto-streamer.h (struct lto_stmt_fixup_hook_list_element): New type.
> > (lto_stmt_fixup_hook_list) Declare.
> >
> > * lto-streamer-in.c (input_function): Call all stmt fixup hooks in
> > lto_stmt_fixup_hook_list.
> > (lto_stmt_fixup_hook_list) New variable.
> >
> > Index: icln/gcc/lto-streamer-in.c
> > ===================================================================
> > --- icln.orig/gcc/lto-streamer-in.c
> > +++ icln/gcc/lto-streamer-in.c
> > @@ -59,6 +59,9 @@ struct string_slot
> >  /* The table to hold the file names.  */
> >  static htab_t file_name_hash_table;
> >  
> > +/* Linked list of pointers to stmt uids -> stmts fixup functions.  */
> > +struct lto_stmt_fixup_hook_list_element *lto_stmt_fixup_hook_list;
> > +
> >  
> >  /* Check that tag ACTUAL has one of the given values.  NUM_TAGS is the
> >     number of valid tag values to check.  */
> > @@ -1261,6 +1264,9 @@ input_function (tree fn_decl, struct dat
> >    gimple *stmts;
> >    basic_block bb;
> >    struct bitpack_d *bp;
> > +  struct cgraph_node *node;
> > +  struct lto_stmt_fixup_hook_list_element *fixup_hook;
> > +
> >  
> >    fn = DECL_STRUCT_FUNCTION (fn_decl);
> >    tag = input_record_start (ib);
> > @@ -1340,7 +1346,12 @@ input_function (tree fn_decl, struct dat
> >      gimple_set_body (fn_decl, bb_seq (ei_edge (ei)->dest));
> >    }
> >  
> > -  fixup_call_stmt_edges (cgraph_node (fn_decl), stmts);
> > +  node = cgraph_node (fn_decl);
> > +  fixup_call_stmt_edges (node, stmts);
> > +  for (fixup_hook = lto_stmt_fixup_hook_list;
> > +       fixup_hook;
> > +       fixup_hook = fixup_hook->next)
> > +    fixup_hook->hook (node, stmts);
> >  
> >    update_ssa (TODO_update_ssa_only_virtuals);
> >    free_dominance_info (CDI_DOMINATORS);
> > Index: icln/gcc/lto-streamer.h
> > ===================================================================
> > --- icln.orig/gcc/lto-streamer.h
> > +++ icln/gcc/lto-streamer.h
> > @@ -689,6 +689,13 @@ struct data_in
> >    struct lto_streamer_cache_d *reader_cache;
> >  };
> >  
> > +/* Add-only linked list of functions that turn gimple statement uids into
> > +   gimple statements in IPA-pass info.  */
> > +struct lto_stmt_fixup_hook_list_element
> > +{
> > +  void (*hook)(struct cgraph_node *, gimple *);
> > +  struct lto_stmt_fixup_hook_list_element *next;
> > +};
> >  
> >  /* In lto-section-in.c  */
> >  extern struct lto_input_block * lto_create_simple_input_block (
> > @@ -803,6 +810,8 @@ extern void lto_check_version (int, int)
> >  
> >  
> >  /* In lto-streamer-in.c */
> > +extern struct lto_stmt_fixup_hook_list_element *lto_stmt_fixup_hook_list;
> > +
> >  extern void lto_input_cgraph (struct lto_file_decl_data *, const char *);
> >  extern void lto_init_reader (void);
> >  extern tree lto_input_tree (struct lto_input_block *, struct data_in *);
> >
> >
>
> --
> Richard Guenther <rguenther@...>
> Novell / SUSE Labs
> SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 - GF: Markus Rex

Re: [RFC PATCH, LTO] Linked list of stmt uids->stmts fixup hooks

by Richard Guenther-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, 4 Nov 2009, Martin Jambor wrote:

> Hi,
>
> On Wed, Nov 04, 2009 at 10:45:03AM +0100, Richard Guenther wrote:
> > On Tue, 3 Nov 2009, Martin Jambor wrote:
> >
> > > Hi,
> > >
> > > while working on streaming of indirect inlinining information I
> > > need to turn gimple stmt uids into gimple statements in the same way
> > > this is done for call graph edges.  
> > >
> > > I can either call a function in ipa-prop.c doing this directly from
> > > input_function() in lto-streamer-in.c or add some generic simplisitc
> > > infrastructure like what is in the patch below.  I simply added a
> > > linked list of hooks that I envision will consist of static
> > > structures, one per running IPA pass that needs this.
> > >
> > > Alternatively, running fixup_call_stmt_edges() after IPA decisions are
> > > made (and inlining decisions in particular).  So far I assumed it was
> > > called before in non-wpa mode on purpose.
> > >
> > > The patch is untested.  What do you think about this approach?
> >
> > Shouldn't this maybe be a IPA pass lto hook instead?
> >
>
> I don't really care.  On one hand, if more IPA-passes need this (or
> other fixups which could be bundled together into a big one) it would
> certainly make sense.  On the other hand, I have written the first and
> for the forseeable future the only user yesterday and even that one
> will probably go away in 4.6 because (AFAIK) Honza plans to turn the
> param call notes into special cgraph edges (with an unknown callee)
> connected to the cgraph node directly.  That is a good idea as it will
> enable us to put IPA information on it (jump functions etc) in the
> usual way.
>
> But I did not have the guts to make this change in stage 3 and
> streaming the notes so far seems easy so I proposed this meanwhile.
>
> Neverhteless, the bottom line is that I can turn this into an IPA-pass
> standard hook if a maintainer decides that is a way to go.

I think it's cleaner and it shouldn't be much work to remove that again
if required.

Richard.

Re: [RFC PATCH, LTO] Linked list of stmt uids->stmts fixup hooks

by Martin Jambor-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

On Wed, Nov 04, 2009 at 03:33:55PM +0100, Richard Guenther wrote:

> On Wed, 4 Nov 2009, Martin Jambor wrote:
>
> > Hi,
> >
> > On Wed, Nov 04, 2009 at 10:45:03AM +0100, Richard Guenther wrote:
> > > On Tue, 3 Nov 2009, Martin Jambor wrote:
> > >
> > > > Hi,
> > > >
> > > > while working on streaming of indirect inlinining information I
> > > > need to turn gimple stmt uids into gimple statements in the same way
> > > > this is done for call graph edges.  
> > > >
> > > > I can either call a function in ipa-prop.c doing this directly from
> > > > input_function() in lto-streamer-in.c or add some generic simplisitc
> > > > infrastructure like what is in the patch below.  I simply added a
> > > > linked list of hooks that I envision will consist of static
> > > > structures, one per running IPA pass that needs this.
> > > >
> > > > Alternatively, running fixup_call_stmt_edges() after IPA decisions are
> > > > made (and inlining decisions in particular).  So far I assumed it was
> > > > called before in non-wpa mode on purpose.
> > > >
> > > > The patch is untested.  What do you think about this approach?
> > >
> > > Shouldn't this maybe be a IPA pass lto hook instead?
> > >
> >
> > I don't really care.  On one hand, if more IPA-passes need this (or
> > other fixups which could be bundled together into a big one) it would
> > certainly make sense.  On the other hand, I have written the first and
> > for the forseeable future the only user yesterday and even that one
> > will probably go away in 4.6 because (AFAIK) Honza plans to turn the
> > param call notes into special cgraph edges (with an unknown callee)
> > connected to the cgraph node directly.  That is a good idea as it will
> > enable us to put IPA information on it (jump functions etc) in the
> > usual way.
> >
> > But I did not have the guts to make this change in stage 3 and
> > streaming the notes so far seems easy so I proposed this meanwhile.
> >
> > Neverhteless, the bottom line is that I can turn this into an IPA-pass
> > standard hook if a maintainer decides that is a way to go.
>
> I think it's cleaner and it shouldn't be much work to remove that again
> if required.

OK, this patch does exactly that.  I have bootstrapped and tested it
on x86_64-linux with no problems.  That is not surprising because it
does not do much on its own, but I have also successfully tested my
call note streaming patch on top of this.  I am now still in the
process of bootstrapping the latter and so will submit it separately
later.

So, OK for trunk?

Thanks,

Martin


2009-11-06  Martin Jambor  <mjambor@...>

        * tree-pass.h (struct ipa_opt_pass_d): Added stmt_fixup field.
        (execute_all_ipa_stmt_fixups): Declare.
        * ipa-cp.c (pass_ipa_cp): Added stmt_fixup value.
        * ipa-inline.c (pass_ipa_inline): Likewise.
        * ipa-pure-const.c (pass_ipa_pure_cons): Likewise.
        * ipa-reference.c (pass_ipa_reference): Likewise.
        * ipa.c (pass_ipa_whole_program_visibility): Likewise.
        * lto-streamer-out.c (pass_ipa_lto_gimple_out): Likewise.
        (pass_ipa_lto_finish_out): Likewise.
        * lto-wpa-fixup.c (pass_ipa_lto_wpa_fixup): Likewise.
        * passes.c (execute_ipa_stmt_fixups): New function.
        (execute_all_ipa_stmt_fixups): New function.
        * lto-streamer-in.c (input_function): Call execute_all_ipa_stmt_fixups.

Index: icln/gcc/lto-streamer-in.c
===================================================================
--- icln.orig/gcc/lto-streamer-in.c 2009-11-06 12:25:27.000000000 +0100
+++ icln/gcc/lto-streamer-in.c 2009-11-06 12:55:49.000000000 +0100
@@ -1261,6 +1261,7 @@ input_function (tree fn_decl, struct dat
   gimple *stmts;
   basic_block bb;
   struct bitpack_d *bp;
+  struct cgraph_node *node;
 
   fn = DECL_STRUCT_FUNCTION (fn_decl);
   tag = input_record_start (ib);
@@ -1340,7 +1341,9 @@ input_function (tree fn_decl, struct dat
     gimple_set_body (fn_decl, bb_seq (ei_edge (ei)->dest));
   }
 
-  fixup_call_stmt_edges (cgraph_node (fn_decl), stmts);
+  node = cgraph_node (fn_decl);
+  fixup_call_stmt_edges (node, stmts);
+  execute_all_ipa_stmt_fixups (node, stmts);
 
   update_ssa (TODO_update_ssa_only_virtuals);
   free_dominance_info (CDI_DOMINATORS);
Index: icln/gcc/ipa-cp.c
===================================================================
--- icln.orig/gcc/ipa-cp.c 2009-11-06 12:25:27.000000000 +0100
+++ icln/gcc/ipa-cp.c 2009-11-06 12:55:49.000000000 +0100
@@ -1327,6 +1327,7 @@ struct ipa_opt_pass_d pass_ipa_cp =
  ipcp_write_summary, /* write_summary */
  ipcp_read_summary, /* read_summary */
  NULL, /* function_read_summary */
+ NULL, /* stmt_fixup */
  0, /* TODOs */
  NULL, /* function_transform */
  NULL, /* variable_transform */
Index: icln/gcc/ipa-inline.c
===================================================================
--- icln.orig/gcc/ipa-inline.c 2009-11-06 12:25:27.000000000 +0100
+++ icln/gcc/ipa-inline.c 2009-11-06 12:55:49.000000000 +0100
@@ -2020,6 +2020,7 @@ struct ipa_opt_pass_d pass_ipa_inline =
  inline_write_summary, /* write_summary */
  inline_read_summary, /* read_summary */
  NULL, /* function_read_summary */
+ NULL, /* stmt_fixup */
  0, /* TODOs */
  inline_transform, /* function_transform */
  NULL, /* variable_transform */
Index: icln/gcc/ipa-pure-const.c
===================================================================
--- icln.orig/gcc/ipa-pure-const.c 2009-11-06 12:25:27.000000000 +0100
+++ icln/gcc/ipa-pure-const.c 2009-11-06 12:55:49.000000000 +0100
@@ -1100,6 +1100,7 @@ struct ipa_opt_pass_d pass_ipa_pure_cons
  pure_const_write_summary, /* write_summary */
  pure_const_read_summary, /* read_summary */
  NULL, /* function_read_summary */
+ NULL, /* stmt_fixup */
  0, /* TODOs */
  NULL,                /* function_transform */
  NULL /* variable_transform */
Index: icln/gcc/ipa-reference.c
===================================================================
--- icln.orig/gcc/ipa-reference.c 2009-11-06 12:25:27.000000000 +0100
+++ icln/gcc/ipa-reference.c 2009-11-06 12:55:49.000000000 +0100
@@ -1511,6 +1511,7 @@ struct ipa_opt_pass_d pass_ipa_reference
  ipa_reference_write_summary, /* write_summary */
  ipa_reference_read_summary, /* read_summary */
  NULL, /* function_read_summary */
+ NULL, /* stmt_fixup */
  0, /* TODOs */
  NULL,                /* function_transform */
  NULL /* variable_transform */
Index: icln/gcc/ipa.c
===================================================================
--- icln.orig/gcc/ipa.c 2009-11-06 12:25:27.000000000 +0100
+++ icln/gcc/ipa.c 2009-11-06 12:55:49.000000000 +0100
@@ -425,6 +425,7 @@ struct ipa_opt_pass_d pass_ipa_whole_pro
  NULL, /* write_summary */
  NULL, /* read_summary */
  NULL, /* function_read_summary */
+ NULL, /* stmt_fixup */
  0, /* TODOs */
  NULL, /* function_transform */
  NULL, /* variable_transform */
Index: icln/gcc/lto-streamer-out.c
===================================================================
--- icln.orig/gcc/lto-streamer-out.c 2009-11-06 12:25:27.000000000 +0100
+++ icln/gcc/lto-streamer-out.c 2009-11-06 12:55:49.000000000 +0100
@@ -2115,6 +2115,7 @@ struct ipa_opt_pass_d pass_ipa_lto_gimpl
  lto_output,           /* write_summary */
  NULL,         /* read_summary */
  NULL, /* function_read_summary */
+ NULL, /* stmt_fixup */
  0, /* TODOs */
  NULL,                /* function_transform */
  NULL /* variable_transform */
@@ -2545,6 +2546,7 @@ struct ipa_opt_pass_d pass_ipa_lto_finis
  produce_asm_for_decls, /* write_summary */
  NULL,         /* read_summary */
  NULL, /* function_read_summary */
+ NULL, /* stmt_fixup */
  0, /* TODOs */
  NULL,                /* function_transform */
  NULL /* variable_transform */
Index: icln/gcc/lto-wpa-fixup.c
===================================================================
--- icln.orig/gcc/lto-wpa-fixup.c 2009-11-06 12:25:27.000000000 +0100
+++ icln/gcc/lto-wpa-fixup.c 2009-11-06 12:55:49.000000000 +0100
@@ -274,6 +274,7 @@ struct ipa_opt_pass_d pass_ipa_lto_wpa_f
  lto_output_wpa_fixup, /* write_summary */
  lto_input_wpa_fixup, /* read_summary */
  NULL, /* function_read_summary */
+ NULL, /* stmt_fixup */
  0, /* TODOs */
  NULL,                /* function_transform */
  NULL /* variable_transform */
Index: icln/gcc/passes.c
===================================================================
--- icln.orig/gcc/passes.c 2009-11-06 12:25:27.000000000 +0100
+++ icln/gcc/passes.c 2009-11-06 12:56:33.000000000 +0100
@@ -1745,6 +1745,50 @@ execute_ipa_pass_list (struct opt_pass *
   while (pass);
 }
 
+/* Execute stmt fixup hooks of all passes in PASS for NODE and STMTS.  */
+
+static void
+execute_ipa_stmt_fixups (struct opt_pass *pass,
+  struct cgraph_node *node, gimple *stmts)
+{
+  while (pass)
+    {
+      /* Execute all of the IPA_PASSes in the list.  */
+      if (pass->type == IPA_PASS
+  && (!pass->gate || pass->gate ()))
+ {
+  struct ipa_opt_pass_d *ipa_pass = (struct ipa_opt_pass_d *) pass;
+
+  if (ipa_pass->stmt_fixup)
+    {
+      pass_init_dump_file (pass);
+      /* If a timevar is present, start it.  */
+      if (pass->tv_id)
+ timevar_push (pass->tv_id);
+
+      ipa_pass->stmt_fixup (node, stmts);
+
+      /* Stop timevar.  */
+      if (pass->tv_id)
+ timevar_pop (pass->tv_id);
+      pass_fini_dump_file (pass);
+    }
+  if (pass->sub)
+    execute_ipa_stmt_fixups (pass->sub, node, stmts);
+ }
+      pass = pass->next;
+    }
+}
+
+/* Execute stmt fixup hooks of all IPA passes for NODE and STMTS.  */
+
+void
+execute_all_ipa_stmt_fixups (struct cgraph_node *node, gimple *stmts)
+{
+  execute_ipa_stmt_fixups (all_regular_ipa_passes, node, stmts);
+}
+
+
 extern void debug_properties (unsigned int);
 extern void dump_properties (FILE *, unsigned int);
 
Index: icln/gcc/tree-pass.h
===================================================================
--- icln.orig/gcc/tree-pass.h 2009-11-06 12:25:27.000000000 +0100
+++ icln/gcc/tree-pass.h 2009-11-06 12:55:49.000000000 +0100
@@ -185,7 +185,10 @@ struct ipa_opt_pass_d
      as needed so both calls are necessary.  */
   void (*read_summary) (void);
   void (*function_read_summary) (struct cgraph_node *);
-  
+  /* Hook to convert gimple stmt uids into true gimple statements.  The second
+     parameter is an array of statements indexed by their uid. */
+  void (*stmt_fixup) (struct cgraph_node *, gimple *);
+
   /* Results of interprocedural propagation of an IPA pass is applied to
      function body via this hook.  */
   unsigned int function_transform_todo_flags_start;
@@ -566,6 +569,7 @@ extern void execute_pass_list (struct op
 extern void execute_ipa_pass_list (struct opt_pass *);
 extern void execute_ipa_summary_passes (struct ipa_opt_pass_d *);
 extern void execute_all_ipa_transforms (void);
+extern void execute_all_ipa_stmt_fixups (struct cgraph_node *, gimple *);
 
 extern void print_current_pass (FILE *);
 extern void debug_pass (void);

Re: [RFC PATCH, LTO] Linked list of stmt uids->stmts fixup hooks

by Diego Novillo-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Nov 6, 2009 at 09:18, Martin Jambor <mjambor@...> wrote:

> 2009-11-06  Martin Jambor  <mjambor@...>
>
>        * tree-pass.h (struct ipa_opt_pass_d): Added stmt_fixup field.
>        (execute_all_ipa_stmt_fixups): Declare.
>        * ipa-cp.c (pass_ipa_cp): Added stmt_fixup value.
>        * ipa-inline.c (pass_ipa_inline): Likewise.
>        * ipa-pure-const.c (pass_ipa_pure_cons): Likewise.
>        * ipa-reference.c (pass_ipa_reference): Likewise.
>        * ipa.c (pass_ipa_whole_program_visibility): Likewise.
>        * lto-streamer-out.c (pass_ipa_lto_gimple_out): Likewise.
>        (pass_ipa_lto_finish_out): Likewise.
>        * lto-wpa-fixup.c (pass_ipa_lto_wpa_fixup): Likewise.
>        * passes.c (execute_ipa_stmt_fixups): New function.
>        (execute_all_ipa_stmt_fixups): New function.
>        * lto-streamer-in.c (input_function): Call execute_all_ipa_stmt_fixups.

OK.


Diego.