diff mbox

[2/2] Get rid of global state accesses in dominance.c

Message ID 55CD3EA1.1050104@gmail.com
State New
Headers show

Commit Message

Mikhail Maltsev Aug. 14, 2015, 1:04 a.m. UTC
The second part removes all global state accesses (i.e. accesses to cfun and
it's members) from dominance.c. This requires to change lots of code, but I hope
that this is a step in right direction (if my understanding of ongoing
re-architecture w.r.t. to global state is correct).

For now this second part lacks a changelog entry, but it's very "mechanical". I
will, of course, write it if the patch gets approved.

Comments

Richard Biener Aug. 14, 2015, 8:02 a.m. UTC | #1
On Fri, Aug 14, 2015 at 3:04 AM, Mikhail Maltsev <maltsevm@gmail.com> wrote:
> The second part removes all global state accesses (i.e. accesses to cfun and
> it's members) from dominance.c. This requires to change lots of code, but I hope
> that this is a step in right direction (if my understanding of ongoing
> re-architecture w.r.t. to global state is correct).
>
> For now this second part lacks a changelog entry, but it's very "mechanical". I
> will, of course, write it if the patch gets approved.

So the last time I did similar refactoring I wondered if we can somehow avoid
the "noise" in non-IPA passes.  Ideas I came up with are

 a)  Inherit gimple/rtl pass classes from a class which is initialized with the
      function the pass operates on and provides methods like

    bool dom_info_available_p (..) { return dom_info_available_p (fn, ...); }

     thus wraps APIs working on a specific function.

 b)  Do sth similar but make it work with overloads and clever (no idea what!)
    C++ that disables them if this_fn cannot be looked up

    template <disable-me-if-this_fn-cannot_be_lookedup-at-instantiation-place>
    bool dom_info_available_p (..., struct function *fn = this_fn);

all of the above would of course require that passes make all their
implementation
be methods of their pass class.  So even more refactoring.

Note that we do not have any IPA pass which accesses dominators, so the
implicit 'cfun' use was ok.  The cases I refactored were those where we had
to push/pop_cfun () in IPA passes (which can be expensive) because it
used APIs with implicit cfun.

Overall I'm not sure we want all APIs using 'cfun' to be refactored.
It is after
all useless noise to callers if all callers are effectively using 'cfun'.

Refactoring APIs that are used from IPA and make push/pop_cfun necessary
for them are another thing.  (there are still plenty left I think)

Richard.


> --
> Regards,
>     Mikhail Maltsev
Jeff Law Aug. 14, 2015, 6:25 p.m. UTC | #2
On 08/14/2015 02:02 AM, Richard Biener wrote:
> On Fri, Aug 14, 2015 at 3:04 AM, Mikhail Maltsev <maltsevm@gmail.com> wrote:
>> The second part removes all global state accesses (i.e. accesses to cfun and
>> it's members) from dominance.c. This requires to change lots of code, but I hope
>> that this is a step in right direction (if my understanding of ongoing
>> re-architecture w.r.t. to global state is correct).
>>
>> For now this second part lacks a changelog entry, but it's very "mechanical". I
>> will, of course, write it if the patch gets approved.
>
> So the last time I did similar refactoring I wondered if we can somehow avoid
> the "noise" in non-IPA passes.  Ideas I came up with are
>
>   a)  Inherit gimple/rtl pass classes from a class which is initialized with the
>        function the pass operates on and provides methods like
>
>      bool dom_info_available_p (..) { return dom_info_available_p (fn, ...); }
>
>       thus wraps APIs working on a specific function.
>
>   b)  Do sth similar but make it work with overloads and clever (no idea what!)
>      C++ that disables them if this_fn cannot be looked up
>
>      template <disable-me-if-this_fn-cannot_be_lookedup-at-instantiation-place>
>      bool dom_info_available_p (..., struct function *fn = this_fn);
>
> all of the above would of course require that passes make all their
> implementation
> be methods of their pass class.  So even more refactoring.
>
> Note that we do not have any IPA pass which accesses dominators, so the
> implicit 'cfun' use was ok.  The cases I refactored were those where we had
> to push/pop_cfun () in IPA passes (which can be expensive) because it
> used APIs with implicit cfun.
>
> Overall I'm not sure we want all APIs using 'cfun' to be refactored.
> It is after
> all useless noise to callers if all callers are effectively using 'cfun'.
And since the main driver for eliminating global state is David's work 
on the JIT, perhaps see if any of this helps David in a noticeable way 
before giving it a yea/nea.

Jeff
David Malcolm Aug. 14, 2015, 8:11 p.m. UTC | #3
On Fri, 2015-08-14 at 12:25 -0600, Jeff Law wrote:
> On 08/14/2015 02:02 AM, Richard Biener wrote:
> > On Fri, Aug 14, 2015 at 3:04 AM, Mikhail Maltsev <maltsevm@gmail.com> wrote:
> >> The second part removes all global state accesses (i.e. accesses to cfun and
> >> it's members) from dominance.c. This requires to change lots of code, but I hope
> >> that this is a step in right direction (if my understanding of ongoing
> >> re-architecture w.r.t. to global state is correct).
> >>
> >> For now this second part lacks a changelog entry, but it's very "mechanical". I
> >> will, of course, write it if the patch gets approved.
> >
> > So the last time I did similar refactoring I wondered if we can somehow avoid
> > the "noise" in non-IPA passes.  Ideas I came up with are
> >
> >   a)  Inherit gimple/rtl pass classes from a class which is initialized with the
> >        function the pass operates on and provides methods like
> >
> >      bool dom_info_available_p (..) { return dom_info_available_p (fn, ...); }
> >
> >       thus wraps APIs working on a specific function.
> >
> >   b)  Do sth similar but make it work with overloads and clever (no idea what!)
> >      C++ that disables them if this_fn cannot be looked up
> >
> >      template <disable-me-if-this_fn-cannot_be_lookedup-at-instantiation-place>
> >      bool dom_info_available_p (..., struct function *fn = this_fn);
> >
> > all of the above would of course require that passes make all their
> > implementation
> > be methods of their pass class.  So even more refactoring.
> >
> > Note that we do not have any IPA pass which accesses dominators, so the
> > implicit 'cfun' use was ok.  The cases I refactored were those where we had
> > to push/pop_cfun () in IPA passes (which can be expensive) because it
> > used APIs with implicit cfun.
> >
> > Overall I'm not sure we want all APIs using 'cfun' to be refactored.
> > It is after
> > all useless noise to callers if all callers are effectively using 'cfun'.
> And since the main driver for eliminating global state is David's work 
> on the JIT, perhaps see if any of this helps David in a noticeable way 
> before giving it a yea/nea.

The JIT guards all access to GCC's state in a big mutex ("jit_mutex", in
gcc/jit/jit-playback.c).

For example, this includes everything to do with GC and GTY, since
there's implicitly a single set of GC roots and the GC code isn't thread
safe.

So in theory this patch might reduce the amount of things that need to
be guarded by the mutex, but sadly the mountain of work there is so
large that I'm not sure how helpful it is.  (sigh)

I've been tackling things on an as-needed basis - for example, the
recent timevar global-state removal was motivated by wanting to expose a
profiling API to jit client code.

So if there are other benefits beyond merely eliminating accesses to
globals, then maybe it's good.  Does the code become simpler, more easy
to understand?  Does it eliminate the need to change "cfun" (IIRC that
can be expensive).

For example, the jit has some rather ugly code to purge global state
after each in-process invocation.  If that can be simplified or made
less ugly, that's good.

Hope this is constructive.
Dave
Mikhail Maltsev Aug. 15, 2015, 6:05 a.m. UTC | #4
On 08/14/2015 11:02 AM, Richard Biener wrote:
> So the last time I did similar refactoring I wondered if we can somehow avoid
> the "noise" in non-IPA passes.  Ideas I came up with are
> 
>  a)  Inherit gimple/rtl pass classes from a class which is initialized with the
>       function the pass operates on and provides methods like
> 
>     bool dom_info_available_p (..) { return dom_info_available_p (fn, ...); }
> 
>      thus wraps APIs working on a specific function.
> 
>  b)  Do sth similar but make it work with overloads and clever (no idea what!)
>     C++ that disables them if this_fn cannot be looked up
> 
>     template <disable-me-if-this_fn-cannot_be_lookedup-at-instantiation-place>
>     bool dom_info_available_p (..., struct function *fn = this_fn);
> 
I attached some sketch of what this "clever C++" could look like. It still
requires some changes in classes which would use this new base class, but they
are not very significant compared to converting pass functions into members of
these classes.

> all of the above would of course require that passes make all their
> implementation
> be methods of their pass class.  So even more refactoring.
The good thing is that this can be done incrementally, i.e. changing one pass at
a time.

> Refactoring APIs that are used from IPA and make push/pop_cfun necessary
> for them are another thing.  (there are still plenty left I think)
What I could find is:
1. ipa_analyze_node
2. some transactional memory-related stuff: ipa_tm_scan_irr_function,
ipa_tm_transform_transaction, ipa_tm_transform_clone, ipa_tm_execute.
3. tree_profiling

Presumably there are no more calculate_dominance_info/free_dominance_info call
sites with push_cfun/pop_cfun nearby (except for passes.c, but they are not
related to IPA). So now I need to figure out, what other global state (which is
set up by push_cfun) can these functions use? Could you give some advice about
that, in sense, what should I look for (e.g., push_cfun calls some target hooks,
but I did not try to look in detail, what kind of actions are performed by it)?

As for the API. I propose to, at least, remove uses of cfun from dominance.c
itself, but provide helper functions which will allow to leave the callers
unchanged, but make it possible to use all dominance-related API on functions
other than cfun.
Does such change sound reasonable to you?


On 08/14/2015 11:11 PM, David Malcolm wrote:
> The JIT guards all access to GCC's state in a big mutex ("jit_mutex", in
> gcc/jit/jit-playback.c).
Yeah, I know, I looked through JIT documentation briefly.
> 
> For example, this includes everything to do with GC and GTY, since
> there's implicitly a single set of GC roots and the GC code isn't thread
> safe.
And GGC is a "stop-the-world" collector, which is just not designed for
multithreaded environment. (sigh)

As for the patch, I think reviewing this variant does not make much sense,
because of Richard suggestion on how to avoid changing the callers. But still
thanks for looking.

> 
> I've been tackling things on an as-needed basis - for example, the
> recent timevar global-state removal was motivated by wanting to expose a
> profiling API to jit client code.
> 
By the way, speaking of timevars. I wrote about my concerns w.r.t. them, but did
not get any feedback:
https://gcc.gnu.org/ml/gcc/2015-07/msg00165.html
Briefly speaking, I noticed that our timers introduce rather significant
measurement errors and proposed some ideas about reducing them. What do you think?
Richard Biener Aug. 18, 2015, 10:05 a.m. UTC | #5
On Sat, Aug 15, 2015 at 8:05 AM, Mikhail Maltsev <maltsevm@gmail.com> wrote:
> On 08/14/2015 11:02 AM, Richard Biener wrote:
>> So the last time I did similar refactoring I wondered if we can somehow avoid
>> the "noise" in non-IPA passes.  Ideas I came up with are
>>
>>  a)  Inherit gimple/rtl pass classes from a class which is initialized with the
>>       function the pass operates on and provides methods like
>>
>>     bool dom_info_available_p (..) { return dom_info_available_p (fn, ...); }
>>
>>      thus wraps APIs working on a specific function.
>>
>>  b)  Do sth similar but make it work with overloads and clever (no idea what!)
>>     C++ that disables them if this_fn cannot be looked up
>>
>>     template <disable-me-if-this_fn-cannot_be_lookedup-at-instantiation-place>
>>     bool dom_info_available_p (..., struct function *fn = this_fn);
>>
> I attached some sketch of what this "clever C++" could look like. It still
> requires some changes in classes which would use this new base class, but they
> are not very significant compared to converting pass functions into members of
> these classes.
>
>> all of the above would of course require that passes make all their
>> implementation
>> be methods of their pass class.  So even more refactoring.
> The good thing is that this can be done incrementally, i.e. changing one pass at
> a time.

True.  I think we want a cfun.h header so that if cfun.h is not
included the overloads
with the default parameter don't work (uh, hopefully they'll still parse...).

Note that one of the unfortunate thing is this default arg stuff only
works on trailing
arguments and thus is inconsistend with other API having a function * argument.
It also makes it hard to apply to APIs that use default args themselves.

Not using default args but forwarder overloads like

dominated_by_p (cdi_direction, basic_block, basic_block)
{
  return dominated_by_p (cfun, dir, bb1, bb2);
}

would avoid this.  Of course then choosing one or the other becomes a pure
name-lookup issue, but I supose that's ok.

And of course with those available there isn't a good reason (apart from JIT
avoiding globals) to switch a pass over to the new scheme.

>> Refactoring APIs that are used from IPA and make push/pop_cfun necessary
>> for them are another thing.  (there are still plenty left I think)
> What I could find is:
> 1. ipa_analyze_node
> 2. some transactional memory-related stuff: ipa_tm_scan_irr_function,
> ipa_tm_transform_transaction, ipa_tm_transform_clone, ipa_tm_execute.
> 3. tree_profiling
>
> Presumably there are no more calculate_dominance_info/free_dominance_info call
> sites with push_cfun/pop_cfun nearby (except for passes.c, but they are not
> related to IPA). So now I need to figure out, what other global state (which is
> set up by push_cfun) can these functions use? Could you give some advice about
> that, in sense, what should I look for (e.g., push_cfun calls some target hooks,
> but I did not try to look in detail, what kind of actions are performed by it)?

Actions can include computing register preferences and other expensive stuff
if a function has a target or optimize attribute different from the previously
active one.  It's the push/pop_cfun calls from ipa-* that are expensive, but
more so that from tree-sra.c (that's in theory quadratic).  Basically whenever
only very little is done inside a push/pop pair the it's best to avoid it.
Calling push/pop from non-IPA context is to be avoided even more so.

> As for the API. I propose to, at least, remove uses of cfun from dominance.c
> itself, but provide helper functions which will allow to leave the callers
> unchanged, but make it possible to use all dominance-related API on functions
> other than cfun.
> Does such change sound reasonable to you?

Like providing the overload I suggested above?  Yes, that makes sense to me.

Thanks,
Richard.

>
> On 08/14/2015 11:11 PM, David Malcolm wrote:
>> The JIT guards all access to GCC's state in a big mutex ("jit_mutex", in
>> gcc/jit/jit-playback.c).
> Yeah, I know, I looked through JIT documentation briefly.
>>
>> For example, this includes everything to do with GC and GTY, since
>> there's implicitly a single set of GC roots and the GC code isn't thread
>> safe.
> And GGC is a "stop-the-world" collector, which is just not designed for
> multithreaded environment. (sigh)
>
> As for the patch, I think reviewing this variant does not make much sense,
> because of Richard suggestion on how to avoid changing the callers. But still
> thanks for looking.
>
>>
>> I've been tackling things on an as-needed basis - for example, the
>> recent timevar global-state removal was motivated by wanting to expose a
>> profiling API to jit client code.
>>
> By the way, speaking of timevars. I wrote about my concerns w.r.t. them, but did
> not get any feedback:
> https://gcc.gnu.org/ml/gcc/2015-07/msg00165.html
> Briefly speaking, I noticed that our timers introduce rather significant
> measurement errors and proposed some ideas about reducing them. What do you think?
>
> --
> Regards,
>     Mikhail Maltsev
diff mbox

Patch

diff --git a/gcc/asan.c b/gcc/asan.c
index 4f5adaa..a9c597b 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -1536,8 +1536,8 @@  create_cond_insert_point (gimple_stmt_iterator *iter,
   /* Update dominance info for the newly created then_bb; note that
      fallthru_bb's dominance info has already been updated by
      split_bock.  */
-  if (dom_info_available_p (CDI_DOMINATORS))
-    set_immediate_dominator (CDI_DOMINATORS, then_bb, cond_bb);
+  if (dom_info_available_p (cfun, CDI_DOMINATORS))
+    set_immediate_dominator (cfun, CDI_DOMINATORS, then_bb, cond_bb);
 
   *then_block = then_bb;
   *fallthrough_block = fallthru_bb;
diff --git a/gcc/auto-profile.c b/gcc/auto-profile.c
index fa0cd07..15f3f93 100644
--- a/gcc/auto-profile.c
+++ b/gcc/auto-profile.c
@@ -1118,7 +1118,7 @@  afdo_find_equiv_class (bb_set *annotated_bb)
     bb->aux = bb;
     dom_bbs = get_dominated_by (CDI_DOMINATORS, bb);
     FOR_EACH_VEC_ELT (dom_bbs, i, bb1)
-      if (bb1->aux == NULL && dominated_by_p (CDI_POST_DOMINATORS, bb, bb1)
+      if (bb1->aux == NULL && dominated_by_p (cfun, CDI_POST_DOMINATORS, bb, bb1)
 	  && bb1->loop_father == bb->loop_father)
 	{
 	  bb1->aux = bb;
@@ -1130,7 +1130,7 @@  afdo_find_equiv_class (bb_set *annotated_bb)
 	}
     dom_bbs = get_dominated_by (CDI_POST_DOMINATORS, bb);
     FOR_EACH_VEC_ELT (dom_bbs, i, bb1)
-      if (bb1->aux == NULL && dominated_by_p (CDI_DOMINATORS, bb, bb1)
+      if (bb1->aux == NULL && dominated_by_p (cfun, CDI_DOMINATORS, bb, bb1)
 	  && bb1->loop_father == bb->loop_father)
 	{
 	  bb1->aux = bb;
@@ -1351,8 +1351,8 @@  afdo_calculate_branch_prob (bb_set *annotated_bb, edge_set *annotated_edge)
   if (!has_sample)
     return;
 
-  calculate_dominance_info (CDI_POST_DOMINATORS);
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_POST_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_DOMINATORS);
   loop_optimizer_init (0);
 
   afdo_find_equiv_class (annotated_bb);
@@ -1389,8 +1389,8 @@  afdo_calculate_branch_prob (bb_set *annotated_bb, edge_set *annotated_edge)
   }
 
   loop_optimizer_finalize ();
-  free_dominance_info (CDI_DOMINATORS);
-  free_dominance_info (CDI_POST_DOMINATORS);
+  free_dominance_info (cfun, CDI_DOMINATORS);
+  free_dominance_info (cfun, CDI_POST_DOMINATORS);
 }
 
 /* Perform value profile transformation using AutoFDO profile. Add the
@@ -1516,8 +1516,8 @@  afdo_annotate_cfg (const stmt_set &promoted_stmts)
   if (flag_value_profile_transformations)
     {
       gimple_value_profile_transformations ();
-      free_dominance_info (CDI_DOMINATORS);
-      free_dominance_info (CDI_POST_DOMINATORS);
+      free_dominance_info (cfun, CDI_DOMINATORS);
+      free_dominance_info (cfun, CDI_POST_DOMINATORS);
       update_ssa (TODO_update_ssa);
     }
 }
@@ -1602,8 +1602,8 @@  auto_profile (void)
     if (execute_fixup_cfg () & TODO_cleanup_cfg)
       cleanup_tree_cfg ();
 
-    free_dominance_info (CDI_DOMINATORS);
-    free_dominance_info (CDI_POST_DOMINATORS);
+    free_dominance_info (cfun, CDI_DOMINATORS);
+    free_dominance_info (cfun, CDI_POST_DOMINATORS);
     cgraph_edge::rebuild_edges ();
     compute_inline_parameters (cgraph_node::get (current_function_decl), true);
     pop_cfun ();
diff --git a/gcc/bt-load.c b/gcc/bt-load.c
index 031b95d..27e0f15 100644
--- a/gcc/bt-load.c
+++ b/gcc/bt-load.c
@@ -899,7 +899,7 @@  augment_live_range (bitmap live_range, HARD_REG_SET *btrs_live_in_range,
 
   tos = worklist = XNEWVEC (basic_block, n_basic_blocks_for_fn (cfun) + 1);
 
-  if (dominated_by_p (CDI_DOMINATORS, new_bb, head_bb))
+  if (dominated_by_p (cfun, CDI_DOMINATORS, new_bb, head_bb))
     {
       if (new_bb == head_bb)
 	{
@@ -916,7 +916,7 @@  augment_live_range (bitmap live_range, HARD_REG_SET *btrs_live_in_range,
       edge_iterator ei;
       int new_block = new_bb->index;
 
-      gcc_assert (dominated_by_p (CDI_DOMINATORS, head_bb, new_bb));
+      gcc_assert (dominated_by_p (cfun, CDI_DOMINATORS, head_bb, new_bb));
 
       IOR_HARD_REG_SET (*btrs_live_in_range, btrs_live[head_bb->index]);
       bitmap_set_bit (live_range, new_block);
@@ -1061,7 +1061,7 @@  combine_btr_defs (btr_def def, HARD_REG_SET *btrs_live_in_range)
       if (other_def != def
 	  && other_def->uses != NULL
 	  && ! other_def->has_ambiguous_use
-	  && dominated_by_p (CDI_DOMINATORS, other_def->bb, def->bb))
+	  && dominated_by_p (cfun, CDI_DOMINATORS, other_def->bb, def->bb))
 	{
 	  /* def->bb dominates the other def, so def and other_def could
 	     be combined.  */
@@ -1478,12 +1478,12 @@  branch_target_load_optimize (bool after_prologue_epilogue_gen)
 
 
       /* Dominator info is also needed for migrate_btr_def.  */
-      calculate_dominance_info (CDI_DOMINATORS);
+      calculate_dominance_info (cfun, CDI_DOMINATORS);
       migrate_btr_defs (klass,
 		       (targetm.branch_target_register_callee_saved
 			(after_prologue_epilogue_gen)));
 
-      free_dominance_info (CDI_DOMINATORS);
+      free_dominance_info (cfun, CDI_DOMINATORS);
     }
 }
 
diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c
index 7e576bc..680b2e9 100644
--- a/gcc/cfgcleanup.c
+++ b/gcc/cfgcleanup.c
@@ -2909,7 +2909,7 @@  delete_unreachable_blocks (void)
      better chance of retaining most debug information than
      otherwise.  */
   if (MAY_HAVE_DEBUG_INSNS && current_ir_type () == IR_GIMPLE
-      && dom_info_available_p (CDI_DOMINATORS))
+      && dom_info_available_p (cfun, CDI_DOMINATORS))
     {
       for (b = EXIT_BLOCK_PTR_FOR_FN (cfun)->prev_bb;
 	   b != ENTRY_BLOCK_PTR_FOR_FN (cfun); b = prev_bb)
@@ -3087,10 +3087,10 @@  cleanup_cfg (int mode)
     {
       timevar_push (TV_REPAIR_LOOPS);
       /* The above doesn't preserve dominance info if available.  */
-      gcc_assert (!dom_info_available_p (CDI_DOMINATORS));
-      calculate_dominance_info (CDI_DOMINATORS);
+      gcc_assert (!dom_info_available_p (cfun, CDI_DOMINATORS));
+      calculate_dominance_info (cfun, CDI_DOMINATORS);
       fix_loop_structure (NULL);
-      free_dominance_info (CDI_DOMINATORS);
+      free_dominance_info (cfun, CDI_DOMINATORS);
       timevar_pop (TV_REPAIR_LOOPS);
     }
 
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 7df9d06..fcd8785 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -5845,7 +5845,7 @@  pass_expand::execute (function *fun)
   /* Some backends want to know that we are expanding to RTL.  */
   currently_expanding_to_rtl = 1;
   /* Dominators are not kept up-to-date as we may create new basic-blocks.  */
-  free_dominance_info (CDI_DOMINATORS);
+  free_dominance_info (cfun, CDI_DOMINATORS);
 
   rtl_profile_for_bb (ENTRY_BLOCK_PTR_FOR_FN (fun));
 
@@ -6032,8 +6032,8 @@  pass_expand::execute (function *fun)
     }
 
   /* Free stuff we no longer need after GIMPLE optimizations.  */
-  free_dominance_info (CDI_DOMINATORS);
-  free_dominance_info (CDI_POST_DOMINATORS);
+  free_dominance_info (cfun, CDI_DOMINATORS);
+  free_dominance_info (cfun, CDI_POST_DOMINATORS);
   delete_tree_cfg_annotations ();
 
   timevar_push (TV_OUT_OF_SSA);
diff --git a/gcc/cfghooks.c b/gcc/cfghooks.c
index 2cfdcfc..be99736 100644
--- a/gcc/cfghooks.c
+++ b/gcc/cfghooks.c
@@ -464,8 +464,8 @@  redirect_edge_and_branch_force (edge e, basic_block dest)
 
   ret = cfg_hooks->redirect_edge_and_branch_force (e, dest);
 
-  if (ret != NULL && dom_info_available_p (CDI_DOMINATORS))
-    set_immediate_dominator (CDI_DOMINATORS, ret, src);
+  if (ret != NULL && dom_info_available_p (cfun, CDI_DOMINATORS))
+    set_immediate_dominator (cfun, CDI_DOMINATORS, ret, src);
 
   if (current_loops != NULL)
     {
@@ -504,10 +504,10 @@  split_block_1 (basic_block bb, void *i)
   new_bb->frequency = bb->frequency;
   new_bb->discriminator = bb->discriminator;
 
-  if (dom_info_available_p (CDI_DOMINATORS))
+  if (dom_info_available_p (cfun, CDI_DOMINATORS))
     {
-      redirect_immediate_dominators (CDI_DOMINATORS, bb, new_bb);
-      set_immediate_dominator (CDI_DOMINATORS, new_bb, bb);
+      redirect_immediate_dominators (cfun, CDI_DOMINATORS, bb, new_bb);
+      set_immediate_dominator (cfun, CDI_DOMINATORS, new_bb, bb);
     }
 
   if (current_loops != NULL)
@@ -598,10 +598,10 @@  delete_basic_block (basic_block bb)
   while (EDGE_COUNT (bb->succs) != 0)
     remove_edge (EDGE_SUCC (bb, 0));
 
-  if (dom_info_available_p (CDI_DOMINATORS))
-    delete_from_dominance_info (CDI_DOMINATORS, bb);
-  if (dom_info_available_p (CDI_POST_DOMINATORS))
-    delete_from_dominance_info (CDI_POST_DOMINATORS, bb);
+  if (dom_info_available_p (cfun, CDI_DOMINATORS))
+    delete_from_dominance_info (cfun, CDI_DOMINATORS, bb);
+  if (dom_info_available_p (cfun, CDI_POST_DOMINATORS))
+    delete_from_dominance_info (cfun, CDI_POST_DOMINATORS, bb);
 
   /* Remove the basic block from the array.  */
   expunge_block (bb);
@@ -639,10 +639,10 @@  split_edge (edge e)
       single_succ_edge (ret)->flags |= EDGE_IRREDUCIBLE_LOOP;
     }
 
-  if (dom_info_available_p (CDI_DOMINATORS))
-    set_immediate_dominator (CDI_DOMINATORS, ret, single_pred (ret));
+  if (dom_info_available_p (cfun, CDI_DOMINATORS))
+    set_immediate_dominator (cfun, CDI_DOMINATORS, ret, single_pred (ret));
 
-  if (dom_info_state (CDI_DOMINATORS) >= DOM_NO_FAST_QUERY)
+  if (dom_info_state (cfun, CDI_DOMINATORS) >= DOM_NO_FAST_QUERY)
     {
       /* There are two cases:
 
@@ -662,13 +662,14 @@  split_edge (edge e)
 	      if (f == single_succ_edge (ret))
 		continue;
 
-	      if (!dominated_by_p (CDI_DOMINATORS, f->src,
+	      if (!dominated_by_p (cfun, CDI_DOMINATORS, f->src,
 				   single_succ (ret)))
 		break;
 	    }
 
 	  if (!f)
-	    set_immediate_dominator (CDI_DOMINATORS, single_succ (ret), ret);
+	    set_immediate_dominator (cfun, CDI_DOMINATORS,
+				     single_succ (ret), ret);
 	}
     }
 
@@ -700,10 +701,10 @@  create_basic_block_1 (void *head, void *end, basic_block after)
 
   ret = cfg_hooks->create_basic_block (head, end, after);
 
-  if (dom_info_available_p (CDI_DOMINATORS))
-    add_to_dominance_info (CDI_DOMINATORS, ret);
-  if (dom_info_available_p (CDI_POST_DOMINATORS))
-    add_to_dominance_info (CDI_POST_DOMINATORS, ret);
+  if (dom_info_available_p (cfun, CDI_DOMINATORS))
+    add_to_dominance_info (cfun, CDI_DOMINATORS, ret);
+  if (dom_info_available_p (cfun, CDI_POST_DOMINATORS))
+    add_to_dominance_info (cfun, CDI_POST_DOMINATORS, ret);
 
   return ret;
 }
@@ -827,13 +828,13 @@  merge_blocks (basic_block a, basic_block b)
   /* B hasn't quite yet ceased to exist.  Attempt to prevent mishap.  */
   b->preds = b->succs = NULL;
 
-  if (dom_info_available_p (CDI_DOMINATORS))
-    redirect_immediate_dominators (CDI_DOMINATORS, b, a);
+  if (dom_info_available_p (cfun, CDI_DOMINATORS))
+    redirect_immediate_dominators (cfun, CDI_DOMINATORS, b, a);
 
-  if (dom_info_available_p (CDI_DOMINATORS))
-    delete_from_dominance_info (CDI_DOMINATORS, b);
-  if (dom_info_available_p (CDI_POST_DOMINATORS))
-    delete_from_dominance_info (CDI_POST_DOMINATORS, b);
+  if (dom_info_available_p (cfun, CDI_DOMINATORS))
+    delete_from_dominance_info (cfun, CDI_DOMINATORS, b);
+  if (dom_info_available_p (cfun, CDI_POST_DOMINATORS))
+    delete_from_dominance_info (cfun, CDI_POST_DOMINATORS, b);
 
   expunge_block (b);
 }
@@ -896,13 +897,13 @@  make_forwarder_block (basic_block bb, bool (*redirect_edge_p) (edge),
         }
     }
 
-  if (dom_info_available_p (CDI_DOMINATORS))
+  if (dom_info_available_p (cfun, CDI_DOMINATORS))
     {
       vec<basic_block> doms_to_fix;
       doms_to_fix.create (2);
       doms_to_fix.quick_push (dummy);
       doms_to_fix.quick_push (bb);
-      iterate_fix_dominators (CDI_DOMINATORS, doms_to_fix, false);
+      iterate_fix_dominators (cfun, CDI_DOMINATORS, doms_to_fix, false);
       doms_to_fix.release ();
     }
 
@@ -1014,8 +1015,8 @@  force_nonfallthru (edge e)
   ret = cfg_hooks->force_nonfallthru (e);
   if (ret != NULL)
     {
-      if (dom_info_available_p (CDI_DOMINATORS))
-	set_immediate_dominator (CDI_DOMINATORS, ret, src);
+      if (dom_info_available_p (cfun, CDI_DOMINATORS))
+	set_immediate_dominator (cfun, CDI_DOMINATORS, ret, src);
 
       if (current_loops != NULL)
 	{
@@ -1370,7 +1371,7 @@  copy_bbs (basic_block *bbs, unsigned n, basic_block *new_bbs,
 	  if (dom_bb->flags & BB_DUPLICATED)
 	    {
 	      dom_bb = get_bb_copy (dom_bb);
-	      set_immediate_dominator (CDI_DOMINATORS, new_bb, dom_bb);
+	      set_immediate_dominator (cfun, CDI_DOMINATORS, new_bb, dom_bb);
 	    }
 	}
     }
diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c
index b8a1244..742ffcd 100644
--- a/gcc/cfgloop.c
+++ b/gcc/cfgloop.c
@@ -97,7 +97,7 @@  get_loop_latch_edges (const struct loop *loop)
 
   FOR_EACH_EDGE (e, ei, loop->header->preds)
     {
-      if (dominated_by_p (CDI_DOMINATORS, e->src, loop->header))
+      if (dominated_by_p (cfun, CDI_DOMINATORS, e->src, loop->header))
 	ret.safe_push (e);
     }
 
@@ -235,7 +235,7 @@  flow_loop_nodes_find (basic_block header, struct loop *loop)
   FOR_EACH_EDGE (latch, latch_ei, loop->header->preds)
     {
       if (latch->src->loop_father == loop
-	  || !dominated_by_p (CDI_DOMINATORS, latch->src, loop->header))
+	  || !dominated_by_p (cfun, CDI_DOMINATORS, latch->src, loop->header))
 	continue;
 
       num_nodes++;
@@ -384,7 +384,7 @@  bb_loop_header_p (basic_block header)
     {
       basic_block latch = e->src;
       if (latch != ENTRY_BLOCK_PTR_FOR_FN (cfun)
-	  && dominated_by_p (CDI_DOMINATORS, latch, header))
+	  && dominated_by_p (cfun, CDI_DOMINATORS, latch, header))
 	return true;
     }
 
@@ -408,7 +408,7 @@  flow_loops_find (struct loops *loops)
   unsigned i;
 
   /* Ensure that the dominators are computed.  */
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_DOMINATORS);
 
   if (!loops)
     {
@@ -582,12 +582,12 @@  find_subloop_latch_edge_by_ivs (struct loop *loop ATTRIBUTE_UNUSED, vec<edge> la
 
   /* Find the candidate for the latch edge.  */
   for (i = 1; latches.iterate (i, &e); i++)
-    if (dominated_by_p (CDI_DOMINATORS, latch->src, e->src))
+    if (dominated_by_p (cfun, CDI_DOMINATORS, latch->src, e->src))
       latch = e;
 
   /* Verify that it dominates all the latch edges.  */
   FOR_EACH_VEC_ELT (latches, i, e)
-    if (!dominated_by_p (CDI_DOMINATORS, e->src, latch->src))
+    if (!dominated_by_p (cfun, CDI_DOMINATORS, e->src, latch->src))
       return NULL;
 
   /* Check for a phi node that would deny that this is a latch edge of
@@ -793,7 +793,7 @@  glb_enum_p (const_basic_block bb, const void *glb_loop)
 {
   const struct loop *const loop = (const struct loop *) glb_loop;
   return (bb != loop->header
-	  && dominated_by_p (CDI_DOMINATORS, bb, loop->header));
+	  && dominated_by_p (cfun, CDI_DOMINATORS, bb, loop->header));
 }
 
 /* Gets basic blocks of a LOOP.  Header is the 0-th block, rest is in dfs
@@ -859,7 +859,7 @@  fill_sons_in_loop (const struct loop *loop, basic_block bb,
       if (!flow_bb_inside_loop_p (loop, son))
 	continue;
 
-      if (dominated_by_p (CDI_DOMINATORS, loop->latch, son))
+      if (dominated_by_p (cfun, CDI_DOMINATORS, loop->latch, son))
 	{
 	  postpone = son;
 	  continue;
@@ -1317,7 +1317,7 @@  verify_loop_structure (void)
   edge e;
   unsigned num = number_of_loops (cfun);
   struct loop_exit *exit, *mexit;
-  bool dom_available = dom_info_available_p (CDI_DOMINATORS);
+  bool dom_available = dom_info_available_p (cfun, CDI_DOMINATORS);
   sbitmap visited;
 
   if (loops_state_satisfies_p (LOOPS_NEED_FIXUP))
@@ -1328,9 +1328,9 @@  verify_loop_structure (void)
 
   /* We need up-to-date dominators, compute or verify them.  */
   if (!dom_available)
-    calculate_dominance_info (CDI_DOMINATORS);
+    calculate_dominance_info (cfun, CDI_DOMINATORS);
   else
-    verify_dominators (CDI_DOMINATORS);
+    verify_dominators (cfun, CDI_DOMINATORS);
 
   /* Check the loop tree root.  */
   if (current_loops->tree_root->header != ENTRY_BLOCK_PTR_FOR_FN (cfun)
@@ -1437,7 +1437,7 @@  verify_loop_structure (void)
 	      error ("loop %d%'s latch does not have an edge to its header", i);
 	      err = 1;
 	    }
-	  if (!dominated_by_p (CDI_DOMINATORS, loop->latch, loop->header))
+	  if (!dominated_by_p (cfun, CDI_DOMINATORS, loop->latch, loop->header))
 	    {
 	      error ("loop %d%'s latch is not dominated by its header", i);
 	      err = 1;
@@ -1647,7 +1647,7 @@  verify_loop_structure (void)
   gcc_assert (!err);
 
   if (!dom_available)
-    free_dominance_info (CDI_DOMINATORS);
+    free_dominance_info (cfun, CDI_DOMINATORS);
 }
 
 /* Returns latch edge of LOOP.  */
diff --git a/gcc/cfgloopanal.c b/gcc/cfgloopanal.c
index b178650..8a5e326 100644
--- a/gcc/cfgloopanal.c
+++ b/gcc/cfgloopanal.c
@@ -50,7 +50,7 @@  bool
 just_once_each_iteration_p (const struct loop *loop, const_basic_block bb)
 {
   /* It must be executed at least once each iteration.  */
-  if (!dominated_by_p (CDI_DOMINATORS, loop->latch, bb))
+  if (!dominated_by_p (cfun, CDI_DOMINATORS, loop->latch, bb))
     return false;
 
   /* And just once.  */
diff --git a/gcc/cfgloopmanip.c b/gcc/cfgloopmanip.c
index 1f9a2b3..8245dd9 100644
--- a/gcc/cfgloopmanip.c
+++ b/gcc/cfgloopmanip.c
@@ -48,7 +48,7 @@  static void fix_bb_placements (basic_block, bool *, bitmap);
 static bool
 rpe_enum_p (const_basic_block bb, const void *data)
 {
-  return dominated_by_p (CDI_DOMINATORS, bb, (const_basic_block) data);
+  return dominated_by_p (cfun, CDI_DOMINATORS, bb, (const_basic_block) data);
 }
 
 /* Remove basic blocks BBS.  NBBS is the number of the basic blocks.  */
@@ -338,7 +338,7 @@  remove_path (edge e)
   for (l = e->src->loop_father; loop_outer (l); l = f)
     {
       f = loop_outer (l);
-      if (dominated_by_p (CDI_DOMINATORS, l->latch, e->dest))
+      if (dominated_by_p (cfun, CDI_DOMINATORS, l->latch, e->dest))
         unloop (l, &irred_invalidated, NULL);
     }
 
@@ -405,14 +405,14 @@  remove_path (edge e)
       for (ldom = first_dom_son (CDI_DOMINATORS, bb);
 	   ldom;
 	   ldom = next_dom_son (CDI_DOMINATORS, ldom))
-	if (!dominated_by_p (CDI_DOMINATORS, from, ldom))
+	if (!dominated_by_p (cfun, CDI_DOMINATORS, from, ldom))
 	  dom_bbs.safe_push (ldom);
     }
 
   free (seen);
 
   /* Recount dominators.  */
-  iterate_fix_dominators (CDI_DOMINATORS, dom_bbs, true);
+  iterate_fix_dominators (cfun, CDI_DOMINATORS, dom_bbs, true);
   dom_bbs.release ();
   free (bord_bbs);
 
@@ -643,7 +643,7 @@  update_dominators_in_loop (struct loop *loop)
 	  }
     }
 
-  iterate_fix_dominators (CDI_DOMINATORS, dom_bbs, false);
+  iterate_fix_dominators (cfun, CDI_DOMINATORS, dom_bbs, false);
   free (body);
   free (seen);
   dom_bbs.release ();
@@ -717,15 +717,15 @@  create_empty_if_region_on_edge (edge entry_edge, tree condition)
   e_false->flags &= ~EDGE_FALLTHRU;
   e_false->flags |= EDGE_FALSE_VALUE;
 
-  set_immediate_dominator (CDI_DOMINATORS, cond_bb, entry_edge->src);
-  set_immediate_dominator (CDI_DOMINATORS, true_bb, cond_bb);
-  set_immediate_dominator (CDI_DOMINATORS, false_bb, cond_bb);
-  set_immediate_dominator (CDI_DOMINATORS, join_bb, cond_bb);
+  set_immediate_dominator (cfun, CDI_DOMINATORS, cond_bb, entry_edge->src);
+  set_immediate_dominator (cfun, CDI_DOMINATORS, true_bb, cond_bb);
+  set_immediate_dominator (cfun, CDI_DOMINATORS, false_bb, cond_bb);
+  set_immediate_dominator (cfun, CDI_DOMINATORS, join_bb, cond_bb);
 
   exit_edge = single_succ_edge (join_bb);
 
   if (single_pred_p (exit_edge->dest))
-    set_immediate_dominator (CDI_DOMINATORS, exit_edge->dest, join_bb);
+    set_immediate_dominator (cfun, CDI_DOMINATORS, exit_edge->dest, join_bb);
 
   return exit_edge;
 }
@@ -791,9 +791,9 @@  create_empty_loop_on_edge (edge entry_edge,
   redirect_edge_succ_nodup (single_succ_edge (loop_latch), loop_header);
 
   /* Set immediate dominator information.  */
-  set_immediate_dominator (CDI_DOMINATORS, loop_header, pred_bb);
-  set_immediate_dominator (CDI_DOMINATORS, loop_latch, loop_header);
-  set_immediate_dominator (CDI_DOMINATORS, succ_bb, loop_header);
+  set_immediate_dominator (cfun, CDI_DOMINATORS, loop_header, pred_bb);
+  set_immediate_dominator (cfun, CDI_DOMINATORS, loop_latch, loop_header);
+  set_immediate_dominator (cfun, CDI_DOMINATORS, succ_bb, loop_header);
 
   /* Initialize a loop structure and put it in a loop hierarchy.  */
   loop = alloc_loop ();
@@ -891,11 +891,11 @@  loopify (edge latch_edge, edge header_edge,
       loop_redirect_edge (false_edge, loop->header);
 
       /* Update dominators.  */
-      set_immediate_dominator (CDI_DOMINATORS, switch_bb, pred_bb);
-      set_immediate_dominator (CDI_DOMINATORS, loop->header, switch_bb);
+      set_immediate_dominator (cfun, CDI_DOMINATORS, switch_bb, pred_bb);
+      set_immediate_dominator (cfun, CDI_DOMINATORS, loop->header, switch_bb);
     }
 
-  set_immediate_dominator (CDI_DOMINATORS, succ_bb, switch_bb);
+  set_immediate_dominator (cfun, CDI_DOMINATORS, succ_bb, switch_bb);
 
   /* Compute new loop.  */
   add_loop (loop, outer);
@@ -1230,7 +1230,7 @@  duplicate_loop_to_header_edge (struct loop *loop, edge e,
 	  for (i = 0; i < n; i++)
 	    {
 	      if (bbs[i] != orig->src
-		  && dominated_by_p (CDI_DOMINATORS, bbs[i], orig->src))
+		  && dominated_by_p (cfun, CDI_DOMINATORS, bbs[i], orig->src))
 		bitmap_set_bit (bbs_to_scale, i);
 	    }
 	}
@@ -1360,7 +1360,7 @@  duplicate_loop_to_header_edge (struct loop *loop, edge e,
 	  redirect_edge_and_branch_force (latch_edge, new_bbs[0]);
 	  redirect_edge_and_branch_force (new_spec_edges[SE_LATCH],
 					  loop->header);
-	  set_immediate_dominator (CDI_DOMINATORS, new_bbs[0], latch);
+	  set_immediate_dominator (cfun, CDI_DOMINATORS, new_bbs[0], latch);
 	  latch = loop->latch = new_bbs[n - 1];
 	  e = latch_edge = new_spec_edges[SE_LATCH];
 	}
@@ -1369,7 +1369,7 @@  duplicate_loop_to_header_edge (struct loop *loop, edge e,
 	  redirect_edge_and_branch_force (new_spec_edges[SE_LATCH],
 					  loop->header);
 	  redirect_edge_and_branch_force (e, new_bbs[0]);
-	  set_immediate_dominator (CDI_DOMINATORS, new_bbs[0], e->src);
+	  set_immediate_dominator (cfun, CDI_DOMINATORS, new_bbs[0], e->src);
 	  e = new_spec_edges[SE_LATCH];
 	}
 
@@ -1429,7 +1429,7 @@  duplicate_loop_to_header_edge (struct loop *loop, edge e,
 
   /* Update the original loop.  */
   if (!is_latch)
-    set_immediate_dominator (CDI_DOMINATORS, e->dest, e->src);
+    set_immediate_dominator (cfun, CDI_DOMINATORS, e->dest, e->src);
   if (flags & DLTHE_FLAG_UPDATE_FREQ)
     {
       scale_bbs_frequencies_int (bbs, n, scale_main, REG_BR_PROB_BASE);
@@ -1453,7 +1453,7 @@  duplicate_loop_to_header_edge (struct loop *loop, edge e,
 	    continue;
 	  dom_bb = nearest_common_dominator (
 			CDI_DOMINATORS, first_active[i], first_active_latch);
-	  set_immediate_dominator (CDI_DOMINATORS, dominated, dom_bb);
+	  set_immediate_dominator (cfun, CDI_DOMINATORS, dominated, dom_bb);
 	}
       dom_bbs.release ();
     }
@@ -1664,8 +1664,8 @@  lv_adjust_loop_entry_edge (basic_block first_head, basic_block second_head,
   e1->count = apply_probability (e->count, e1->probability);
   e->count = apply_probability (e->count, e->probability);
 
-  set_immediate_dominator (CDI_DOMINATORS, first_head, new_head);
-  set_immediate_dominator (CDI_DOMINATORS, second_head, new_head);
+  set_immediate_dominator (cfun, CDI_DOMINATORS, first_head, new_head);
+  set_immediate_dominator (cfun, CDI_DOMINATORS, second_head, new_head);
 
   /* Adjust loop header phi nodes.  */
   lv_adjust_loop_header_phi (first_head, second_head, new_head, e1);
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index 15ce8a7..b882ac9 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -2317,10 +2317,10 @@  find_partition_fixes (bool flag_only)
   if (bbs_in_cold_partition.is_empty ())
     return vNULL;
 
-  bool dom_calculated_here = !dom_info_available_p (CDI_DOMINATORS);
+  bool dom_calculated_here = !dom_info_available_p (cfun, CDI_DOMINATORS);
 
   if (dom_calculated_here)
-    calculate_dominance_info (CDI_DOMINATORS);
+    calculate_dominance_info (cfun, CDI_DOMINATORS);
 
   while (! bbs_in_cold_partition.is_empty  ())
     {
@@ -2348,7 +2348,7 @@  find_partition_fixes (bool flag_only)
     }
 
   if (dom_calculated_here)
-    free_dominance_info (CDI_DOMINATORS);
+    free_dominance_info (cfun, CDI_DOMINATORS);
 
   return bbs_to_fix;
 }
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 22a9852..b4bc359 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -1704,8 +1704,8 @@  release_function_body (tree decl)
 	    }
 	  if (cfun->cfg)
 	    {
-	      gcc_assert (!dom_info_available_p (CDI_DOMINATORS));
-	      gcc_assert (!dom_info_available_p (CDI_POST_DOMINATORS));
+	      gcc_assert (!dom_info_available_p (cfun, CDI_DOMINATORS));
+	      gcc_assert (!dom_info_available_p (cfun, CDI_POST_DOMINATORS));
 	      clear_edges ();
 	      cfun->cfg = NULL;
 	    }
@@ -3322,8 +3322,8 @@  cgraph_node::get_body (void)
       push_cfun (DECL_STRUCT_FUNCTION (decl));
       execute_all_ipa_transforms ();
       cgraph_edge::rebuild_edges ();
-      free_dominance_info (CDI_DOMINATORS);
-      free_dominance_info (CDI_POST_DOMINATORS);
+      free_dominance_info (cfun, CDI_DOMINATORS);
+      free_dominance_info (cfun, CDI_POST_DOMINATORS);
       pop_cfun ();
       updated = true;
 
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index a95ce9e..071478b 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -305,6 +305,7 @@  symbol_table::process_new_functions (void)
     {
       cgraph_node *node = cgraph_new_nodes[i];
       fndecl = node->decl;
+      function *fn = DECL_STRUCT_FUNCTION (fndecl);
       switch (state)
 	{
 	case CONSTRUCTION:
@@ -326,14 +327,14 @@  symbol_table::process_new_functions (void)
 	  gimple_register_cfg_hooks ();
 	  if (!node->analyzed)
 	    node->analyze ();
-	  push_cfun (DECL_STRUCT_FUNCTION (fndecl));
+	  push_cfun (fn);
 	  if ((state == IPA_SSA || state == IPA_SSA_AFTER_INLINING)
-	      && !gimple_in_ssa_p (DECL_STRUCT_FUNCTION (fndecl)))
+	      && !gimple_in_ssa_p (fn))
 	    g->get_passes ()->execute_early_local_passes ();
 	  else if (inline_summaries != NULL)
 	    compute_inline_parameters (node, true);
-	  free_dominance_info (CDI_POST_DOMINATORS);
-	  free_dominance_info (CDI_DOMINATORS);
+	  free_dominance_info (fn, CDI_POST_DOMINATORS);
+	  free_dominance_info (fn, CDI_DOMINATORS);
 	  pop_cfun ();
 	  call_cgraph_insertion_hooks (node);
 	  break;
@@ -645,8 +646,8 @@  cgraph_node::analyze (void)
 	  gimple_register_cfg_hooks ();
 	  bitmap_obstack_initialize (NULL);
 	  execute_pass_list (cfun, g->get_passes ()->all_lowering_passes);
-	  free_dominance_info (CDI_POST_DOMINATORS);
-	  free_dominance_info (CDI_DOMINATORS);
+	  free_dominance_info (cfun, CDI_POST_DOMINATORS);
+	  free_dominance_info (cfun, CDI_DOMINATORS);
 	  compact_blocks ();
 	  bitmap_obstack_release (NULL);
 	  lowered = true;
@@ -1827,7 +1828,7 @@  cgraph_node::expand_thunk (bool output_asm_thunks, bool force_gimple_thunk)
 #ifdef ENABLE_CHECKING
       verify_flow_info ();
 #endif
-      free_dominance_info (CDI_DOMINATORS);
+      free_dominance_info (cfun, CDI_DOMINATORS);
 
       /* Since we want to emit the thunk, we explicitly mark its name as
 	 referenced.  */
diff --git a/gcc/compare-elim.c b/gcc/compare-elim.c
index b65d09e..1f72fc6 100644
--- a/gcc/compare-elim.c
+++ b/gcc/compare-elim.c
@@ -436,13 +436,13 @@  find_comparison_dom_walker::before_dom_children (basic_block bb)
 static void
 find_comparisons (void)
 {
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_DOMINATORS);
 
   find_comparison_dom_walker (CDI_DOMINATORS)
     .walk (cfun->cfg->x_entry_block_ptr);
 
   clear_aux_for_blocks ();
-  free_dominance_info (CDI_DOMINATORS);
+  free_dominance_info (cfun, CDI_DOMINATORS);
 }
 
 /* Select an alternate CC_MODE for a comparison insn comparing A and B.
diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index 238b9b0..6c35ba6 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -15475,7 +15475,7 @@  r10k_simplify_address (rtx x, rtx_insn *insn)
 		  && DF_REF_BB (def) == ENTRY_BLOCK_PTR_FOR_FN (cfun))
 		newx = virtual_incoming_args_rtx;
 	    }
-	  else if (dominated_by_p (CDI_DOMINATORS, DF_REF_BB (use),
+	  else if (dominated_by_p (cfun, CDI_DOMINATORS, DF_REF_BB (use),
 				   DF_REF_BB (def)))
 	    {
 	      /* Make sure that DEF_INSN is a single set of REG.  */
@@ -15692,7 +15692,7 @@  r10k_insert_cache_barriers (void)
     }
 
   /* Calculate dominators.  */
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_DOMINATORS);
 
   /* Bit X of PROTECTED_BBS is set if the last operation in basic block
      X is protected by a cache barrier.  */
@@ -15768,7 +15768,7 @@  r10k_insert_cache_barriers (void)
 
   sbitmap_free (protected_bbs);
 
-  free_dominance_info (CDI_DOMINATORS);
+  free_dominance_info (cfun, CDI_DOMINATORS);
 }
 
 /* If INSN is a call, return the underlying CALL expr.  Return NULL_RTX
diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index 5814694..60977a4 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -9548,9 +9548,9 @@  s390_optimize_nonescaping_tx (void)
   if (tbegin_bb == NULL || tend_bb == NULL)
     return;
 
-  calculate_dominance_info (CDI_POST_DOMINATORS);
-  result = dominated_by_p (CDI_POST_DOMINATORS, tbegin_bb, tend_bb);
-  free_dominance_info (CDI_POST_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_POST_DOMINATORS);
+  result = dominated_by_p (cfun, CDI_POST_DOMINATORS, tbegin_bb, tend_bb);
+  free_dominance_info (cfun, CDI_POST_DOMINATORS);
 
   if (!result)
     return;
diff --git a/gcc/dominance.c b/gcc/dominance.c
index 3c4f228..c8d655d 100644
--- a/gcc/dominance.c
+++ b/gcc/dominance.c
@@ -613,73 +613,73 @@  assign_dfs_numbers (et_node *node, int *num)
    static dominator tree.  */
 
 static void
-compute_dom_fast_query (cdi_direction dir)
+compute_dom_fast_query (function *fn, cdi_direction dir)
 {
   int num = 0;
   basic_block bb;
   unsigned int dir_index = dom_convert_dir_to_idx (dir);
 
-  gcc_checking_assert (dom_info_available_p (dir));
+  gcc_checking_assert (dom_info_available_p (fn, dir));
 
-  if (dom_computed[dir_index] == DOM_OK)
+  if (fn->cfg->x_dom_computed[dir_index] == DOM_OK)
     return;
 
-  FOR_ALL_BB_FN (bb, cfun)
+  FOR_ALL_BB_FN (bb, fn)
     {
       if (!bb->dom[dir_index]->father)
 	assign_dfs_numbers (bb->dom[dir_index], &num);
     }
 
-  dom_computed[dir_index] = DOM_OK;
+  fn->cfg->x_dom_computed[dir_index] = DOM_OK;
 }
 
 /* The main entry point into this module.  DIR is set depending on whether
    we want to compute dominators or postdominators.  */
 
 void
-calculate_dominance_info (cdi_direction dir)
+calculate_dominance_info (function *fn, cdi_direction dir)
 {
   unsigned int dir_index = dom_convert_dir_to_idx (dir);
   bool reverse = (dir == CDI_POST_DOMINATORS) ? true : false;
 
-  if (dom_computed[dir_index] == DOM_OK)
+  if (fn->cfg->x_dom_computed[dir_index] == DOM_OK)
     {
       if (ENABLE_CHECKING)
-	verify_dominators (dir);
+	verify_dominators (fn, dir);
       return;
     }
 
   timevar_push (TV_DOMINANCE);
-  if (!dom_info_available_p (cfun, dir))
+  if (!dom_info_available_p (fn, dir))
     {
-      gcc_assert (!n_bbs_in_dom_tree[dir_index]);
+      gcc_assert (!fn->cfg->x_n_bbs_in_dom_tree[dir_index]);
 
       basic_block b;
-      FOR_ALL_BB_FN (b, cfun)
+      FOR_ALL_BB_FN (b, fn)
 	{
 	  b->dom[dir_index] = et_new_tree (b);
 	}
-      n_bbs_in_dom_tree[dir_index] = n_basic_blocks_for_fn (cfun);
+      fn->cfg->x_n_bbs_in_dom_tree[dir_index] = n_basic_blocks_for_fn (fn);
 
-      dom_info di (cfun, dir);
+      dom_info di (fn, dir);
       di.calc_dfs_tree (reverse);
       di.calc_idoms (reverse);
 
-      FOR_EACH_BB_FN (b, cfun)
+      FOR_EACH_BB_FN (b, fn)
 	{
 	  if (basic_block d = di.get_idom (b))
 	    et_set_father (b->dom[dir_index], d->dom[dir_index]);
 	}
 
-      dom_computed[dir_index] = DOM_NO_FAST_QUERY;
+      fn->cfg->x_dom_computed[dir_index] = DOM_NO_FAST_QUERY;
     }
   else
     {
       if (ENABLE_CHECKING)
-	verify_dominators (dir);
+	verify_dominators (fn, dir);
     }
 
-  compute_dom_fast_query (dir);
+  compute_dom_fast_query (fn, dir);
 
   timevar_pop (TV_DOMINANCE);
 }
@@ -706,12 +706,6 @@  free_dominance_info (function *fn, cdi_direction dir)
   fn->cfg->x_dom_computed[dir_index] = DOM_NONE;
 }
 
-void
-free_dominance_info (cdi_direction dir)
-{
-  free_dominance_info (cfun, dir);
-}
-
 /* Return the immediate dominator of basic block BB.  */
 basic_block
 get_immediate_dominator (cdi_direction dir, basic_block bb)
@@ -719,8 +713,6 @@  get_immediate_dominator (cdi_direction dir, basic_block bb)
   unsigned int dir_index = dom_convert_dir_to_idx (dir);
   et_node *node = bb->dom[dir_index];
 
-  gcc_checking_assert (dom_computed[dir_index]);
-
   if (!node->father)
     return NULL;
 
@@ -730,13 +722,13 @@  get_immediate_dominator (cdi_direction dir, basic_block bb)
 /* Set the immediate dominator of the block possibly removing
    existing edge.  NULL can be used to remove any edge.  */
 void
-set_immediate_dominator (cdi_direction dir, basic_block bb,
+set_immediate_dominator (function *fn, cdi_direction dir, basic_block bb,
 			 basic_block dominated_by)
 {
   unsigned int dir_index = dom_convert_dir_to_idx (dir);
   et_node *node = bb->dom[dir_index];
 
-  gcc_checking_assert (dom_computed[dir_index]);
+  gcc_checking_assert (fn->cfg->x_dom_computed[dir_index]);
 
   if (node->father)
     {
@@ -748,8 +740,8 @@  set_immediate_dominator (cdi_direction dir, basic_block bb,
   if (dominated_by)
     et_set_father (node, dominated_by->dom[dir_index]);
 
-  if (dom_computed[dir_index] == DOM_OK)
-    dom_computed[dir_index] = DOM_NO_FAST_QUERY;
+  if (fn->cfg->x_dom_computed[dir_index] == DOM_OK)
+    fn->cfg->x_dom_computed[dir_index] = DOM_NO_FAST_QUERY;
 }
 
 /* Returns the list of basic blocks immediately dominated by BB, in the
@@ -761,8 +753,6 @@  get_dominated_by (cdi_direction dir, basic_block bb)
   et_node *node = bb->dom[dir_index], *son = node->son;
   vec<basic_block> bbs = vNULL;
 
-  gcc_checking_assert (dom_computed[dir_index]);
-
   if (!son)
     return vNULL;
 
@@ -835,14 +825,14 @@  get_all_dominated_blocks (cdi_direction dir, basic_block bb)
 
 /* Redirect all edges pointing to BB to TO.  */
 void
-redirect_immediate_dominators (cdi_direction dir, basic_block bb,
+redirect_immediate_dominators (function *fn, cdi_direction dir, basic_block bb,
 			       basic_block to)
 {
   unsigned int dir_index = dom_convert_dir_to_idx (dir);
   et_node *bb_node = bb->dom[dir_index],
 	  *to_node = to->dom[dir_index];
 
-  gcc_checking_assert (dom_computed[dir_index]);
+  gcc_checking_assert (fn->cfg->x_dom_computed[dir_index]);
 
   if (!bb_node->son)
     return;
@@ -853,8 +843,8 @@  redirect_immediate_dominators (cdi_direction dir, basic_block bb,
       et_set_father (son, to_node);
     }
 
-  if (dom_computed[dir_index] == DOM_OK)
-    dom_computed[dir_index] = DOM_NO_FAST_QUERY;
+  if (fn->cfg->x_dom_computed[dir_index] == DOM_OK)
+    fn->cfg->x_dom_computed[dir_index] = DOM_NO_FAST_QUERY;
 }
 
 /* Find first basic block in the tree dominating both BB1 and BB2.  */
@@ -863,8 +853,6 @@  nearest_common_dominator (cdi_direction dir, basic_block bb1, basic_block bb2)
 {
   unsigned int dir_index = dom_convert_dir_to_idx (dir);
 
-  gcc_checking_assert (dom_computed[dir_index]);
-
   if (!bb1)
     return bb2;
   if (!bb2)
@@ -878,16 +866,17 @@  nearest_common_dominator (cdi_direction dir, basic_block bb1, basic_block bb2)
    using dominance direction DIR.  */
 
 basic_block
-nearest_common_dominator_for_set (cdi_direction dir, bitmap blocks)
+nearest_common_dominator_for_set (function *fn, cdi_direction dir,
+				  bitmap blocks)
 {
   unsigned i;
   bitmap_iterator bi;
 
   unsigned first = bitmap_first_set_bit (blocks);
-  basic_block dom = BASIC_BLOCK_FOR_FN (cfun, first);
+  basic_block dom = BASIC_BLOCK_FOR_FN (fn, first);
   EXECUTE_IF_SET_IN_BITMAP (blocks, 0, i, bi)
-    if (dom != BASIC_BLOCK_FOR_FN (cfun, i))
-      dom = nearest_common_dominator (dir, dom, BASIC_BLOCK_FOR_FN (cfun, i));
+    if (dom != BASIC_BLOCK_FOR_FN (fn, i))
+      dom = nearest_common_dominator (dir, dom, BASIC_BLOCK_FOR_FN (fn, i));
 
   return dom;
 }
@@ -969,14 +958,15 @@  nearest_common_dominator_for_set (cdi_direction dir, bitmap blocks)
 
 /* Return TRUE in case BB1 is dominated by BB2.  */
 bool
-dominated_by_p (cdi_direction dir, const_basic_block bb1, const_basic_block bb2)
+dominated_by_p (function *fn, cdi_direction dir, const_basic_block bb1,
+		const_basic_block bb2)
 {
   unsigned int dir_index = dom_convert_dir_to_idx (dir);
   et_node *n1 = bb1->dom[dir_index], *n2 = bb2->dom[dir_index];
 
-  gcc_checking_assert (dom_computed[dir_index]);
+  gcc_checking_assert (fn->cfg->x_dom_computed[dir_index]);
 
-  if (dom_computed[dir_index] == DOM_OK)
+  if (fn->cfg->x_dom_computed[dir_index] == DOM_OK)
     return (n1->dfs_num_in >= n2->dfs_num_in
   	    && n1->dfs_num_out <= n2->dfs_num_out);
 
@@ -991,7 +981,6 @@  bb_dom_dfs_in (cdi_direction dir, basic_block bb)
   unsigned int dir_index = dom_convert_dir_to_idx (dir);
   et_node *n = bb->dom[dir_index];
 
-  gcc_checking_assert (dom_computed[dir_index] == DOM_OK);
   return n->dfs_num_in;
 }
 
@@ -1003,25 +992,24 @@  bb_dom_dfs_out (cdi_direction dir, basic_block bb)
   unsigned int dir_index = dom_convert_dir_to_idx (dir);
   et_node *n = bb->dom[dir_index];
 
-  gcc_checking_assert (dom_computed[dir_index] == DOM_OK);
   return n->dfs_num_out;
 }
 
 /* Verify invariants of dominator structure.  */
 DEBUG_FUNCTION void
-verify_dominators (cdi_direction dir)
+verify_dominators (function *fn, cdi_direction dir)
 {
   bool reverse = (dir == CDI_POST_DOMINATORS) ? true : false;
 
-  gcc_assert (dom_info_available_p (dir));
+  gcc_assert (dom_info_available_p (fn, dir));
 
-  dom_info di (cfun, dir);
+  dom_info di (fn, dir);
   di.calc_dfs_tree (reverse);
   di.calc_idoms (reverse);
 
   bool err = false;
   basic_block bb;
-  FOR_EACH_BB_FN (bb, cfun)
+  FOR_EACH_BB_FN (bb, fn)
     {
       basic_block imm_bb = get_immediate_dominator (dir, bb);
       if (!imm_bb)
@@ -1048,20 +1036,17 @@  verify_dominators (cdi_direction dir)
    reaches a fixed point.  */
 
 basic_block
-recompute_dominator (cdi_direction dir, basic_block bb)
+recompute_dominator (function *fn, cdi_direction dir, basic_block bb)
 {
-  unsigned int dir_index = dom_convert_dir_to_idx (dir);
   basic_block dom_bb = NULL;
   edge e;
   edge_iterator ei;
 
-  gcc_checking_assert (dom_computed[dir_index]);
-
   if (dir == CDI_DOMINATORS)
     {
       FOR_EACH_EDGE (e, ei, bb->preds)
 	{
-	  if (!dominated_by_p (dir, e->src, bb))
+	  if (!dominated_by_p (fn, dir, e->src, bb))
 	    dom_bb = nearest_common_dominator (dir, dom_bb, e->src);
 	}
     }
@@ -1069,7 +1054,7 @@  recompute_dominator (cdi_direction dir, basic_block bb)
     {
       FOR_EACH_EDGE (e, ei, bb->succs)
 	{
-	  if (!dominated_by_p (dir, e->dest, bb))
+	  if (!dominated_by_p (fn, dir, e->dest, bb))
 	    dom_bb = nearest_common_dominator (dir, dom_bb, e->dest);
 	}
     }
@@ -1085,22 +1070,22 @@  recompute_dominator (cdi_direction dir, basic_block bb)
    from BBS.  */
 
 static void
-prune_bbs_to_update_dominators (vec<basic_block> bbs, bool conservative)
+prune_bbs_to_update_dominators (function *fn, vec<basic_block> bbs,
+				bool conservative)
 {
-  unsigned i;
   bool single;
   basic_block bb, dom = NULL;
   edge_iterator ei;
   edge e;
 
-  for (i = 0; bbs.iterate (i, &bb);)
+  for (unsigned i = 0; bbs.iterate (i, &bb);)
     {
-      if (bb == ENTRY_BLOCK_PTR_FOR_FN (cfun))
+      if (bb == ENTRY_BLOCK_PTR_FOR_FN (fn))
 	goto succeed;
 
       if (single_pred_p (bb))
 	{
-	  set_immediate_dominator (CDI_DOMINATORS, bb, single_pred (bb));
+	  set_immediate_dominator (fn, CDI_DOMINATORS, bb, single_pred (bb));
 	  goto succeed;
 	}
 
@@ -1111,7 +1096,7 @@  prune_bbs_to_update_dominators (vec<basic_block> bbs, bool conservative)
       dom = NULL;
       FOR_EACH_EDGE (e, ei, bb->preds)
 	{
-	  if (dominated_by_p (CDI_DOMINATORS, e->src, bb))
+	  if (dominated_by_p (fn, CDI_DOMINATORS, e->src, bb))
 	    continue;
 
 	  if (!dom)
@@ -1127,7 +1112,7 @@  prune_bbs_to_update_dominators (vec<basic_block> bbs, bool conservative)
       if (single
 	  || find_edge (dom, bb))
 	{
-	  set_immediate_dominator (CDI_DOMINATORS, bb, dom);
+	  set_immediate_dominator (fn, CDI_DOMINATORS, bb, dom);
 	  goto succeed;
 	}
 
@@ -1155,8 +1140,8 @@  root_of_dom_tree (cdi_direction dir, basic_block bb)
    blocks.  */
 
 static void
-determine_dominators_for_sons (graph *g, vec<basic_block> bbs, int y, int *son,
-			       int *brother)
+determine_dominators_for_sons (function *fn, graph *g, vec<basic_block> bbs,
+			       int y, int *son, int *brother)
 {
   if (son[y] == -1)
     return;
@@ -1165,8 +1150,8 @@  determine_dominators_for_sons (graph *g, vec<basic_block> bbs, int y, int *son,
     {
       /* Handle the common case Y has just one son specially.  */
       basic_block bb = bbs[son[y]];
-      set_immediate_dominator (CDI_DOMINATORS, bb,
-			       recompute_dominator (CDI_DOMINATORS, bb));
+      set_immediate_dominator (fn, CDI_DOMINATORS, bb,
+			       recompute_dominator (fn, CDI_DOMINATORS, bb));
       identify_vertices (g, y, son[y]);
       return;
     }
@@ -1184,7 +1169,7 @@  determine_dominators_for_sons (graph *g, vec<basic_block> bbs, int y, int *son,
 
   basic_block ybb;
   if (y == (int) bbs.length ())
-    ybb = ENTRY_BLOCK_PTR_FOR_FN (cfun);
+    ybb = ENTRY_BLOCK_PTR_FOR_FN (fn);
   else
     ybb = bbs[y];
 
@@ -1212,7 +1197,7 @@  determine_dominators_for_sons (graph *g, vec<basic_block> bbs, int y, int *son,
       FOR_EACH_VEC_ELT (sccs[i], si, a)
 	{
 	  basic_block bb = bbs[a];
-	  set_immediate_dominator (CDI_DOMINATORS, bb, dom);
+	  set_immediate_dominator (fn, CDI_DOMINATORS, bb, dom);
 	}
     }
 
@@ -1232,7 +1217,7 @@  determine_dominators_for_sons (graph *g, vec<basic_block> bbs, int y, int *son,
    a block of BBS in the current dominance tree dominate it.  */
 
 void
-iterate_fix_dominators (cdi_direction dir, vec<basic_block> bbs,
+iterate_fix_dominators (function *fn, cdi_direction dir, vec<basic_block> bbs,
 			bool conservative)
 {
   unsigned int dir_index = dom_convert_dir_to_idx (dir);
@@ -1244,7 +1229,8 @@  iterate_fix_dominators (cdi_direction dir, vec<basic_block> bbs,
      problems would be unused, untested, and almost surely buggy.  We keep
      the DIR argument for consistency with the rest of the dominator analysis
      interface.  */
-  gcc_checking_assert (dir == CDI_DOMINATORS && dom_computed[dir_index]);
+  gcc_checking_assert (dir == CDI_DOMINATORS
+		       && fn->cfg->x_dom_computed[dir_index]);
 
   /* The algorithm we use takes inspiration from the following papers, although
      the details are quite different from any of them:
@@ -1305,10 +1291,10 @@  iterate_fix_dominators (cdi_direction dir, vec<basic_block> bbs,
       unsigned i;
       basic_block bb;
       FOR_EACH_VEC_ELT (bbs, i, bb)
-	set_immediate_dominator (CDI_DOMINATORS, bb, NULL);
+	set_immediate_dominator (fn, CDI_DOMINATORS, bb, NULL);
     }
 
-  prune_bbs_to_update_dominators (bbs, conservative);
+  prune_bbs_to_update_dominators (fn, bbs, conservative);
   int n = bbs.length ();
 
   if (n == 0)
@@ -1317,8 +1303,8 @@  iterate_fix_dominators (cdi_direction dir, vec<basic_block> bbs,
   if (n == 1)
     {
       basic_block bb = bbs[0];
-      set_immediate_dominator (CDI_DOMINATORS, bb,
-			       recompute_dominator (CDI_DOMINATORS, bb));
+      set_immediate_dominator (fn, CDI_DOMINATORS, bb,
+			       recompute_dominator (fn, CDI_DOMINATORS, bb));
       return;
     }
 
@@ -1330,10 +1316,10 @@  iterate_fix_dominators (cdi_direction dir, vec<basic_block> bbs,
     {
       /* If the dominance tree is conservatively correct, split it now.  */
       if (conservative)
-	set_immediate_dominator (CDI_DOMINATORS, bb, NULL);
+	set_immediate_dominator (fn, CDI_DOMINATORS, bb, NULL);
       map.put (bb, i);
     }
-  map.put (ENTRY_BLOCK_PTR_FOR_FN (cfun), n);
+  map.put (ENTRY_BLOCK_PTR_FOR_FN (fn), n);
 
   graph *g = new_graph (n + 1);
   for (int y = 0; y < g->n_vertices; y++)
@@ -1372,7 +1358,7 @@  iterate_fix_dominators (cdi_direction dir, vec<basic_block> bbs,
     continue;
   while (y != -1)
     {
-      determine_dominators_for_sons (g, bbs, y, son, brother);
+      determine_dominators_for_sons (fn, g, bbs, y, son, brother);
 
       if (brother[y] != -1)
 	{
@@ -1392,33 +1378,34 @@  iterate_fix_dominators (cdi_direction dir, vec<basic_block> bbs,
 }
 
 void
-add_to_dominance_info (cdi_direction dir, basic_block bb)
+add_to_dominance_info (function *fn, cdi_direction dir, basic_block bb)
 {
   unsigned int dir_index = dom_convert_dir_to_idx (dir);
 
-  gcc_checking_assert (dom_computed[dir_index] && !bb->dom[dir_index]);
+  gcc_checking_assert (fn->cfg->x_dom_computed[dir_index]
+		       && !bb->dom[dir_index]);
 
-  n_bbs_in_dom_tree[dir_index]++;
+  fn->cfg->x_n_bbs_in_dom_tree[dir_index]++;
 
   bb->dom[dir_index] = et_new_tree (bb);
 
-  if (dom_computed[dir_index] == DOM_OK)
-    dom_computed[dir_index] = DOM_NO_FAST_QUERY;
+  if (fn->cfg->x_dom_computed[dir_index] == DOM_OK)
+    fn->cfg->x_dom_computed[dir_index] = DOM_NO_FAST_QUERY;
 }
 
 void
-delete_from_dominance_info (cdi_direction dir, basic_block bb)
+delete_from_dominance_info (function *fn, cdi_direction dir, basic_block bb)
 {
   unsigned int dir_index = dom_convert_dir_to_idx (dir);
 
-  gcc_checking_assert (dom_computed[dir_index]);
+  gcc_checking_assert (fn->cfg->x_dom_computed[dir_index]);
 
   et_free_tree (bb->dom[dir_index]);
   bb->dom[dir_index] = NULL;
-  n_bbs_in_dom_tree[dir_index]--;
+  fn->cfg->x_n_bbs_in_dom_tree[dir_index]--;
 
-  if (dom_computed[dir_index] == DOM_OK)
-    dom_computed[dir_index] = DOM_NO_FAST_QUERY;
+  if (fn->cfg->x_dom_computed[dir_index] == DOM_OK)
+    fn->cfg->x_dom_computed[dir_index] = DOM_NO_FAST_QUERY;
 }
 
 /* Returns the first son of BB in the dominator or postdominator tree
@@ -1457,20 +1444,14 @@  dom_info_state (function *fn, cdi_direction dir)
   return fn->cfg->x_dom_computed[dir_index];
 }
 
-dom_state
-dom_info_state (cdi_direction dir)
-{
-  return dom_info_state (cfun, dir);
-}
-
 /* Set the dominance availability for dominance info DIR to NEW_STATE.  */
 
 void
-set_dom_info_availability (cdi_direction dir, dom_state new_state)
+set_dom_info_availability (function *fn, cdi_direction dir, dom_state new_state)
 {
   unsigned int dir_index = dom_convert_dir_to_idx (dir);
 
-  dom_computed[dir_index] = new_state;
+  fn->cfg->x_dom_computed[dir_index] = new_state;
 }
 
 /* Returns true if dominance information for direction DIR is available.  */
@@ -1481,17 +1462,11 @@  dom_info_available_p (function *fn, cdi_direction dir)
   return dom_info_state (fn, dir) != DOM_NONE;
 }
 
-bool
-dom_info_available_p (cdi_direction dir)
-{
-  return dom_info_available_p (cfun, dir);
-}
-
 DEBUG_FUNCTION void
-debug_dominance_info (cdi_direction dir)
+debug_dominance_info (function *fn, cdi_direction dir)
 {
   basic_block bb;
-  FOR_EACH_BB_FN (bb, cfun)
+  FOR_EACH_BB_FN (bb, fn)
     if (basic_block bb2 = get_immediate_dominator (dir, bb))
       fprintf (stderr, "%i %i\n", bb->index, bb2->index);
 }
diff --git a/gcc/dominance.h b/gcc/dominance.h
index cc5be88..41ed936 100644
--- a/gcc/dominance.h
+++ b/gcc/dominance.h
@@ -35,11 +35,10 @@  enum dom_state
   DOM_OK		/* Everything is ok.  */
 };
 
-extern void calculate_dominance_info (cdi_direction);
+extern void calculate_dominance_info (function *, cdi_direction);
 extern void free_dominance_info (function *, cdi_direction);
-extern void free_dominance_info (cdi_direction);
 extern basic_block get_immediate_dominator (cdi_direction, basic_block);
-extern void set_immediate_dominator (cdi_direction, basic_block,
+extern void set_immediate_dominator (function *, cdi_direction, basic_block,
 				     basic_block);
 extern vec<basic_block> get_dominated_by (cdi_direction, basic_block);
 extern vec<basic_block> get_dominated_by_region (cdi_direction, basic_block *,
@@ -47,26 +46,26 @@  extern vec<basic_block> get_dominated_by_region (cdi_direction, basic_block *,
 extern vec<basic_block> get_dominated_to_depth (cdi_direction, basic_block,
 						int);
 extern vec<basic_block> get_all_dominated_blocks (cdi_direction, basic_block);
-extern void redirect_immediate_dominators (cdi_direction, basic_block,
-					   basic_block);
+extern void redirect_immediate_dominators (function *, cdi_direction,
+					   basic_block, basic_block);
 extern basic_block nearest_common_dominator (cdi_direction,
 					     basic_block, basic_block);
-extern basic_block nearest_common_dominator_for_set (cdi_direction, bitmap);
-extern bool dominated_by_p (cdi_direction, const_basic_block,
+extern basic_block nearest_common_dominator_for_set (function *, cdi_direction,
+						     bitmap);
+extern bool dominated_by_p (function *fn, cdi_direction, const_basic_block,
 			    const_basic_block);
 unsigned bb_dom_dfs_in (cdi_direction, basic_block);
 unsigned bb_dom_dfs_out (cdi_direction, basic_block);
-extern void verify_dominators (cdi_direction);
-basic_block recompute_dominator (cdi_direction, basic_block);
-extern void iterate_fix_dominators (cdi_direction, vec<basic_block> , bool);
-extern void add_to_dominance_info (cdi_direction, basic_block);
-extern void delete_from_dominance_info (cdi_direction, basic_block);
+extern void verify_dominators (function *, cdi_direction);
+basic_block recompute_dominator (function *, cdi_direction, basic_block);
+extern void iterate_fix_dominators (function *, cdi_direction,
+				    vec<basic_block>, bool);
+extern void add_to_dominance_info (function *, cdi_direction, basic_block);
+extern void delete_from_dominance_info (function *, cdi_direction, basic_block);
 extern basic_block first_dom_son (cdi_direction, basic_block);
 extern basic_block next_dom_son (cdi_direction, basic_block);
 extern dom_state dom_info_state (function *, cdi_direction);
-extern dom_state dom_info_state (cdi_direction);
-extern void set_dom_info_availability (cdi_direction, dom_state);
+extern void set_dom_info_availability (function *, cdi_direction, dom_state);
 extern bool dom_info_available_p (function *, cdi_direction);
-extern bool dom_info_available_p (cdi_direction);
 
 #endif /* GCC_DOMINANCE_H */
diff --git a/gcc/final.c b/gcc/final.c
index 5d91609..18f244f 100644
--- a/gcc/final.c
+++ b/gcc/final.c
@@ -802,7 +802,7 @@  compute_alignments (void)
     }
 
   loop_optimizer_finalize ();
-  free_dominance_info (CDI_DOMINATORS);
+  free_dominance_info (cfun, CDI_DOMINATORS);
   return 0;
 }
 
diff --git a/gcc/function.h b/gcc/function.h
index e92c17c..24c366c 100644
--- a/gcc/function.h
+++ b/gcc/function.h
@@ -452,8 +452,6 @@  set_loops_for_fn (struct function *fn, struct loops *loops)
 #define current_function_funcdef_no (cfun->funcdef_no)
 
 #define current_loops (cfun->x_current_loops)
-#define dom_computed (cfun->cfg->x_dom_computed)
-#define n_bbs_in_dom_tree (cfun->cfg->x_n_bbs_in_dom_tree)
 #define VALUE_HISTOGRAMS(fun) (fun)->value_histograms
 
 /* A pointer to a function to create target specific, per-function
diff --git a/gcc/fwprop.c b/gcc/fwprop.c
index 16c7981..bbddc39 100644
--- a/gcc/fwprop.c
+++ b/gcc/fwprop.c
@@ -739,7 +739,7 @@  use_killed_between (df_ref use, rtx_insn *def_insn, rtx_insn *target_insn)
      cases and assume that DEF is not available.  */
   if (def_bb == target_bb
       ? DF_INSN_LUID (def_insn) >= DF_INSN_LUID (target_insn)
-      : !dominated_by_p (CDI_DOMINATORS, target_bb, def_bb))
+      : !dominated_by_p (cfun, CDI_DOMINATORS, target_bb, def_bb))
     return true;
 
   /* Check if the reg in USE has only one definition.  We already
@@ -1395,7 +1395,7 @@  static void
 fwprop_init (void)
 {
   num_changes = 0;
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_DOMINATORS);
 
   /* We do not always want to propagate into loops, so we have to find
      loops and be careful about them.  Avoid CFG modifications so that
@@ -1423,7 +1423,7 @@  fwprop_done (void)
   sparseset_free (active_defs_check);
 #endif
 
-  free_dominance_info (CDI_DOMINATORS);
+  free_dominance_info (cfun, CDI_DOMINATORS);
   cleanup_cfg (0);
   delete_trivially_dead_insns (get_insns (), max_reg_num ());
 
diff --git a/gcc/gcse.c b/gcc/gcse.c
index 4d95b48..fb181dd 100644
--- a/gcc/gcse.c
+++ b/gcc/gcse.c
@@ -2717,7 +2717,7 @@  free_code_hoist_mem (void)
   sbitmap_vector_free (hoist_vbein);
   sbitmap_vector_free (hoist_vbeout);
 
-  free_dominance_info (CDI_DOMINATORS);
+  free_dominance_info (cfun, CDI_DOMINATORS);
 }
 
 /* Compute the very busy expressions at entry/exit from each block.
@@ -2787,7 +2787,7 @@  compute_code_hoist_data (void)
   compute_local_properties (transp, comp, antloc, &expr_hash_table);
   prune_expressions (false);
   compute_code_hoist_vbeinout ();
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_DOMINATORS);
   if (dump_file)
     fprintf (dump_file, "\n");
 }
@@ -3231,7 +3231,8 @@  hoist_code (void)
 		    {
 		      basic_block lca;
 
-		      lca = nearest_common_dominator_for_set (CDI_DOMINATORS,
+		      lca = nearest_common_dominator_for_set (cfun,
+							      CDI_DOMINATORS,
 							      from_bbs);
 		      if (lca != bb)
 			/* Punt, it's better to hoist these occurrences to
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index de64c05..8e5c02b 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -4346,9 +4346,9 @@  and_comparisons_1 (enum tree_code code1, tree op1a, tree op1b,
 		      /* In simple cases we can look through PHI nodes,
 			 but we have to be careful with loops.
 			 See PR49073.  */
-		      if (! dom_info_available_p (CDI_DOMINATORS)
+		      if (! dom_info_available_p (cfun, CDI_DOMINATORS)
 			  || gimple_bb (def_stmt) == gimple_bb (stmt)
-			  || dominated_by_p (CDI_DOMINATORS,
+			  || dominated_by_p (cfun, CDI_DOMINATORS,
 					     gimple_bb (def_stmt),
 					     gimple_bb (stmt)))
 			return NULL_TREE;
@@ -4810,9 +4810,9 @@  or_comparisons_1 (enum tree_code code1, tree op1a, tree op1b,
 		      /* In simple cases we can look through PHI nodes,
 			 but we have to be careful with loops.
 			 See PR49073.  */
-		      if (! dom_info_available_p (CDI_DOMINATORS)
+		      if (! dom_info_available_p (cfun, CDI_DOMINATORS)
 			  || gimple_bb (def_stmt) == gimple_bb (stmt)
-			  || dominated_by_p (CDI_DOMINATORS,
+			  || dominated_by_p (cfun, CDI_DOMINATORS,
 					     gimple_bb (def_stmt),
 					     gimple_bb (stmt)))
 			return NULL_TREE;
diff --git a/gcc/gimple-ssa-isolate-paths.c b/gcc/gimple-ssa-isolate-paths.c
index 6f84f85..3e75f64 100644
--- a/gcc/gimple-ssa-isolate-paths.c
+++ b/gcc/gimple-ssa-isolate-paths.c
@@ -452,10 +452,10 @@  find_explicit_erroneous_behaviour (void)
 		      || TREE_CODE (valbase) == PARM_DECL)
 		    {
 		      /* We only need it for this particular case.  */
-		      calculate_dominance_info (CDI_POST_DOMINATORS);
+		      calculate_dominance_info (cfun, CDI_POST_DOMINATORS);
 		      const char* msg;
 		      bool always_executed = dominated_by_p
-			(CDI_POST_DOMINATORS,
+			(cfun, CDI_POST_DOMINATORS,
 			 single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun)), bb);
 		      if (always_executed)
 			msg = N_("function returns address of local variable");
@@ -530,10 +530,10 @@  gimple_ssa_isolate_erroneous_paths (void)
   /* We scramble the CFG and loop structures a bit, clean up
      appropriately.  We really should incrementally update the
      loop structures, in theory it shouldn't be that hard.  */
-  free_dominance_info (CDI_POST_DOMINATORS);
+  free_dominance_info (cfun, CDI_POST_DOMINATORS);
   if (cfg_altered)
     {
-      free_dominance_info (CDI_DOMINATORS);
+      free_dominance_info (cfun, CDI_DOMINATORS);
       loops_state_set (LOOPS_NEED_FIXUP);
       return TODO_cleanup_cfg | TODO_update_ssa;
     }
diff --git a/gcc/gimple-ssa-strength-reduction.c b/gcc/gimple-ssa-strength-reduction.c
index b369ef5..3b38fcf 100644
--- a/gcc/gimple-ssa-strength-reduction.c
+++ b/gcc/gimple-ssa-strength-reduction.c
@@ -515,7 +515,7 @@  find_basis_for_base_expr (slsr_cand_t c, tree base_expr)
 	  || one_basis->cand_stmt == c->cand_stmt
 	  || !operand_equal_p (one_basis->stride, c->stride, 0)
 	  || !types_compatible_p (one_basis->cand_type, c->cand_type)
-	  || !dominated_by_p (CDI_DOMINATORS,
+	  || !dominated_by_p (cfun, CDI_DOMINATORS,
 			      gimple_bb (c->cand_stmt),
 			      gimple_bb (one_basis->cand_stmt)))
 	continue;
@@ -555,7 +555,7 @@  find_basis_for_candidate (slsr_cand_t c)
 	  basis_bb = gimple_bb (basis->cand_stmt);
 
 	  if (phi_bb == basis_bb
-	      || !dominated_by_p (CDI_DOMINATORS, phi_bb, basis_bb))
+	      || !dominated_by_p (cfun, CDI_DOMINATORS, phi_bb, basis_bb))
 	    {
 	      basis = NULL;
 	      c->basis = 0;
@@ -2361,7 +2361,8 @@  phi_add_costs (gimple phi, slsr_cand_t c, int one_add_cost)
   slsr_cand_t basis = lookup_cand (c->basis);
   basic_block basis_bb = gimple_bb (basis->cand_stmt);
 
-  if (phi_bb == basis_bb || !dominated_by_p (CDI_DOMINATORS, phi_bb, basis_bb))
+  if (phi_bb == basis_bb
+      || !dominated_by_p (cfun, CDI_DOMINATORS, phi_bb, basis_bb))
     return COST_INFINITE;
 
   for (i = 0; i < gimple_phi_num_args (phi); i++)
@@ -2487,7 +2488,7 @@  record_increment (slsr_cand_t c, widest_int increment, bool is_phi_adjust)
 	     dominate this candidate, it's not going to be useful to
 	     us after all.  */
 	  if (incr_vec[i].initializer
-	      && !dominated_by_p (CDI_DOMINATORS,
+	      && !dominated_by_p (cfun, CDI_DOMINATORS,
 				  gimple_bb (c->cand_stmt),
 				  incr_vec[i].init_bb))
 	    {
diff --git a/gcc/graphite-isl-ast-to-gimple.c b/gcc/graphite-isl-ast-to-gimple.c
index dfb012f..7ae55d0 100644
--- a/gcc/graphite-isl-ast-to-gimple.c
+++ b/gcc/graphite-isl-ast-to-gimple.c
@@ -581,7 +581,7 @@  translate_isl_ast_for_loop (loop_p context_loop,
   next_e = translate_isl_ast (loop, for_body, to_body, ip);
   isl_ast_node_free (for_body);
   redirect_edge_succ_nodup (next_e, after);
-  set_immediate_dominator (CDI_DOMINATORS, next_e->dest, next_e->src);
+  set_immediate_dominator (cfun, CDI_DOMINATORS, next_e->dest, next_e->src);
 
   if (flag_loop_parallelize_all)
   {
diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c
index fb7247e..d7dc641 100644
--- a/gcc/graphite-scop-detection.c
+++ b/gcc/graphite-scop-detection.c
@@ -606,7 +606,7 @@  scopdet_basic_block_info (basic_block bb, loop_p outermost_loop,
 	    /* If we do not dominate result.next, remove it.  It's either
 	       the exit block, or another bb dominates it and will
 	       call the scop detection for this bb.  */
-	    if (!dominated_by_p (CDI_DOMINATORS, result.next, bb))
+	    if (!dominated_by_p (cfun, CDI_DOMINATORS, result.next, bb))
 	      result.next = NULL;
 
 	    if (exit_e->src->loop_father != loop)
@@ -645,7 +645,7 @@  scopdet_basic_block_info (basic_block bb, loop_p outermost_loop,
 		  - The loop dominates bbs, that are not exit destinations.  */
         FOR_EACH_VEC_ELT (exits, i, e)
           if (e->src->loop_father == loop
-	      && dominated_by_p (CDI_DOMINATORS, e->dest, e->src))
+	      && dominated_by_p (cfun, CDI_DOMINATORS, e->dest, e->src))
 	    {
 	      if (loop_outer (outermost_loop))
 		outermost_loop = loop_outer (outermost_loop);
@@ -718,7 +718,7 @@  scopdet_basic_block_info (basic_block bb, loop_p outermost_loop,
 		continue;
 	      }
 
-	    if (!dominated_by_p (CDI_DOMINATORS, e->dest, bb))
+	    if (!dominated_by_p (cfun, CDI_DOMINATORS, e->dest, bb))
 	      {
 		result.difficult = true;
 		continue;
@@ -752,7 +752,7 @@  scopdet_basic_block_info (basic_block bb, loop_p outermost_loop,
 	  {
 	    /* Only return a next pointer if we dominate this pointer.
 	       Otherwise it will be handled by the bb dominating it.  */
-	    if (dominated_by_p (CDI_DOMINATORS, last_exit, bb)
+	    if (dominated_by_p (cfun, CDI_DOMINATORS, last_exit, bb)
 		&& last_exit != bb)
 	      result.next = last_exit;
 	    else
@@ -992,7 +992,7 @@  create_single_entry_edge (sd_region *region)
   |  5  */
 
   if (region->entry->loop_father->header != region->entry
-      || dominated_by_p (CDI_DOMINATORS,
+      || dominated_by_p (cfun, CDI_DOMINATORS,
 			 loop_latch_edge (region->entry->loop_father)->src,
 			 region->exit))
     {
@@ -1128,7 +1128,7 @@  create_sese_edges (vec<sd_region> regions)
 
   unmark_exit_edges (regions);
 
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_DOMINATORS);
   fix_loop_structure (NULL);
 
 #ifdef ENABLE_CHECKING
@@ -1441,7 +1441,7 @@  canonicalize_loop_closed_ssa (loop_p loop)
 
   /* The code above does not properly handle changes in the post dominance
      information (yet).  */
-  free_dominance_info (CDI_POST_DOMINATORS);
+  free_dominance_info (cfun, CDI_POST_DOMINATORS);
 }
 
 /* Converts the current loop closed SSA form to a canonical form
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index fdcc790..5d8c148 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -342,7 +342,7 @@  all_non_dominated_preds_marked_p (basic_block bb, sbitmap map)
 
   FOR_EACH_EDGE (e, ei, bb->preds)
     if (!bitmap_bit_p (map, e->src->index)
-	&& !dominated_by_p (CDI_DOMINATORS, e->src, bb))
+	&& !dominated_by_p (cfun, CDI_DOMINATORS, e->src, bb))
 	return false;
 
   return true;
@@ -2930,7 +2930,7 @@  dr_indices_valid_in_loop (tree ref ATTRIBUTE_UNUSED, tree *index, void *data)
   if (!def_bb)
     return true;
 
-  return dominated_by_p (CDI_DOMINATORS, header, def_bb);
+  return dominated_by_p (cfun, CDI_DOMINATORS, header, def_bb);
 }
 
 /* When the result of a CLOSE_PHI is written to a memory location,
diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c
index 0912606..a14dc76 100644
--- a/gcc/haifa-sched.c
+++ b/gcc/haifa-sched.c
@@ -8216,8 +8216,8 @@  sched_create_recovery_edges (basic_block first_bb, basic_block rec,
     edge_flags = 0;
 
   make_single_succ_edge (rec, second_bb, edge_flags);
-  if (dom_info_available_p (CDI_DOMINATORS))
-    set_immediate_dominator (CDI_DOMINATORS, rec, first_bb);
+  if (dom_info_available_p (cfun, CDI_DOMINATORS))
+    set_immediate_dominator (cfun, CDI_DOMINATORS, rec, first_bb);
 }
 
 /* This function creates recovery code for INSN.  If MUTATE_P is nonzero,
diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
index a46efec..1e090bf 100644
--- a/gcc/ifcvt.c
+++ b/gcc/ifcvt.c
@@ -3548,7 +3548,7 @@  find_if_header (basic_block test_bb, int pass)
       && find_cond_trap (test_bb, then_edge, else_edge))
     goto success;
 
-  if (dom_info_state (CDI_POST_DOMINATORS) >= DOM_NO_FAST_QUERY
+  if (dom_info_state (cfun, CDI_POST_DOMINATORS) >= DOM_NO_FAST_QUERY
       && (reload_completed || !targetm.have_conditional_execution ()))
     {
       if (find_if_case_1 (test_bb, then_edge, else_edge))
@@ -4263,7 +4263,7 @@  find_if_case_2 (basic_block test_bb, edge then_edge, edge else_edge)
   if (else_prob > then_prob)
     ;
   else if (else_succ->dest->index < NUM_FIXED_BLOCKS
-	   || dominated_by_p (CDI_POST_DOMINATORS, then_bb,
+	   || dominated_by_p (cfun, CDI_POST_DOMINATORS, then_bb,
 			      else_succ->dest))
     ;
   else
@@ -4652,10 +4652,10 @@  if_convert (bool after_combine)
   loop_optimizer_init (AVOID_CFG_MODIFICATIONS);
   mark_loop_exit_edges ();
   loop_optimizer_finalize ();
-  free_dominance_info (CDI_DOMINATORS);
+  free_dominance_info (cfun, CDI_DOMINATORS);
 
   /* Compute postdominators.  */
-  calculate_dominance_info (CDI_POST_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_POST_DOMINATORS);
 
   df_set_flags (DF_LR_RUN_DCE);
 
@@ -4696,7 +4696,7 @@  if_convert (bool after_combine)
     fprintf (dump_file, "\n\n========== no more changes\n");
 #endif
 
-  free_dominance_info (CDI_POST_DOMINATORS);
+  free_dominance_info (cfun, CDI_POST_DOMINATORS);
 
   if (dump_file)
     fflush (dump_file);
diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c
index 3a8f0ec..f8f0fa9 100644
--- a/gcc/ipa-inline-analysis.c
+++ b/gcc/ipa-inline-analysis.c
@@ -2501,7 +2501,7 @@  estimate_function_body_sizes (struct cgraph_node *node, bool early)
      
   if (opt_for_fn (node->decl, optimize))
     {
-      calculate_dominance_info (CDI_DOMINATORS);
+      calculate_dominance_info (cfun, CDI_DOMINATORS);
       if (!early)
         loop_optimizer_init (LOOPS_NORMAL | LOOPS_HAVE_RECORDED_EXITS);
       else
@@ -2858,7 +2858,7 @@  estimate_function_body_sizes (struct cgraph_node *node, bool early)
         loop_optimizer_finalize ();
       else if (!ipa_edge_args_vector)
 	ipa_free_all_node_params ();
-      free_dominance_info (CDI_DOMINATORS);
+      free_dominance_info (cfun, CDI_DOMINATORS);
     }
   if (dump_file)
     {
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index c862cff..adb4096 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -2296,7 +2296,7 @@  ipa_analyze_node (struct cgraph_node *node)
 
   struct function *func = DECL_STRUCT_FUNCTION (node->decl);
   push_cfun (func);
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (func, CDI_DOMINATORS);
   ipa_initialize_node_params (node);
   ipa_analyze_controlled_uses (node);
 
@@ -2326,7 +2326,7 @@  ipa_analyze_node (struct cgraph_node *node)
   FOR_EACH_VEC_ELT (fbi.bb_infos, i, bi)
     free_ipa_bb_info (bi);
   fbi.bb_infos.release ();
-  free_dominance_info (CDI_DOMINATORS);
+  free_dominance_info (func, CDI_DOMINATORS);
   pop_cfun ();
 }
 
@@ -5281,7 +5281,7 @@  ipcp_transform_function (struct cgraph_node *node)
 
   descriptors.safe_grow_cleared (param_count);
   ipa_populate_param_decls (node, descriptors);
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_DOMINATORS);
   ipcp_modif_dom_walker (&fbi, descriptors, aggval, &something_changed,
 			 &cfg_changed).walk (ENTRY_BLOCK_PTR_FOR_FN (cfun));
 
@@ -5290,7 +5290,7 @@  ipcp_transform_function (struct cgraph_node *node)
   FOR_EACH_VEC_ELT (fbi.bb_infos, i, bi)
     free_ipa_bb_info (bi);
   fbi.bb_infos.release ();
-  free_dominance_info (CDI_DOMINATORS);
+  free_dominance_info (cfun, CDI_DOMINATORS);
   (*ipcp_transformations)[node->uid].agg_values = NULL;
   (*ipcp_transformations)[node->uid].alignments = NULL;
   descriptors.release ();
diff --git a/gcc/ipa-split.c b/gcc/ipa-split.c
index 69f293f..3cea9a8 100644
--- a/gcc/ipa-split.c
+++ b/gcc/ipa-split.c
@@ -402,7 +402,7 @@  dominated_by_forbidden (basic_block bb)
 
   EXECUTE_IF_SET_IN_BITMAP (forbidden_dominators, 1, dom_bb, bi)
     {
-      if (dominated_by_p (CDI_DOMINATORS, bb,
+      if (dominated_by_p (cfun, CDI_DOMINATORS, bb,
 			  BASIC_BLOCK_FOR_FN (cfun, dom_bb)))
 	return true;
     }
@@ -1668,8 +1668,8 @@  split_function (basic_block return_bb, struct split_point *split_point,
 	  gsi_insert_after (&gsi, ret, GSI_NEW_STMT);
 	}
     }
-  free_dominance_info (CDI_DOMINATORS);
-  free_dominance_info (CDI_POST_DOMINATORS);
+  free_dominance_info (cfun, CDI_DOMINATORS);
+  free_dominance_info (cfun, CDI_POST_DOMINATORS);
   compute_inline_parameters (node, true);
 }
 
@@ -1767,7 +1767,7 @@  execute_split_functions (void)
 
   /* Initialize bitmap to track forbidden calls.  */
   forbidden_dominators = BITMAP_ALLOC (NULL);
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_DOMINATORS);
 
   /* Compute local info about basic blocks and determine function size/time.  */
   bb_info_vec.safe_grow_cleared (last_basic_block_for_fn (cfun) + 1);
diff --git a/gcc/ira.c b/gcc/ira.c
index 23ed1db..a49daff 100644
--- a/gcc/ira.c
+++ b/gcc/ira.c
@@ -4397,7 +4397,7 @@  insn_dominated_by_p (rtx i1, rtx i2, int *uid_luid)
 
   if (bb1 == bb2)
     return uid_luid[INSN_UID (i2)] < uid_luid[INSN_UID (i1)];
-  return dominated_by_p (CDI_DOMINATORS, bb1, bb2);
+  return dominated_by_p (cfun, CDI_DOMINATORS, bb1, bb2);
 }
 
 /* Record the range of register numbers added by find_moveable_pseudos.  */
@@ -4458,7 +4458,7 @@  find_moveable_pseudos (void)
   pseudo_replaced_reg.safe_grow_cleared (max_regs);
 
   df_analyze ();
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_DOMINATORS);
 
   i = 0;
   bitmap_initialize (&live, 0);
@@ -4774,7 +4774,7 @@  find_moveable_pseudos (void)
   regstat_free_ri ();
   regstat_init_n_sets_and_refs ();
   regstat_compute_ri ();
-  free_dominance_info (CDI_DOMINATORS);
+  free_dominance_info (cfun, CDI_DOMINATORS);
 }
 
 /* If SET pattern SET is an assignment from a hard register to a pseudo which
@@ -4919,7 +4919,7 @@  split_live_ranges_for_shrink_wrap (void)
       return false;
     }
 
-  call_dom = nearest_common_dominator_for_set (CDI_DOMINATORS, &need_new);
+  call_dom = nearest_common_dominator_for_set (cfun, CDI_DOMINATORS, &need_new);
   bitmap_clear (&need_new);
   if (call_dom == first)
     return false;
@@ -4932,13 +4932,13 @@  split_live_ranges_for_shrink_wrap (void)
   if (call_dom == first)
     return false;
 
-  calculate_dominance_info (CDI_POST_DOMINATORS);
-  if (dominated_by_p (CDI_POST_DOMINATORS, first, call_dom))
+  calculate_dominance_info (cfun, CDI_POST_DOMINATORS);
+  if (dominated_by_p (cfun, CDI_POST_DOMINATORS, first, call_dom))
     {
-      free_dominance_info (CDI_POST_DOMINATORS);
+      free_dominance_info (cfun, CDI_POST_DOMINATORS);
       return false;
     }
-  free_dominance_info (CDI_POST_DOMINATORS);
+  free_dominance_info (cfun, CDI_POST_DOMINATORS);
 
   if (dump_file)
     fprintf (dump_file, "Will split live ranges of parameters at BB %i\n",
@@ -4960,7 +4960,7 @@  split_live_ranges_for_shrink_wrap (void)
 
 	  basic_block ubb = BLOCK_FOR_INSN (uin);
 	  if (ubb == call_dom
-	      || dominated_by_p (CDI_DOMINATORS, ubb, call_dom))
+	      || dominated_by_p (cfun, CDI_DOMINATORS, ubb, call_dom))
 	    {
 	      if (!newreg)
 		newreg = ira_create_new_reg (dest);
@@ -5163,12 +5163,12 @@  ira (FILE *f)
   init_reg_equiv ();
   if (ira_conflicts_p)
     {
-      calculate_dominance_info (CDI_DOMINATORS);
+      calculate_dominance_info (cfun, CDI_DOMINATORS);
 
       if (split_live_ranges_for_shrink_wrap ())
 	df_analyze ();
 
-      free_dominance_info (CDI_DOMINATORS);
+      free_dominance_info (cfun, CDI_DOMINATORS);
     }
 
   df_clear_flags (DF_NO_INSN_RESCAN);
@@ -5293,7 +5293,7 @@  ira (FILE *f)
 	     change if new insns were generated?  Can that be handled
 	     by updating the loop tree incrementally?  */
 	  loop_optimizer_finalize ();
-	  free_dominance_info (CDI_DOMINATORS);
+	  free_dominance_info (cfun, CDI_DOMINATORS);
 	  loop_optimizer_init (AVOID_CFG_MODIFICATIONS
 			       | LOOPS_HAVE_RECORDED_EXITS);
 
@@ -5383,7 +5383,7 @@  do_reload (void)
       if (current_loops != NULL)
 	{
 	  loop_optimizer_finalize ();
-	  free_dominance_info (CDI_DOMINATORS);
+	  free_dominance_info (cfun, CDI_DOMINATORS);
 	}
       FOR_ALL_BB_FN (bb, cfun)
 	bb->loop_father = NULL;
@@ -5430,7 +5430,7 @@  do_reload (void)
       if (current_loops != NULL)
 	{
 	  loop_optimizer_finalize ();
-	  free_dominance_info (CDI_DOMINATORS);
+	  free_dominance_info (cfun, CDI_DOMINATORS);
 	}
       FOR_ALL_BB_FN (bb, cfun)
 	bb->loop_father = NULL;
diff --git a/gcc/loop-doloop.c b/gcc/loop-doloop.c
index 6554597..aa0ad99 100644
--- a/gcc/loop-doloop.c
+++ b/gcc/loop-doloop.c
@@ -505,7 +505,7 @@  doloop_modify (struct loop *loop, struct niter_desc *desc,
       /* Expand the condition testing the assumptions and if it does not pass,
 	 reset the count register to 0.  */
       redirect_edge_and_branch_force (single_succ_edge (preheader), new_preheader);
-      set_immediate_dominator (CDI_DOMINATORS, new_preheader, preheader);
+      set_immediate_dominator (cfun, CDI_DOMINATORS, new_preheader, preheader);
 
       set_zero->count = 0;
       set_zero->frequency = 0;
@@ -542,13 +542,13 @@  doloop_modify (struct loop *loop, struct niter_desc *desc,
 	  end_sequence ();
 	  emit_insn_after (sequence, BB_END (set_zero));
 
-	  set_immediate_dominator (CDI_DOMINATORS, set_zero,
-				   recompute_dominator (CDI_DOMINATORS,
+	  set_immediate_dominator (cfun, CDI_DOMINATORS, set_zero,
+				   recompute_dominator (cfun, CDI_DOMINATORS,
 							set_zero));
 	}
 
-      set_immediate_dominator (CDI_DOMINATORS, new_preheader,
-			       recompute_dominator (CDI_DOMINATORS,
+      set_immediate_dominator (cfun, CDI_DOMINATORS, new_preheader,
+			       recompute_dominator (cfun, CDI_DOMINATORS,
 						    new_preheader));
     }
 
diff --git a/gcc/loop-init.c b/gcc/loop-init.c
index a9a3d6fa..fba7198 100644
--- a/gcc/loop-init.c
+++ b/gcc/loop-init.c
@@ -102,7 +102,7 @@  loop_optimizer_init (unsigned flags)
       gcc_assert (cfun->curr_properties & PROP_loops);
 
       /* Ensure that the dominators are computed, like flow_loops_find does.  */
-      calculate_dominance_info (CDI_DOMINATORS);
+      calculate_dominance_info (cfun, CDI_DOMINATORS);
 
 #ifdef ENABLE_CHECKING
       if (!needs_fixup)
@@ -211,7 +211,7 @@  fix_loop_structure (bitmap changed_bbs)
     fprintf (dump_file, "fix_loop_structure: fixing up loops for function\n");
 
   /* We need exact and fast dominance info to be available.  */
-  gcc_assert (dom_info_state (CDI_DOMINATORS) == DOM_OK);
+  gcc_assert (dom_info_state (cfun, CDI_DOMINATORS) == DOM_OK);
 
   if (loops_state_satisfies_p (LOOPS_HAVE_RECORDED_EXITS))
     {
@@ -480,7 +480,7 @@  pass_rtl_loop_done::execute (function *fun)
   /* No longer preserve loops, remove them now.  */
   fun->curr_properties &= ~PROP_loops;
   loop_optimizer_finalize ();
-  free_dominance_info (CDI_DOMINATORS);
+  free_dominance_info (fun, CDI_DOMINATORS);
 
   cleanup_cfg (0);
   if (dump_file)
diff --git a/gcc/loop-invariant.c b/gcc/loop-invariant.c
index 52c8ae8..4a106a3 100644
--- a/gcc/loop-invariant.c
+++ b/gcc/loop-invariant.c
@@ -288,7 +288,7 @@  invariant_for_use (df_ref use)
     return NULL;
 
   def_bb = DF_REF_BB (def);
-  if (!dominated_by_p (CDI_DOMINATORS, bb, def_bb))
+  if (!dominated_by_p (cfun, CDI_DOMINATORS, bb, def_bb))
     return NULL;
   return invariant_table[DF_REF_ID (def)];
 }
@@ -563,7 +563,7 @@  compute_always_reached (struct loop *loop, basic_block *body,
 
   for (i = 0; i < loop->num_nodes; i++)
     {
-      if (dominated_by_p (CDI_DOMINATORS, loop->latch, body[i]))
+      if (dominated_by_p (cfun, CDI_DOMINATORS, loop->latch, body[i]))
 	bitmap_set_bit (always_reached, i);
 
       if (bitmap_bit_p (may_exit, i))
@@ -832,7 +832,7 @@  check_dependency (basic_block bb, df_ref use, bitmap depends_on)
      dominates insn, because def has invariant_table[DF_REF_ID(def)]
      defined and we process the insns in the basic block bb
      sequentially.  */
-  if (!dominated_by_p (CDI_DOMINATORS, bb, def_bb))
+  if (!dominated_by_p (cfun, CDI_DOMINATORS, bb, def_bb))
     return false;
 
   bitmap_set_bit (depends_on, def_data->invno);
@@ -1542,7 +1542,7 @@  can_move_invariant_reg (struct loop *loop, struct invariant *inv, rtx reg)
       /* Don't move if a use is not dominated by def in insn.  */
       if (use_bb == bb && DF_INSN_LUID (insn) >= DF_INSN_LUID (use_insn))
 	return false;
-      if (!dominated_by_p (CDI_DOMINATORS, use_bb, bb))
+      if (!dominated_by_p (cfun, CDI_DOMINATORS, use_bb, bb))
 	return false;
     }
 
diff --git a/gcc/loop-iv.c b/gcc/loop-iv.c
index 6e9cc8c..c7f2cad 100644
--- a/gcc/loop-iv.c
+++ b/gcc/loop-iv.c
@@ -372,7 +372,7 @@  iv_get_reaching_def (rtx_insn *insn, rtx reg, df_ref *def)
   if (use_bb == def_bb)
     dom_p = (DF_INSN_LUID (def_insn) < DF_INSN_LUID (insn));
   else
-    dom_p = dominated_by_p (CDI_DOMINATORS, use_bb, def_bb);
+    dom_p = dominated_by_p (cfun, CDI_DOMINATORS, use_bb, def_bb);
 
   if (dom_p)
     {
@@ -2901,7 +2901,7 @@  check_simple_exit (struct loop *loop, edge e, struct niter_desc *desc)
     return;
 
   /* It must be tested (at least) once during any iteration.  */
-  if (!dominated_by_p (CDI_DOMINATORS, loop->latch, exit_bb))
+  if (!dominated_by_p (cfun, CDI_DOMINATORS, loop->latch, exit_bb))
     return;
 
   /* It must end in a simple conditional jump.  */
diff --git a/gcc/loop-unroll.c b/gcc/loop-unroll.c
index 913bd3c..b7a3319 100644
--- a/gcc/loop-unroll.c
+++ b/gcc/loop-unroll.c
@@ -314,7 +314,7 @@  unroll_loops (int flags)
 
     if (changed)
       {
-	calculate_dominance_info (CDI_DOMINATORS);
+	calculate_dominance_info (cfun, CDI_DOMINATORS);
 	fix_loop_structure (NULL);
       }
 
@@ -978,7 +978,7 @@  unroll_loop_runtime_iterations (struct loop *loop)
       gcc_assert (branch_code != NULL_RTX);
 
       swtch = split_edge_and_insert (single_pred_edge (swtch), branch_code);
-      set_immediate_dominator (CDI_DOMINATORS, preheader, swtch);
+      set_immediate_dominator (cfun, CDI_DOMINATORS, preheader, swtch);
       single_pred_edge (swtch)->probability = REG_BR_PROB_BASE - p;
       e = make_edge (swtch, preheader,
 		     single_succ_edge (swtch)->flags & EDGE_IRREDUCIBLE_LOOP);
@@ -998,7 +998,7 @@  unroll_loop_runtime_iterations (struct loop *loop)
       gcc_assert (branch_code != NULL_RTX);
 
       swtch = split_edge_and_insert (single_succ_edge (swtch), branch_code);
-      set_immediate_dominator (CDI_DOMINATORS, preheader, swtch);
+      set_immediate_dominator (cfun, CDI_DOMINATORS, preheader, swtch);
       single_succ_edge (swtch)->probability = REG_BR_PROB_BASE - p;
       e = make_edge (swtch, preheader,
 		     single_succ_edge (swtch)->flags & EDGE_IRREDUCIBLE_LOOP);
@@ -1007,7 +1007,7 @@  unroll_loop_runtime_iterations (struct loop *loop)
     }
 
   /* Recount dominators for outer blocks.  */
-  iterate_fix_dominators (CDI_DOMINATORS, dom_bbs, false);
+  iterate_fix_dominators (cfun, CDI_DOMINATORS, dom_bbs, false);
 
   /* And unroll loop.  */
 
@@ -1562,7 +1562,7 @@  analyze_insns_in_loop (struct loop *loop)
   for (i = 0; i < loop->num_nodes; i++)
     {
       bb = body[i];
-      if (!dominated_by_p (CDI_DOMINATORS, loop->latch, bb))
+      if (!dominated_by_p (cfun, CDI_DOMINATORS, loop->latch, bb))
 	continue;
 
       FOR_BB_INSNS (bb, insn)
diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c
index 2eb8051..d5172c4 100644
--- a/gcc/lto-streamer-in.c
+++ b/gcc/lto-streamer-in.c
@@ -1152,8 +1152,8 @@  input_function (tree fn_decl, struct data_in *data_in,
   execute_all_ipa_stmt_fixups (node, stmts);
 
   update_ssa (TODO_update_ssa_only_virtuals);
-  free_dominance_info (CDI_DOMINATORS);
-  free_dominance_info (CDI_POST_DOMINATORS);
+  free_dominance_info (cfun, CDI_DOMINATORS);
+  free_dominance_info (cfun, CDI_POST_DOMINATORS);
   free (stmts);
   pop_cfun ();
 }
diff --git a/gcc/modulo-sched.c b/gcc/modulo-sched.c
index d9596c3..1f92368 100644
--- a/gcc/modulo-sched.c
+++ b/gcc/modulo-sched.c
@@ -3386,7 +3386,7 @@  pass_sms::execute (function *fun ATTRIBUTE_UNUSED)
   FOR_EACH_BB_FN (bb, fun)
     if (bb->next_bb != EXIT_BLOCK_PTR_FOR_FN (fun))
       bb->aux = bb->next_bb;
-  free_dominance_info (CDI_DOMINATORS);
+  free_dominance_info (cfun, CDI_DOMINATORS);
   cfg_layout_finalize ();
 #endif /* INSN_SCHEDULING */
   return 0;
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index c1dc919..106c5b5 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -4919,8 +4919,8 @@  expand_parallel_call (struct omp_region *region, basic_block bb,
 
 	  then_bb = create_empty_bb (cond_bb);
 	  else_bb = create_empty_bb (then_bb);
-	  set_immediate_dominator (CDI_DOMINATORS, then_bb, cond_bb);
-	  set_immediate_dominator (CDI_DOMINATORS, else_bb, cond_bb);
+	  set_immediate_dominator (cfun, CDI_DOMINATORS, then_bb, cond_bb);
+	  set_immediate_dominator (cfun, CDI_DOMINATORS, else_bb, cond_bb);
 
 	  stmt = gimple_build_cond_empty (cond);
 	  gsi = gsi_start_bb (cond_bb);
@@ -5512,7 +5512,7 @@  expand_omp_taskreg (struct omp_region *region)
 	  e2 = make_edge (e->src, BRANCH_EDGE (entry_bb)->dest, EDGE_ABNORMAL);
 	  gcc_assert (e2->dest == region->exit);
 	  remove_edge (BRANCH_EDGE (entry_bb));
-	  set_immediate_dominator (CDI_DOMINATORS, e2->dest, e->src);
+	  set_immediate_dominator (cfun, CDI_DOMINATORS, e2->dest, e->src);
 	  gsi = gsi_last_bb (region->exit);
 	  gcc_assert (!gsi_end_p (gsi)
 		      && gimple_code (gsi_stmt (gsi)) == GIMPLE_OMP_RETURN);
@@ -5552,7 +5552,7 @@  expand_omp_taskreg (struct omp_region *region)
 	  if (!exit_bb)
 	    make_edge (new_bb, dest_bb, EDGE_FALLTHRU);
 	  remove_edge (e2);
-	  set_immediate_dominator (CDI_DOMINATORS, dest_bb, new_bb);
+	  set_immediate_dominator (cfun, CDI_DOMINATORS, dest_bb, new_bb);
 	}
       /* When the OMP expansion process cannot guarantee an up-to-date
          loop tree arrange for the child function to fixup loops.  */
@@ -5753,7 +5753,7 @@  expand_omp_for_init_counts (struct omp_for_data *fd, gimple_stmt_iterator *gsi,
 	      assign_stmt = gimple_build_assign (fd->loop.n2,
 						 build_zero_cst (type));
 	      gsi_insert_before (gsi, assign_stmt, GSI_SAME_STMT);
-	      set_immediate_dominator (CDI_DOMINATORS, zero_iter_bb,
+	      set_immediate_dominator (cfun, CDI_DOMINATORS, zero_iter_bb,
 				       entry_bb);
 	    }
 	  ne = make_edge (entry_bb, zero_iter_bb, EDGE_FALSE_VALUE);
@@ -5952,7 +5952,7 @@  extract_omp_for_update_vars (struct omp_for_data *fd, basic_block cont_bb,
       else
 	collapse_bb = bb;
 
-      set_immediate_dominator (CDI_DOMINATORS, bb, last_bb);
+      set_immediate_dominator (cfun, CDI_DOMINATORS, bb, last_bb);
 
       if (POINTER_TYPE_P (vtype))
 	t = fold_build_pointer_plus (fd->loops[i].v, fd->loops[i].step);
@@ -6177,7 +6177,7 @@  expand_omp_for_generic (struct omp_region *region,
 	  entry_bb = e->dest;
 	  make_edge (zero_iter_bb, entry_bb, EDGE_FALLTHRU);
 	  gsi = gsi_last_bb (entry_bb);
-	  set_immediate_dominator (CDI_DOMINATORS, entry_bb,
+	  set_immediate_dominator (cfun, CDI_DOMINATORS, entry_bb,
 				   get_immediate_dominator (CDI_DOMINATORS,
 							    zero_iter_bb));
 	}
@@ -6443,14 +6443,14 @@  expand_omp_for_generic (struct omp_region *region,
 	}
       make_edge (l2_bb, l0_bb, EDGE_TRUE_VALUE);
 
-      set_immediate_dominator (CDI_DOMINATORS, l2_bb,
-			       recompute_dominator (CDI_DOMINATORS, l2_bb));
-      set_immediate_dominator (CDI_DOMINATORS, l3_bb,
-			       recompute_dominator (CDI_DOMINATORS, l3_bb));
-      set_immediate_dominator (CDI_DOMINATORS, l0_bb,
-			       recompute_dominator (CDI_DOMINATORS, l0_bb));
-      set_immediate_dominator (CDI_DOMINATORS, l1_bb,
-			       recompute_dominator (CDI_DOMINATORS, l1_bb));
+      set_immediate_dominator (cfun, CDI_DOMINATORS, l2_bb,
+			       recompute_dominator (cfun, CDI_DOMINATORS, l2_bb));
+      set_immediate_dominator (cfun, CDI_DOMINATORS, l3_bb,
+			       recompute_dominator (cfun, CDI_DOMINATORS, l3_bb));
+      set_immediate_dominator (cfun, CDI_DOMINATORS, l0_bb,
+			       recompute_dominator (cfun, CDI_DOMINATORS, l0_bb));
+      set_immediate_dominator (cfun, CDI_DOMINATORS, l1_bb,
+			       recompute_dominator (cfun, CDI_DOMINATORS, l1_bb));
 
       struct loop *outer_loop = alloc_loop ();
       outer_loop->header = l0_bb;
@@ -6844,14 +6844,14 @@  expand_omp_for_static_nochunk (struct omp_region *region,
 	= ep ? EDGE_FALSE_VALUE : EDGE_FALLTHRU;
     }
 
-  set_immediate_dominator (CDI_DOMINATORS, second_bb, entry_bb);
-  set_immediate_dominator (CDI_DOMINATORS, third_bb, entry_bb);
-  set_immediate_dominator (CDI_DOMINATORS, seq_start_bb, third_bb);
+  set_immediate_dominator (cfun, CDI_DOMINATORS, second_bb, entry_bb);
+  set_immediate_dominator (cfun, CDI_DOMINATORS, third_bb, entry_bb);
+  set_immediate_dominator (cfun, CDI_DOMINATORS, seq_start_bb, third_bb);
 
-  set_immediate_dominator (CDI_DOMINATORS, body_bb,
-			   recompute_dominator (CDI_DOMINATORS, body_bb));
-  set_immediate_dominator (CDI_DOMINATORS, fin_bb,
-			   recompute_dominator (CDI_DOMINATORS, fin_bb));
+  set_immediate_dominator (cfun, CDI_DOMINATORS, body_bb,
+			   recompute_dominator (cfun, CDI_DOMINATORS, body_bb));
+  set_immediate_dominator (cfun, CDI_DOMINATORS, fin_bb,
+			   recompute_dominator (cfun, CDI_DOMINATORS, fin_bb));
 
   struct loop *loop = body_bb->loop_father;
   if (loop != entry_bb->loop_father)
@@ -7322,15 +7322,15 @@  expand_omp_for_static_chunk (struct omp_region *region,
     }
 
   if (!broken_loop)
-    set_immediate_dominator (CDI_DOMINATORS, trip_update_bb, cont_bb);
-  set_immediate_dominator (CDI_DOMINATORS, iter_part_bb,
-			   recompute_dominator (CDI_DOMINATORS, iter_part_bb));
-  set_immediate_dominator (CDI_DOMINATORS, fin_bb,
-			   recompute_dominator (CDI_DOMINATORS, fin_bb));
-  set_immediate_dominator (CDI_DOMINATORS, seq_start_bb,
-			   recompute_dominator (CDI_DOMINATORS, seq_start_bb));
-  set_immediate_dominator (CDI_DOMINATORS, body_bb,
-			   recompute_dominator (CDI_DOMINATORS, body_bb));
+    set_immediate_dominator (cfun, CDI_DOMINATORS, trip_update_bb, cont_bb);
+  set_immediate_dominator (cfun, CDI_DOMINATORS, iter_part_bb,
+			   recompute_dominator (cfun, CDI_DOMINATORS, iter_part_bb));
+  set_immediate_dominator (cfun, CDI_DOMINATORS, fin_bb,
+			   recompute_dominator (cfun, CDI_DOMINATORS, fin_bb));
+  set_immediate_dominator (cfun, CDI_DOMINATORS, seq_start_bb,
+			   recompute_dominator (cfun, CDI_DOMINATORS, seq_start_bb));
+  set_immediate_dominator (cfun, CDI_DOMINATORS, body_bb,
+			   recompute_dominator (cfun, CDI_DOMINATORS, body_bb));
 
   if (!broken_loop)
     {
@@ -7503,9 +7503,9 @@  expand_cilk_for (struct omp_region *region, struct omp_for_data *fd)
   e->probability = REG_BR_PROB_BASE * 7 / 8;
   ne->probability = REG_BR_PROB_BASE / 8;
 
-  set_immediate_dominator (CDI_DOMINATORS, l1_bb, entry_bb);
-  set_immediate_dominator (CDI_DOMINATORS, l2_bb, l2_dom_bb);
-  set_immediate_dominator (CDI_DOMINATORS, l0_bb, l1_bb);
+  set_immediate_dominator (cfun, CDI_DOMINATORS, l1_bb, entry_bb);
+  set_immediate_dominator (cfun, CDI_DOMINATORS, l2_bb, l2_dom_bb);
+  set_immediate_dominator (cfun, CDI_DOMINATORS, l0_bb, l1_bb);
 
   if (!broken_loop)
     {
@@ -7803,9 +7803,9 @@  expand_omp_simd (struct omp_region *region, struct omp_for_data *fd)
   e->probability = REG_BR_PROB_BASE * 7 / 8;
   ne->probability = REG_BR_PROB_BASE / 8;
 
-  set_immediate_dominator (CDI_DOMINATORS, l1_bb, entry_bb);
-  set_immediate_dominator (CDI_DOMINATORS, l2_bb, l2_dom_bb);
-  set_immediate_dominator (CDI_DOMINATORS, l0_bb, l1_bb);
+  set_immediate_dominator (cfun, CDI_DOMINATORS, l1_bb, entry_bb);
+  set_immediate_dominator (cfun, CDI_DOMINATORS, l2_bb, l2_dom_bb);
+  set_immediate_dominator (cfun, CDI_DOMINATORS, l0_bb, l1_bb);
 
   if (!broken_loop)
     {
@@ -8140,7 +8140,7 @@  expand_omp_sections (struct omp_region *region)
   gsi_insert_after (&si, stmt, GSI_SAME_STMT);
   gsi_remove (&si, true);
 
-  set_immediate_dominator (CDI_DOMINATORS, default_bb, l0_bb);
+  set_immediate_dominator (cfun, CDI_DOMINATORS, default_bb, l0_bb);
 }
 
 
@@ -9099,8 +9099,8 @@  expand_omp_target (struct omp_region *region)
 
       then_bb = create_empty_bb (cond_bb);
       else_bb = create_empty_bb (then_bb);
-      set_immediate_dominator (CDI_DOMINATORS, then_bb, cond_bb);
-      set_immediate_dominator (CDI_DOMINATORS, else_bb, cond_bb);
+      set_immediate_dominator (cfun, CDI_DOMINATORS, then_bb, cond_bb);
+      set_immediate_dominator (cfun, CDI_DOMINATORS, else_bb, cond_bb);
 
       stmt = gimple_build_cond_empty (cond);
       gsi = gsi_last_bb (cond_bb);
@@ -9491,7 +9491,7 @@  static void
 build_omp_regions (void)
 {
   gcc_assert (root_omp_region == NULL);
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_DOMINATORS);
   build_omp_regions_1 (ENTRY_BLOCK_PTR_FOR_FN (cfun), NULL, false);
 }
 
@@ -13578,7 +13578,7 @@  simd_clone_adjust (struct cgraph_node *node)
 	  }
       }
 
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_DOMINATORS);
   add_loop (loop, loop->header->loop_father);
   update_ssa (TODO_update_ssa);
 
diff --git a/gcc/passes.c b/gcc/passes.c
index d8e9271..521811c 100644
--- a/gcc/passes.c
+++ b/gcc/passes.c
@@ -2383,8 +2383,8 @@  execute_pass_list (function *fn, opt_pass *pass)
   execute_pass_list_1 (pass);
   if (fn->cfg)
     {
-      free_dominance_info (CDI_DOMINATORS);
-      free_dominance_info (CDI_POST_DOMINATORS);
+      free_dominance_info (fn, CDI_DOMINATORS);
+      free_dominance_info (fn, CDI_POST_DOMINATORS);
     }
   pop_cfun ();
 }
diff --git a/gcc/predict.c b/gcc/predict.c
index 965d7cb..4f22714 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -2296,8 +2296,8 @@  tree_estimate_probability_bb (basic_block bb)
       /* Look for block we are guarding (ie we dominate it,
 	 but it doesn't postdominate us).  */
       if (e->dest != EXIT_BLOCK_PTR_FOR_FN (cfun) && e->dest != bb
-	  && dominated_by_p (CDI_DOMINATORS, e->dest, e->src)
-	  && !dominated_by_p (CDI_POST_DOMINATORS, e->src, e->dest))
+	  && dominated_by_p (cfun, CDI_DOMINATORS, e->dest, e->src)
+	  && !dominated_by_p (cfun, CDI_POST_DOMINATORS, e->src, e->dest))
 	{
 	  gimple_stmt_iterator bi;
 
@@ -2337,7 +2337,7 @@  tree_estimate_probability (void)
   /* We use loop_niter_by_eval, which requires that the loops have
      preheaders.  */
   create_preheaders (CP_SIMPLE_PREHEADERS);
-  calculate_dominance_info (CDI_POST_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_POST_DOMINATORS);
 
   bb_predictions = new hash_map<const_basic_block, edge_prediction *>;
   tree_bb_level_predictions ();
@@ -2359,7 +2359,7 @@  tree_estimate_probability (void)
   bb_predictions = NULL;
 
   estimate_bb_frequencies (false);
-  free_dominance_info (CDI_POST_DOMINATORS);
+  free_dominance_info (cfun, CDI_POST_DOMINATORS);
   remove_fake_exit_edges ();
 }
 
@@ -2380,7 +2380,7 @@  predict_paths_for_bb (basic_block cur, basic_block bb,
      set of all blocks postdominated by BB.  */
   FOR_EACH_EDGE (e, ei, cur->preds)
     if (e->src->index >= NUM_FIXED_BLOCKS
-	&& !dominated_by_p (CDI_POST_DOMINATORS, e->src, bb))
+	&& !dominated_by_p (cfun, CDI_POST_DOMINATORS, e->src, bb))
     {
       edge e2;
       edge_iterator ei2;
@@ -2389,14 +2389,15 @@  predict_paths_for_bb (basic_block cur, basic_block bb,
       /* Ignore fake edges and eh, we predict them as not taken anyway.  */
       if (e->flags & (EDGE_EH | EDGE_FAKE))
 	continue;
-      gcc_assert (bb == cur || dominated_by_p (CDI_POST_DOMINATORS, cur, bb));
+      gcc_assert (bb == cur
+		  || dominated_by_p (cfun, CDI_POST_DOMINATORS, cur, bb));
 
       /* See if there is an edge from e->src that is not abnormal
 	 and does not lead to BB.  */
       FOR_EACH_EDGE (e2, ei2, e->src->succs)
 	if (e2 != e
 	    && !(e2->flags & (EDGE_EH | EDGE_FAKE))
-	    && !dominated_by_p (CDI_POST_DOMINATORS, e2->dest, bb))
+	    && !dominated_by_p (cfun, CDI_POST_DOMINATORS, e2->dest, bb))
 	  {
 	    found = true;
 	    break;
@@ -2446,7 +2447,7 @@  predict_paths_leading_to_edge (edge e, enum br_predictor pred,
   FOR_EACH_EDGE (e2, ei, bb->succs)
     if (e2->dest != e->src && e2->dest != e->dest
 	&& !(e->flags & (EDGE_EH | EDGE_FAKE))
-	&& !dominated_by_p (CDI_POST_DOMINATORS, e->src, e2->dest))
+	&& !dominated_by_p (cfun, CDI_POST_DOMINATORS, e->src, e2->dest))
       {
 	has_nonloop_edge = true;
 	break;
diff --git a/gcc/sanopt.c b/gcc/sanopt.c
index 269c11d..dcffeea 100644
--- a/gcc/sanopt.c
+++ b/gcc/sanopt.c
@@ -608,7 +608,7 @@  sanopt_optimize (function *fun)
 
   /* We're going to do a dominator walk, so ensure that we have
      dominance information.  */
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (fun, CDI_DOMINATORS);
 
   /* Recursively walk the dominator tree optimizing away
      redundant checks.  */
@@ -697,7 +697,7 @@  pass_sanopt::execute (function *fun)
 	      switch (ifn)
 		{
 		case IFN_UBSAN_NULL:
-		  no_next = ubsan_expand_null_ifn (&gsi);
+		  no_next = ubsan_expand_null_ifn (fun, &gsi);
 		  break;
 		case IFN_UBSAN_BOUNDS:
 		  no_next = ubsan_expand_bounds_ifn (&gsi);
diff --git a/gcc/sched-rgn.c b/gcc/sched-rgn.c
index ce2c172..73f7bd1 100644
--- a/gcc/sched-rgn.c
+++ b/gcc/sched-rgn.c
@@ -841,7 +841,7 @@  haifa_find_rgns (void)
 		    {
 		      /* Now verify that the block is dominated by the loop
 			 header.  */
-		      if (!dominated_by_p (CDI_DOMINATORS, jbb, bb))
+		      if (!dominated_by_p (cfun, CDI_DOMINATORS, jbb, bb))
 			break;
 		    }
 		}
@@ -3146,7 +3146,7 @@  sched_rgn_init (bool single_blocks_p)
     {
       /* Compute the dominators and post dominators.  */
       if (!sel_sched_p ())
-	calculate_dominance_info (CDI_DOMINATORS);
+	calculate_dominance_info (cfun, CDI_DOMINATORS);
 
       /* Find regions.  */
       find_rgns ();
@@ -3157,7 +3157,7 @@  sched_rgn_init (bool single_blocks_p)
       /* For now.  This will move as more and more of haifa is converted
 	 to using the cfg code.  */
       if (!sel_sched_p ())
-	free_dominance_info (CDI_DOMINATORS);
+	free_dominance_info (cfun, CDI_DOMINATORS);
     }
 
   gcc_assert (0 < nr_regions && nr_regions <= n_basic_blocks_for_fn (cfun));
diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c
index 9988285..a095368 100644
--- a/gcc/sel-sched-ir.c
+++ b/gcc/sel-sched-ir.c
@@ -3803,7 +3803,7 @@  maybe_tidy_empty_bb (basic_block bb)
   if (!dom_bbs.is_empty ())
     {
       dom_bbs.safe_push (succ_bb);
-      iterate_fix_dominators (CDI_DOMINATORS, dom_bbs, false);
+      iterate_fix_dominators (cfun, CDI_DOMINATORS, dom_bbs, false);
       dom_bbs.release ();
     }
 
@@ -3891,7 +3891,7 @@  tidy_control_flow (basic_block xbb, bool full_tidying)
 
 #ifdef ENABLE_CHECKING
   verify_backedges ();
-  verify_dominators (CDI_DOMINATORS);
+  verify_dominators (cfun, CDI_DOMINATORS);
 #endif
 
   return changed;
@@ -5220,8 +5220,9 @@  sel_remove_bb (basic_block bb, bool remove_from_cfg_p)
     {
       basic_block succ = single_succ (bb);
       delete_and_free_basic_block (bb);
-      set_immediate_dominator (CDI_DOMINATORS, succ,
-                               recompute_dominator (CDI_DOMINATORS, succ));
+      set_immediate_dominator (cfun, CDI_DOMINATORS, succ,
+			       recompute_dominator (cfun, CDI_DOMINATORS,
+						    succ));
     }
 
   rgn_setup_region (CONTAINING_RGN (idx));
@@ -5588,10 +5589,11 @@  sel_redirect_edge_and_branch_force (edge e, basic_block to)
   if (jump)
     sel_init_new_insn (jump, INSN_INIT_TODO_LUID | INSN_INIT_TODO_SIMPLEJUMP,
 		       old_seqno);
-  set_immediate_dominator (CDI_DOMINATORS, to,
-			   recompute_dominator (CDI_DOMINATORS, to));
-  set_immediate_dominator (CDI_DOMINATORS, orig_dest,
-			   recompute_dominator (CDI_DOMINATORS, orig_dest));
+  set_immediate_dominator (cfun, CDI_DOMINATORS, to,
+			   recompute_dominator (cfun, CDI_DOMINATORS, to));
+  set_immediate_dominator (cfun, CDI_DOMINATORS, orig_dest,
+			   recompute_dominator (cfun, CDI_DOMINATORS,
+						orig_dest));
 }
 
 /* A wrapper for redirect_edge_and_branch.  Return TRUE if blocks connected by
@@ -5647,10 +5649,11 @@  sel_redirect_edge_and_branch (edge e, basic_block to)
      Otherwise we'll update in maybe_tidy_empty_bb.  */
   if (!maybe_unreachable)
     {
-      set_immediate_dominator (CDI_DOMINATORS, to,
-                               recompute_dominator (CDI_DOMINATORS, to));
-      set_immediate_dominator (CDI_DOMINATORS, orig_dest,
-                               recompute_dominator (CDI_DOMINATORS, orig_dest));
+      set_immediate_dominator (cfun, CDI_DOMINATORS, to,
+			       recompute_dominator (cfun, CDI_DOMINATORS, to));
+      set_immediate_dominator (cfun, CDI_DOMINATORS, orig_dest,
+			       recompute_dominator (cfun, CDI_DOMINATORS,
+						    orig_dest));
     }
   return recompute_toporder_p;
 }
@@ -6401,9 +6404,10 @@  sel_remove_loop_preheader (void)
                     free_data_sets (prev_bb);
                 }
 
-              set_immediate_dominator (CDI_DOMINATORS, next_bb,
-                                       recompute_dominator (CDI_DOMINATORS,
-                                                            next_bb));
+	      set_immediate_dominator (cfun, CDI_DOMINATORS, next_bb,
+				       recompute_dominator (cfun,
+							    CDI_DOMINATORS,
+							    next_bb));
             }
         }
       vec_free (preheader_blocks);
diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c
index 1860444..e2d5f44 100644
--- a/gcc/sel-sched.c
+++ b/gcc/sel-sched.c
@@ -4835,7 +4835,7 @@  remove_insns_that_need_bookkeeping (fence_t fence, av_set_t *av_ptr)
 	  && (!bookkeeping_p || VINSN_UNIQUE_P (EXPR_VINSN (expr)))
 	  && (EXPR_SPEC (expr)
 	      || !EXPR_ORIG_BB_INDEX (expr)
-	      || !dominated_by_p (CDI_DOMINATORS,
+	      || !dominated_by_p (cfun, CDI_DOMINATORS,
 				  BASIC_BLOCK_FOR_FN (cfun,
 						      EXPR_ORIG_BB_INDEX (expr)),
 				  BLOCK_FOR_INSN (FENCE_INSN (fence)))))
@@ -7654,7 +7654,7 @@  sel_sched_region (int rgn)
 static void
 sel_global_init (void)
 {
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_DOMINATORS);
   alloc_sched_pools ();
 
   /* Setup the infos for sched_init.  */
@@ -7696,7 +7696,7 @@  sel_global_finish (void)
     sel_finish_pipelining ();
 
   free_sched_pools ();
-  free_dominance_info (CDI_DOMINATORS);
+  free_dominance_info (cfun, CDI_DOMINATORS);
 }
 
 /* Return true when we need to skip selective scheduling.  Used for debugging.  */
diff --git a/gcc/sese.h b/gcc/sese.h
index 52aa868..e87029a 100644
--- a/gcc/sese.h
+++ b/gcc/sese.h
@@ -90,13 +90,13 @@  bb_in_region (basic_block bb, basic_block entry, basic_block exit)
     /* Check that there are no edges coming in the region: all the
        predecessors of EXIT are dominated by ENTRY.  */
     FOR_EACH_EDGE (e, ei, exit->preds)
-      dominated_by_p (CDI_DOMINATORS, e->src, entry);
+      dominated_by_p (cfun, CDI_DOMINATORS, e->src, entry);
   }
 #endif
 
-  return dominated_by_p (CDI_DOMINATORS, bb, entry)
-	 && !(dominated_by_p (CDI_DOMINATORS, bb, exit)
-	      && !dominated_by_p (CDI_DOMINATORS, entry, exit));
+  return dominated_by_p (cfun, CDI_DOMINATORS, bb, entry)
+	 && !(dominated_by_p (cfun, CDI_DOMINATORS, bb, exit)
+	      && !dominated_by_p (cfun, CDI_DOMINATORS, entry, exit));
 }
 
 /* Checks whether BB is contained in the region delimited by ENTRY and
@@ -255,8 +255,8 @@  static inline void
 recompute_all_dominators (void)
 {
   mark_irreducible_loops ();
-  free_dominance_info (CDI_DOMINATORS);
-  calculate_dominance_info (CDI_DOMINATORS);
+  free_dominance_info (cfun, CDI_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_DOMINATORS);
 }
 
 typedef struct gimple_bb
diff --git a/gcc/tracer.c b/gcc/tracer.c
index cad7ab1..dc7f421 100644
--- a/gcc/tracer.c
+++ b/gcc/tracer.c
@@ -413,7 +413,7 @@  pass_tracer::execute (function *fun)
   changed = tail_duplicate ();
   if (changed)
     {
-      free_dominance_info (CDI_DOMINATORS);
+      free_dominance_info (fun, CDI_DOMINATORS);
       /* If we changed the CFG schedule loops for fixup by cleanup_cfg.  */
       loops_state_set (LOOPS_NEED_FIXUP);
     }
diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c
index 891e638..37abc0c 100644
--- a/gcc/trans-mem.c
+++ b/gcc/trans-mem.c
@@ -1070,7 +1070,7 @@  transaction_invariant_address_p (const_tree mem, basic_block region_entry_block)
 
       def_bb = gimple_bb (SSA_NAME_DEF_STMT (TREE_OPERAND (mem, 0)));
       return def_bb != region_entry_block
-	&& dominated_by_p (CDI_DOMINATORS, region_entry_block, def_bb);
+	&& dominated_by_p (cfun, CDI_DOMINATORS, region_entry_block, def_bb);
     }
 
   mem = strip_invariant_refs (mem);
@@ -1153,11 +1153,11 @@  tm_log_add (basic_block entry_block, tree addr, gimple stmt)
 	    return;
 	  /* We already have a store to the same address, higher up the
 	     dominator tree.  Nothing to do.  */
-	  if (dominated_by_p (CDI_DOMINATORS,
+	  if (dominated_by_p (cfun, CDI_DOMINATORS,
 			      gimple_bb (stmt), gimple_bb (oldstmt)))
 	    return;
 	  /* We should be processing blocks in dominator tree order.  */
-	  gcc_assert (!dominated_by_p (CDI_DOMINATORS,
+	  gcc_assert (!dominated_by_p (cfun, CDI_DOMINATORS,
 				       gimple_bb (oldstmt), gimple_bb (stmt)));
 	}
       /* Store is on a different code path.  */
@@ -1400,7 +1400,8 @@  thread_private_new_memory (basic_block entry_block, tree x)
       /* If the malloc call is outside the transaction, this is
 	 thread-local.  */
       if (retval != mem_thread_local
-	  && !dominated_by_p (CDI_DOMINATORS, gimple_bb (stmt), entry_block))
+	  && !dominated_by_p (cfun, CDI_DOMINATORS,
+			      gimple_bb (stmt), entry_block))
 	retval = mem_thread_local;
 
       if (is_gimple_assign (stmt))
@@ -2027,7 +2028,7 @@  gate_tm_init (void)
   if (!flag_tm)
     return false;
 
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_DOMINATORS);
   bitmap_obstack_initialize (&tm_obstack);
 
   /* If the function is a TM_CLONE, then the entire function is the region.  */
@@ -3026,7 +3027,7 @@  execute_tm_mark (void)
 
   if (pending_edge_inserts_p)
     gsi_commit_edge_inserts ();
-  free_dominance_info (CDI_DOMINATORS);
+  free_dominance_info (cfun, CDI_DOMINATORS);
   return 0;
 }
 
@@ -3236,7 +3237,7 @@  pass_tm_edges::execute (function *fun)
   /* We've got to release the dominance info now, to indicate that it
      must be rebuilt completely.  Otherwise we'll crash trying to update
      the SSA web in the TODO section following this pass.  */
-  free_dominance_info (CDI_DOMINATORS);
+  free_dominance_info (fun, CDI_DOMINATORS);
   bitmap_obstack_release (&tm_obstack);
   all_tm_regions = NULL;
 
@@ -4216,7 +4217,7 @@  ipa_tm_scan_calls_transaction (struct tm_ipa_cg_data *d,
   // ??? In ipa_uninstrument_transaction we don't try to update dominators
   // because copy_bbs doesn't return a VEC like iterate_fix_dominators expects.
   // Instead, just release dominators here so update_ssa recomputes them.
-  free_dominance_info (CDI_DOMINATORS);
+  free_dominance_info (cfun, CDI_DOMINATORS);
 
   // When building the uninstrumented code path, copy_bbs will have invoked
   // create_new_def_for starting an "ssa update context".  There is only one
@@ -4536,8 +4537,9 @@  ipa_tm_scan_irr_function (struct cgraph_node *node, bool for_clone)
       || DECL_STRUCT_FUNCTION (node->decl)->cfg == NULL)
     return false;
 
-  push_cfun (DECL_STRUCT_FUNCTION (node->decl));
-  calculate_dominance_info (CDI_DOMINATORS);
+  function *fn = DECL_STRUCT_FUNCTION (node->decl);
+  push_cfun (fn);
+  calculate_dominance_info (fn, CDI_DOMINATORS);
 
   d = get_cg_data (&node, true);
   auto_vec<basic_block, 10> queue;
@@ -5266,8 +5268,9 @@  ipa_tm_transform_transaction (struct cgraph_node *node)
 
   d = get_cg_data (&node, true);
 
-  push_cfun (DECL_STRUCT_FUNCTION (node->decl));
-  calculate_dominance_info (CDI_DOMINATORS);
+  function *fn = DECL_STRUCT_FUNCTION (node->decl);
+  push_cfun (fn);
+  calculate_dominance_info (fn, CDI_DOMINATORS);
 
   for (region = d->all_tm_regions; region; region = region->next)
     {
@@ -5309,8 +5312,9 @@  ipa_tm_transform_clone (struct cgraph_node *node)
   if (!node->callees && !node->indirect_calls && !d->irrevocable_blocks_clone)
     return;
 
-  push_cfun (DECL_STRUCT_FUNCTION (d->clone->decl));
-  calculate_dominance_info (CDI_DOMINATORS);
+  function *fn = DECL_STRUCT_FUNCTION (d->clone->decl);
+  push_cfun (fn);
+  calculate_dominance_info (fn, CDI_DOMINATORS);
 
   need_ssa_rename =
     ipa_tm_transform_calls (d->clone, NULL,
@@ -5368,8 +5372,9 @@  ipa_tm_execute (void)
 	    continue;
 	  }
 
-	push_cfun (DECL_STRUCT_FUNCTION (node->decl));
-	calculate_dominance_info (CDI_DOMINATORS);
+	function *fn = DECL_STRUCT_FUNCTION (node->decl);
+	push_cfun (fn);
+	calculate_dominance_info (fn, CDI_DOMINATORS);
 
 	tm_region_init (NULL);
 	if (all_tm_regions)
diff --git a/gcc/tree-call-cdce.c b/gcc/tree-call-cdce.c
index 6e9b14c..2527dcb 100644
--- a/gcc/tree-call-cdce.c
+++ b/gcc/tree-call-cdce.c
@@ -939,8 +939,8 @@  pass_call_cdce::execute (function *fun)
 
   if (something_changed)
     {
-      free_dominance_info (CDI_DOMINATORS);
-      free_dominance_info (CDI_POST_DOMINATORS);
+      free_dominance_info (fun, CDI_DOMINATORS);
+      free_dominance_info (fun, CDI_POST_DOMINATORS);
       /* As we introduced new control-flow we need to insert PHI-nodes
          for the call-clobbers of the remaining call.  */
       mark_virtual_operands_for_renaming (fun);
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 588ab69..026a44f 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -5411,8 +5411,8 @@  gimple_verify_flow_info (void)
 	}
     }
 
-  if (dom_info_state (CDI_DOMINATORS) >= DOM_NO_FAST_QUERY)
-    verify_dominators (CDI_DOMINATORS);
+  if (dom_info_state (cfun, CDI_DOMINATORS) >= DOM_NO_FAST_QUERY)
+    verify_dominators (cfun, CDI_DOMINATORS);
 
   return err;
 }
@@ -6040,12 +6040,12 @@  gimple_duplicate_sese_region (edge entry, edge exit,
     {
       copying_header = true;
 
-      if (!dominated_by_p (CDI_DOMINATORS, loop->latch, exit->src))
+      if (!dominated_by_p (cfun, CDI_DOMINATORS, loop->latch, exit->src))
 	return false;
 
       for (i = 0; i < n_region; i++)
 	if (region[i] != exit->src
-	    && dominated_by_p (CDI_DOMINATORS, region[i], exit->src))
+	    && dominated_by_p (cfun, CDI_DOMINATORS, region[i], exit->src))
 	  return false;
     }
 
@@ -6125,9 +6125,9 @@  gimple_duplicate_sese_region (edge entry, edge exit,
      well.  */
   if (update_dominance)
     {
-      set_immediate_dominator (CDI_DOMINATORS, entry->dest, entry->src);
+      set_immediate_dominator (cfun, CDI_DOMINATORS, entry->dest, entry->src);
       doms.safe_push (get_bb_original (entry->dest));
-      iterate_fix_dominators (CDI_DOMINATORS, doms, false);
+      iterate_fix_dominators (cfun, CDI_DOMINATORS, doms, false);
       doms.release ();
     }
 
@@ -6285,7 +6285,7 @@  gimple_duplicate_sese_tail (edge entry ATTRIBUTE_UNUSED, edge exit ATTRIBUTE_UNU
     switch_bb = entry->src;
   else
     switch_bb = split_edge (entry);
-  set_immediate_dominator (CDI_DOMINATORS, nentry_bb, switch_bb);
+  set_immediate_dominator (cfun, CDI_DOMINATORS, nentry_bb, switch_bb);
 
   gsi = gsi_last_bb (switch_bb);
   cond_stmt = last_stmt (exit->src);
@@ -6333,7 +6333,7 @@  gimple_duplicate_sese_tail (edge entry ATTRIBUTE_UNUSED, edge exit ATTRIBUTE_UNU
   
   /* Anything that is outside of the region, but was dominated by something
      inside needs to update dominance info.  */
-  iterate_fix_dominators (CDI_DOMINATORS, doms, false);
+  iterate_fix_dominators (cfun, CDI_DOMINATORS, doms, false);
   doms.release ();
   /* Update the SSA web.  */
   update_ssa (TODO_update_ssa);
@@ -6659,7 +6659,7 @@  move_block_to_fn (struct function *dest_cfun, basic_block bb,
   unsigned old_len, new_len;
 
   /* Remove BB from dominance structures.  */
-  delete_from_dominance_info (CDI_DOMINATORS, bb);
+  delete_from_dominance_info (cfun, CDI_DOMINATORS, bb);
 
   /* Move BB from its current loop to the copy in the new function.  */
   if (current_loops)
@@ -7040,7 +7040,7 @@  move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb,
      region.  */
   gcc_assert (entry_bb != exit_bb
               && (!exit_bb
-		  || dominated_by_p (CDI_DOMINATORS, exit_bb, entry_bb)));
+		  || dominated_by_p (cfun, CDI_DOMINATORS, exit_bb, entry_bb)));
 
   /* Collect all the blocks in the region.  Manually add ENTRY_BB
      because it won't be added by dfs_enumerate_from.  */
@@ -7280,9 +7280,9 @@  move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb,
       e->probability = exit_prob[i];
     }
 
-  set_immediate_dominator (CDI_DOMINATORS, bb, dom_entry);
+  set_immediate_dominator (cfun, CDI_DOMINATORS, bb, dom_entry);
   FOR_EACH_VEC_ELT (dom_bbs, i, abb)
-    set_immediate_dominator (CDI_DOMINATORS, abb, bb);
+    set_immediate_dominator (cfun, CDI_DOMINATORS, abb, bb);
   dom_bbs.release ();
 
   if (exit_bb)
@@ -7899,7 +7899,7 @@  remove_edge_and_dominated_blocks (edge e)
       && e->src->loop_father == e->dest->loop_father)
     loops_state_set (LOOPS_NEED_FIXUP);
 
-  if (!dom_info_available_p (CDI_DOMINATORS))
+  if (!dom_info_available_p (cfun, CDI_DOMINATORS))
     {
       remove_edge (e);
       return;
@@ -7926,7 +7926,7 @@  remove_edge_and_dominated_blocks (edge e)
       if (f == e)
 	continue;
 
-      if (!dominated_by_p (CDI_DOMINATORS, f->src, e->dest))
+      if (!dominated_by_p (cfun, CDI_DOMINATORS, f->src, e->dest))
 	{
 	  none_removed = true;
 	  break;
@@ -8000,7 +8000,7 @@  remove_edge_and_dominated_blocks (edge e)
 	bbs_to_fix_dom.safe_push (dbb);
     }
 
-  iterate_fix_dominators (CDI_DOMINATORS, bbs_to_fix_dom, true);
+  iterate_fix_dominators (cfun, CDI_DOMINATORS, bbs_to_fix_dom, true);
 
   BITMAP_FREE (df);
   BITMAP_FREE (df_idom);
@@ -8381,10 +8381,10 @@  insert_cond_bb (basic_block bb, gimple stmt, gimple cond)
   fall->flags = EDGE_FALSE_VALUE;
 
   /* Update dominance info.  */
-  if (dom_info_available_p (CDI_DOMINATORS))
+  if (dom_info_available_p (cfun, CDI_DOMINATORS))
     {
-      set_immediate_dominator (CDI_DOMINATORS, new_bb, bb);
-      set_immediate_dominator (CDI_DOMINATORS, fall->dest, bb);
+      set_immediate_dominator (cfun, CDI_DOMINATORS, new_bb, bb);
+      set_immediate_dominator (cfun, CDI_DOMINATORS, fall->dest, bb);
     }
 
   /* Update loop info.  */
diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c
index f3da9c5..136555a 100644
--- a/gcc/tree-cfgcleanup.c
+++ b/gcc/tree-cfgcleanup.c
@@ -526,7 +526,7 @@  remove_forwarder_block (basic_block bb)
   bitmap_set_bit (cfgcleanup_altered_bbs, dest->index);
 
   /* Update the dominators.  */
-  if (dom_info_available_p (CDI_DOMINATORS))
+  if (dom_info_available_p (cfun, CDI_DOMINATORS))
     {
       basic_block dom, dombb, domdest;
 
@@ -541,7 +541,7 @@  remove_forwarder_block (basic_block bb)
       else
 	dom = nearest_common_dominator (CDI_DOMINATORS, domdest, dombb);
 
-      set_immediate_dominator (CDI_DOMINATORS, dest, dom);
+      set_immediate_dominator (cfun, CDI_DOMINATORS, dest, dom);
     }
 
   /* Adjust latch infomation of BB's parent loop as otherwise
@@ -717,22 +717,22 @@  cleanup_tree_cfg_noloop (void)
 
      If dominance information is available, there cannot be any unreachable
      blocks.  */
-  if (!dom_info_available_p (CDI_DOMINATORS))
+  if (!dom_info_available_p (cfun, CDI_DOMINATORS))
     {
       changed = delete_unreachable_blocks ();
-      calculate_dominance_info (CDI_DOMINATORS);
+      calculate_dominance_info (cfun, CDI_DOMINATORS);
     }
   else
     {
 #ifdef ENABLE_CHECKING
-      verify_dominators (CDI_DOMINATORS);
+      verify_dominators (cfun, CDI_DOMINATORS);
 #endif
       changed = false;
     }
 
   changed |= cleanup_tree_cfg_1 ();
 
-  gcc_assert (dom_info_available_p (CDI_DOMINATORS));
+  gcc_assert (dom_info_available_p (cfun, CDI_DOMINATORS));
   compact_blocks ();
 
 #ifdef ENABLE_CHECKING
@@ -755,7 +755,7 @@  repair_loop_structures (void)
   bitmap changed_bbs;
   unsigned n_new_loops;
 
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_DOMINATORS);
 
   timevar_push (TV_REPAIR_LOOPS);
   changed_bbs = BITMAP_ALLOC (NULL);
@@ -905,7 +905,7 @@  remove_forwarder_block_with_phi (basic_block bb)
   else
     dom = nearest_common_dominator (CDI_DOMINATORS, domdest, dombb);
 
-  set_immediate_dominator (CDI_DOMINATORS, dest, dom);
+  set_immediate_dominator (cfun, CDI_DOMINATORS, dest, dom);
 
   /* Adjust latch infomation of BB's parent loop as otherwise
      the cfg hook has a hard time not to kill the loop.  */
@@ -979,7 +979,7 @@  pass_merge_phi::execute (function *fun)
   basic_block *current = worklist;
   basic_block bb;
 
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (fun, CDI_DOMINATORS);
 
   /* Find all PHI nodes that we may be able to merge.  */
   FOR_EACH_BB_FN (bb, fun)
@@ -1000,7 +1000,7 @@  pass_merge_phi::execute (function *fun)
 	  || bb_has_abnormal_pred (bb))
 	continue;
 
-      if (!dominated_by_p (CDI_DOMINATORS, dest, bb))
+      if (!dominated_by_p (fun, CDI_DOMINATORS, dest, bb))
 	{
 	  /* If BB does not dominate DEST, then the PHI nodes at
 	     DEST must be the only users of the results of the PHI
diff --git a/gcc/tree-chkp-opt.c b/gcc/tree-chkp-opt.c
index 66c99bd..5ed2077 100644
--- a/gcc/tree-chkp-opt.c
+++ b/gcc/tree-chkp-opt.c
@@ -1180,7 +1180,7 @@  chkp_reduce_bounds_lifetime (void)
 	    continue;
 
 	  if (dom_bb &&
-	      dominated_by_p (CDI_DOMINATORS,
+	      dominated_by_p (cfun, CDI_DOMINATORS,
 			      dom_bb, gimple_bb (use_stmt)))
 	    {
 	      dom_use = use_stmt;
@@ -1267,8 +1267,8 @@  chkp_opt_init (void)
 {
   check_infos.create (0);
 
-  calculate_dominance_info (CDI_DOMINATORS);
-  calculate_dominance_info (CDI_POST_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_POST_DOMINATORS);
 
   /* With LTO constant bounds vars may be not initialized by now.
      Get constant bounds vars to handle their assignments during
@@ -1283,7 +1283,7 @@  chkp_opt_fini (void)
 {
   chkp_fix_cfg ();
 
-  free_dominance_info (CDI_POST_DOMINATORS);
+  free_dominance_info (cfun, CDI_POST_DOMINATORS);
 }
 
 /* Checker optimization pass function.  */
diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c
index 8c1b48c..a0832f5 100644
--- a/gcc/tree-chkp.c
+++ b/gcc/tree-chkp.c
@@ -4359,8 +4359,8 @@  chkp_init (void)
   chkp_get_zero_bounds_var ();
   chkp_get_none_bounds_var ();
 
-  calculate_dominance_info (CDI_DOMINATORS);
-  calculate_dominance_info (CDI_POST_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_POST_DOMINATORS);
 
   bitmap_obstack_initialize (NULL);
 }
@@ -4376,8 +4376,8 @@  chkp_fini (void)
   delete chkp_reg_addr_bounds;
   delete chkp_incomplete_bounds_map;
 
-  free_dominance_info (CDI_DOMINATORS);
-  free_dominance_info (CDI_POST_DOMINATORS);
+  free_dominance_info (cfun, CDI_DOMINATORS);
+  free_dominance_info (cfun, CDI_POST_DOMINATORS);
 
   bitmap_obstack_release (NULL);
 
diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c
index 193fc65..6056580 100644
--- a/gcc/tree-complex.c
+++ b/gcc/tree-complex.c
@@ -1170,10 +1170,10 @@  expand_complex_div_wide (gimple_stmt_iterator *gsi, tree inner_type,
 
       /* Update dominance info.  Note that bb_join's data was
          updated by split_block.  */
-      if (dom_info_available_p (CDI_DOMINATORS))
+      if (dom_info_available_p (cfun, CDI_DOMINATORS))
         {
-          set_immediate_dominator (CDI_DOMINATORS, bb_true, bb_cond);
-          set_immediate_dominator (CDI_DOMINATORS, bb_false, bb_cond);
+	  set_immediate_dominator (cfun, CDI_DOMINATORS, bb_true, bb_cond);
+	  set_immediate_dominator (cfun, CDI_DOMINATORS, bb_false, bb_cond);
         }
 
       rr = create_tmp_reg (inner_type);
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index c1ca468..33387e4 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -3353,8 +3353,8 @@  pass_lower_resx::execute (function *fun)
 
   if (dominance_invalidated)
     {
-      free_dominance_info (CDI_DOMINATORS);
-      free_dominance_info (CDI_POST_DOMINATORS);
+      free_dominance_info (fun, CDI_DOMINATORS);
+      free_dominance_info (fun, CDI_POST_DOMINATORS);
     }
 
   return any_rewritten ? TODO_update_ssa_only_virtuals : 0;
@@ -4554,8 +4554,8 @@  execute_cleanup_eh_1 (void)
 
       if (changed)
 	{
-	  free_dominance_info (CDI_DOMINATORS);
-	  free_dominance_info (CDI_POST_DOMINATORS);
+	  free_dominance_info (cfun, CDI_DOMINATORS);
+	  free_dominance_info (cfun, CDI_POST_DOMINATORS);
 
           /* We delayed all basic block deletion, as we may have performed
 	     cleanups on EH edges while non-EH edges were still present.  */
diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c
index 291e602..2aa0929 100644
--- a/gcc/tree-if-conv.c
+++ b/gcc/tree-if-conv.c
@@ -432,7 +432,7 @@  add_to_predicate_list (struct loop *loop, basic_block bb, tree nc)
 
   /* If dominance tells us this basic block is always executed,
      don't record any predicates for it.  */
-  if (dominated_by_p (CDI_DOMINATORS, loop->latch, bb))
+  if (dominated_by_p (cfun, CDI_DOMINATORS, loop->latch, bb))
     return;
 
   dom_bb = get_immediate_dominator (CDI_DOMINATORS, bb);
@@ -497,7 +497,7 @@  add_to_dst_predicate_list (struct loop *loop, edge e,
     cond = fold_build2 (TRUTH_AND_EXPR, boolean_type_node,
 			prev_cond, cond);
 
-  if (!dominated_by_p (CDI_DOMINATORS, loop->latch, e->dest))
+  if (!dominated_by_p (cfun, CDI_DOMINATORS, loop->latch, e->dest))
     add_to_predicate_list (loop, e->dest, cond);
 }
 
@@ -1037,7 +1037,7 @@  if_convertible_bb_p (struct loop *loop, basic_block bb, basic_block exit_bb)
 	}
       else if (bb == loop->latch
 	       && bb != exit_bb
-	       && !dominated_by_p (CDI_DOMINATORS, bb, exit_bb))
+	       && !dominated_by_p (cfun, CDI_DOMINATORS, bb, exit_bb))
 	  {
 	    if (dump_file && (dump_flags & TDF_DETAILS))
 	      fprintf (dump_file, "latch is not dominated by exit_block\n");
@@ -1256,8 +1256,8 @@  if_convertible_loop_p_1 (struct loop *loop,
   if (!res)
     return false;
 
-  calculate_dominance_info (CDI_DOMINATORS);
-  calculate_dominance_info (CDI_POST_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_POST_DOMINATORS);
 
   /* Allow statements that can be handled during if-conversion.  */
   ifc_bbs = get_loop_body_in_if_conv_order (loop);
@@ -1314,7 +1314,7 @@  if_convertible_loop_p_1 (struct loop *loop,
       gimple_stmt_iterator itr;
 
       /* Check the if-convertibility of statements in predicated BBs.  */
-      if (!dominated_by_p (CDI_DOMINATORS, loop->latch, bb))
+      if (!dominated_by_p (cfun, CDI_DOMINATORS, loop->latch, bb))
 	for (itr = gsi_start_bb (bb); !gsi_end_p (itr); gsi_next (&itr))
 	  if (!if_convertible_stmt_p (gsi_stmt (itr), *refs,
 				      any_mask_load_store))
@@ -2232,7 +2232,7 @@  combine_blocks (struct loop *loop, bool any_mask_load_store)
 	{
 	  /* Connect this node to loop header.  */
 	  make_edge (loop->header, exit_bb, EDGE_FALLTHRU);
-	  set_immediate_dominator (CDI_DOMINATORS, exit_bb, loop->header);
+	  set_immediate_dominator (cfun, CDI_DOMINATORS, exit_bb, loop->header);
 	}
 
       /* Redirect non-exit edges to loop->latch.  */
@@ -2241,13 +2241,13 @@  combine_blocks (struct loop *loop, bool any_mask_load_store)
 	  if (!loop_exit_edge_p (loop, e))
 	    redirect_edge_and_branch (e, loop->latch);
 	}
-      set_immediate_dominator (CDI_DOMINATORS, loop->latch, exit_bb);
+      set_immediate_dominator (cfun, CDI_DOMINATORS, loop->latch, exit_bb);
     }
   else
     {
       /* If the loop does not have an exit, reconnect header and latch.  */
       make_edge (loop->header, loop->latch, EDGE_FALLTHRU);
-      set_immediate_dominator (CDI_DOMINATORS, loop->latch, loop->header);
+      set_immediate_dominator (cfun, CDI_DOMINATORS, loop->latch, loop->header);
     }
 
   merge_target_bb = loop->header;
@@ -2727,7 +2727,7 @@  tree_if_conversion (struct loop *loop)
       free (ifc_bbs);
       ifc_bbs = NULL;
     }
-  free_dominance_info (CDI_POST_DOMINATORS);
+  free_dominance_info (cfun, CDI_POST_DOMINATORS);
 
   return todo;
 }
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index e1ceea4..3e360d4 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -4950,8 +4950,8 @@  optimize_inline_calls (tree fn)
   push_gimplify_context ();
 
   /* We make no attempts to keep dominance info up-to-date.  */
-  free_dominance_info (CDI_DOMINATORS);
-  free_dominance_info (CDI_POST_DOMINATORS);
+  free_dominance_info (cfun, CDI_DOMINATORS);
+  free_dominance_info (cfun, CDI_POST_DOMINATORS);
 
   /* Register specific gimple functions.  */
   gimple_register_cfg_hooks ();
@@ -5842,8 +5842,8 @@  tree_function_versioning (tree old_decl, tree new_decl,
   delete id.decl_map;
   if (id.debug_map)
     delete id.debug_map;
-  free_dominance_info (CDI_DOMINATORS);
-  free_dominance_info (CDI_POST_DOMINATORS);
+  free_dominance_info (cfun, CDI_DOMINATORS);
+  free_dominance_info (cfun, CDI_POST_DOMINATORS);
 
   fold_marked_statements (0, id.statements_to_fold);
   delete id.statements_to_fold;
@@ -5852,7 +5852,7 @@  tree_function_versioning (tree old_decl, tree new_decl,
     cgraph_edge::rebuild_references ();
   if (loops_state_satisfies_p (LOOPS_NEED_FIXUP))
     {
-      calculate_dominance_info (CDI_DOMINATORS);
+      calculate_dominance_info (cfun, CDI_DOMINATORS);
       fix_loop_structure (NULL);
     }
   update_ssa (TODO_update_ssa);
@@ -5881,8 +5881,8 @@  tree_function_versioning (tree old_decl, tree new_decl,
 	}
     }
 
-  free_dominance_info (CDI_DOMINATORS);
-  free_dominance_info (CDI_POST_DOMINATORS);
+  free_dominance_info (cfun, CDI_DOMINATORS);
+  free_dominance_info (cfun, CDI_POST_DOMINATORS);
 
   gcc_assert (!id.debug_stmts.exists ());
   pop_cfun ();
diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c
index cc77618..178f963 100644
--- a/gcc/tree-into-ssa.c
+++ b/gcc/tree-into-ssa.c
@@ -556,7 +556,7 @@  set_livein_block (tree var, basic_block bb)
       int def_block_index = bitmap_first_set_bit (db_p->def_blocks);
 
       if (def_block_index == -1
-	  || ! dominated_by_p (CDI_DOMINATORS, bb,
+	  || ! dominated_by_p (cfun, CDI_DOMINATORS, bb,
 	                       BASIC_BLOCK_FOR_FN (cfun, def_block_index)))
 	info->need_phi_state = NEED_PHI_STATE_MAYBE;
     }
@@ -1274,7 +1274,7 @@  rewrite_debug_stmt_uses (gimple stmt)
 	    ;
 	  /* If definition bb doesn't dominate the current bb,
 	     it can't be used.  */
-	  else if (def_bb && !dominated_by_p (CDI_DOMINATORS, bb, def_bb))
+	  else if (def_bb && !dominated_by_p (cfun, CDI_DOMINATORS, bb, def_bb))
 	    def = NULL;
 	  /* If there is just one definition and dominates the current
 	     bb, it is fine.  */
@@ -2376,7 +2376,7 @@  pass_build_ssa::execute (function *fun)
     bitmap_initialize (&dfs[bb->index], &bitmap_default_obstack);
 
   /* 1- Compute dominance frontiers.  */
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (fun, CDI_DOMINATORS);
   compute_dominance_frontiers (dfs);
 
   /* 2- Find and mark definition sites.  */
@@ -3032,12 +3032,12 @@  insert_updated_phi_nodes_for (tree var, bitmap_head *dfs, bitmap blocks,
 	  /* If doing regular SSA updates for GIMPLE registers, we are
 	     only interested in IDF blocks dominated by the nearest
 	     common dominator of all the definition blocks.  */
-	  entry = nearest_common_dominator_for_set (CDI_DOMINATORS,
+	  entry = nearest_common_dominator_for_set (cfun, CDI_DOMINATORS,
 						    db->def_blocks);
 	  if (entry != ENTRY_BLOCK_PTR_FOR_FN (cfun))
 	    EXECUTE_IF_SET_IN_BITMAP (idf, 0, i, bi)
 	      if (BASIC_BLOCK_FOR_FN (cfun, i) != entry
-		  && dominated_by_p (CDI_DOMINATORS,
+		  && dominated_by_p (cfun, CDI_DOMINATORS,
 				     BASIC_BLOCK_FOR_FN (cfun, i), entry))
 		bitmap_set_bit (pruned_idf, i);
 	}
@@ -3242,7 +3242,7 @@  update_ssa (unsigned update_flags)
   blocks_to_update = BITMAP_ALLOC (NULL);
 
   /* Ensure that the dominance information is up-to-date.  */
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_DOMINATORS);
 
   insert_phi_p = (update_flags != TODO_update_ssa_no_phi);
 
@@ -3309,7 +3309,7 @@  update_ssa (unsigned update_flags)
     {
       /* Otherwise, the entry block to the region is the nearest
 	 common dominator for the blocks in BLOCKS.  */
-      start_bb = nearest_common_dominator_for_set (CDI_DOMINATORS,
+      start_bb = nearest_common_dominator_for_set (cfun, CDI_DOMINATORS,
 						   blocks_to_update);
     }
 
@@ -3357,7 +3357,7 @@  update_ssa (unsigned update_flags)
 	 We need to re-compute START_BB to include the newly added
 	 blocks.  */
       if (start_bb != ENTRY_BLOCK_PTR_FOR_FN (cfun))
-	start_bb = nearest_common_dominator_for_set (CDI_DOMINATORS,
+	start_bb = nearest_common_dominator_for_set (cfun, CDI_DOMINATORS,
 						     blocks_to_update);
     }
 
diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c
index 213793e..642bac9 100644
--- a/gcc/tree-loop-distribution.c
+++ b/gcc/tree-loop-distribution.c
@@ -919,8 +919,8 @@  destroy_loop (struct loop *loop)
     }
   free (bbs);
 
-  set_immediate_dominator (CDI_DOMINATORS, dest,
-			   recompute_dominator (CDI_DOMINATORS, dest));
+  set_immediate_dominator (cfun, CDI_DOMINATORS, dest,
+			   recompute_dominator (cfun, CDI_DOMINATORS, dest));
 }
 
 /* Generates code for PARTITION.  */
@@ -1063,7 +1063,7 @@  classify_partition (loop_p loop, struct graph *rdg, partition_t partition)
   nb_iter = number_of_latch_executions (loop);
   if (!nb_iter || nb_iter == chrec_dont_know)
     return;
-  if (dominated_by_p (CDI_DOMINATORS, single_exit (loop)->src,
+  if (dominated_by_p (cfun, CDI_DOMINATORS, single_exit (loop)->src,
 		      gimple_bb (DR_STMT (single_store))))
     plus_one = true;
 
@@ -1081,7 +1081,7 @@  classify_partition (loop_p loop, struct graph *rdg, partition_t partition)
 	  && flow_bb_inside_loop_p (loop, gimple_bb (SSA_NAME_DEF_STMT (rhs))))
 	return;
       if (!adjacent_dr_p (single_store)
-	  || !dominated_by_p (CDI_DOMINATORS,
+	  || !dominated_by_p (cfun, CDI_DOMINATORS,
 			      loop->latch, gimple_bb (stmt)))
 	return;
       partition->kind = PKIND_MEMSET;
@@ -1101,7 +1101,7 @@  classify_partition (loop_p loop, struct graph *rdg, partition_t partition)
 	  || !adjacent_dr_p (single_load)
 	  || !operand_equal_p (DR_STEP (single_store),
 			       DR_STEP (single_load), 0)
-	  || !dominated_by_p (CDI_DOMINATORS,
+	  || !dominated_by_p (cfun, CDI_DOMINATORS,
 			      loop->latch, gimple_bb (store)))
 	return;
       /* Now check that if there is a dependence this dependence is
@@ -1788,10 +1788,10 @@  out:
 	{
 	  if (!cd)
 	    {
-	      calculate_dominance_info (CDI_DOMINATORS);
-	      calculate_dominance_info (CDI_POST_DOMINATORS);
+	      calculate_dominance_info (fun, CDI_DOMINATORS);
+	      calculate_dominance_info (fun, CDI_POST_DOMINATORS);
 	      cd = new control_dependences (create_edge_list ());
-	      free_dominance_info (CDI_POST_DOMINATORS);
+	      free_dominance_info (fun, CDI_POST_DOMINATORS);
 	    }
 	  nb_generated_loops = distribute_loop (loop, work_list, cd,
 						&nb_generated_calls);
diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index d017479..14a87e4 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -799,8 +799,8 @@  expr_invariant_in_region_p (edge entry, edge exit, tree expr)
     {
       def_bb = gimple_bb (SSA_NAME_DEF_STMT (expr));
       if (def_bb
-	  && dominated_by_p (CDI_DOMINATORS, def_bb, entry_bb)
-	  && !dominated_by_p (CDI_DOMINATORS, def_bb, exit_bb))
+	  && dominated_by_p (cfun, CDI_DOMINATORS, def_bb, entry_bb)
+	  && !dominated_by_p (cfun, CDI_DOMINATORS, def_bb, exit_bb))
 	return false;
 
       return true;
@@ -1740,8 +1740,8 @@  transform_to_exit_first_loop_alt (struct loop *loop,
   loop->header = new_header;
 
   /* Recalculate dominance info.  */
-  free_dominance_info (CDI_DOMINATORS);
-  calculate_dominance_info (CDI_DOMINATORS);
+  free_dominance_info (cfun, CDI_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_DOMINATORS);
 }
 
 /* Tries to moves the exit condition of LOOP to the beginning of its header
@@ -2122,8 +2122,8 @@  create_parallel_loop (struct loop *loop, tree loop_fn, tree data,
   gsi_insert_after (&gsi, omp_return_stmt2, GSI_NEW_STMT);
 
   /* After the above dom info is hosed.  Re-compute it.  */
-  free_dominance_info (CDI_DOMINATORS);
-  calculate_dominance_info (CDI_DOMINATORS);
+  free_dominance_info (cfun, CDI_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_DOMINATORS);
 
   return paral_bb;
 }
diff --git a/gcc/tree-predcom.c b/gcc/tree-predcom.c
index ea0d30c..9bdad7f 100644
--- a/gcc/tree-predcom.c
+++ b/gcc/tree-predcom.c
@@ -837,7 +837,7 @@  split_data_refs_to_components (struct loop *loop,
       dataref->distance = 0;
 
       dataref->always_accessed
-	      = dominated_by_p (CDI_DOMINATORS, last_always_executed,
+	      = dominated_by_p (cfun, CDI_DOMINATORS, last_always_executed,
 				gimple_bb (dataref->stmt));
       dataref->pos = comp->refs.length ();
       comp->refs.quick_push (dataref);
@@ -879,7 +879,7 @@  suitable_component_p (struct loop *loop, struct component *comp)
       if (!just_once_each_iteration_p (loop, ba))
 	return false;
 
-      gcc_assert (dominated_by_p (CDI_DOMINATORS, ba, bp));
+      gcc_assert (dominated_by_p (cfun, CDI_DOMINATORS, ba, bp));
       bp = ba;
 
       if (DR_IS_WRITE (a->ref))
diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c
index 4dcc58d..9bcb3cc 100644
--- a/gcc/tree-profile.c
+++ b/gcc/tree-profile.c
@@ -538,7 +538,8 @@  tree_profiling (void)
 	  && flag_test_coverage)
 	continue;
 
-      push_cfun (DECL_STRUCT_FUNCTION (node->decl));
+      function *fn = DECL_STRUCT_FUNCTION (node->decl);
+      push_cfun (fn);
 
       /* Local pure-const may imply need to fixup the cfg.  */
       if (execute_fixup_cfg () & TODO_cleanup_cfg)
@@ -558,8 +559,8 @@  tree_profiling (void)
       /* The above could hose dominator info.  Currently there is
 	 none coming in, this is a safety valve.  It should be
 	 easy to adjust it, if and when there is some.  */
-      free_dominance_info (CDI_DOMINATORS);
-      free_dominance_info (CDI_POST_DOMINATORS);
+      free_dominance_info (fn, CDI_DOMINATORS);
+      free_dominance_info (fn, CDI_POST_DOMINATORS);
       pop_cfun ();
     }
 
diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c
index 3219160..b3ad9ec 100644
--- a/gcc/tree-scalar-evolution.c
+++ b/gcc/tree-scalar-evolution.c
@@ -2295,7 +2295,7 @@  instantiate_scev_name (basic_block instantiate_below,
      evolutions in outer loops), nothing to do.  */
   if (!def_bb
       || loop_depth (def_bb->loop_father) == 0
-      || dominated_by_p (CDI_DOMINATORS, instantiate_below, def_bb))
+      || dominated_by_p (cfun, CDI_DOMINATORS, instantiate_below, def_bb))
     return chrec;
 
   /* We cache the value of instantiated variable to avoid exponential
@@ -2348,7 +2348,7 @@  instantiate_scev_name (basic_block instantiate_below,
 				    inner_loop, res,
 				    fold_conversions, size_expr);
 	}
-      else if (!dominated_by_p (CDI_DOMINATORS, instantiate_below,
+      else if (!dominated_by_p (cfun, CDI_DOMINATORS, instantiate_below,
 				gimple_bb (SSA_NAME_DEF_STMT (res))))
 	res = chrec_dont_know;
     }
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index 818c290..44e1a58 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -4966,7 +4966,7 @@  modify_function (struct cgraph_node *node, ipa_parm_adjustment_vec adjustments)
   bool cfg_changed;
 
   cgraph_edge::rebuild_edges ();
-  free_dominance_info (CDI_DOMINATORS);
+  free_dominance_info (cfun, CDI_DOMINATORS);
   pop_cfun ();
 
   /* This must be done after rebuilding cgraph edges for node above.
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index e103220..d8fc9d0 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -2509,7 +2509,7 @@  get_continuation_for_phi_1 (gimple phi, tree arg0, tree arg1,
     return arg0;
   else if (gimple_nop_p (def0)
 	   || (!gimple_nop_p (def1)
-	       && dominated_by_p (CDI_DOMINATORS,
+	       && dominated_by_p (cfun, CDI_DOMINATORS,
 				  gimple_bb (def1), gimple_bb (def0))))
     {
       if (maybe_skip_until (phi, arg0, ref, arg1, cnt,
@@ -2517,7 +2517,7 @@  get_continuation_for_phi_1 (gimple phi, tree arg0, tree arg1,
 	return arg0;
     }
   else if (gimple_nop_p (def1)
-	   || dominated_by_p (CDI_DOMINATORS,
+	   || dominated_by_p (cfun, CDI_DOMINATORS,
 			      gimple_bb (def0), gimple_bb (def1)))
     {
       if (maybe_skip_until (phi, arg1, ref, arg0, cnt,
@@ -2592,7 +2592,7 @@  get_continuation_for_phi (gimple phi, ao_ref *ref,
 		arg0 = arg1;
 		break;
 	      }
-	    if (dominated_by_p (CDI_DOMINATORS,
+	    if (dominated_by_p (cfun, CDI_DOMINATORS,
 				gimple_bb (SSA_NAME_DEF_STMT (arg0)),
 				gimple_bb (SSA_NAME_DEF_STMT (arg1))))
 	      arg0 = arg1;
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 398ddc1..716d27f 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -1120,7 +1120,7 @@  ccp_visit_phi_node (gphi *phi)
       && new_val.lattice_val == CONSTANT
       && TREE_CODE (new_val.value) == SSA_NAME
       && ! SSA_NAME_IS_DEFAULT_DEF (new_val.value)
-      && ! dominated_by_p (CDI_DOMINATORS, gimple_bb (phi),
+      && ! dominated_by_p (cfun, CDI_DOMINATORS, gimple_bb (phi),
 			   gimple_bb (SSA_NAME_DEF_STMT (new_val.value))))
     {
       new_val.lattice_val = VARYING;
@@ -2405,12 +2405,12 @@  static unsigned int
 do_ssa_ccp (void)
 {
   unsigned int todo = 0;
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_DOMINATORS);
   ccp_initialize ();
   ssa_propagate (ccp_visit_stmt, ccp_visit_phi_node);
   if (ccp_finalize ())
     todo = (TODO_cleanup_cfg | TODO_update_ssa);
-  free_dominance_info (CDI_DOMINATORS);
+  free_dominance_info (cfun, CDI_DOMINATORS);
   return todo;
 }
 
diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c
index 2d2edc8..30bb331 100644
--- a/gcc/tree-ssa-dce.c
+++ b/gcc/tree-ssa-dce.c
@@ -511,7 +511,7 @@  mark_aliased_reaching_defs_necessary_1 (ao_ref *ref, tree vdef, void *data)
 		      unless we decide to compute stmt UIDs
 		      (see PR58246).  */
 		   && (basic_block) data != gimple_bb (def_stmt)
-		   && dominated_by_p (CDI_DOMINATORS, (basic_block) data,
+		   && dominated_by_p (cfun, CDI_DOMINATORS, (basic_block) data,
 				      gimple_bb (def_stmt))
 		   && operand_equal_p (ref->ref, lhs, 0))
 	    return true;
@@ -1304,7 +1304,7 @@  eliminate_unnecessary_stmts (void)
      # DEBUG a => y_1 + z_2 - b_4
 
      as desired.  */
-  gcc_assert (dom_info_available_p (CDI_DOMINATORS));
+  gcc_assert (dom_info_available_p (cfun, CDI_DOMINATORS));
   h = get_all_dominated_blocks (CDI_DOMINATORS,
 				single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun)));
 
@@ -1608,7 +1608,7 @@  perform_tree_ssa_dce (bool aggressive)
 {
   bool something_changed = 0;
 
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_DOMINATORS);
 
   /* Preheaders are needed for SCEV to work.
      Simple lateches and recorded exits improve chances that loop will
@@ -1622,7 +1622,7 @@  perform_tree_ssa_dce (bool aggressive)
   if (aggressive)
     {
       /* Compute control dependence.  */
-      calculate_dominance_info (CDI_POST_DOMINATORS);
+      calculate_dominance_info (cfun, CDI_POST_DOMINATORS);
       cd = new control_dependences (create_edge_list ());
 
       visited_control_parents =
@@ -1649,13 +1649,13 @@  perform_tree_ssa_dce (bool aggressive)
   something_changed |= cfg_altered;
 
   /* We do not update postdominators, so free them unconditionally.  */
-  free_dominance_info (CDI_POST_DOMINATORS);
+  free_dominance_info (cfun, CDI_POST_DOMINATORS);
 
   /* If we removed paths in the CFG, then we need to update
      dominators as well.  I haven't investigated the possibility
      of incrementally updating dominators.  */
   if (cfg_altered)
-    free_dominance_info (CDI_DOMINATORS);
+    free_dominance_info (cfun, CDI_DOMINATORS);
 
   statistics_counter_event (cfun, "Statements deleted", stats.removed);
   statistics_counter_event (cfun, "PHI nodes deleted", stats.removed_phis);
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index 3eb003c..4011294 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -1172,7 +1172,7 @@  pass_dominator::execute (function *fun)
   need_eh_cleanup = BITMAP_ALLOC (NULL);
   need_noreturn_fixup.create (0);
 
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (fun, CDI_DOMINATORS);
   cfg_altered = false;
 
   /* We need to know loop structures in order to avoid destroying them
@@ -1221,7 +1221,7 @@  pass_dominator::execute (function *fun)
   cfg_altered |= thread_through_all_blocks (first_pass_instance);
 
   if (cfg_altered)
-    free_dominance_info (CDI_DOMINATORS);
+    free_dominance_info (fun, CDI_DOMINATORS);
 
   /* Removal of statements may make some EH edges dead.  Purge
      such edges from the CFG as needed.  */
@@ -1487,7 +1487,7 @@  record_temporary_equivalences (edge e)
 		 handle PHIs then this should only consider use_stmts
 		 in basic-blocks we have already visited.  */
 	      if (e->dest == gimple_bb (use_stmt)
-		  || !dominated_by_p (CDI_DOMINATORS,
+		  || !dominated_by_p (cfun, CDI_DOMINATORS,
 				      e->dest, gimple_bb (use_stmt)))
 		continue;
 	      tree lhs2 = gimple_get_lhs (use_stmt);
@@ -1625,7 +1625,7 @@  single_incoming_edge_ignoring_loop_edges (basic_block bb)
     {
       /* A loop back edge can be identified by the destination of
 	 the edge dominating the source of the edge.  */
-      if (dominated_by_p (CDI_DOMINATORS, e->src, e->dest))
+      if (dominated_by_p (cfun, CDI_DOMINATORS, e->src, e->dest))
 	continue;
 
       /* If we have already seen a non-loop edge, then we must have
@@ -3150,7 +3150,7 @@  pass_phi_only_cprop::execute (function *fun)
   interesting_names = BITMAP_ALLOC (NULL);
   interesting_names1 = BITMAP_ALLOC (NULL);
 
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (fun, CDI_DOMINATORS);
   cfg_altered = false;
 
   /* First phase.  Eliminate degenerate PHIs via a dominator
@@ -3192,7 +3192,7 @@  pass_phi_only_cprop::execute (function *fun)
 
   if (cfg_altered)
     {
-      free_dominance_info (CDI_DOMINATORS);
+      free_dominance_info (fun, CDI_DOMINATORS);
       /* If we changed the CFG schedule loops for fixup by cfgcleanup.  */
       loops_state_set (LOOPS_NEED_FIXUP);
     }
diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c
index 4ad19b3..db4c22d 100644
--- a/gcc/tree-ssa-dse.c
+++ b/gcc/tree-ssa-dse.c
@@ -139,11 +139,11 @@  dse_possible_dead_store_p (ao_ref *ref, gimple stmt, gimple *use_stmt)
 	      if (temp
 		  /* Make sure we are not in a loop latch block.  */
 		  || gimple_bb (stmt) == gimple_bb (use_stmt)
-		  || dominated_by_p (CDI_DOMINATORS,
+		  || dominated_by_p (cfun, CDI_DOMINATORS,
 				     gimple_bb (stmt), gimple_bb (use_stmt))
 		  /* We can look through PHIs to regions post-dominating
 		     the DSE candidate stmt.  */
-		  || !dominated_by_p (CDI_POST_DOMINATORS,
+		  || !dominated_by_p (cfun, CDI_POST_DOMINATORS,
 				      gimple_bb (stmt), gimple_bb (use_stmt)))
 		{
 		  fail = true;
@@ -153,7 +153,7 @@  dse_possible_dead_store_p (ao_ref *ref, gimple stmt, gimple *use_stmt)
 	         stmt defining the virtual operand we are processing,
 		 we have processed it already in this case.  */
 	      if (gimple_bb (defvar_def) != gimple_bb (use_stmt)
-		  && !dominated_by_p (CDI_DOMINATORS,
+		  && !dominated_by_p (cfun, CDI_DOMINATORS,
 				      gimple_bb (defvar_def),
 				      gimple_bb (use_stmt)))
 		temp = use_stmt;
@@ -387,8 +387,8 @@  pass_dse::execute (function *fun)
      can be [re]computed on an as-needed basis.  Particularly since
      this pass could be seen as an extension of DCE which needs post
      dominators.  */
-  calculate_dominance_info (CDI_POST_DOMINATORS);
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (fun, CDI_POST_DOMINATORS);
+  calculate_dominance_info (fun, CDI_DOMINATORS);
 
   /* Dead store elimination is fundamentally a walk of the post-dominator
      tree and a backwards walk of statements within each block.  */
@@ -405,7 +405,7 @@  pass_dse::execute (function *fun)
   BITMAP_FREE (need_eh_cleanup);
     
   /* For now, just wipe the post-dominator information.  */
-  free_dominance_info (CDI_POST_DOMINATORS);
+  free_dominance_info (fun, CDI_POST_DOMINATORS);
   return 0;
 }
 
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
index ccfde5f..740600d 100644
--- a/gcc/tree-ssa-forwprop.c
+++ b/gcc/tree-ssa-forwprop.c
@@ -1093,7 +1093,7 @@  simplify_gimple_switch_label_vec (gswitch *stmt, tree index_type)
 	    {
 	      remove_edge (e);
 	      cfg_changed = true;
-	      free_dominance_info (CDI_DOMINATORS);
+	      free_dominance_info (cfun, CDI_DOMINATORS);
 	    }
 	  else
 	    ei_next (&ei);
diff --git a/gcc/tree-ssa-ifcombine.c b/gcc/tree-ssa-ifcombine.c
index ef3d16d..838a76f 100644
--- a/gcc/tree-ssa-ifcombine.c
+++ b/gcc/tree-ssa-ifcombine.c
@@ -748,7 +748,7 @@  pass_tree_ifcombine::execute (function *fun)
   int i;
 
   bbs = single_pred_before_succ_order ();
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (fun, CDI_DOMINATORS);
 
   /* Search every basic block for COND_EXPR we may be able to optimize.
 
diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c
index b85d9cb..5d31f8a 100644
--- a/gcc/tree-ssa-loop-im.c
+++ b/gcc/tree-ssa-loop-im.c
@@ -636,13 +636,13 @@  extract_true_false_args_from_phi (basic_block dom, gphi *phi,
   if (tem == true_edge
       || (single_pred_p (true_edge->dest)
 	  && (tem->src == true_edge->dest
-	      || dominated_by_p (CDI_DOMINATORS,
+	      || dominated_by_p (cfun, CDI_DOMINATORS,
 				 tem->src, true_edge->dest))))
     arg0 = PHI_ARG_DEF (phi, tem->dest_idx);
   else if (tem == false_edge
 	   || (single_pred_p (false_edge->dest)
 	       && (tem->src == false_edge->dest
-		   || dominated_by_p (CDI_DOMINATORS,
+		   || dominated_by_p (cfun, CDI_DOMINATORS,
 				      tem->src, false_edge->dest))))
     arg1 = PHI_ARG_DEF (phi, tem->dest_idx);
   else
@@ -651,13 +651,13 @@  extract_true_false_args_from_phi (basic_block dom, gphi *phi,
   if (tem == true_edge
       || (single_pred_p (true_edge->dest)
 	  && (tem->src == true_edge->dest
-	      || dominated_by_p (CDI_DOMINATORS,
+	      || dominated_by_p (cfun, CDI_DOMINATORS,
 				 tem->src, true_edge->dest))))
     arg0 = PHI_ARG_DEF (phi, tem->dest_idx);
   else if (tem == false_edge
 	   || (single_pred_p (false_edge->dest)
 	       && (tem->src == false_edge->dest
-		   || dominated_by_p (CDI_DOMINATORS,
+		   || dominated_by_p (cfun, CDI_DOMINATORS,
 				      tem->src, false_edge->dest))))
     arg1 = PHI_ARG_DEF (phi, tem->dest_idx);
   else
@@ -1864,15 +1864,16 @@  execute_sm_if_changed (edge ex, tree mem, tree tmp_var, tree flag)
   then_old_edge = make_edge (then_bb, old_dest,
 			     EDGE_FALLTHRU | (irr ? EDGE_IRREDUCIBLE_LOOP : 0));
 
-  set_immediate_dominator (CDI_DOMINATORS, then_bb, new_bb);
+  set_immediate_dominator (cfun, CDI_DOMINATORS, then_bb, new_bb);
 
   if (prev_edges)
     {
       basic_block prevbb = prev_edges->last_cond_fallthru->src;
       redirect_edge_succ (prev_edges->last_cond_fallthru, new_bb);
-      set_immediate_dominator (CDI_DOMINATORS, new_bb, prevbb);
-      set_immediate_dominator (CDI_DOMINATORS, old_dest,
-			       recompute_dominator (CDI_DOMINATORS, old_dest));
+      set_immediate_dominator (cfun, CDI_DOMINATORS, new_bb, prevbb);
+      set_immediate_dominator (cfun, CDI_DOMINATORS, old_dest,
+			       recompute_dominator (cfun, CDI_DOMINATORS,
+						    old_dest));
     }
 
   /* ?? Because stores may alias, they must happen in the exact
@@ -2359,7 +2360,7 @@  fill_always_executed_in_1 (struct loop *loop, sbitmap contains_call)
 	  edge_iterator ei;
 	  bb = bbs[i];
 
-	  if (dominated_by_p (CDI_DOMINATORS, loop->latch, bb))
+	  if (dominated_by_p (cfun, CDI_DOMINATORS, loop->latch, bb))
 	    last = bb;
 
 	  if (bitmap_bit_p (contains_call, bb->index))
@@ -2381,7 +2382,7 @@  fill_always_executed_in_1 (struct loop *loop, sbitmap contains_call)
 
 	  if (bb->loop_father->header == bb)
 	    {
-	      if (!dominated_by_p (CDI_DOMINATORS, loop->latch, bb))
+	      if (!dominated_by_p (cfun, CDI_DOMINATORS, loop->latch, bb))
 		break;
 
 	      /* In a loop that is always entered we may proceed anyway.
diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c
index eca70a9..5d0bbc5 100644
--- a/gcc/tree-ssa-loop-ivcanon.c
+++ b/gcc/tree-ssa-loop-ivcanon.c
@@ -237,7 +237,7 @@  tree_estimate_loop_size (struct loop *loop, edge exit, edge edge_to_cancel, stru
   for (i = 0; i < loop->num_nodes; i++)
     {
       if (edge_to_cancel && body[i] != edge_to_cancel->src
-	  && dominated_by_p (CDI_DOMINATORS, body[i], edge_to_cancel->src))
+	  && dominated_by_p (cfun, CDI_DOMINATORS, body[i], edge_to_cancel->src))
 	after_exit = true;
       else
 	after_exit = false;
@@ -639,7 +639,8 @@  unloop_loops (bitmap loop_closed_ssa_invalidated,
       latch_edge->dest->loop_father = current_loops->tree_root;
       latch_edge->dest->count = 0;
       latch_edge->dest->frequency = 0;
-      set_immediate_dominator (CDI_DOMINATORS, latch_edge->dest, latch_edge->src);
+      set_immediate_dominator (cfun, CDI_DOMINATORS, latch_edge->dest,
+			       latch_edge->src);
 
       gsi = gsi_start_bb (latch_edge->dest);
       gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 6bce3a1..8d21b3a 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -705,7 +705,7 @@  stmt_after_inc_pos (struct iv_cand *cand, gimple stmt, bool true_if_equal)
   basic_block cand_bb = gimple_bb (cand->incremented_at);
   basic_block stmt_bb = gimple_bb (stmt);
 
-  if (!dominated_by_p (CDI_DOMINATORS, stmt_bb, cand_bb))
+  if (!dominated_by_p (cfun, CDI_DOMINATORS, stmt_bb, cand_bb))
     return false;
 
   if (stmt_bb != cand_bb)
@@ -2744,7 +2744,8 @@  add_autoinc_candidates (struct ivopts_data *data, tree base, tree step,
      It must not be in an inner nested loop, or one side of an if
      statement.  */
   if (use_bb->loop_father != data->current_loop
-      || !dominated_by_p (CDI_DOMINATORS, data->current_loop->latch, use_bb)
+      || !dominated_by_p (cfun, CDI_DOMINATORS,
+			  data->current_loop->latch, use_bb)
       || stmt_could_throw_p (use->stmt)
       || !cst_and_fits_in_hwi (step))
     return;
@@ -5012,7 +5013,7 @@  may_eliminate_iv (struct ivopts_data *data,
   ex_bb = gimple_bb (use->stmt);
   if (use->stmt != last_stmt (ex_bb)
       || gimple_code (use->stmt) != GIMPLE_COND
-      || !dominated_by_p (CDI_DOMINATORS, loop->latch, ex_bb))
+      || !dominated_by_p (cfun, CDI_DOMINATORS, loop->latch, ex_bb))
     return false;
 
   exit = EDGE_SUCC (ex_bb, 0);
diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c
index cb762df..191b9b9 100644
--- a/gcc/tree-ssa-loop-manip.c
+++ b/gcc/tree-ssa-loop-manip.c
@@ -253,7 +253,7 @@  compute_live_loop_exits (bitmap live_exits, bitmap use_blocks,
 	     If BB dominates PRED, then we're probably looking at a loop.
 	     We're only interested in looking up in the dominance tree
 	     because DEF_BB dominates all the uses.  */
-	  if (pred_visited || dominated_by_p (CDI_DOMINATORS, pred, bb))
+	  if (pred_visited || dominated_by_p (cfun, CDI_DOMINATORS, pred, bb))
 	    continue;
 
 	  worklist.quick_push (pred);
@@ -559,7 +559,7 @@  replace_uses_in_dominated_bbs (tree old_val, tree new_val, basic_block bb)
 
   FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, old_val)
     {
-      if (!dominated_by_p (CDI_DOMINATORS, gimple_bb (use_stmt), bb))
+      if (!dominated_by_p (cfun, CDI_DOMINATORS, gimple_bb (use_stmt), bb))
 	  continue;
 
       use_operand_p use_p;
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c
index 633e3d1..7fcbdeb 100644
--- a/gcc/tree-ssa-loop-niter.c
+++ b/gcc/tree-ssa-loop-niter.c
@@ -1934,7 +1934,7 @@  number_of_iterations_exit (struct loop *loop, edge exit,
   affine_iv iv0, iv1;
   bool safe;
 
-  safe = dominated_by_p (CDI_DOMINATORS, loop->latch, exit->src);
+  safe = dominated_by_p (cfun, CDI_DOMINATORS, loop->latch, exit->src);
 
   if (every_iteration && !safe)
     return false;
@@ -2631,7 +2631,7 @@  do_warn_aggressive_loop_optimizations (struct loop *loop,
 	 known constant bound.  */
       || wi::cmpu (i_bound, wi::to_widest (loop->nb_iterations)) >= 0
       /* And undefined behavior happens unconditionally.  */
-      || !dominated_by_p (CDI_DOMINATORS, loop->latch, gimple_bb (stmt)))
+      || !dominated_by_p (cfun, CDI_DOMINATORS, loop->latch, gimple_bb (stmt)))
     return;
 
   edge e = single_exit (loop);
@@ -2700,7 +2700,7 @@  record_estimate (struct loop *loop, tree bound, const widest_int &i_bound,
 
   /* If statement is executed on every path to the loop latch, we can directly
      infer the upper bound on the # of iterations of the loop.  */
-  if (!dominated_by_p (CDI_DOMINATORS, loop->latch, gimple_bb (at_stmt)))
+  if (!dominated_by_p (cfun, CDI_DOMINATORS, loop->latch, gimple_bb (at_stmt)))
     return;
 
   /* Update the number of iteration estimates according to the bound.
@@ -2909,7 +2909,7 @@  idx_infer_loop_bounds (tree base, tree *idx, void *dta)
 
   /* If access is not executed on every iteration, we must ensure that overlow may
      not make the access valid later.  */
-  if (!dominated_by_p (CDI_DOMINATORS, loop->latch, gimple_bb (data->stmt))
+  if (!dominated_by_p (cfun, CDI_DOMINATORS, loop->latch, gimple_bb (data->stmt))
       && scev_probably_wraps_p (initial_condition_in_loop_num (ev, loop->num),
 				step, data->stmt, loop, true))
     reliable = false;
@@ -3096,7 +3096,7 @@  infer_loop_bounds_from_undefined (struct loop *loop)
 	 use the operations in it to infer reliable upper bound on the
 	 # of iterations of the loop.  However, we can use it as a guess. 
 	 Reliable guesses come only from array bounds.  */
-      reliable = dominated_by_p (CDI_DOMINATORS, loop->latch, bb);
+      reliable = dominated_by_p (cfun, CDI_DOMINATORS, loop->latch, bb);
 
       for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi))
 	{
@@ -3675,7 +3675,7 @@  stmt_dominates_stmt_p (gimple s1, gimple s2)
       return false;
     }
 
-  return dominated_by_p (CDI_DOMINATORS, bb2, bb1);
+  return dominated_by_p (cfun, CDI_DOMINATORS, bb2, bb1);
 }
 
 /* Returns true when we can prove that the number of executions of
diff --git a/gcc/tree-ssa-loop.c b/gcc/tree-ssa-loop.c
index 078b1d1..cdf9d70 100644
--- a/gcc/tree-ssa-loop.c
+++ b/gcc/tree-ssa-loop.c
@@ -73,11 +73,11 @@  public:
 }; // class pass_fix_loops
 
 unsigned int
-pass_fix_loops::execute (function *)
+pass_fix_loops::execute (function *fn)
 {
   if (loops_state_satisfies_p (LOOPS_NEED_FIXUP))
     {
-      calculate_dominance_info (CDI_DOMINATORS);
+      calculate_dominance_info (fn, CDI_DOMINATORS);
       fix_loop_structure (NULL);
     }
   return 0;
diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c
index eae5358..30efdbc 100644
--- a/gcc/tree-ssa-math-opts.c
+++ b/gcc/tree-ssa-math-opts.c
@@ -328,7 +328,7 @@  compute_merit (struct occurrence *occ)
       else
 	bb = dom;
 
-      if (dominated_by_p (CDI_POST_DOMINATORS, bb, occ_child->bb))
+      if (dominated_by_p (cfun, CDI_POST_DOMINATORS, bb, occ_child->bb))
         occ->num_divisions += occ_child->num_divisions;
     }
 }
@@ -551,8 +551,8 @@  pass_cse_reciprocals::execute (function *fun)
     ("dominators for recip", n_basic_blocks_for_fn (fun) / 3 + 1);
 
   memset (&reciprocal_stats, 0, sizeof (reciprocal_stats));
-  calculate_dominance_info (CDI_DOMINATORS);
-  calculate_dominance_info (CDI_POST_DOMINATORS);
+  calculate_dominance_info (fun, CDI_DOMINATORS);
+  calculate_dominance_info (fun, CDI_POST_DOMINATORS);
 
 #ifdef ENABLE_CHECKING
   FOR_EACH_BB_FN (bb, fun)
@@ -676,8 +676,8 @@  pass_cse_reciprocals::execute (function *fun)
   statistics_counter_event (fun, "reciprocal functions inserted",
 			    reciprocal_stats.rfuncs_inserted);
 
-  free_dominance_info (CDI_DOMINATORS);
-  free_dominance_info (CDI_POST_DOMINATORS);
+  free_dominance_info (fun, CDI_DOMINATORS);
+  free_dominance_info (fun, CDI_POST_DOMINATORS);
   delete occ_pool;
   return 0;
 }
@@ -703,10 +703,10 @@  maybe_record_sincos (vec<gimple> *stmts,
   basic_block use_bb = gimple_bb (use_stmt);
   if (*top_bb
       && (*top_bb == use_bb
-	  || dominated_by_p (CDI_DOMINATORS, use_bb, *top_bb)))
+	  || dominated_by_p (cfun, CDI_DOMINATORS, use_bb, *top_bb)))
     stmts->safe_push (use_stmt);
   else if (!*top_bb
-	   || dominated_by_p (CDI_DOMINATORS, *top_bb, use_bb))
+	   || dominated_by_p (cfun, CDI_DOMINATORS, *top_bb, use_bb))
     {
       stmts->safe_push (use_stmt);
       *top_bb = use_bb;
@@ -1733,7 +1733,7 @@  pass_cse_sincos::execute (function *fun)
   basic_block bb;
   bool cfg_changed = false;
 
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (fun, CDI_DOMINATORS);
   memset (&sincos_stats, 0, sizeof (sincos_stats));
 
   FOR_EACH_BB_FN (bb, fun)
@@ -1873,7 +1873,7 @@  pass_cse_sincos::execute (function *fun)
   statistics_counter_event (fun, "sincos statements inserted",
 			    sincos_stats.inserted);
 
-  free_dominance_info (CDI_DOMINATORS);
+  free_dominance_info (fun, CDI_DOMINATORS);
   return cfg_changed ? TODO_cleanup_cfg : 0;
 }
 
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index d46ba62..46a7085 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -1620,7 +1620,7 @@  get_non_trapping (void)
   hash_set<tree> *nontrap = new hash_set<tree>;
   /* We're going to do a dominator walk, so ensure that we have
      dominance information.  */
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_DOMINATORS);
 
   nontrapping_dom_walker (CDI_DOMINATORS, nontrap)
     .walk (cfun->cfg->x_entry_block_ptr);
diff --git a/gcc/tree-ssa-phiprop.c b/gcc/tree-ssa-phiprop.c
index d5d1f24..ac30c7c 100644
--- a/gcc/tree-ssa-phiprop.c
+++ b/gcc/tree-ssa-phiprop.c
@@ -120,7 +120,7 @@  phivn_valid_p (struct phiprop_d *phivn, tree name, basic_block bb)
       /* If BB does not dominate a VDEF, the value is invalid.  */
       if ((gimple_vdef (use_stmt) != NULL_TREE
 	   || gimple_code (use_stmt) == GIMPLE_PHI)
-	  && !dominated_by_p (CDI_DOMINATORS, gimple_bb (use_stmt), bb))
+	  && !dominated_by_p (cfun, CDI_DOMINATORS, gimple_bb (use_stmt), bb))
 	{
 	  ok = false;
 	  BREAK_FROM_IMM_USE_STMT (ui2);
@@ -306,7 +306,7 @@  propagate_with_phi (basic_block bb, gphi *phi, struct phiprop_d *phivn,
 
       /* Only replace loads in blocks that post-dominate the PHI node.  That
          makes sure we don't end up speculating loads.  */
-      if (!dominated_by_p (CDI_POST_DOMINATORS,
+      if (!dominated_by_p (cfun, CDI_POST_DOMINATORS,
 			   bb, gimple_bb (use_stmt)))
 	continue;
          
@@ -329,7 +329,7 @@  propagate_with_phi (basic_block bb, gphi *phi, struct phiprop_d *phivn,
       def_stmt = SSA_NAME_DEF_STMT (vuse);
       if (!SSA_NAME_IS_DEFAULT_DEF (vuse)
 	  && (gimple_bb (def_stmt) == bb
-	      || !dominated_by_p (CDI_DOMINATORS,
+	      || !dominated_by_p (cfun, CDI_DOMINATORS,
 				  bb, gimple_bb (def_stmt))))
 	goto next;
 
@@ -408,8 +408,8 @@  pass_phiprop::execute (function *fun)
   unsigned i;
   size_t n;
 
-  calculate_dominance_info (CDI_DOMINATORS);
-  calculate_dominance_info (CDI_POST_DOMINATORS);
+  calculate_dominance_info (fun, CDI_DOMINATORS);
+  calculate_dominance_info (fun, CDI_POST_DOMINATORS);
 
   n = num_ssa_names;
   phivn = XCNEWVEC (struct phiprop_d, n);
@@ -427,7 +427,7 @@  pass_phiprop::execute (function *fun)
   bbs.release ();
   free (phivn);
 
-  free_dominance_info (CDI_POST_DOMINATORS);
+  free_dominance_info (fun, CDI_POST_DOMINATORS);
 
   return 0;
 }
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index 697958d..5362b91 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -2056,7 +2056,7 @@  prune_clobbered_mems (bitmap_set_t set, basic_block block)
 	      gimple def_stmt = SSA_NAME_DEF_STMT (ref->vuse);
 	      if (!gimple_nop_p (def_stmt)
 		  && ((gimple_bb (def_stmt) != block
-		       && !dominated_by_p (CDI_DOMINATORS,
+		       && !dominated_by_p (cfun, CDI_DOMINATORS,
 					   block, gimple_bb (def_stmt)))
 		      || (gimple_bb (def_stmt) == block
 			  && value_dies_in_block_x (expr, block))))
@@ -4764,8 +4764,8 @@  init_pre (void)
 
   alloc_aux_for_blocks (sizeof (struct bb_bitmap_sets));
 
-  calculate_dominance_info (CDI_POST_DOMINATORS);
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_POST_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_DOMINATORS);
 
   bitmap_obstack_initialize (&grand_bitmap_obstack);
   phi_translate_table = new hash_table<expr_pred_trans_d> (5110);
@@ -4799,7 +4799,7 @@  fini_pre ()
 
   free_aux_for_blocks ();
 
-  free_dominance_info (CDI_POST_DOMINATORS);
+  free_dominance_info (cfun, CDI_POST_DOMINATORS);
 }
 
 namespace {
diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c
index b7684e0..419f8b7 100644
--- a/gcc/tree-ssa-propagate.c
+++ b/gcc/tree-ssa-propagate.c
@@ -1063,7 +1063,7 @@  replace_phi_args_in (gphi *phi, ssa_prop_get_value_fn get_value)
 		 get removed without replacing its uses.  */
 	      if (TREE_CODE (val) != SSA_NAME
 		  && bb->loop_father->header == bb
-		  && dominated_by_p (CDI_DOMINATORS, e->src, bb)
+		  && dominated_by_p (cfun, CDI_DOMINATORS, e->src, bb)
 		  && is_gimple_assign (SSA_NAME_DEF_STMT (arg))
 		  && (gimple_assign_rhs_code (SSA_NAME_DEF_STMT (arg))
 		      == ASSERT_EXPR))
@@ -1333,7 +1333,7 @@  substitute_and_fold (ssa_prop_get_value_fn get_value_fn,
 
   memset (&prop_stats, 0, sizeof (prop_stats));
 
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_DOMINATORS);
   substitute_and_fold_dom_walker walker(CDI_DOMINATORS,
 					get_value_fn, fold_fn, do_dce);
   walker.walk (ENTRY_BLOCK_PTR_FOR_FN (cfun));
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c
index efb813c..b763522 100644
--- a/gcc/tree-ssa-reassoc.c
+++ b/gcc/tree-ssa-reassoc.c
@@ -1246,7 +1246,7 @@  reassoc_stmt_dominates_stmt_p (gimple s1, gimple s2)
       return false;
     }
 
-  return dominated_by_p (CDI_DOMINATORS, bb2, bb1);
+  return dominated_by_p (cfun, CDI_DOMINATORS, bb2, bb1);
 }
 
 /* Insert STMT after INSERT_POINT.  */
@@ -4920,8 +4920,8 @@  branch_fixup (void)
       gsi = gsi_for_stmt (use_stmt);
       gsi_remove (&gsi, true);
 
-      set_immediate_dominator (CDI_DOMINATORS, merge_bb, cond_bb);
-      set_immediate_dominator (CDI_POST_DOMINATORS, cond_bb, merge_bb);
+      set_immediate_dominator (cfun, CDI_DOMINATORS, merge_bb, cond_bb);
+      set_immediate_dominator (cfun, CDI_POST_DOMINATORS, cond_bb, merge_bb);
     }
   reassoc_branch_fixups.release ();
 }
@@ -4998,7 +4998,7 @@  init_reassoc (void)
     bb_rank[bbs[i]] = ++rank  << 16;
 
   free (bbs);
-  calculate_dominance_info (CDI_POST_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_POST_DOMINATORS);
   plus_negates = vNULL;
 }
 
@@ -5025,7 +5025,7 @@  fini_reassoc (void)
   operand_entry_pool.release ();
   free (bb_rank);
   plus_negates.release ();
-  free_dominance_info (CDI_POST_DOMINATORS);
+  free_dominance_info (cfun, CDI_POST_DOMINATORS);
   loop_optimizer_finalize ();
 }
 
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index a72a920..2b7e646 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -4169,7 +4169,7 @@  init_scc_vn (void)
   int j;
   int *rpo_numbers_temp;
 
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_DOMINATORS);
   mark_dfs_back_edges ();
 
   sccstack.create (0);
@@ -4459,7 +4459,7 @@  sccvn_dom_walker::before_dom_children (basic_block bb)
      reachable.  */
   bool reachable = bb == ENTRY_BLOCK_PTR_FOR_FN (cfun);
   FOR_EACH_EDGE (e, ei, bb->preds)
-    if (!dominated_by_p (CDI_DOMINATORS, e->src, bb))
+    if (!dominated_by_p (cfun, CDI_DOMINATORS, e->src, bb))
       reachable |= (e->flags & EDGE_EXECUTABLE);
 
   /* If the block is not reachable all outgoing edges are not
diff --git a/gcc/tree-ssa-sink.c b/gcc/tree-ssa-sink.c
index 8118f35..388c65d 100644
--- a/gcc/tree-ssa-sink.c
+++ b/gcc/tree-ssa-sink.c
@@ -394,7 +394,7 @@  statement_sink_location (gimple stmt, basic_block frombb,
 	      bb = nearest_common_dominator (CDI_DOMINATORS, bb, commondom);
 	      if (!found)
 		found = bb;
-	      else if (dominated_by_p (CDI_DOMINATORS, bb, found))
+	      else if (dominated_by_p (cfun, CDI_DOMINATORS, bb, found))
 		found = bb;
 	      /* If we can't improve, stop.  */
 	      if (found == commondom)
@@ -408,7 +408,7 @@  statement_sink_location (gimple stmt, basic_block frombb,
       /* Our common dominator has to be dominated by frombb in order to be a
 	 trivially safe place to put this statement, since it has multiple
 	 uses.  */
-      if (!dominated_by_p (CDI_DOMINATORS, commondom, frombb))
+      if (!dominated_by_p (cfun, CDI_DOMINATORS, commondom, frombb))
 	return false;
 
       commondom = select_best_block (frombb, commondom, stmt);
@@ -627,11 +627,11 @@  pass_sink_code::execute (function *fun)
   split_critical_edges ();
   connect_infinite_loops_to_exit ();
   memset (&sink_stats, 0, sizeof (sink_stats));
-  calculate_dominance_info (CDI_DOMINATORS);
-  calculate_dominance_info (CDI_POST_DOMINATORS);
+  calculate_dominance_info (fun, CDI_DOMINATORS);
+  calculate_dominance_info (fun, CDI_POST_DOMINATORS);
   sink_code_in_bb (EXIT_BLOCK_PTR_FOR_FN (fun));
   statistics_counter_event (fun, "Sunk statements", sink_stats.sunk);
-  free_dominance_info (CDI_POST_DOMINATORS);
+  free_dominance_info (fun, CDI_POST_DOMINATORS);
   remove_fake_exit_edges ();
   loop_optimizer_finalize ();
 
diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c
index cfe4dd9..e8577f6 100644
--- a/gcc/tree-ssa-strlen.c
+++ b/gcc/tree-ssa-strlen.c
@@ -2171,7 +2171,7 @@  do_invalidate (basic_block dombb, gimple phi, bitmap visited, int *count)
       if (bb == NULL
 	  || bb == dombb
 	  || !bitmap_set_bit (visited, bb->index)
-	  || !dominated_by_p (CDI_DOMINATORS, bb, dombb))
+	  || !dominated_by_p (cfun, CDI_DOMINATORS, bb, dombb))
 	continue;
       while (1)
 	{
@@ -2197,7 +2197,7 @@  do_invalidate (basic_block dombb, gimple phi, bitmap visited, int *count)
 	      if (bb == NULL
 		  || bb == dombb
 		  || !bitmap_set_bit (visited, bb->index)
-		  || !dominated_by_p (CDI_DOMINATORS, bb, dombb))
+		  || !dominated_by_p (cfun, CDI_DOMINATORS, bb, dombb))
 		break;
 	    }
 	}
@@ -2357,7 +2357,7 @@  pass_strlen::execute (function *fun)
   ssa_ver_to_stridx.safe_grow_cleared (num_ssa_names);
   max_stridx = 1;
 
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (fun, CDI_DOMINATORS);
 
   /* String length optimization is implemented as a walk of the dominator
      tree and a forward walk of statements within each block.  */
diff --git a/gcc/tree-ssa-tail-merge.c b/gcc/tree-ssa-tail-merge.c
index 88a3032..9c2dc9f 100644
--- a/gcc/tree-ssa-tail-merge.c
+++ b/gcc/tree-ssa-tail-merge.c
@@ -426,7 +426,7 @@  update_dep_bb (basic_block use_bb, tree val)
     return;
 
   if (BB_DEP_BB (use_bb) == NULL
-      || dominated_by_p (CDI_DOMINATORS, dep_bb, BB_DEP_BB (use_bb)))
+      || dominated_by_p (cfun, CDI_DOMINATORS, dep_bb, BB_DEP_BB (use_bb)))
     BB_DEP_BB (use_bb) = dep_bb;
 }
 
@@ -946,7 +946,8 @@  update_rep_bb (bb_cluster c, basic_block bb)
      BB_DEP_BB, which is really BB_LAST_DEP_BB.
      The benefit of choosing the bb with last deps earlier, is that it can
      potentially be used as replacement for more bbs.  */
-  if (dominated_by_p (CDI_DOMINATORS, BB_DEP_BB (c->rep_bb), BB_DEP_BB (bb)))
+  if (dominated_by_p (cfun, CDI_DOMINATORS, BB_DEP_BB (c->rep_bb),
+		      BB_DEP_BB (bb)))
     c->rep_bb = bb;
 }
 
@@ -1366,10 +1367,10 @@  deps_ok_for_redirect_from_bb_to_bb (basic_block from, basic_block to)
 
   FOR_EACH_EDGE (e, ei, from->preds)
     bitmap_set_bit (from_preds, e->src->index);
-  cd = nearest_common_dominator_for_set (CDI_DOMINATORS, from_preds);
+  cd = nearest_common_dominator_for_set (cfun, CDI_DOMINATORS, from_preds);
   BITMAP_FREE (from_preds);
 
-  return dominated_by_p (CDI_DOMINATORS, dep_bb, cd);
+  return dominated_by_p (cfun, CDI_DOMINATORS, dep_bb, cd);
 }
 
 /* Returns true if replacing BB1 (or its replacement bb) by BB2 (or its
@@ -1600,7 +1601,7 @@  update_debug_stmt (gimple stmt)
       gimple def_stmt = SSA_NAME_DEF_STMT (name);
       basic_block bbdef = gimple_bb (def_stmt);
       if (bbdef == NULL || bbuse == bbdef
-	  || dominated_by_p (CDI_DOMINATORS, bbuse, bbdef))
+	  || dominated_by_p (cfun, CDI_DOMINATORS, bbuse, bbdef))
 	continue;
 
       gimple_debug_bind_reset_value (stmt);
@@ -1652,11 +1653,11 @@  tail_merge_optimize (unsigned int todo)
 
   timevar_push (TV_TREE_TAIL_MERGE);
 
-  if (!dom_info_available_p (CDI_DOMINATORS))
+  if (!dom_info_available_p (cfun, CDI_DOMINATORS))
     {
       /* PRE can leave us with unreachable blocks, remove them now.  */
       delete_unreachable_blocks ();
-      calculate_dominance_info (CDI_DOMINATORS);
+      calculate_dominance_info (cfun, CDI_DOMINATORS);
     }
   init_worklist ();
 
@@ -1685,12 +1686,12 @@  tail_merge_optimize (unsigned int todo)
       if (nr_bbs_removed == 0)
 	break;
 
-      free_dominance_info (CDI_DOMINATORS);
+      free_dominance_info (cfun, CDI_DOMINATORS);
 
       if (iteration_nr == max_iterations)
 	break;
 
-      calculate_dominance_info (CDI_DOMINATORS);
+      calculate_dominance_info (cfun, CDI_DOMINATORS);
       update_worklist ();
     }
 
@@ -1702,7 +1703,7 @@  tail_merge_optimize (unsigned int todo)
     {
       if (MAY_HAVE_DEBUG_STMTS)
 	{
-	  calculate_dominance_info (CDI_DOMINATORS);
+	  calculate_dominance_info (cfun, CDI_DOMINATORS);
 	  update_debug_stmts ();
 	}
 
diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c
index 7164122..d0a5c1c 100644
--- a/gcc/tree-ssa-threadedge.c
+++ b/gcc/tree-ssa-threadedge.c
@@ -136,7 +136,7 @@  lhs_of_dominating_assert (tree op, basic_block bb, gimple stmt)
           && gimple_assign_single_p (use_stmt)
           && TREE_CODE (gimple_assign_rhs1 (use_stmt)) == ASSERT_EXPR
           && TREE_OPERAND (gimple_assign_rhs1 (use_stmt), 0) == op
-	  && dominated_by_p (CDI_DOMINATORS, bb, gimple_bb (use_stmt)))
+	  && dominated_by_p (cfun, CDI_DOMINATORS, bb, gimple_bb (use_stmt)))
 	{
 	  return gimple_assign_lhs (use_stmt);
 	}
diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c
index 5a5f8df..89f7247 100644
--- a/gcc/tree-ssa-threadupdate.c
+++ b/gcc/tree-ssa-threadupdate.c
@@ -1542,7 +1542,7 @@  thread_block_1 (basic_block bb, bool noloop_only, bool joiners)
     }
 
   /* We do not update dominance info.  */
-  free_dominance_info (CDI_DOMINATORS);
+  free_dominance_info (cfun, CDI_DOMINATORS);
 
   /* We know we only thread through the loop header to loop exits.
      Let the basic block duplication hook know we are not creating
@@ -2595,7 +2595,7 @@  thread_through_all_blocks (bool may_peel_loop_headers)
       if (duplicate_thread_path (entry, exit, region, len - 1, NULL))
 	{
 	  /* We do not update dominance info.  */
-	  free_dominance_info (CDI_DOMINATORS);
+	  free_dominance_info (cfun, CDI_DOMINATORS);
 	  bitmap_set_bit (threaded_blocks, entry->src->index);
 	  retval = true;
 	}
diff --git a/gcc/tree-ssa-uncprop.c b/gcc/tree-ssa-uncprop.c
index 437f69d..404231e 100644
--- a/gcc/tree-ssa-uncprop.c
+++ b/gcc/tree-ssa-uncprop.c
@@ -438,7 +438,7 @@  single_incoming_edge_ignoring_loop_edges (basic_block bb)
     {
       /* A loop back edge can be identified by the destination of
 	 the edge dominating the source of the edge.  */
-      if (dominated_by_p (CDI_DOMINATORS, e->src, e->dest))
+      if (dominated_by_p (cfun, CDI_DOMINATORS, e->src, e->dest))
 	continue;
 
       /* If we have already seen a non-loop edge, then we must have
@@ -527,7 +527,7 @@  pass_uncprop::execute (function *fun)
 
   /* We're going to do a dominator walk, so ensure that we have
      dominance information.  */
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (fun, CDI_DOMINATORS);
 
   /* Recursively walk the dominator tree undoing unprofitable
      constant/copy propagations.  */
diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c
index 3f007b5..bec0765 100644
--- a/gcc/tree-ssa-uninit.c
+++ b/gcc/tree-ssa-uninit.c
@@ -184,7 +184,7 @@  warn_uninitialized_vars (bool warn_possibly_uninitialized)
 
   FOR_EACH_BB_FN (bb, cfun)
     {
-      bool always_executed = dominated_by_p (CDI_POST_DOMINATORS,
+      bool always_executed = dominated_by_p (cfun, CDI_POST_DOMINATORS,
 					     single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun)), bb);
       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	{
@@ -360,7 +360,7 @@  find_dom (basic_block block)
 static bool
 is_non_loop_exit_postdominating (basic_block bb1, basic_block bb2)
 {
-  if (!dominated_by_p (CDI_POST_DOMINATORS, bb2, bb1))
+  if (!dominated_by_p (cfun, CDI_POST_DOMINATORS, bb2, bb1))
     return false;
 
   if (single_pred_p (bb1) && !single_succ_p (bb2))
@@ -383,7 +383,7 @@  find_control_equiv_block (basic_block bb)
   if (!is_non_loop_exit_postdominating (pdom, bb))
     return NULL;
 
-  if (dominated_by_p (CDI_DOMINATORS, pdom, bb))
+  if (dominated_by_p (cfun, CDI_DOMINATORS, pdom, bb))
     return pdom;
 
   return NULL;
@@ -661,10 +661,11 @@  find_predicates (pred_chain_union *preds,
   /* First find the closest bb that is control equivalent to PHI_BB
      that also dominates USE_BB.  */
   cd_root = phi_bb;
-  while (dominated_by_p (CDI_DOMINATORS, use_bb, cd_root))
+  while (dominated_by_p (cfun, CDI_DOMINATORS, use_bb, cd_root))
     {
       basic_block ctrl_eq_bb = find_control_equiv_block (cd_root);
-      if (ctrl_eq_bb && dominated_by_p (CDI_DOMINATORS, use_bb, ctrl_eq_bb))
+      if (ctrl_eq_bb && dominated_by_p (cfun, CDI_DOMINATORS, use_bb,
+					ctrl_eq_bb))
         cd_root = ctrl_eq_bb;
       else
         break;
@@ -718,8 +719,8 @@  collect_phi_def_edges (gphi *phi, basic_block cd_root,
           gimple def = SSA_NAME_DEF_STMT (opnd);
 
           if (gimple_code (def) == GIMPLE_PHI
-              && dominated_by_p (CDI_DOMINATORS,
-                                 gimple_bb (def), cd_root))
+	      && dominated_by_p (cfun, CDI_DOMINATORS,
+				 gimple_bb (def), cd_root))
             collect_phi_def_edges (as_a <gphi *> (def), cd_root, edges,
                                    visited_phis);
           else if (!uninit_undefined_value_p (opnd))
@@ -2413,8 +2414,8 @@  pass_late_warn_uninitialized::execute (function *fun)
   gphi_iterator gsi;
   vec<gphi *> worklist = vNULL;
 
-  calculate_dominance_info (CDI_DOMINATORS);
-  calculate_dominance_info (CDI_POST_DOMINATORS);
+  calculate_dominance_info (fun, CDI_DOMINATORS);
+  calculate_dominance_info (fun, CDI_POST_DOMINATORS);
   /* Re-do the plain uninitialized variable check, as optimization may have
      straightened control flow.  Do this first so that we don't accidentally
      get a "may be" warning when we'd have seen an "is" warning later.  */
@@ -2466,7 +2467,7 @@  pass_late_warn_uninitialized::execute (function *fun)
   worklist.release ();
   delete possibly_undefined_names;
   possibly_undefined_names = NULL;
-  free_dominance_info (CDI_POST_DOMINATORS);
+  free_dominance_info (fun, CDI_POST_DOMINATORS);
   timevar_pop (TV_TREE_UNINIT);
   return 0;
 }
@@ -2488,14 +2489,14 @@  execute_early_warn_uninitialized (void)
      optimization we want to warn about possible uninitialized as late
      as possible, thus don't do it here.  However, without
      optimization we need to warn here about "may be uninitialized".  */
-  calculate_dominance_info (CDI_POST_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_POST_DOMINATORS);
 
   warn_uninitialized_vars (/*warn_possibly_uninitialized=*/!optimize);
 
   /* Post-dominator information can not be reliably updated. Free it
      after the use.  */
 
-  free_dominance_info (CDI_POST_DOMINATORS);
+  free_dominance_info (cfun, CDI_POST_DOMINATORS);
   return 0;
 }
 
diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
index 9646466..ec8a65b 100644
--- a/gcc/tree-ssa.c
+++ b/gcc/tree-ssa.c
@@ -363,7 +363,7 @@  insert_debug_temp_for_var_def (gimple_stmt_iterator *gsi, tree var)
     {
       bool no_value = false;
 
-      if (!dom_info_available_p (CDI_DOMINATORS))
+      if (!dom_info_available_p (cfun, CDI_DOMINATORS))
 	{
 	  struct walk_stmt_info wi;
 
@@ -760,7 +760,7 @@  verify_use (basic_block bb, basic_block def_bb, use_operand_p use_p,
       err = true;
     }
   else if (bb != def_bb
-	   && !dominated_by_p (CDI_DOMINATORS, bb, def_bb))
+	   && !dominated_by_p (cfun, CDI_DOMINATORS, bb, def_bb))
     {
       error ("definition in block %i does not dominate use in block %i",
 	     def_bb->index, bb->index);
@@ -918,7 +918,7 @@  verify_ssa (bool check_modified_stmt, bool check_ssa_operands)
   basic_block *definition_block = XCNEWVEC (basic_block, num_ssa_names);
   ssa_op_iter iter;
   tree op;
-  enum dom_state orig_dom_state = dom_info_state (CDI_DOMINATORS);
+  enum dom_state orig_dom_state = dom_info_state (cfun, CDI_DOMINATORS);
   bitmap names_defined_in_bb = BITMAP_ALLOC (NULL);
 
   gcc_assert (!need_ssa_update_p (cfun));
@@ -947,7 +947,7 @@  verify_ssa (bool check_modified_stmt, bool check_ssa_operands)
 	}
     }
 
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_DOMINATORS);
 
   /* Now verify all the uses and make sure they agree with the definitions
      found in the previous pass.  */
@@ -1035,9 +1035,9 @@  verify_ssa (bool check_modified_stmt, bool check_ssa_operands)
   /* Restore the dominance information to its prior known state, so
      that we do not perturb the compiler's subsequent behavior.  */
   if (orig_dom_state == DOM_NONE)
-    free_dominance_info (CDI_DOMINATORS);
+    free_dominance_info (cfun, CDI_DOMINATORS);
   else
-    set_dom_info_availability (CDI_DOMINATORS, orig_dom_state);
+    set_dom_info_availability (cfun, CDI_DOMINATORS, orig_dom_state);
 
   BITMAP_FREE (names_defined_in_bb);
   timevar_pop (TV_TREE_SSA_VERIFY);
diff --git a/gcc/tree-stdarg.c b/gcc/tree-stdarg.c
index cd595a9..31c0afc 100644
--- a/gcc/tree-stdarg.c
+++ b/gcc/tree-stdarg.c
@@ -64,7 +64,7 @@  reachable_at_most_once (basic_block va_arg_bb, basic_block va_start_bb)
   if (va_arg_bb == va_start_bb)
     return true;
 
-  if (! dominated_by_p (CDI_DOMINATORS, va_arg_bb, va_start_bb))
+  if (! dominated_by_p (cfun, CDI_DOMINATORS, va_arg_bb, va_start_bb))
     return false;
 
   visited = sbitmap_alloc (last_basic_block_for_fn (cfun));
@@ -792,7 +792,7 @@  optimize_va_list_gpr_fpr_size (function *fun)
   if (va_list_simple_ptr)
     fun->va_list_fpr_size = VA_LIST_MAX_FPR_SIZE;
 
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (fun, CDI_DOMINATORS);
   memset (&wi, 0, sizeof (wi));
   wi.info = si.va_list_vars;
 
@@ -1093,7 +1093,7 @@  expand_ifn_va_arg_1 (function *fun)
   if (!modified)
     return;
 
-  free_dominance_info (CDI_DOMINATORS);
+  free_dominance_info (fun, CDI_DOMINATORS);
   update_ssa (TODO_update_ssa);
 }
 
diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c
index 3201912..909a9e8 100644
--- a/gcc/tree-switch-conversion.c
+++ b/gcc/tree-switch-conversion.c
@@ -122,8 +122,8 @@  hoist_edge_and_branch_if_true (gimple_stmt_iterator *gsip,
   if (update_dominators)
     {
       if (dominated_e_true)
-	set_immediate_dominator (CDI_DOMINATORS, e_true->dest, split_bb);
-      set_immediate_dominator (CDI_DOMINATORS, e_false->dest, split_bb);
+	set_immediate_dominator (cfun, CDI_DOMINATORS, e_true->dest, split_bb);
+      set_immediate_dominator (cfun, CDI_DOMINATORS, e_false->dest, split_bb);
     }
 
   return new_bb;
@@ -285,7 +285,7 @@  emit_case_bit_tests (gswitch *swtch, tree index_expr,
   basic_block switch_bb = gimple_bb (swtch);
   basic_block default_bb, new_default_bb, new_bb;
   edge default_edge;
-  bool update_dom = dom_info_available_p (CDI_DOMINATORS);
+  bool update_dom = dom_info_available_p (cfun, CDI_DOMINATORS);
 
   vec<basic_block> bbs_to_fix_dom = vNULL;
 
@@ -429,7 +429,7 @@  emit_case_bit_tests (gswitch *swtch, tree index_expr,
 	  edge e = find_edge (new_bb, dom_son);
 	  if (e && single_pred_p (e->dest))
 	    continue;
-	  set_immediate_dominator (CDI_DOMINATORS, dom_son, switch_bb);
+	  set_immediate_dominator (cfun, CDI_DOMINATORS, dom_son, switch_bb);
 	  bbs_to_fix_dom.safe_push (dom_son);
 	}
       dom_bbs.release ();
@@ -476,7 +476,7 @@  emit_case_bit_tests (gswitch *swtch, tree index_expr,
   if (update_dom)
     {
       /* Fix up the dominator tree.  */
-      iterate_fix_dominators (CDI_DOMINATORS, bbs_to_fix_dom, true);
+      iterate_fix_dominators (cfun, CDI_DOMINATORS, bbs_to_fix_dom, true);
       bbs_to_fix_dom.release ();
     }
 }
@@ -1311,15 +1311,15 @@  gen_inbound_check (gswitch *swtch, struct switch_conv_info *info)
   fix_phi_nodes (e1f, e2f, bbf, info);
 
   /* Fix the dominator tree, if it is available.  */
-  if (dom_info_available_p (CDI_DOMINATORS))
+  if (dom_info_available_p (cfun, CDI_DOMINATORS))
     {
       vec<basic_block> bbs_to_fix_dom;
 
-      set_immediate_dominator (CDI_DOMINATORS, bb1, bb0);
-      set_immediate_dominator (CDI_DOMINATORS, bb2, bb0);
+      set_immediate_dominator (cfun, CDI_DOMINATORS, bb1, bb0);
+      set_immediate_dominator (cfun, CDI_DOMINATORS, bb2, bb0);
       if (! get_immediate_dominator (CDI_DOMINATORS, bbf))
 	/* If bbD was the immediate dominator ...  */
-	set_immediate_dominator (CDI_DOMINATORS, bbf, bb0);
+	set_immediate_dominator (cfun, CDI_DOMINATORS, bbf, bb0);
 
       bbs_to_fix_dom.create (4);
       bbs_to_fix_dom.quick_push (bb0);
@@ -1327,7 +1327,7 @@  gen_inbound_check (gswitch *swtch, struct switch_conv_info *info)
       bbs_to_fix_dom.quick_push (bb2);
       bbs_to_fix_dom.quick_push (bbf);
 
-      iterate_fix_dominators (CDI_DOMINATORS, bbs_to_fix_dom, true);
+      iterate_fix_dominators (cfun, CDI_DOMINATORS, bbs_to_fix_dom, true);
       bbs_to_fix_dom.release ();
     }
 }
@@ -1485,7 +1485,7 @@  pass_convert_switch::execute (function *fun)
 	    /* Make no effort to update the post-dominator tree.  It is actually not
 	       that hard for the transformations we have performed, but it is not
 	       supported by iterate_fix_dominators.  */
-	    free_dominance_info (CDI_POST_DOMINATORS);
+	    free_dominance_info (fun, CDI_POST_DOMINATORS);
 	  }
 	else
 	  {
diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c
index 7b723c2..a19261f 100644
--- a/gcc/tree-tailcall.c
+++ b/gcc/tree-tailcall.c
@@ -1066,7 +1066,7 @@  tree_optimize_tail_calls_1 (bool opt_tailcalls)
     {
       /* We may have created new loops.  Make them magically appear.  */
       loops_state_set (LOOPS_NEED_FIXUP);
-      free_dominance_info (CDI_DOMINATORS);
+      free_dominance_info (cfun, CDI_DOMINATORS);
     }
 
   /* Add phi nodes for the virtual operands defined in the function to the
diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
index efcc4bb..9613fbe 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -146,7 +146,7 @@  adjust_debug_stmts_now (adjust_info *ai)
   gimple stmt;
   basic_block bbdef = gimple_bb (SSA_NAME_DEF_STMT (orig_def));
 
-  gcc_assert (dom_info_available_p (CDI_DOMINATORS));
+  gcc_assert (dom_info_available_p (cfun, CDI_DOMINATORS));
 
   /* Adjust any debug stmts that held onto non-loop-closed
      references.  */
@@ -163,9 +163,9 @@  adjust_debug_stmts_now (adjust_info *ai)
       bbuse = gimple_bb (stmt);
 
       if ((bbuse == bbphi
-	   || dominated_by_p (CDI_DOMINATORS, bbuse, bbphi))
+	   || dominated_by_p (cfun, CDI_DOMINATORS, bbuse, bbphi))
 	  && !(bbuse == bbdef
-	       || dominated_by_p (CDI_DOMINATORS, bbuse, bbdef)))
+	       || dominated_by_p (cfun, CDI_DOMINATORS, bbuse, bbdef)))
 	{
 	  if (new_def)
 	    FOR_EACH_IMM_USE_ON_STMT (use_p, imm_iter)
@@ -847,16 +847,16 @@  slpeel_tree_duplicate_loop_to_edge_cfg (struct loop *loop,
 	}
       redirect_edge_and_branch_force (e, new_preheader);
       flush_pending_stmts (e);
-      set_immediate_dominator (CDI_DOMINATORS, new_preheader, e->src);
+      set_immediate_dominator (cfun, CDI_DOMINATORS, new_preheader, e->src);
       if (was_imm_dom || duplicate_outer_loop)
-	set_immediate_dominator (CDI_DOMINATORS, exit_dest, new_exit->src);
+	set_immediate_dominator (cfun, CDI_DOMINATORS, exit_dest, new_exit->src);
 
       /* And remove the non-necessary forwarder again.  Keep the other
          one so we have a proper pre-header for the loop at the exit edge.  */
       redirect_edge_pred (single_succ_edge (preheader),
 			  single_pred (preheader));
       delete_basic_block (preheader);
-      set_immediate_dominator (CDI_DOMINATORS, scalar_loop->header,
+      set_immediate_dominator (cfun, CDI_DOMINATORS, scalar_loop->header,
 			       loop_preheader_edge (scalar_loop)->src);
     }
   else /* Add the copy at entry.  */
@@ -867,7 +867,7 @@  slpeel_tree_duplicate_loop_to_edge_cfg (struct loop *loop,
 	  redirect_edge_pred (single_succ_edge (preheader),
 			      single_pred (preheader));
 	  delete_basic_block (preheader);
-	  set_immediate_dominator (CDI_DOMINATORS, scalar_loop->header,
+	  set_immediate_dominator (cfun, CDI_DOMINATORS, scalar_loop->header,
 				   loop_preheader_edge (scalar_loop)->src);
 	  preheader = split_edge (loop_preheader_edge (loop));
 	  entry_e = single_pred_edge (preheader);
@@ -875,18 +875,18 @@  slpeel_tree_duplicate_loop_to_edge_cfg (struct loop *loop,
 
       redirect_edge_and_branch_force (entry_e, new_preheader);
       flush_pending_stmts (entry_e);
-      set_immediate_dominator (CDI_DOMINATORS, new_preheader, entry_e->src);
+      set_immediate_dominator (cfun, CDI_DOMINATORS, new_preheader, entry_e->src);
 
       redirect_edge_and_branch_force (new_exit, preheader);
       flush_pending_stmts (new_exit);
-      set_immediate_dominator (CDI_DOMINATORS, preheader, new_exit->src);
+      set_immediate_dominator (cfun, CDI_DOMINATORS, preheader, new_exit->src);
 
       /* And remove the non-necessary forwarder again.  Keep the other
          one so we have a proper pre-header for the loop at the exit edge.  */
       redirect_edge_pred (single_succ_edge (new_preheader),
 			  single_pred (new_preheader));
       delete_basic_block (new_preheader);
-      set_immediate_dominator (CDI_DOMINATORS, new_loop->header,
+      set_immediate_dominator (cfun, CDI_DOMINATORS, new_loop->header,
 			       loop_preheader_edge (new_loop)->src);
     }
 
@@ -920,7 +920,7 @@  slpeel_tree_duplicate_loop_to_edge_cfg (struct loop *loop,
   free (bbs);
 
 #ifdef ENABLE_CHECKING
-  verify_dominators (CDI_DOMINATORS);
+  verify_dominators (cfun, CDI_DOMINATORS);
 #endif
 
   return new_loop;
@@ -967,7 +967,7 @@  slpeel_add_loop_guard (basic_block guard_bb, tree cond,
   new_e->count = apply_probability (enter_e->count, probability);
   enter_e->count -= new_e->count;
   enter_e->probability = inverse_probability (probability);
-  set_immediate_dominator (CDI_DOMINATORS, exit_bb, dom_bb);
+  set_immediate_dominator (cfun, CDI_DOMINATORS, exit_bb, dom_bb);
   return new_e;
 }
 
@@ -1066,11 +1066,11 @@  set_prologue_iterations (basic_block bb_before_first_loop,
 
   e = single_pred_edge (bb_before_first_loop);
   then_bb = split_edge (e);
-  set_immediate_dominator (CDI_DOMINATORS, then_bb, cond_bb);
+  set_immediate_dominator (cfun, CDI_DOMINATORS, then_bb, cond_bb);
 
   e_false = make_single_succ_edge (cond_bb, bb_before_first_loop,
 				   EDGE_FALSE_VALUE);
-  set_immediate_dominator (CDI_DOMINATORS, bb_before_first_loop, cond_bb);
+  set_immediate_dominator (cfun, CDI_DOMINATORS, bb_before_first_loop, cond_bb);
 
   e_true = EDGE_PRED (then_bb, 0);
   e_true->flags &= ~EDGE_FALLTHRU;
@@ -2389,11 +2389,11 @@  vect_loop_versioning (loop_vec_info loop_vinfo,
 				      scalar_preheader);
       redirect_edge_and_branch_force (scalar_e, preheader);
       redirect_edge_and_branch_force (e, condition_bb);
-      set_immediate_dominator (CDI_DOMINATORS, condition_bb,
+      set_immediate_dominator (cfun, CDI_DOMINATORS, condition_bb,
 			       single_pred (condition_bb));
-      set_immediate_dominator (CDI_DOMINATORS, scalar_preheader,
+      set_immediate_dominator (cfun, CDI_DOMINATORS, scalar_preheader,
 			       single_pred (scalar_preheader));
-      set_immediate_dominator (CDI_DOMINATORS, preheader,
+      set_immediate_dominator (cfun, CDI_DOMINATORS, preheader,
 			       condition_bb);
     }
   else
diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c
index bc3117d..1f74013 100644
--- a/gcc/tree-vect-patterns.c
+++ b/gcc/tree-vect-patterns.c
@@ -1908,7 +1908,7 @@  vect_recog_rotate_pattern (vec<gimple> *stmts, tree *type_in, tree *type_out)
 	{
 	  basic_block bb = gimple_bb (SSA_NAME_DEF_STMT (oprnd1));
 	  if (bb == NULL
-	      || !dominated_by_p (CDI_DOMINATORS, ext_def->dest, bb))
+	      || !dominated_by_p (cfun, CDI_DOMINATORS, ext_def->dest, bb))
 	    ext_def = NULL;
 	}
     }
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 685eb72..2989b57 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -5037,7 +5037,7 @@  register_new_assert_for (tree name, tree expr,
 	     the assertion up in the dominance tree by updating its
 	     location information.  */
 	  if ((e == NULL || !EDGE_CRITICAL_P (e))
-	      && dominated_by_p (CDI_DOMINATORS, loc->bb, dest_bb))
+	      && dominated_by_p (cfun, CDI_DOMINATORS, loc->bb, dest_bb))
 	    {
 	      loc->bb = dest_bb;
 	      loc->e = e;
@@ -5300,7 +5300,8 @@  register_edge_assert_for_2 (tree name, edge e, gimple_stmt_iterator bsi,
 	    continue;
 
 	  /* Cut off to use-stmts that are dominating the predecessor.  */
-	  if (!dominated_by_p (CDI_DOMINATORS, e->src, gimple_bb (use_stmt)))
+	  if (!dominated_by_p (cfun, CDI_DOMINATORS, e->src,
+			       gimple_bb (use_stmt)))
 	    continue;
 
 	  tree name2 = gimple_assign_lhs (use_stmt);
@@ -6460,7 +6461,7 @@  insert_range_assertions (void)
   need_assert_for = BITMAP_ALLOC (NULL);
   asserts_for = XCNEWVEC (assert_locus_t, num_ssa_names);
 
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_DOMINATORS);
 
   find_assert_locations ();
   if (!bitmap_empty_p (need_assert_for))
@@ -10133,7 +10134,7 @@  identify_jump_threads (void)
   /* Ugh.  When substituting values earlier in this pass we can
      wipe the dominance information.  So rebuild the dominator
      information as we need it within the jump threading code.  */
-  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (cfun, CDI_DOMINATORS);
 
   /* We do not allow VRP information to be used for jump threading
      across a back edge in the CFG.  Otherwise it becomes too
@@ -10406,7 +10407,7 @@  execute_vrp (void)
 
   if (to_remove_edges.length () > 0)
     {
-      free_dominance_info (CDI_DOMINATORS);
+      free_dominance_info (cfun, CDI_DOMINATORS);
       loops_state_set (LOOPS_NEED_FIXUP);
     }
 
diff --git a/gcc/ubsan.c b/gcc/ubsan.c
index 7983c93..5af3d5c 100644
--- a/gcc/ubsan.c
+++ b/gcc/ubsan.c
@@ -741,7 +741,7 @@  ubsan_expand_bounds_ifn (gimple_stmt_iterator *gsi)
    could be changed to any other pointer type.  */
 
 bool
-ubsan_expand_null_ifn (gimple_stmt_iterator *gsip)
+ubsan_expand_null_ifn (function *cur_fn, gimple_stmt_iterator *gsip)
 {
   gimple_stmt_iterator gsi = *gsip;
   gimple stmt = gsi_stmt (gsi);
@@ -807,8 +807,8 @@  ubsan_expand_null_ifn (gimple_stmt_iterator *gsip)
   /* Update dominance info for the newly created then_bb; note that
      fallthru_bb's dominance info has already been updated by
      split_block.  */
-  if (dom_info_available_p (CDI_DOMINATORS))
-    set_immediate_dominator (CDI_DOMINATORS, then_bb, cond_bb);
+  if (dom_info_available_p (cur_fn, CDI_DOMINATORS))
+    set_immediate_dominator (cur_fn, CDI_DOMINATORS, then_bb, cond_bb);
 
   /* Put the ubsan builtin call into the newly created BB.  */
   if (flag_sanitize_undefined_trap_on_error)
@@ -874,10 +874,10 @@  ubsan_expand_null_ifn (gimple_stmt_iterator *gsip)
 	  e->probability = REG_BR_PROB_BASE - PROB_VERY_UNLIKELY;
 
 	  /* Update dominance info.  */
-	  if (dom_info_available_p (CDI_DOMINATORS))
+	  if (dom_info_available_p (cur_fn, CDI_DOMINATORS))
 	    {
-	      set_immediate_dominator (CDI_DOMINATORS, fallthru_bb, cond1_bb);
-	      set_immediate_dominator (CDI_DOMINATORS, then_bb, cond1_bb);
+	      set_immediate_dominator (cur_fn, CDI_DOMINATORS, fallthru_bb, cond1_bb);
+	      set_immediate_dominator (cur_fn, CDI_DOMINATORS, then_bb, cond1_bb);
 	    }
 
 	  gsi2 = gsi_start_bb (cond2_bb);
diff --git a/gcc/ubsan.h b/gcc/ubsan.h
index 9f23a38..0ce912f 100644
--- a/gcc/ubsan.h
+++ b/gcc/ubsan.h
@@ -44,7 +44,7 @@  enum ubsan_print_style {
 
 extern bool do_ubsan_in_current_function (void);
 extern bool ubsan_expand_bounds_ifn (gimple_stmt_iterator *);
-extern bool ubsan_expand_null_ifn (gimple_stmt_iterator *);
+extern bool ubsan_expand_null_ifn (function *, gimple_stmt_iterator *);
 extern bool ubsan_expand_objsize_ifn (gimple_stmt_iterator *);
 extern bool ubsan_expand_vptr_ifn (gimple_stmt_iterator *);
 extern bool ubsan_instrument_unreachable (gimple_stmt_iterator *);