Hi!

I've noticed pre_and_rev_post_order_compute_fn is one of (apparently many)
functions that take a struct function * argument and accept any function, as
long as it is cfun.  For a patch I've been working on I actually need it
to handle other functions as well and in this case it is trivial to fix.
I've seen several others e.g. in graph.c, though some of those are harder to
deal with, as some there are calls to functions that don't have a variant
with struct function * argument and assume cfun implicitly.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2019-02-07  Jakub Jelinek  <ja...@redhat.com>

        * cfganal.c (pre_and_rev_post_order_compute_fn): Use fn instead of
        cfun everywhere.

--- gcc/cfganal.c.jj    2019-01-01 12:37:17.915962514 +0100
+++ gcc/cfganal.c       2019-02-07 20:47:29.035520143 +0100
@@ -951,10 +951,10 @@ pre_and_rev_post_order_compute_fn (struc
                                   bool include_entry_exit)
 {
   int pre_order_num = 0;
-  int rev_post_order_num = n_basic_blocks_for_fn (cfun) - 1;
+  int rev_post_order_num = n_basic_blocks_for_fn (fn) - 1;
 
   /* Allocate stack for back-tracking up CFG.  */
-  auto_vec<edge_iterator, 20> stack (n_basic_blocks_for_fn (cfun) + 1);
+  auto_vec<edge_iterator, 20> stack (n_basic_blocks_for_fn (fn) + 1);
 
   if (include_entry_exit)
     {
@@ -968,7 +968,7 @@ pre_and_rev_post_order_compute_fn (struc
     rev_post_order_num -= NUM_FIXED_BLOCKS;
 
   /* Allocate bitmap to track nodes that have been visited.  */
-  auto_sbitmap visited (last_basic_block_for_fn (cfun));
+  auto_sbitmap visited (last_basic_block_for_fn (fn));
 
   /* None of the nodes in the CFG have been visited yet.  */
   bitmap_clear (visited);

        Jakub

Reply via email to