From 928e2d33daafe1943766dfb437f6ba7b795dfa41 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Sat, 25 May 2013 02:12:40 -0400
Subject: [PATCH 2/2] autogenerated

---
 gcc/ChangeLog                            | 599 +++++++++++++++++++++++++++++++
 gcc/alias.c                              |   4 +-
 gcc/asan.c                               |   4 +-
 gcc/auto-inc-dec.c                       |   2 +-
 gcc/bb-reorder.c                         |  84 ++---
 gcc/bt-load.c                            |  46 +--
 gcc/caller-save.c                        |   8 +-
 gcc/cfg.c                                |  56 +--
 gcc/cfganal.c                            | 124 +++----
 gcc/cfgbuild.c                           |  34 +-
 gcc/cfgcleanup.c                         |  68 ++--
 gcc/cfgexpand.c                          |  90 ++---
 gcc/cfghooks.c                           |  38 +-
 gcc/cfgloop.c                            |  52 +--
 gcc/cfgloopanal.c                        |  14 +-
 gcc/cfgloopmanip.c                       |  24 +-
 gcc/cfgrtl.c                             | 214 +++++------
 gcc/cgraphbuild.c                        |  10 +-
 gcc/cgraphunit.c                         |   8 +-
 gcc/combine-stack-adj.c                  |   2 +-
 gcc/combine.c                            |  28 +-
 gcc/compare-elim.c                       |   2 +-
 gcc/config/alpha/alpha.c                 |   2 +-
 gcc/config/arm/arm.c                     |   8 +-
 gcc/config/bfin/bfin.c                   |   6 +-
 gcc/config/c6x/c6x.c                     |   6 +-
 gcc/config/epiphany/resolve-sw-modes.c   |   6 +-
 gcc/config/frv/frv.c                     |  10 +-
 gcc/config/i386/i386.c                   |  20 +-
 gcc/config/ia64/ia64.c                   |  10 +-
 gcc/config/mips/mips.c                   |  10 +-
 gcc/config/picochip/picochip.c           |   2 +-
 gcc/config/rs6000/rs6000.c               |   4 +-
 gcc/config/s390/s390.c                   |   2 +-
 gcc/config/sh/sh.c                       |   2 +-
 gcc/config/spu/spu.c                     |  10 +-
 gcc/config/tilegx/tilegx.c               |   4 +-
 gcc/config/tilepro/tilepro.c             |   4 +-
 gcc/coverage.c                           |   4 +-
 gcc/cprop.c                              |  48 +--
 gcc/cse.c                                |  14 +-
 gcc/dce.c                                |  10 +-
 gcc/df-core.c                            |  76 ++--
 gcc/df-problems.c                        |  56 +--
 gcc/df-scan.c                            |  44 +--
 gcc/dominance.c                          |  62 ++--
 gcc/domwalk.c                            |  10 +-
 gcc/dse.c                                |  16 +-
 gcc/except.c                             |   6 +-
 gcc/final.c                              |   8 +-
 gcc/function.c                           |  70 ++--
 gcc/fwprop.c                             |   4 +-
 gcc/gcse.c                               |  88 ++---
 gcc/gimple-iterator.c                    |   8 +-
 gcc/gimple-ssa-strength-reduction.c      |   4 +-
 gcc/gimple.c                             |   6 +-
 gcc/graph.c                              |  12 +-
 gcc/graphite-clast-to-gimple.c           |   2 +-
 gcc/graphite-scop-detection.c            |  12 +-
 gcc/graphite-sese-to-poly.c              |   6 +-
 gcc/graphite.c                           |   8 +-
 gcc/haifa-sched.c                        |  34 +-
 gcc/hw-doloop.c                          |  10 +-
 gcc/ifcvt.c                              |  30 +-
 gcc/init-regs.c                          |   2 +-
 gcc/ipa-inline-analysis.c                |  14 +-
 gcc/ipa-prop.c                           |   2 +-
 gcc/ipa-pure-const.c                     |   4 +-
 gcc/ipa-split.c                          |  46 +--
 gcc/ira-build.c                          |  16 +-
 gcc/ira-color.c                          |   2 +-
 gcc/ira-costs.c                          |   2 +-
 gcc/ira-emit.c                           |  26 +-
 gcc/ira-int.h                            |   2 +-
 gcc/ira.c                                |  32 +-
 gcc/jump.c                               |   2 +-
 gcc/lcm.c                                | 158 ++++----
 gcc/loop-init.c                          |   6 +-
 gcc/loop-invariant.c                     |   2 +-
 gcc/loop-iv.c                            |   4 +-
 gcc/loop-unroll.c                        |  12 +-
 gcc/loop-unswitch.c                      |   2 +-
 gcc/lower-subreg.c                       |   8 +-
 gcc/lra-assigns.c                        |   4 +-
 gcc/lra-coalesce.c                       |   4 +-
 gcc/lra-constraints.c                    |   6 +-
 gcc/lra-eliminations.c                   |   2 +-
 gcc/lra-lives.c                          |   8 +-
 gcc/lra-spills.c                         |   6 +-
 gcc/lra.c                                |  16 +-
 gcc/lto-streamer-in.c                    |   6 +-
 gcc/lto-streamer-out.c                   |   4 +-
 gcc/mcf.c                                |  26 +-
 gcc/mode-switching.c                     |  32 +-
 gcc/modulo-sched.c                       |   6 +-
 gcc/omp-low.c                            |   6 +-
 gcc/optabs.c                             |   2 +-
 gcc/postreload-gcse.c                    |  10 +-
 gcc/postreload.c                         |   4 +-
 gcc/predict.c                            |  70 ++--
 gcc/profile.c                            |  72 ++--
 gcc/recog.c                              |   6 +-
 gcc/ree.c                                |   2 +-
 gcc/reg-stack.c                          |  20 +-
 gcc/regcprop.c                           |   8 +-
 gcc/reginfo.c                            |   2 +-
 gcc/regmove.c                            |   6 +-
 gcc/regrename.c                          |  14 +-
 gcc/regs.h                               |   2 +-
 gcc/regstat.c                            |   8 +-
 gcc/reload.c                             |   6 +-
 gcc/reload1.c                            |  16 +-
 gcc/reorg.c                              |   2 +-
 gcc/resource.c                           |  16 +-
 gcc/sched-deps.c                         |   2 +-
 gcc/sched-ebb.c                          |  10 +-
 gcc/sched-int.h                          |   8 +-
 gcc/sched-rgn.c                          | 134 +++----
 gcc/sched-vis.c                          |   2 +-
 gcc/sel-sched-dump.c                     |   2 +-
 gcc/sel-sched-ir.c                       |  60 ++--
 gcc/sel-sched-ir.h                       |  10 +-
 gcc/sel-sched.c                          |  22 +-
 gcc/sese.c                               |   6 +-
 gcc/stack-ptr-mod.c                      |   2 +-
 gcc/store-motion.c                       |  40 +--
 gcc/testsuite/ChangeLog                  |  12 +
 gcc/testsuite/g++.dg/plugin/selfassign.c |   2 +-
 gcc/testsuite/gcc.dg/plugin/selfassign.c |   2 +-
 gcc/tracer.c                             |  12 +-
 gcc/trans-mem.c                          |  28 +-
 gcc/tree-call-cdce.c                     |   2 +-
 gcc/tree-cfg.c                           | 144 ++++----
 gcc/tree-cfgcleanup.c                    |  22 +-
 gcc/tree-complex.c                       |   8 +-
 gcc/tree-dfa.c                           |   6 +-
 gcc/tree-eh.c                            |   6 +-
 gcc/tree-emutls.c                        |   2 +-
 gcc/tree-if-conv.c                       |   4 +-
 gcc/tree-inline.c                        |  54 +--
 gcc/tree-into-ssa.c                      |  60 ++--
 gcc/tree-loop-distribution.c             |   2 +-
 gcc/tree-mudflap.c                       |   6 +-
 gcc/tree-nrv.c                           |   6 +-
 gcc/tree-object-size.c                   |   2 +-
 gcc/tree-optimize.c                      |  10 +-
 gcc/tree-outof-ssa.c                     |   8 +-
 gcc/tree-profile.c                       |   4 +-
 gcc/tree-scalar-evolution.c              |   2 +-
 gcc/tree-scalar-evolution.h              |   2 +-
 gcc/tree-sra.c                           |  26 +-
 gcc/tree-ssa-ccp.c                       |  10 +-
 gcc/tree-ssa-coalesce.c                  |   8 +-
 gcc/tree-ssa-copy.c                      |   2 +-
 gcc/tree-ssa-copyrename.c                |   4 +-
 gcc/tree-ssa-dce.c                       |  52 +--
 gcc/tree-ssa-dom.c                       |  14 +-
 gcc/tree-ssa-dse.c                       |   2 +-
 gcc/tree-ssa-forwprop.c                  |   2 +-
 gcc/tree-ssa-ifcombine.c                 |   2 +-
 gcc/tree-ssa-live.c                      |  46 +--
 gcc/tree-ssa-live.h                      |   8 +-
 gcc/tree-ssa-loop-ch.c                   |   6 +-
 gcc/tree-ssa-loop-im.c                   |  14 +-
 gcc/tree-ssa-loop-ivopts.c               |   2 +-
 gcc/tree-ssa-loop-manip.c                |  28 +-
 gcc/tree-ssa-loop-niter.c                |   4 +-
 gcc/tree-ssa-loop-prefetch.c             |   2 +-
 gcc/tree-ssa-loop-unswitch.c             |   2 +-
 gcc/tree-ssa-math-opts.c                 |  14 +-
 gcc/tree-ssa-phiopt.c                    |  14 +-
 gcc/tree-ssa-phiprop.c                   |   2 +-
 gcc/tree-ssa-pre.c                       |  36 +-
 gcc/tree-ssa-propagate.c                 |  16 +-
 gcc/tree-ssa-reassoc.c                   |  18 +-
 gcc/tree-ssa-sccvn.c                     |   6 +-
 gcc/tree-ssa-sink.c                      |   8 +-
 gcc/tree-ssa-strlen.c                    |   2 +-
 gcc/tree-ssa-structalias.c               |   4 +-
 gcc/tree-ssa-tail-merge.c                |  38 +-
 gcc/tree-ssa-ter.c                       |   2 +-
 gcc/tree-ssa-threadupdate.c              |   4 +-
 gcc/tree-ssa-uncprop.c                   |  12 +-
 gcc/tree-ssa-uninit.c                    |  16 +-
 gcc/tree-ssa.c                           |  10 +-
 gcc/tree-stdarg.c                        |  10 +-
 gcc/tree-switch-conversion.c             |   2 +-
 gcc/tree-tailcall.c                      |  16 +-
 gcc/tree-vect-generic.c                  |   2 +-
 gcc/tree-vectorizer.c                    |   2 +-
 gcc/tree-vrp.c                           |  20 +-
 gcc/tsan.c                               |   6 +-
 gcc/value-prof.c                         |   6 +-
 gcc/var-tracking.c                       |  54 +--
 gcc/varasm.c                             |   2 +-
 gcc/web.c                                |   6 +-
 196 files changed, 2438 insertions(+), 1827 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6631a6a..851756b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,604 @@
 2013-05-25  David Malcolm  <dmalcolm@redhat.com>
 
+	Patch autogenerated by refactor_cfun.py from
+	https://github.com/davidmalcolm/gcc-refactoring-scripts
+	revision a205d8d1341c462a14673fc0fcd22b039baf7865
+
+	* alias.c (ao_ref_from_mem): Remove uses of macros: BASIC_BLOCK,
+	n_basic_blocks.
+
+	* asan.c (asan_mem_ref_get_alloc_pool): Remove uses of macros:
+	FOR_EACH_BB, last_basic_block.
+
+	* auto-inc-dec.c (set_inc_state): Remove usage of FOR_EACH_BB macro.
+
+	* bb-reorder.c (bb_visited_trace): Remove uses of macros:
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_EACH_BB, last_basic_block,
+	n_basic_blocks.
+
+	* bt-load.c (basic_block_freq): Remove uses of macros: BASIC_BLOCK,
+	ENTRY_BLOCK_PTR, last_basic_block, n_basic_blocks.
+
+	* caller-save.c (reg_save_code): Remove usage of BASIC_BLOCK macro.
+
+	* cfg.c (init_flow): Remove uses of macros: BASIC_BLOCK,
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_ALL_BB, FOR_EACH_BB,
+	SET_BASIC_BLOCK, last_basic_block, n_basic_blocks, n_edges.
+
+	* cfganal.c (mark_dfs_back_edges): Remove uses of macros:
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_ALL_BB, FOR_EACH_BB,
+	last_basic_block, n_basic_blocks.
+
+	* cfgbuild.c (inside_basic_block_p): Remove uses of macros:
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_EACH_BB, last_basic_block,
+	profile_status.
+
+	* cfgcleanup.c (notice_new_block): Remove uses of macros:
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_ALL_BB, FOR_EACH_BB,
+	n_basic_blocks.
+
+	* cfgexpand.c (gimple_assign_rhs_to_tree): Remove uses of macros:
+	BASIC_BLOCK, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_ALL_BB, FOR_EACH_BB,
+	last_basic_block.
+
+	* cfghooks.c (rtl_register_cfg_hooks): Remove uses of macros:
+	BASIC_BLOCK, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_ALL_BB,
+	FOR_EACH_BB_REVERSE, last_basic_block, n_basic_blocks, n_edges,
+	profile_status.
+
+	* cfgloop.c (flow_loops_cfg_dump): Remove uses of macros: BASIC_BLOCK,
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_EACH_BB, last_basic_block,
+	n_basic_blocks.
+
+	* cfgloopanal.c (just_once_each_iteration_p): Remove uses of macros:
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_EACH_BB, last_basic_block,
+	profile_status.
+
+	* cfgloopmanip.c (rpe_enum_p): Remove uses of macros: ENTRY_BLOCK_PTR,
+	EXIT_BLOCK_PTR, last_basic_block, n_basic_blocks.
+
+	* cfgrtl.c (can_delete_note_p): Remove uses of macros: BASIC_BLOCK,
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_ALL_BB, FOR_EACH_BB,
+	FOR_EACH_BB_REVERSE, SET_BASIC_BLOCK, basic_block_info,
+	last_basic_block, n_basic_blocks, profile_status.
+
+	* cgraphbuild.c (record_reference): Remove uses of macros:
+	ENTRY_BLOCK_PTR, FOR_EACH_BB.
+
+	* cgraphunit.c (cgraph_decide_is_function_needed): Remove uses of
+	macros: ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
+
+	* combine-stack-adj.c (combine_stack_adjustments): Remove usage of
+	FOR_EACH_BB macro.
+
+	* combine.c (alloc_insn_link): Remove uses of macros: ENTRY_BLOCK_PTR,
+	EXIT_BLOCK_PTR, FOR_EACH_BB.
+
+	* compare-elim.c (conforming_compare): Remove usage of ENTRY_BLOCK_PTR
+	macro.
+
+	* coverage.c (get_gcov_type): Remove uses of macros: FOR_EACH_BB,
+	n_basic_blocks.
+
+	* cprop.c (cprop_alloc): Remove uses of macros: ENTRY_BLOCK_PTR,
+	EXIT_BLOCK_PTR, FOR_EACH_BB, last_basic_block, n_basic_blocks,
+	n_edges.
+
+	* cse.c (fixed_base_plus_p): Remove uses of macros: BASIC_BLOCK,
+	EXIT_BLOCK_PTR, FOR_EACH_BB, last_basic_block.
+
+	* dce.c (deletable_insn_p_1): Remove uses of macros: BASIC_BLOCK,
+	FOR_ALL_BB, FOR_EACH_BB, FOR_EACH_BB_REVERSE.
+
+	* df-core.c (definitions): Remove uses of macros: BASIC_BLOCK,
+	FOR_ALL_BB, FOR_EACH_BB, SET_BASIC_BLOCK, last_basic_block,
+	n_basic_blocks, n_edges.
+
+	* df-problems.c (df_chain_dump): Remove uses of macros: BASIC_BLOCK,
+	EXIT_BLOCK_PTR, FOR_ALL_BB, FOR_EACH_BB, last_basic_block.
+
+	* df-scan.c (df_scan_free_internal): Remove uses of macros:
+	BASIC_BLOCK, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_ALL_BB, FOR_EACH_BB.
+
+	* dominance.c (init_dom_info): Remove uses of macros: BASIC_BLOCK,
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_ALL_BB, FOR_EACH_BB,
+	FOR_EACH_BB_REVERSE, last_basic_block, n_basic_blocks.
+
+	* domwalk.c (cmp_bb_postorder): Remove uses of macros:
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, last_basic_block, n_basic_blocks.
+
+	* dse.c (lowpart_bitmask): Remove uses of macros: EXIT_BLOCK_PTR,
+	FOR_ALL_BB, FOR_EACH_BB, last_basic_block.
+
+	* except.c (init_eh): Remove uses of macros: ENTRY_BLOCK_PTR,
+	FOR_EACH_BB.
+
+	* final.c (init_final): Remove uses of macros: ENTRY_BLOCK_PTR,
+	FOR_EACH_BB, FOR_EACH_BB_REVERSE.
+
+	* function.c (push_function_context): Remove uses of macros:
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_EACH_BB, FOR_EACH_BB_REVERSE,
+	last_basic_block, n_basic_blocks.
+
+	* fwprop.c (get_def_for_use): Remove uses of macros: ENTRY_BLOCK_PTR,
+	n_basic_blocks.
+
+	* gcse.c (compute_can_copy): Remove uses of macros: BASIC_BLOCK,
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_EACH_BB, FOR_EACH_BB_REVERSE,
+	last_basic_block, n_basic_blocks, n_edges.
+
+	* gimple-iterator.c (update_modified_stmt): Remove uses of macros:
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_EACH_BB.
+
+	* gimple-ssa-strength-reduction.c (lookup_cand): Remove usage of
+	ENTRY_BLOCK_PTR macro.
+
+	* gimple.c (gimple_set_code): Remove usage of label_to_block_map
+	macro.
+
+	* graph.c (open_graph_file): Remove uses of macros: BASIC_BLOCK,
+	EXIT_BLOCK_PTR, FOR_ALL_BB, last_basic_block.
+
+	* graphite-clast-to-gimple.c (gmp_cst_to_tree): Remove usage of
+	ENTRY_BLOCK_PTR macro.
+
+	* graphite-scop-detection.c (get_bb_type): Remove uses of macros:
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_ALL_BB.
+
+	* graphite-sese-to-poly.c (tree_int_to_gmp): Remove uses of macros:
+	FOR_EACH_BB, last_basic_block.
+
+	* graphite.c (print_global_statistics): Remove uses of macros:
+	FOR_ALL_BB, n_basic_blocks, profile_status.
+
+	* haifa-sched.c (void): Remove uses of macros: EXIT_BLOCK_PTR,
+	FOR_EACH_BB, last_basic_block, n_basic_blocks.
+
+	* hw-doloop.c (dump_hwloops): Remove uses of macros: EXIT_BLOCK_PTR,
+	FOR_EACH_BB.
+
+	* ifcvt.c (count_bb_insns): Remove uses of macros: ENTRY_BLOCK_PTR,
+	EXIT_BLOCK_PTR, FOR_EACH_BB.
+
+	* init-regs.c (initialize_uninitialized_regs): Remove usage of
+	FOR_EACH_BB macro.
+
+	* ipa-inline-analysis.c (true_predicate): Remove uses of macros:
+	BASIC_BLOCK, ENTRY_BLOCK_PTR, n_basic_blocks.
+
+	* ipa-prop.c (ipa_get_param_decl_index_1): Remove usage of FOR_EACH_BB
+	macro.
+
+	* ipa-pure-const.c (function_always_visible_to_compiler_p): Remove
+	uses of macros: EXIT_BLOCK_PTR, FOR_EACH_BB.
+
+	* ipa-split.c (test_nonssa_use): Remove uses of macros: BASIC_BLOCK,
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_EACH_BB, last_basic_block.
+
+	* ira-build.c (init_loop_tree_node): Remove uses of macros:
+	ENTRY_BLOCK_PTR, FOR_EACH_BB, last_basic_block, n_basic_blocks.
+
+	* ira-color.c (find_hard_regs): Remove usage of EXIT_BLOCK_PTR macro.
+
+	* ira-costs.c (initiate_regno_cost_classes): Remove usage of
+	FOR_EACH_BB macro.
+
+	* ira-emit.c (ira_initiate_emit_data): Remove uses of macros:
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_EACH_BB, last_basic_block.
+
+	* ira-int.h (ira_assert): Remove usage of ENTRY_BLOCK_PTR macro.
+
+	* ira.c (setup_reg_mode_hard_regset): Remove uses of macros:
+	FOR_ALL_BB, FOR_EACH_BB, FOR_EACH_BB_REVERSE, last_basic_block.
+
+	* jump.c (rebuild_jump_labels_1): Remove usage of FOR_EACH_BB macro.
+
+	* lcm.c (compute_antinout_edge): Remove uses of macros:
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_EACH_BB, FOR_EACH_BB_REVERSE,
+	last_basic_block, n_basic_blocks.
+
+	* loop-init.c (apply_loop_flags): Remove uses of macros: FOR_ALL_BB,
+	FOR_EACH_BB.
+
+	* loop-invariant.c (check_invariant_table_size): Remove usage of
+	FOR_EACH_BB macro.
+
+	* loop-iv.c (iv_extend_to_rtx_code): Remove usage of ENTRY_BLOCK_PTR
+	macro.
+
+	* loop-unroll.c (report_unroll_peel): Remove uses of macros:
+	BASIC_BLOCK, last_basic_block, profile_status.
+
+	* loop-unswitch.c (compare_and_jump_seq): Remove usage of
+	EXIT_BLOCK_PTR macro.
+
+	* lower-subreg.c (shift_cost): Remove uses of macros: BASIC_BLOCK,
+	FOR_EACH_BB, last_basic_block.
+
+	* lra-assigns.c (process_copy_to_form_thread): Remove uses of macros:
+	ENTRY_BLOCK_PTR, FOR_EACH_BB.
+
+	* lra-coalesce.c (move_freq_compare_func): Remove usage of FOR_EACH_BB
+	macro.
+
+	* lra-constraints.c (strip_subreg): Remove uses of macros:
+	EXIT_BLOCK_PTR, FOR_EACH_BB.
+
+	* lra-eliminations.c (print_elim_table): Remove usage of FOR_EACH_BB
+	macro.
+
+	* lra-lives.c (free_live_range): Remove uses of macros: BASIC_BLOCK,
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, last_basic_block, n_basic_blocks.
+
+	* lra-spills.c (assign_mem_slot): Remove usage of FOR_EACH_BB macro.
+
+	* lra.c (expand_reg_data): Remove uses of macros: EXIT_BLOCK_PTR,
+	FOR_EACH_BB, last_basic_block, n_basic_blocks.
+
+	* lto-streamer-in.c (lto_tag_check_set): Remove uses of macros:
+	ENTRY_BLOCK_PTR, FOR_ALL_BB.
+
+	* lto-streamer-out.c (clear_line_info): Remove uses of macros:
+	ENTRY_BLOCK_PTR, FOR_ALL_BB.
+
+	* mcf.c (print_basic_block): Remove uses of macros: ENTRY_BLOCK_PTR,
+	EXIT_BLOCK_PTR, FOR_ALL_BB, FOR_EACH_BB, n_basic_blocks, n_edges.
+
+	* mode-switching.c (new_seginfo): Remove uses of macros:
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_EACH_BB, FOR_EACH_BB_REVERSE,
+	last_basic_block.
+
+	* modulo-sched.c (sms_print_insn): Remove uses of macros:
+	EXIT_BLOCK_PTR, FOR_EACH_BB.
+
+	* omp-low.c (scan_omp_op): Remove uses of macros: ENTRY_BLOCK_PTR,
+	FOR_EACH_BB.
+
+	* optabs.c (hash_libfunc): Remove usage of profile_status macro.
+
+	* postreload-gcse.c (hash_expr): Remove uses of macros:
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_EACH_BB.
+
+	* postreload.c (reload_cse_regs): Remove uses of macros: FOR_EACH_BB,
+	FOR_EACH_BB_REVERSE.
+
+	* predict.c (maybe_hot_frequency_p): Remove uses of macros:
+	BASIC_BLOCK, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_ALL_BB, FOR_EACH_BB,
+	profile_status.
+
+	* profile.c (instrument_edges): Remove uses of macros:
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_EACH_BB, n_basic_blocks,
+	profile_status.
+
+	* recog.c (init_recog_no_volatile): Remove uses of macros:
+	FOR_EACH_BB_REVERSE, last_basic_block.
+
+	* ree.c (combine_set_extension): Remove usage of FOR_EACH_BB macro.
+
+	* reg-stack.c (stack_regs_mentioned_p): Remove uses of macros:
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_EACH_BB, n_basic_blocks.
+
+	* regcprop.c (free_debug_insn_changes): Remove uses of macros:
+	FOR_EACH_BB, last_basic_block.
+
+	* reginfo.c (reg_set_to_hard_reg_set): Remove usage of FOR_EACH_BB
+	macro.
+
+	* regmove.c (regclass_compatible_p): Remove uses of macros:
+	FOR_EACH_BB, FOR_EACH_BB_REVERSE.
+
+	* regrename.c (regrename_chain_from_id): Remove uses of macros:
+	BASIC_BLOCK, FOR_EACH_BB, last_basic_block, n_basic_blocks.
+
+	* regs.h (REG_N_SETS): Remove usage of ENTRY_BLOCK_PTR macro.
+
+	* regstat.c (regstat_init_n_sets_and_refs): Remove uses of macros:
+	BASIC_BLOCK, FOR_EACH_BB.
+
+	* reload.c (small_register_class_p): Remove usage of ENTRY_BLOCK_PTR
+	macro.
+
+	* reload1.c (init_reload): Remove uses of macros: EXIT_BLOCK_PTR,
+	FOR_EACH_BB, last_basic_block, n_basic_blocks.
+
+	* reorg.c (skip_consecutive_labels): Remove usage of n_basic_blocks
+	macro.
+
+	* resource.c (update_live_status): Remove uses of macros: BASIC_BLOCK,
+	ENTRY_BLOCK_PTR, FOR_EACH_BB, last_basic_block.
+
+	* sched-deps.c (ds_to_dk): Remove usage of n_basic_blocks macro.
+
+	* sched-ebb.c (save_ebb_state): Remove uses of macros: BASIC_BLOCK,
+	EXIT_BLOCK_PTR, FOR_EACH_BB, n_basic_blocks.
+
+	* sched-int.h (sel_sched_p): Remove uses of macros: BASIC_BLOCK,
+	EXIT_BLOCK_PTR.
+
+	* sched-rgn.c (is_cfg_nonregular): Remove uses of macros: BASIC_BLOCK,
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_ALL_BB, FOR_EACH_BB,
+	last_basic_block, n_basic_blocks, n_edges.
+
+	* sched-vis.c (print_exp): Remove usage of BASIC_BLOCK macro.
+
+	* sel-sched-dump.c (switch_dump): Remove usage of FOR_EACH_BB macro.
+
+	* sel-sched-ir.c (ilist_copy): Remove uses of macros: BASIC_BLOCK,
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_EACH_BB, last_basic_block,
+	n_basic_blocks.
+
+	* sel-sched-ir.h (_list_alloc): Remove usage of EXIT_BLOCK_PTR macro.
+
+	* sel-sched.c (advance_one_cycle): Remove uses of macros: BASIC_BLOCK,
+	EXIT_BLOCK_PTR, SET_BASIC_BLOCK, n_basic_blocks.
+
+	* sese.c (debug_rename_elt): Remove usage of FOR_EACH_BB macro.
+
+	* stack-ptr-mod.c (notice_stack_pointer_modification_1): Remove usage
+	of FOR_EACH_BB macro.
+
+	* store-motion.c (st_expr_entry): Remove uses of macros:
+	EXIT_BLOCK_PTR, FOR_EACH_BB, last_basic_block, n_basic_blocks.
+
+	* tracer.c (mark_bb_seen): Remove uses of macros: FOR_EACH_BB,
+	last_basic_block, n_basic_blocks.
+
+	* trans-mem.c (get_attrs_for): Remove uses of macros: BASIC_BLOCK,
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_EACH_BB, last_basic_block.
+
+	* tree-call-cdce.c (get_domain): Remove usage of FOR_EACH_BB macro.
+
+	* tree-cfg.c (init_empty_tree_cfg_for_function): Remove uses of
+	macros: BASIC_BLOCK, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_ALL_BB,
+	FOR_EACH_BB, SET_BASIC_BLOCK, basic_block_info, label_to_block_map,
+	last_basic_block, n_basic_blocks, n_edges, profile_status.
+
+	* tree-cfgcleanup.c (remove_fallthru_edge): Remove uses of macros:
+	BASIC_BLOCK, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_EACH_BB,
+	last_basic_block, n_basic_blocks.
+
+	* tree-complex.c (cvc_lookup): Remove uses of macros: ENTRY_BLOCK_PTR,
+	FOR_EACH_BB, last_basic_block.
+
+	* tree-dfa.c (renumber_gimple_stmt_uids): Remove uses of macros:
+	FOR_ALL_BB, FOR_EACH_BB.
+
+	* tree-eh.c (using_eh_for_cleanups): Remove usage of FOR_EACH_BB
+	macro.
+
+	* tree-emutls.c (prefix_name): Remove usage of FOR_EACH_BB macro.
+
+	* tree-if-conv.c (bb_has_predicate): Remove uses of macros:
+	EXIT_BLOCK_PTR, FOR_EACH_BB.
+
+	* tree-inline.c (insert_decl_map): Remove uses of macros: BASIC_BLOCK,
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_EACH_BB, last_basic_block,
+	n_basic_blocks, profile_status.
+
+	* tree-into-ssa.c (mark_for_renaming): Remove uses of macros:
+	BASIC_BLOCK, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_EACH_BB,
+	last_basic_block.
+
+	* tree-loop-distribution.c (partition_alloc): Remove usage of
+	FOR_ALL_BB macro.
+
+	* tree-mudflap.c (mf_artificial): Remove uses of macros:
+	ENTRY_BLOCK_PTR, last_basic_block.
+
+	* tree-nrv.c (finalize_nrv_r): Remove usage of FOR_EACH_BB macro.
+
+	* tree-object-size.c (init_offset_limit): Remove usage of FOR_EACH_BB
+	macro.
+
+	* tree-optimize.c (execute_cleanup_cfg_post_optimizing): Remove uses
+	of macros: ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_EACH_BB.
+
+	* tree-outof-ssa.c (set_location_for_edge): Remove uses of macros:
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_EACH_BB.
+
+	* tree-profile.c (init_ic_make_global_vars): Remove uses of macros:
+	ENTRY_BLOCK_PTR, FOR_EACH_BB.
+
+	* tree-scalar-evolution.c (new_scev_info_str): Remove usage of
+	FOR_EACH_BB macro.
+
+	* tree-scalar-evolution.h (block_before_loop): Remove usage of
+	ENTRY_BLOCK_PTR macro.
+
+	* tree-sra.c (candidate): Remove uses of macros: ENTRY_BLOCK_PTR,
+	EXIT_BLOCK_PTR, FOR_EACH_BB.
+
+	* tree-ssa-ccp.c (dump_lattice_value): Remove uses of macros:
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_EACH_BB.
+
+	* tree-ssa-coalesce.c (coalesce_cost): Remove uses of macros:
+	EXIT_BLOCK_PTR, FOR_EACH_BB.
+
+	* tree-ssa-copy.c (may_propagate_copy): Remove usage of FOR_EACH_BB
+	macro.
+
+	* tree-ssa-copyrename.c (copy_rename_partition_coalesce): Remove usage
+	of FOR_EACH_BB macro.
+
+	* tree-ssa-dce.c (set_control_dependence_map_bit): Remove uses of
+	macros: ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_EACH_BB,
+	last_basic_block.
+
+	* tree-ssa-dom.c (initialize_hash_element): Remove uses of macros:
+	BASIC_BLOCK, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_EACH_BB,
+	last_basic_block.
+
+	* tree-ssa-dse.c (dse_possible_dead_store_p): Remove usage of
+	EXIT_BLOCK_PTR macro.
+
+	* tree-ssa-forwprop.c (get_prop_dest_stmt): Remove usage of
+	FOR_EACH_BB macro.
+
+	* tree-ssa-ifcombine.c (recognize_if_then_else): Remove usage of
+	n_basic_blocks macro.
+
+	* tree-ssa-live.c (var_map_base_init): Remove uses of macros:
+	BASIC_BLOCK, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_EACH_BB,
+	FOR_EACH_BB_REVERSE, last_basic_block.
+
+	* tree-ssa-live.h (num_var_partitions): Remove uses of macros:
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
+
+	* tree-ssa-loop-ch.c (should_duplicate_loop_header_p): Remove usage of
+	n_basic_blocks macro.
+
+	* tree-ssa-loop-im.c (init_lim_data): Remove uses of macros:
+	ENTRY_BLOCK_PTR, FOR_EACH_BB, last_basic_block, n_basic_blocks.
+
+	* tree-ssa-loop-ivopts.c (avg_loop_niter): Remove usage of
+	EXIT_BLOCK_PTR macro.
+
+	* tree-ssa-loop-manip.c (create_iv): Remove uses of macros:
+	BASIC_BLOCK, ENTRY_BLOCK_PTR, FOR_EACH_BB, last_basic_block,
+	n_basic_blocks.
+
+	* tree-ssa-loop-niter.c (split_to_var_and_offset): Remove usage of
+	ENTRY_BLOCK_PTR macro.
+
+	* tree-ssa-loop-prefetch.c (dump_mem_details): Remove usage of
+	EXIT_BLOCK_PTR macro.
+
+	* tree-ssa-loop-unswitch.c (tree_ssa_unswitch_loops): Remove usage of
+	ENTRY_BLOCK_PTR macro.
+
+	* tree-ssa-math-opts.c (occ_new): Remove uses of macros:
+	ENTRY_BLOCK_PTR, FOR_EACH_BB, n_basic_blocks.
+
+	* tree-ssa-phiopt.c (tree_ssa_phiopt): Remove uses of macros:
+	ENTRY_BLOCK_PTR, FOR_EACH_BB, last_basic_block, n_basic_blocks.
+
+	* tree-ssa-phiprop.c (phivn_valid_p): Remove usage of ENTRY_BLOCK_PTR
+	macro.
+
+	* tree-ssa-pre.c (alloc_expression_id): Remove uses of macros:
+	BASIC_BLOCK, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_ALL_BB,
+	last_basic_block, n_basic_blocks.
+
+	* tree-ssa-propagate.c (cfg_blocks_empty_p): Remove uses of macros:
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_ALL_BB, FOR_EACH_BB,
+	last_basic_block.
+
+	* tree-ssa-reassoc.c (phi_rank): Remove uses of macros: BASIC_BLOCK,
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, last_basic_block, n_basic_blocks.
+
+	* tree-ssa-sccvn.c (vn_phi_eq): Remove uses of macros:
+	last_basic_block, n_basic_blocks.
+
+	* tree-ssa-sink.c (find_bb_for_arg): Remove uses of macros:
+	BASIC_BLOCK, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
+
+	* tree-ssa-strlen.c (get_addr_stridx): Remove usage of ENTRY_BLOCK_PTR
+	macro.
+
+	* tree-ssa-structalias.c (get_varinfo): Remove usage of FOR_EACH_BB
+	macro.
+
+	* tree-ssa-tail-merge.c (stmt_local_def): Remove uses of macros:
+	BASIC_BLOCK, FOR_EACH_BB, last_basic_block, n_basic_blocks.
+
+	* tree-ssa-ter.c (new_temp_expr_table): Remove usage of FOR_EACH_BB
+	macro.
+
+	* tree-ssa-threadupdate.c (remove_ctrl_stmt_and_useless_edges): Remove
+	usage of BASIC_BLOCK macro.
+
+	* tree-ssa-uncprop.c (associate_equivalences_with_edges): Remove uses
+	of macros: BASIC_BLOCK, ENTRY_BLOCK_PTR, FOR_EACH_BB,
+	last_basic_block, n_basic_blocks.
+
+	* tree-ssa-uninit.c (get_mask_first_set_bit): Remove uses of macros:
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_EACH_BB.
+
+	* tree-ssa.c (redirect_edge_var_map_add): Remove uses of macros:
+	ENTRY_BLOCK_PTR, FOR_EACH_BB.
+
+	* tree-stdarg.c (reachable_at_most_once): Remove uses of macros:
+	ENTRY_BLOCK_PTR, FOR_EACH_BB, last_basic_block.
+
+	* tree-switch-conversion.c (hoist_edge_and_branch_if_true): Remove
+	usage of FOR_EACH_BB macro.
+
+	* tree-tailcall.c (suitable_for_tail_opt_p): Remove uses of macros:
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR.
+
+	* tree-vect-generic.c (build_replicated_const): Remove usage of
+	FOR_EACH_BB macro.
+
+	* tree-vectorizer.c (vectorize_loops): Remove usage of FOR_EACH_BB
+	macro.
+
+	* tree-vrp.c (live_on_edge): Remove uses of macros: BASIC_BLOCK,
+	FOR_EACH_BB, last_basic_block.
+
+	* tsan.c (get_memory_access_decl): Remove uses of macros:
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_EACH_BB.
+
+	* value-prof.c (gimple_alloc_histogram_value): Remove usage of
+	FOR_EACH_BB macro.
+
+	* var-tracking.c (dv_is_decl_p): Remove uses of macros:
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_ALL_BB, FOR_EACH_BB,
+	last_basic_block, n_basic_blocks, n_edges.
+
+	* varasm.c (section_entry_eq): Remove usage of ENTRY_BLOCK_PTR macro.
+
+	* web.c (unionfind_root): Remove usage of FOR_ALL_BB macro.
+
+	* config/bfin/bfin.c (bfin_globalize_label): Remove uses of macros:
+	ENTRY_BLOCK_PTR, FOR_EACH_BB.
+
+	* config/s390/s390.c (s390_label_align): Remove usage of FOR_EACH_BB
+	macro.
+
+	* config/tilepro/tilepro.c (tilepro_option_override): Remove usage of
+	FOR_EACH_BB macro.
+
+	* config/spu/spu.c (spu_init_machine_status): Remove uses of macros:
+	BASIC_BLOCK, FOR_EACH_BB, last_basic_block, n_basic_blocks.
+
+	* config/arm/arm.c (void): Remove uses of macros: ENTRY_BLOCK_PTR,
+	EXIT_BLOCK_PTR, FOR_EACH_BB.
+
+	* config/epiphany/resolve-sw-modes.c (gate_resolve_sw_modes): Remove
+	uses of macros: FOR_EACH_BB, last_basic_block.
+
+	* config/rs6000/rs6000.c (void): Remove uses of macros:
+	EXIT_BLOCK_PTR, FOR_EACH_BB.
+
+	* config/frv/frv.c (frv_function_ok_for_sibcall): Remove uses of
+	macros: EXIT_BLOCK_PTR, FOR_EACH_BB, last_basic_block.
+
+	* config/alpha/alpha.c (alpha_mangle_type): Remove usage of
+	ENTRY_BLOCK_PTR macro.
+
+	* config/i386/i386.c (gate_insert_vzeroupper): Remove uses of macros:
+	ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, FOR_EACH_BB.
+
+	* config/tilegx/tilegx.c (tilegx_option_override): Remove usage of
+	FOR_EACH_BB macro.
+
+	* config/ia64/ia64.c (init_idents): Remove uses of macros:
+	EXIT_BLOCK_PTR, FOR_EACH_BB, FOR_EACH_BB_REVERSE.
+
+	* config/sh/sh.c (selected_atomic_model): Remove usage of
+	FOR_EACH_BB_REVERSE macro.
+
+	* config/picochip/picochip.c (picochip_secondary_reload): Remove usage
+	of FOR_EACH_BB macro.
+
+	* config/mips/mips.c (mflip_mips16_htab_hash): Remove uses of macros:
+	BASIC_BLOCK, ENTRY_BLOCK_PTR, FOR_EACH_BB, last_basic_block.
+
+	* config/c6x/c6x.c (c6x_init_machine_status): Remove usage of
+	FOR_EACH_BB macro.
+
+2013-05-25  David Malcolm  <dmalcolm@redhat.com>
+
 	Eliminate all direct references to "cfun" from macros in
 	basic-block.h and introduce access methods to control_flow_graph
 
diff --git a/gcc/alias.c b/gcc/alias.c
index ef11c6a..6ebe6db 100644
--- a/gcc/alias.c
+++ b/gcc/alias.c
@@ -2846,7 +2846,7 @@ init_alias_analysis (void)
      The state of the arrays for the set chain in question does not matter
      since the program has undefined behavior.  */
 
-  rpo = XNEWVEC (int, n_basic_blocks);
+  rpo = XNEWVEC (int, cfun->cfg->get_n_basic_blocks ());
   rpo_cnt = pre_and_rev_post_order_compute (NULL, rpo, false);
 
   pass = 0;
@@ -2883,7 +2883,7 @@ init_alias_analysis (void)
       /* Walk the insns adding values to the new_reg_base_value array.  */
       for (i = 0; i < rpo_cnt; i++)
 	{
-	  basic_block bb = BASIC_BLOCK (rpo[i]);
+	  basic_block bb = cfun->cfg->get_basic_block_by_idx (rpo[i]);
 	  FOR_BB_INSNS (bb, insn)
 	    {
 	      if (NONDEBUG_INSN_P (insn))
diff --git a/gcc/asan.c b/gcc/asan.c
index c068b8c..9876612 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -1874,9 +1874,9 @@ transform_statements (void)
 {
   basic_block bb, last_bb = NULL;
   gimple_stmt_iterator i;
-  int saved_last_basic_block = last_basic_block;
+  int saved_last_basic_block = cfun->cfg->get_last_basic_block ();
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       basic_block prev_bb = bb;
 
diff --git a/gcc/auto-inc-dec.c b/gcc/auto-inc-dec.c
index 6119bb6..ca6019e 100644
--- a/gcc/auto-inc-dec.c
+++ b/gcc/auto-inc-dec.c
@@ -1480,7 +1480,7 @@ rest_of_handle_auto_inc_dec (void)
   reg_next_use = XCNEWVEC (rtx, max_reg);
   reg_next_inc_use = XCNEWVEC (rtx, max_reg);
   reg_next_def = XCNEWVEC (rtx, max_reg);
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     merge_in_block (max_reg, bb);
 
   free (reg_next_use);
diff --git a/gcc/bb-reorder.c b/gcc/bb-reorder.c
index 0a1f42a..4955898 100644
--- a/gcc/bb-reorder.c
+++ b/gcc/bb-reorder.c
@@ -274,7 +274,7 @@ find_traces (int *n_traces, struct trace *traces)
   heap = fibheap_new ();
   max_entry_frequency = 0;
   max_entry_count = 0;
-  FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR->succs)
+  FOR_EACH_EDGE (e, ei, cfun->cfg->get_entry_block ()->succs)
     {
       bbd[e->dest->index].heap = heap;
       bbd[e->dest->index].node = fibheap_insert (heap, bb_to_key (e->dest),
@@ -347,7 +347,7 @@ rotate_loop (edge back_edge, struct trace *trace, int trace_n)
       edge_iterator ei;
 
       FOR_EACH_EDGE (e, ei, bb->succs)
-	if (e->dest != EXIT_BLOCK_PTR
+	if (e->dest != cfun->cfg->get_exit_block ()
 	    && bb_visited_trace (e->dest) != trace_n
 	    && (e->flags & EDGE_CAN_FALLTHRU)
 	    && !(e->flags & EDGE_COMPLEX))
@@ -523,7 +523,7 @@ find_traces_1_round (int branch_th, int exec_th, gcov_type count_th,
 	    {
 	      gcc_assert (!(e->flags & EDGE_FAKE));
 
-	      if (e->dest == EXIT_BLOCK_PTR)
+	      if (e->dest == cfun->cfg->get_exit_block ())
 		continue;
 
 	      if (bb_visited_trace (e->dest)
@@ -604,7 +604,7 @@ find_traces_1_round (int branch_th, int exec_th, gcov_type count_th,
 	  FOR_EACH_EDGE (e, ei, bb->succs)
 	    {
 	      if (e == best_edge
-		  || e->dest == EXIT_BLOCK_PTR
+		  || e->dest == cfun->cfg->get_exit_block ()
 		  || bb_visited_trace (e->dest))
 		continue;
 
@@ -679,7 +679,7 @@ find_traces_1_round (int branch_th, int exec_th, gcov_type count_th,
 			     header is not the first block of the function
 			     we can rotate the loop.  */
 
-			  if (best_edge->dest != ENTRY_BLOCK_PTR->next_bb)
+			  if (best_edge->dest != cfun->cfg->get_entry_block ()->next_bb)
 			    {
 			      if (dump_file)
 				{
@@ -775,7 +775,7 @@ find_traces_1_round (int branch_th, int exec_th, gcov_type count_th,
 	 is an end of the trace).  */
       FOR_EACH_EDGE (e, ei, bb->succs)
 	{
-	  if (e->dest == EXIT_BLOCK_PTR
+	  if (e->dest == cfun->cfg->get_exit_block ()
 	      || bb_visited_trace (e->dest))
 	    continue;
 
@@ -824,12 +824,12 @@ copy_bb (basic_block old_bb, edge e, basic_block bb, int trace)
 	     "Duplicated bb %d (created bb %d)\n",
 	     old_bb->index, new_bb->index);
 
-  if (new_bb->index >= array_size || last_basic_block > array_size)
+  if (new_bb->index >= array_size || cfun->cfg->get_last_basic_block () > array_size)
     {
       int i;
       int new_size;
 
-      new_size = MAX (last_basic_block, new_bb->index + 1);
+      new_size = MAX (cfun->cfg->get_last_basic_block (), new_bb->index + 1);
       new_size = GET_ARRAY_SIZE (new_size);
       bbd = XRESIZEVEC (bbro_basic_block_data, bbd, new_size);
       for (i = array_size; i < new_size; i++)
@@ -884,7 +884,7 @@ bb_to_key (basic_block bb)
      or whose predecessor edge is EDGE_DFS_BACK.  */
   FOR_EACH_EDGE (e, ei, bb->preds)
     {
-      if ((e->src != ENTRY_BLOCK_PTR && bbd[e->src->index].end_of_trace >= 0)
+      if ((e->src != cfun->cfg->get_entry_block () && bbd[e->src->index].end_of_trace >= 0)
 	  || (e->flags & EDGE_DFS_BACK))
 	{
 	  int edge_freq = EDGE_FREQUENCY (e);
@@ -1097,7 +1097,7 @@ connect_traces (int n_traces, struct trace *traces)
 	    {
 	      int si = e->src->index;
 
-	      if (e->src != ENTRY_BLOCK_PTR
+	      if (e->src != cfun->cfg->get_entry_block ()
 		  && (e->flags & EDGE_CAN_FALLTHRU)
 		  && !(e->flags & EDGE_COMPLEX)
 		  && bbd[si].end_of_trace >= 0
@@ -1140,7 +1140,7 @@ connect_traces (int n_traces, struct trace *traces)
 	    {
 	      int di = e->dest->index;
 
-	      if (e->dest != EXIT_BLOCK_PTR
+	      if (e->dest != cfun->cfg->get_exit_block ()
 		  && (e->flags & EDGE_CAN_FALLTHRU)
 		  && !(e->flags & EDGE_COMPLEX)
 		  && bbd[di].start_of_trace >= 0
@@ -1211,7 +1211,7 @@ connect_traces (int n_traces, struct trace *traces)
 	      bool try_copy = false;
 
 	      FOR_EACH_EDGE (e, ei, traces[t].last->succs)
-		if (e->dest != EXIT_BLOCK_PTR
+		if (e->dest != cfun->cfg->get_exit_block ()
 		    && (e->flags & EDGE_CAN_FALLTHRU)
 		    && !(e->flags & EDGE_COMPLEX)
 		    && (!best || e->probability > best->probability))
@@ -1236,7 +1236,7 @@ connect_traces (int n_traces, struct trace *traces)
 		      {
 			int di = e2->dest->index;
 
-			if (e2->dest == EXIT_BLOCK_PTR
+			if (e2->dest == cfun->cfg->get_exit_block ()
 			    || ((e2->flags & EDGE_CAN_FALLTHRU)
 				&& !(e2->flags & EDGE_COMPLEX)
 				&& bbd[di].start_of_trace >= 0
@@ -1252,7 +1252,7 @@ connect_traces (int n_traces, struct trace *traces)
 			  {
 			    best = e;
 			    best2 = e2;
-			    if (e2->dest != EXIT_BLOCK_PTR)
+			    if (e2->dest != cfun->cfg->get_exit_block ())
 			      best2_len = traces[bbd[di].start_of_trace].length;
 			    else
 			      best2_len = INT_MAX;
@@ -1281,7 +1281,7 @@ connect_traces (int n_traces, struct trace *traces)
 			       traces[t].last->index, best->dest->index);
 		      if (!next_bb)
 			fputc ('\n', dump_file);
-		      else if (next_bb == EXIT_BLOCK_PTR)
+		      else if (next_bb == cfun->cfg->get_exit_block ())
 			fprintf (dump_file, "exit\n");
 		      else
 			fprintf (dump_file, "%d\n", next_bb->index);
@@ -1289,7 +1289,7 @@ connect_traces (int n_traces, struct trace *traces)
 
 		  new_bb = copy_bb (best->dest, best, traces[t].last, t);
 		  traces[t].last = new_bb;
-		  if (next_bb && next_bb != EXIT_BLOCK_PTR)
+		  if (next_bb && next_bb != cfun->cfg->get_exit_block ())
 		    {
 		      t = bbd[next_bb->index].start_of_trace;
 		      traces[last_trace].last->aux = traces[t].first;
@@ -1421,7 +1421,7 @@ fix_up_crossing_landing_pad (eh_landing_pad old_lp, basic_block old_bb)
   JUMP_LABEL (jump) = post_label;
 
   /* Create new basic block to be dest for lp.  */
-  last_bb = EXIT_BLOCK_PTR->prev_bb;
+  last_bb = cfun->cfg->get_exit_block ()->prev_bb;
   new_bb = create_basic_block (new_label, jump, last_bb);
   new_bb->aux = last_bb->aux;
   last_bb->aux = new_bb;
@@ -1466,7 +1466,7 @@ find_rarely_executed_basic_blocks_and_crossing_edges (void)
   edge_iterator ei;
 
   /* Mark which partition (hot/cold) each basic block belongs in.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       if (probably_never_executed_bb_p (cfun, bb))
 	BB_SET_PARTITION (bb, BB_COLD_PARTITION);
@@ -1517,7 +1517,7 @@ find_rarely_executed_basic_blocks_and_crossing_edges (void)
 
   /* Mark every edge that crosses between sections.  */
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     FOR_EACH_EDGE (e, ei, bb->succs)
       {
 	unsigned int flags = e->flags;
@@ -1525,8 +1525,8 @@ find_rarely_executed_basic_blocks_and_crossing_edges (void)
         /* We should never have EDGE_CROSSING set yet.  */
 	gcc_checking_assert ((flags & EDGE_CROSSING) == 0);
 
-	if (e->src != ENTRY_BLOCK_PTR
-	    && e->dest != EXIT_BLOCK_PTR
+	if (e->src != cfun->cfg->get_entry_block ()
+	    && e->dest != cfun->cfg->get_exit_block ()
 	    && BB_PARTITION (e->src) != BB_PARTITION (e->dest))
 	  {
 	    crossing_edges.safe_push (e);
@@ -1550,7 +1550,7 @@ set_edge_can_fallthru_flag (void)
 {
   basic_block bb;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       edge e;
       edge_iterator ei;
@@ -1593,14 +1593,14 @@ add_labels_and_missing_jumps (vec<edge> crossing_edges)
       basic_block dest = e->dest;
       rtx label, new_jump;
 
-      if (dest == EXIT_BLOCK_PTR)
+      if (dest == cfun->cfg->get_exit_block ())
 	continue;
 
       /* Make sure dest has a label.  */
       label = block_label (dest);
 
       /* Nothing to do for non-fallthru edges.  */
-      if (src == ENTRY_BLOCK_PTR)
+      if (src == cfun->cfg->get_entry_block ())
 	continue;
       if ((e->flags & EDGE_FALLTHRU) == 0)
 	continue;
@@ -1651,7 +1651,7 @@ fix_up_fall_thru_edges (void)
   rtx old_jump;
   rtx fall_thru_label;
 
-  FOR_EACH_BB (cur_bb)
+  FOR_EACH_BB_CFG (cur_bb, cfun->cfg)
     {
       fall_thru = NULL;
       if (EDGE_COUNT (cur_bb->succs) > 0)
@@ -1694,7 +1694,7 @@ fix_up_fall_thru_edges (void)
 	      }
 	}
 
-      if (fall_thru && (fall_thru->dest != EXIT_BLOCK_PTR))
+      if (fall_thru && (fall_thru->dest != cfun->cfg->get_exit_block ()))
 	{
 	  /* Check to see if the fall-thru edge is a crossing edge.  */
 
@@ -1852,7 +1852,7 @@ fix_crossing_conditional_branches (void)
   rtx old_label = NULL_RTX;
   rtx new_label;
 
-  FOR_EACH_BB (cur_bb)
+  FOR_EACH_BB_CFG (cur_bb, cfun->cfg)
     {
       crossing_edge = NULL;
       if (EDGE_COUNT (cur_bb->succs) > 0)
@@ -1929,7 +1929,7 @@ fix_crossing_conditional_branches (void)
 		  new_jump = emit_jump_insn (gen_jump (old_label));
 		  JUMP_LABEL (new_jump) = old_label;
 
-		  last_bb = EXIT_BLOCK_PTR->prev_bb;
+		  last_bb = cfun->cfg->get_exit_block ()->prev_bb;
 		  new_bb = create_basic_block (new_label, new_jump, last_bb);
 		  new_bb->aux = last_bb->aux;
 		  last_bb->aux = new_bb;
@@ -1983,7 +1983,7 @@ fix_crossing_unconditional_branches (void)
   rtx cur_insn;
   edge succ;
 
-  FOR_EACH_BB (cur_bb)
+  FOR_EACH_BB_CFG (cur_bb, cfun->cfg)
     {
       last_insn = BB_END (cur_bb);
 
@@ -2061,7 +2061,7 @@ add_reg_crossing_jump_notes (void)
   edge e;
   edge_iterator ei;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     FOR_EACH_EDGE (e, ei, bb->succs)
       if ((e->flags & EDGE_CROSSING)
 	  && JUMP_P (BB_END (e->src)))
@@ -2080,7 +2080,7 @@ reorder_basic_blocks (void)
 
   gcc_assert (current_ir_type () == IR_RTL_CFGLAYOUT);
 
-  if (n_basic_blocks <= NUM_FIXED_BLOCKS + 1)
+  if (cfun->cfg->get_n_basic_blocks () <= NUM_FIXED_BLOCKS + 1)
     return;
 
   set_edge_can_fallthru_flag ();
@@ -2092,7 +2092,7 @@ reorder_basic_blocks (void)
     uncond_jump_length = get_uncond_jump_length ();
 
   /* We need to know some information for each basic block.  */
-  array_size = GET_ARRAY_SIZE (last_basic_block);
+  array_size = GET_ARRAY_SIZE (cfun->cfg->get_last_basic_block ());
   bbd = XNEWVEC (bbro_basic_block_data, array_size);
   for (i = 0; i < array_size; i++)
     {
@@ -2104,7 +2104,7 @@ reorder_basic_blocks (void)
       bbd[i].node = NULL;
     }
 
-  traces = XNEWVEC (struct trace, n_basic_blocks);
+  traces = XNEWVEC (struct trace, cfun->cfg->get_n_basic_blocks ());
   n_traces = 0;
   find_traces (&n_traces, traces);
   connect_traces (n_traces, traces);
@@ -2142,7 +2142,7 @@ insert_section_boundary_note (void)
   if (!flag_reorder_blocks_and_partition)
     return;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       if (!first_partition)
 	first_partition = BB_PARTITION (bb);
@@ -2175,8 +2175,8 @@ rest_of_handle_reorder_blocks (void)
   reorder_basic_blocks ();
   cleanup_cfg (CLEANUP_EXPENSIVE);
 
-  FOR_EACH_BB (bb)
-    if (bb->next_bb != EXIT_BLOCK_PTR)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
+    if (bb->next_bb != cfun->cfg->get_exit_block ())
       bb->aux = bb->next_bb;
   cfg_layout_finalize ();
 
@@ -2229,7 +2229,7 @@ duplicate_computed_gotos (void)
   bitmap candidates;
   int max_size;
 
-  if (n_basic_blocks <= NUM_FIXED_BLOCKS + 1)
+  if (cfun->cfg->get_n_basic_blocks () <= NUM_FIXED_BLOCKS + 1)
     return 0;
 
   clear_bb_flags ();
@@ -2248,7 +2248,7 @@ duplicate_computed_gotos (void)
   /* Look for blocks that end in a computed jump, and see if such blocks
      are suitable for unfactoring.  If a block is a candidate for unfactoring,
      mark it in the candidates.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       rtx insn;
       edge e;
@@ -2256,7 +2256,7 @@ duplicate_computed_gotos (void)
       int size, all_flags;
 
       /* Build the reorder chain for the original order of blocks.  */
-      if (bb->next_bb != EXIT_BLOCK_PTR)
+      if (bb->next_bb != cfun->cfg->get_exit_block ())
 	bb->aux = bb->next_bb;
 
       /* Obviously the block has to end in a computed jump.  */
@@ -2295,7 +2295,7 @@ duplicate_computed_gotos (void)
     goto done;
 
   /* Duplicate computed gotos.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       if (bb->flags & BB_VISITED)
 	continue;
@@ -2306,7 +2306,7 @@ duplicate_computed_gotos (void)
 	 the exit block or the next block.
 	 The destination must have more than one predecessor.  */
       if (!single_succ_p (bb)
-	  || single_succ (bb) == EXIT_BLOCK_PTR
+	  || single_succ (bb) == cfun->cfg->get_exit_block ()
 	  || single_succ (bb) == bb->next_bb
 	  || single_pred_p (single_succ (bb)))
 	continue;
@@ -2458,7 +2458,7 @@ partition_hot_cold_basic_blocks (void)
 {
   vec<edge> crossing_edges;
 
-  if (n_basic_blocks <= NUM_FIXED_BLOCKS + 1)
+  if (cfun->cfg->get_n_basic_blocks () <= NUM_FIXED_BLOCKS + 1)
     return 0;
 
   df_set_flags (DF_DEFER_INSN_RESCAN);
diff --git a/gcc/bt-load.c b/gcc/bt-load.c
index 9ca1bd9..4e1486b 100644
--- a/gcc/bt-load.c
+++ b/gcc/bt-load.c
@@ -457,10 +457,10 @@ compute_defs_uses_and_gen (fibheap_t all_btr_defs, btr_def *def_array,
   btr_def_group all_btr_def_groups = NULL;
   defs_uses_info info;
 
-  bitmap_vector_clear (bb_gen, last_basic_block);
-  for (i = NUM_FIXED_BLOCKS; i < last_basic_block; i++)
+  bitmap_vector_clear (bb_gen, cfun->cfg->get_last_basic_block ());
+  for (i = NUM_FIXED_BLOCKS; i < cfun->cfg->get_last_basic_block (); i++)
     {
-      basic_block bb = BASIC_BLOCK (i);
+      basic_block bb = cfun->cfg->get_basic_block_by_idx (i);
       int reg;
       btr_def defs_this_bb = NULL;
       rtx insn;
@@ -618,8 +618,8 @@ compute_kill (sbitmap *bb_kill, sbitmap *btr_defset,
 
   /* For each basic block, form the set BB_KILL - the set
      of definitions that the block kills.  */
-  bitmap_vector_clear (bb_kill, last_basic_block);
-  for (i = NUM_FIXED_BLOCKS; i < last_basic_block; i++)
+  bitmap_vector_clear (bb_kill, cfun->cfg->get_last_basic_block ());
+  for (i = NUM_FIXED_BLOCKS; i < cfun->cfg->get_last_basic_block (); i++)
     {
       for (regno = first_btr; regno <= last_btr; regno++)
 	if (TEST_HARD_REG_BIT (all_btrs, regno)
@@ -642,16 +642,16 @@ compute_out (sbitmap *bb_out, sbitmap *bb_gen, sbitmap *bb_kill, int max_uid)
   int changed;
   sbitmap bb_in = sbitmap_alloc (max_uid);
 
-  for (i = NUM_FIXED_BLOCKS; i < last_basic_block; i++)
+  for (i = NUM_FIXED_BLOCKS; i < cfun->cfg->get_last_basic_block (); i++)
     bitmap_copy (bb_out[i], bb_gen[i]);
 
   changed = 1;
   while (changed)
     {
       changed = 0;
-      for (i = NUM_FIXED_BLOCKS; i < last_basic_block; i++)
+      for (i = NUM_FIXED_BLOCKS; i < cfun->cfg->get_last_basic_block (); i++)
 	{
-	  bitmap_union_of_preds (bb_in, bb_out, BASIC_BLOCK (i));
+	  bitmap_union_of_preds (bb_in, bb_out, cfun->cfg->get_basic_block_by_idx (i));
 	  changed |= bitmap_ior_and_compl (bb_out[i], bb_gen[i],
 					       bb_in, bb_kill[i]);
 	}
@@ -668,13 +668,13 @@ link_btr_uses (btr_def *def_array, btr_user *use_array, sbitmap *bb_out,
 
   /* Link uses to the uses lists of all of their reaching defs.
      Count up the number of reaching defs of each use.  */
-  for (i = NUM_FIXED_BLOCKS; i < last_basic_block; i++)
+  for (i = NUM_FIXED_BLOCKS; i < cfun->cfg->get_last_basic_block (); i++)
     {
-      basic_block bb = BASIC_BLOCK (i);
+      basic_block bb = cfun->cfg->get_basic_block_by_idx (i);
       rtx insn;
       rtx last;
 
-      bitmap_union_of_preds (reaching_defs, bb_out, BASIC_BLOCK (i));
+      bitmap_union_of_preds (reaching_defs, bb_out, cfun->cfg->get_basic_block_by_idx (i));
       for (insn = BB_HEAD (bb), last = NEXT_INSN (BB_END (bb));
 	   insn != last;
 	   insn = NEXT_INSN (insn))
@@ -780,8 +780,8 @@ build_btr_def_use_webs (fibheap_t all_btr_defs)
   btr_user *use_array   = XCNEWVEC (btr_user, max_uid);
   sbitmap *btr_defset   = sbitmap_vector_alloc (
 			   (last_btr - first_btr) + 1, max_uid);
-  sbitmap *bb_gen      = sbitmap_vector_alloc (last_basic_block, max_uid);
-  HARD_REG_SET *btrs_written = XCNEWVEC (HARD_REG_SET, last_basic_block);
+  sbitmap *bb_gen      = sbitmap_vector_alloc (cfun->cfg->get_last_basic_block (), max_uid);
+  HARD_REG_SET *btrs_written = XCNEWVEC (HARD_REG_SET, cfun->cfg->get_last_basic_block ());
   sbitmap *bb_kill;
   sbitmap *bb_out;
 
@@ -790,11 +790,11 @@ build_btr_def_use_webs (fibheap_t all_btr_defs)
   compute_defs_uses_and_gen (all_btr_defs, def_array, use_array, btr_defset,
 			     bb_gen, btrs_written);
 
-  bb_kill = sbitmap_vector_alloc (last_basic_block, max_uid);
+  bb_kill = sbitmap_vector_alloc (cfun->cfg->get_last_basic_block (), max_uid);
   compute_kill (bb_kill, btr_defset, btrs_written);
   free (btrs_written);
 
-  bb_out = sbitmap_vector_alloc (last_basic_block, max_uid);
+  bb_out = sbitmap_vector_alloc (cfun->cfg->get_last_basic_block (), max_uid);
   compute_out (bb_out, bb_gen, bb_kill, max_uid);
 
   sbitmap_vector_free (bb_gen);
@@ -814,13 +814,13 @@ build_btr_def_use_webs (fibheap_t all_btr_defs)
 static int
 block_at_edge_of_live_range_p (int bb, btr_def def)
 {
-  if (def->other_btr_uses_before_def && BASIC_BLOCK (bb) == def->bb)
+  if (def->other_btr_uses_before_def && cfun->cfg->get_basic_block_by_idx (bb) == def->bb)
     return 1;
   else if (def->other_btr_uses_after_use)
     {
       btr_user user;
       for (user = def->uses; user != NULL; user = user->next)
-	if (BASIC_BLOCK (bb) == user->bb)
+	if (cfun->cfg->get_basic_block_by_idx (bb) == user->bb)
 	  return 1;
     }
   return 0;
@@ -900,7 +900,7 @@ augment_live_range (bitmap live_range, HARD_REG_SET *btrs_live_in_range,
 {
   basic_block *worklist, *tos;
 
-  tos = worklist = XNEWVEC (basic_block, n_basic_blocks + 1);
+  tos = worklist = XNEWVEC (basic_block, cfun->cfg->get_n_basic_blocks () + 1);
 
   if (dominated_by_p (CDI_DOMINATORS, new_bb, head_bb))
     {
@@ -1328,7 +1328,7 @@ migrate_btr_def (btr_def def, int min_cost)
   def_basic_block_freq = basic_block_freq (def->bb);
 
   for (attempt = get_immediate_dominator (CDI_DOMINATORS, def->bb);
-       !give_up && attempt && attempt != ENTRY_BLOCK_PTR && def->cost >= min_cost;
+       !give_up && attempt && attempt != cfun->cfg->get_entry_block () && def->cost >= min_cost;
        attempt = get_immediate_dominator (CDI_DOMINATORS, attempt))
     {
       /* Try to move the instruction that sets the target register into
@@ -1403,9 +1403,9 @@ migrate_btr_defs (enum reg_class btr_class, int allow_callee_save)
     {
       int i;
 
-      for (i = NUM_FIXED_BLOCKS; i < last_basic_block; i++)
+      for (i = NUM_FIXED_BLOCKS; i < cfun->cfg->get_last_basic_block (); i++)
 	{
-	  basic_block bb = BASIC_BLOCK (i);
+	  basic_block bb = cfun->cfg->get_basic_block_by_idx (i);
 	  fprintf(dump_file,
 	    "Basic block %d: count = " HOST_WIDEST_INT_PRINT_DEC
 	    " loop-depth = %d idom = %d\n",
@@ -1426,8 +1426,8 @@ migrate_btr_defs (enum reg_class btr_class, int allow_callee_save)
 	  first_btr = reg;
       }
 
-  btrs_live = XCNEWVEC (HARD_REG_SET, last_basic_block);
-  btrs_live_at_end = XCNEWVEC (HARD_REG_SET, last_basic_block);
+  btrs_live = XCNEWVEC (HARD_REG_SET, cfun->cfg->get_last_basic_block ());
+  btrs_live_at_end = XCNEWVEC (HARD_REG_SET, cfun->cfg->get_last_basic_block ());
 
   build_btr_def_use_webs (all_btr_defs);
 
diff --git a/gcc/caller-save.c b/gcc/caller-save.c
index 5e65294..eff5b68 100644
--- a/gcc/caller-save.c
+++ b/gcc/caller-save.c
@@ -1414,8 +1414,8 @@ insert_one_insn (struct insn_chain *chain, int before_p, int code, rtx pat)
 		     &new_chain->live_throughout);
 
       CLEAR_REG_SET (&new_chain->dead_or_set);
-      if (chain->insn == BB_HEAD (BASIC_BLOCK (chain->block)))
-	BB_HEAD (BASIC_BLOCK (chain->block)) = new_chain->insn;
+      if (chain->insn == BB_HEAD (cfun->cfg->get_basic_block_by_idx (chain->block)))
+	BB_HEAD (cfun->cfg->get_basic_block_by_idx (chain->block)) = new_chain->insn;
     }
   else
     {
@@ -1434,8 +1434,8 @@ insert_one_insn (struct insn_chain *chain, int before_p, int code, rtx pat)
       note_stores (PATTERN (chain->insn), add_stored_regs,
 		   &new_chain->live_throughout);
       CLEAR_REG_SET (&new_chain->dead_or_set);
-      if (chain->insn == BB_END (BASIC_BLOCK (chain->block)))
-	BB_END (BASIC_BLOCK (chain->block)) = new_chain->insn;
+      if (chain->insn == BB_END (cfun->cfg->get_basic_block_by_idx (chain->block)))
+	BB_END (cfun->cfg->get_basic_block_by_idx (chain->block)) = new_chain->insn;
     }
   new_chain->block = chain->block;
   new_chain->is_caller_save_insn = 1;
diff --git a/gcc/cfg.c b/gcc/cfg.c
index 9c6c939..d657d84 100644
--- a/gcc/cfg.c
+++ b/gcc/cfg.c
@@ -88,7 +88,7 @@ init_flow (struct function *the_fun)
 static void
 free_edge (edge e)
 {
-  n_edges--;
+  cfun->cfg->get_n_edges ()--;
   ggc_free (e);
 }
 
@@ -101,7 +101,7 @@ clear_edges (void)
   edge e;
   edge_iterator ei;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       FOR_EACH_EDGE (e, ei, bb->succs)
 	free_edge (e);
@@ -109,12 +109,12 @@ clear_edges (void)
       vec_safe_truncate (bb->preds, 0);
     }
 
-  FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR->succs)
+  FOR_EACH_EDGE (e, ei, cfun->cfg->get_entry_block ()->succs)
     free_edge (e);
-  vec_safe_truncate (EXIT_BLOCK_PTR->preds, 0);
-  vec_safe_truncate (ENTRY_BLOCK_PTR->succs, 0);
+  vec_safe_truncate (cfun->cfg->get_exit_block ()->preds, 0);
+  vec_safe_truncate (cfun->cfg->get_entry_block ()->succs, 0);
 
-  gcc_assert (!n_edges);
+  gcc_assert (!cfun->cfg->get_n_edges ());
 }
 
 /* Allocate memory for basic_block.  */
@@ -153,8 +153,8 @@ compact_blocks (void)
 {
   int i;
 
-  SET_BASIC_BLOCK (ENTRY_BLOCK, ENTRY_BLOCK_PTR);
-  SET_BASIC_BLOCK (EXIT_BLOCK, EXIT_BLOCK_PTR);
+  cfun->cfg->set_basic_block_by_idx (ENTRY_BLOCK, cfun->cfg->get_entry_block ());
+  cfun->cfg->set_basic_block_by_idx (EXIT_BLOCK, cfun->cfg->get_exit_block ());
 
   if (df)
     df_compact_blocks ();
@@ -163,18 +163,18 @@ compact_blocks (void)
       basic_block bb;
 
       i = NUM_FIXED_BLOCKS;
-      FOR_EACH_BB (bb)
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
 	{
-	  SET_BASIC_BLOCK (i, bb);
+	  cfun->cfg->set_basic_block_by_idx (i, bb);
 	  bb->index = i;
 	  i++;
 	}
-      gcc_assert (i == n_basic_blocks);
+      gcc_assert (i == cfun->cfg->get_n_basic_blocks ());
 
-      for (; i < last_basic_block; i++)
-	SET_BASIC_BLOCK (i, NULL);
+      for (; i < cfun->cfg->get_last_basic_block (); i++)
+	cfun->cfg->set_basic_block_by_idx (i, NULL);
     }
-  last_basic_block = n_basic_blocks;
+  cfun->cfg->get_last_basic_block () = cfun->cfg->get_n_basic_blocks ();
 }
 
 /* Remove block B from the basic block array.  */
@@ -183,8 +183,8 @@ void
 expunge_block (basic_block b)
 {
   unlink_block (b);
-  SET_BASIC_BLOCK (b->index, NULL);
-  n_basic_blocks--;
+  cfun->cfg->set_basic_block_by_idx (b->index, NULL);
+  cfun->cfg->get_n_basic_blocks ()--;
   /* We should be able to ggc_free here, but we are not.
      The dead SSA_NAMES are left pointing to dead statements that are pointing
      to dead basic blocks making garbage collector to die.
@@ -262,7 +262,7 @@ unchecked_make_edge (basic_block src, basic_block dst, int flags)
 {
   edge e;
   e = ggc_alloc_cleared_edge_def ();
-  n_edges++;
+  cfun->cfg->get_n_edges ()++;
 
   e->src = src;
   e->dest = dst;
@@ -282,8 +282,8 @@ edge
 cached_make_edge (sbitmap edge_cache, basic_block src, basic_block dst, int flags)
 {
   if (edge_cache == NULL
-      || src == ENTRY_BLOCK_PTR
-      || dst == EXIT_BLOCK_PTR)
+      || src == cfun->cfg->get_entry_block ()
+      || dst == cfun->cfg->get_exit_block ())
     return make_edge (src, dst, flags);
 
   /* Does the requested edge already exist?  */
@@ -387,7 +387,7 @@ clear_bb_flags (void)
 {
   basic_block bb;
 
-  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
+  FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block (), NULL, next_bb)
     bb->flags &= BB_FLAGS_TO_PRESERVE;
 }
 
@@ -563,7 +563,7 @@ alloc_aux_for_blocks (int size)
     {
       basic_block bb;
 
-      FOR_ALL_BB (bb)
+      FOR_ALL_BB_CFG (bb, cfun->cfg)
 	alloc_aux_for_block (bb, size);
     }
 }
@@ -575,7 +575,7 @@ clear_aux_for_blocks (void)
 {
   basic_block bb;
 
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     bb->aux = NULL;
 }
 
@@ -626,7 +626,7 @@ alloc_aux_for_edges (int size)
     {
       basic_block bb;
 
-      FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
+      FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block (), cfun->cfg->get_exit_block (), next_bb)
 	{
 	  edge e;
 	  edge_iterator ei;
@@ -645,7 +645,7 @@ clear_aux_for_edges (void)
   basic_block bb;
   edge e;
 
-  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
+  FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block (), cfun->cfg->get_exit_block (), next_bb)
     {
       edge_iterator ei;
       FOR_EACH_EDGE (e, ei, bb->succs)
@@ -675,7 +675,7 @@ debug_bb (basic_block bb)
 DEBUG_FUNCTION basic_block
 debug_bb_n (int n)
 {
-  basic_block bb = BASIC_BLOCK (n);
+  basic_block bb = cfun->cfg->get_basic_block_by_idx (n);
   debug_bb (bb);
   return bb;
 }
@@ -813,7 +813,7 @@ brief_dump_cfg (FILE *file, int flags)
 {
   basic_block bb;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       dump_bb_info (file, bb, 0,
 		    flags & (TDF_COMMENT | TDF_DETAILS),
@@ -1124,7 +1124,7 @@ get_bb_original (basic_block bb)
   key.index1 = bb->index;
   entry = bb_original.find (&key);
   if (entry)
-    return BASIC_BLOCK (entry->index2);
+    return cfun->cfg->get_basic_block_by_idx (entry->index2);
   else
     return NULL;
 }
@@ -1149,7 +1149,7 @@ get_bb_copy (basic_block bb)
   key.index1 = bb->index;
   entry = bb_copy.find (&key);
   if (entry)
-    return BASIC_BLOCK (entry->index2);
+    return cfun->cfg->get_basic_block_by_idx (entry->index2);
   else
     return NULL;
 }
diff --git a/gcc/cfganal.c b/gcc/cfganal.c
index 63d17ce..af7ecfd 100644
--- a/gcc/cfganal.c
+++ b/gcc/cfganal.c
@@ -72,21 +72,21 @@ mark_dfs_back_edges (void)
   bool found = false;
 
   /* Allocate the preorder and postorder number arrays.  */
-  pre = XCNEWVEC (int, last_basic_block);
-  post = XCNEWVEC (int, last_basic_block);
+  pre = XCNEWVEC (int, cfun->cfg->get_last_basic_block ());
+  post = XCNEWVEC (int, cfun->cfg->get_last_basic_block ());
 
   /* Allocate stack for back-tracking up CFG.  */
-  stack = XNEWVEC (edge_iterator, n_basic_blocks + 1);
+  stack = XNEWVEC (edge_iterator, cfun->cfg->get_n_basic_blocks () + 1);
   sp = 0;
 
   /* Allocate bitmap to track nodes that have been visited.  */
-  visited = sbitmap_alloc (last_basic_block);
+  visited = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
 
   /* None of the nodes in the CFG have been visited yet.  */
   bitmap_clear (visited);
 
   /* Push the first edge on to the stack.  */
-  stack[sp++] = ei_start (ENTRY_BLOCK_PTR->succs);
+  stack[sp++] = ei_start (cfun->cfg->get_entry_block ()->succs);
 
   while (sp)
     {
@@ -101,7 +101,7 @@ mark_dfs_back_edges (void)
       ei_edge (ei)->flags &= ~EDGE_DFS_BACK;
 
       /* Check if the edge destination has been visited yet.  */
-      if (dest != EXIT_BLOCK_PTR && ! bitmap_bit_p (visited, dest->index))
+      if (dest != cfun->cfg->get_exit_block () && ! bitmap_bit_p (visited, dest->index))
 	{
 	  /* Mark that we have visited the destination.  */
 	  bitmap_set_bit (visited, dest->index);
@@ -118,12 +118,12 @@ mark_dfs_back_edges (void)
 	}
       else
 	{
-	  if (dest != EXIT_BLOCK_PTR && src != ENTRY_BLOCK_PTR
+	  if (dest != cfun->cfg->get_exit_block () && src != cfun->cfg->get_entry_block ()
 	      && pre[src->index] >= pre[dest->index]
 	      && post[dest->index] == 0)
 	    ei_edge (ei)->flags |= EDGE_DFS_BACK, found = true;
 
-	  if (ei_one_before_end_p (ei) && src != ENTRY_BLOCK_PTR)
+	  if (ei_one_before_end_p (ei) && src != cfun->cfg->get_entry_block ())
 	    post[src->index] = postnum++;
 
 	  if (!ei_one_before_end_p (ei))
@@ -152,18 +152,18 @@ find_unreachable_blocks (void)
   edge_iterator ei;
   basic_block *tos, *worklist, bb;
 
-  tos = worklist = XNEWVEC (basic_block, n_basic_blocks);
+  tos = worklist = XNEWVEC (basic_block, cfun->cfg->get_n_basic_blocks ());
 
   /* Clear all the reachability flags.  */
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     bb->flags &= ~BB_REACHABLE;
 
   /* Add our starting points to the worklist.  Almost always there will
      be only one.  It isn't inconceivable that we might one day directly
      support Fortran alternate entry points.  */
 
-  FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR->succs)
+  FOR_EACH_EDGE (e, ei, cfun->cfg->get_entry_block ()->succs)
     {
       *tos++ = e->dest;
 
@@ -217,7 +217,7 @@ create_edge_list (void)
   /* Determine the number of edges in the flow graph by counting successor
      edges on each basic block.  */
   num_edges = 0;
-  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
+  FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block (), cfun->cfg->get_exit_block (), next_bb)
     {
       num_edges += EDGE_COUNT (bb->succs);
     }
@@ -229,7 +229,7 @@ create_edge_list (void)
   num_edges = 0;
 
   /* Follow successors of blocks, and register these edges.  */
-  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
+  FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block (), cfun->cfg->get_exit_block (), next_bb)
     FOR_EACH_EDGE (e, ei, bb->succs)
       elist->index_to_edge[num_edges++] = e;
 
@@ -256,17 +256,17 @@ print_edge_list (FILE *f, struct edge_list *elist)
   int x;
 
   fprintf (f, "Compressed edge list, %d BBs + entry & exit, and %d edges\n",
-	   n_basic_blocks, elist->num_edges);
+	   cfun->cfg->get_n_basic_blocks (), elist->num_edges);
 
   for (x = 0; x < elist->num_edges; x++)
     {
       fprintf (f, " %-4d - edge(", x);
-      if (INDEX_EDGE_PRED_BB (elist, x) == ENTRY_BLOCK_PTR)
+      if (INDEX_EDGE_PRED_BB (elist, x) == cfun->cfg->get_entry_block ())
 	fprintf (f, "entry,");
       else
 	fprintf (f, "%d,", INDEX_EDGE_PRED_BB (elist, x)->index);
 
-      if (INDEX_EDGE_SUCC_BB (elist, x) == EXIT_BLOCK_PTR)
+      if (INDEX_EDGE_SUCC_BB (elist, x) == cfun->cfg->get_exit_block ())
 	fprintf (f, "exit)\n");
       else
 	fprintf (f, "%d)\n", INDEX_EDGE_SUCC_BB (elist, x)->index);
@@ -285,7 +285,7 @@ verify_edge_list (FILE *f, struct edge_list *elist)
   basic_block bb, p, s;
   edge_iterator ei;
 
-  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
+  FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block (), cfun->cfg->get_exit_block (), next_bb)
     {
       FOR_EACH_EDGE (e, ei, bb->succs)
 	{
@@ -310,8 +310,8 @@ verify_edge_list (FILE *f, struct edge_list *elist)
   /* We've verified that all the edges are in the list, now lets make sure
      there are no spurious edges in the list.  This is an expensive check!  */
 
-  FOR_BB_BETWEEN (p, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
-    FOR_BB_BETWEEN (s, ENTRY_BLOCK_PTR->next_bb, NULL, next_bb)
+  FOR_BB_BETWEEN (p, cfun->cfg->get_entry_block (), cfun->cfg->get_exit_block (), next_bb)
+    FOR_BB_BETWEEN (s, cfun->cfg->get_entry_block ()->next_bb, NULL, next_bb)
       {
 	int found_edge = 0;
 
@@ -409,7 +409,7 @@ remove_fake_edges (void)
 {
   basic_block bb;
 
-  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR->next_bb, NULL, next_bb)
+  FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block ()->next_bb, NULL, next_bb)
     remove_fake_predecessors (bb);
 }
 
@@ -418,7 +418,7 @@ remove_fake_edges (void)
 void
 remove_fake_exit_edges (void)
 {
-  remove_fake_predecessors (EXIT_BLOCK_PTR);
+  remove_fake_predecessors (cfun->cfg->get_exit_block ());
 }
 
 
@@ -431,9 +431,9 @@ add_noreturn_fake_exit_edges (void)
 {
   basic_block bb;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     if (EDGE_COUNT (bb->succs) == 0)
-      make_single_succ_edge (bb, EXIT_BLOCK_PTR, EDGE_FAKE);
+      make_single_succ_edge (bb, cfun->cfg->get_exit_block (), EDGE_FAKE);
 }
 
 /* This function adds a fake edge between any infinite loops to the
@@ -450,14 +450,14 @@ add_noreturn_fake_exit_edges (void)
 void
 connect_infinite_loops_to_exit (void)
 {
-  basic_block unvisited_block = EXIT_BLOCK_PTR;
+  basic_block unvisited_block = cfun->cfg->get_exit_block ();
   basic_block deadend_block;
   struct depth_first_search_dsS dfs_ds;
 
   /* Perform depth-first search in the reverse graph to find nodes
      reachable from the exit block.  */
   flow_dfs_compute_reverse_init (&dfs_ds);
-  flow_dfs_compute_reverse_add_bb (&dfs_ds, EXIT_BLOCK_PTR);
+  flow_dfs_compute_reverse_add_bb (&dfs_ds, cfun->cfg->get_exit_block ());
 
   /* Repeatedly add fake edges, updating the unreachable nodes.  */
   while (1)
@@ -468,7 +468,7 @@ connect_infinite_loops_to_exit (void)
 	break;
 
       deadend_block = dfs_find_deadend (unvisited_block);
-      make_edge (deadend_block, EXIT_BLOCK_PTR, EDGE_FAKE);
+      make_edge (deadend_block, cfun->cfg->get_exit_block (), EDGE_FAKE);
       flow_dfs_compute_reverse_add_bb (&dfs_ds, deadend_block);
     }
 
@@ -495,17 +495,17 @@ post_order_compute (int *post_order, bool include_entry_exit,
     post_order[post_order_num++] = EXIT_BLOCK;
 
   /* Allocate stack for back-tracking up CFG.  */
-  stack = XNEWVEC (edge_iterator, n_basic_blocks + 1);
+  stack = XNEWVEC (edge_iterator, cfun->cfg->get_n_basic_blocks () + 1);
   sp = 0;
 
   /* Allocate bitmap to track nodes that have been visited.  */
-  visited = sbitmap_alloc (last_basic_block);
+  visited = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
 
   /* None of the nodes in the CFG have been visited yet.  */
   bitmap_clear (visited);
 
   /* Push the first edge on to the stack.  */
-  stack[sp++] = ei_start (ENTRY_BLOCK_PTR->succs);
+  stack[sp++] = ei_start (cfun->cfg->get_entry_block ()->succs);
 
   while (sp)
     {
@@ -519,7 +519,7 @@ post_order_compute (int *post_order, bool include_entry_exit,
       dest = ei_edge (ei)->dest;
 
       /* Check if the edge destination has been visited yet.  */
-      if (dest != EXIT_BLOCK_PTR && ! bitmap_bit_p (visited, dest->index))
+      if (dest != cfun->cfg->get_exit_block () && ! bitmap_bit_p (visited, dest->index))
 	{
 	  /* Mark that we have visited the destination.  */
 	  bitmap_set_bit (visited, dest->index);
@@ -533,7 +533,7 @@ post_order_compute (int *post_order, bool include_entry_exit,
 	}
       else
 	{
-	  if (ei_one_before_end_p (ei) && src != ENTRY_BLOCK_PTR)
+	  if (ei_one_before_end_p (ei) && src != cfun->cfg->get_entry_block ())
 	    post_order[post_order_num++] = src->index;
 
 	  if (!ei_one_before_end_p (ei))
@@ -553,11 +553,11 @@ post_order_compute (int *post_order, bool include_entry_exit,
 
   /* Delete the unreachable blocks if some were found and we are
      supposed to do it.  */
-  if (delete_unreachable && (count != n_basic_blocks))
+  if (delete_unreachable && (count != cfun->cfg->get_n_basic_blocks ()))
     {
       basic_block b;
       basic_block next_bb;
-      for (b = ENTRY_BLOCK_PTR->next_bb; b != EXIT_BLOCK_PTR; b = next_bb)
+      for (b = cfun->cfg->get_entry_block ()->next_bb; b != cfun->cfg->get_exit_block (); b = next_bb)
 	{
 	  next_bb = b->next_bb;
 
@@ -648,17 +648,17 @@ inverted_post_order_compute (int *post_order)
   sbitmap visited;
 
   /* Allocate stack for back-tracking up CFG.  */
-  stack = XNEWVEC (edge_iterator, n_basic_blocks + 1);
+  stack = XNEWVEC (edge_iterator, cfun->cfg->get_n_basic_blocks () + 1);
   sp = 0;
 
   /* Allocate bitmap to track nodes that have been visited.  */
-  visited = sbitmap_alloc (last_basic_block);
+  visited = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
 
   /* None of the nodes in the CFG have been visited yet.  */
   bitmap_clear (visited);
 
   /* Put all blocks that have no successor into the initial work list.  */
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     if (EDGE_COUNT (bb->succs) == 0)
       {
         /* Push the initial edge on to the stack.  */
@@ -699,7 +699,7 @@ inverted_post_order_compute (int *post_order)
             }
           else
             {
-              if (bb != EXIT_BLOCK_PTR && ei_one_before_end_p (ei))
+              if (bb != cfun->cfg->get_exit_block () && ei_one_before_end_p (ei))
                 post_order[post_order_num++] = bb->index;
 
               if (!ei_one_before_end_p (ei))
@@ -712,7 +712,7 @@ inverted_post_order_compute (int *post_order)
       /* Detect any infinite loop and activate the kludge.
          Note that this doesn't check EXIT_BLOCK itself
          since EXIT_BLOCK is always added after the outer do-while loop.  */
-      FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
+      FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block (), cfun->cfg->get_exit_block (), next_bb)
         if (!bitmap_bit_p (visited, bb->index))
           {
             has_unvisited_bb = true;
@@ -745,7 +745,7 @@ inverted_post_order_compute (int *post_order)
         {
           /* No blocks are reachable from EXIT at all.
              Find a dead-end from the ENTRY, and restart the iteration. */
-          basic_block be = dfs_find_deadend (ENTRY_BLOCK_PTR);
+          basic_block be = dfs_find_deadend (cfun->cfg->get_entry_block ());
           gcc_assert (be != NULL);
           bitmap_set_bit (visited, be->index);
           stack[sp++] = ei_start (be->preds);
@@ -782,11 +782,11 @@ pre_and_rev_post_order_compute (int *pre_order, int *rev_post_order,
   edge_iterator *stack;
   int sp;
   int pre_order_num = 0;
-  int rev_post_order_num = n_basic_blocks - 1;
+  int rev_post_order_num = cfun->cfg->get_n_basic_blocks () - 1;
   sbitmap visited;
 
   /* Allocate stack for back-tracking up CFG.  */
-  stack = XNEWVEC (edge_iterator, n_basic_blocks + 1);
+  stack = XNEWVEC (edge_iterator, cfun->cfg->get_n_basic_blocks () + 1);
   sp = 0;
 
   if (include_entry_exit)
@@ -801,13 +801,13 @@ pre_and_rev_post_order_compute (int *pre_order, int *rev_post_order,
     rev_post_order_num -= NUM_FIXED_BLOCKS;
 
   /* Allocate bitmap to track nodes that have been visited.  */
-  visited = sbitmap_alloc (last_basic_block);
+  visited = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
 
   /* None of the nodes in the CFG have been visited yet.  */
   bitmap_clear (visited);
 
   /* Push the first edge on to the stack.  */
-  stack[sp++] = ei_start (ENTRY_BLOCK_PTR->succs);
+  stack[sp++] = ei_start (cfun->cfg->get_entry_block ()->succs);
 
   while (sp)
     {
@@ -821,7 +821,7 @@ pre_and_rev_post_order_compute (int *pre_order, int *rev_post_order,
       dest = ei_edge (ei)->dest;
 
       /* Check if the edge destination has been visited yet.  */
-      if (dest != EXIT_BLOCK_PTR && ! bitmap_bit_p (visited, dest->index))
+      if (dest != cfun->cfg->get_exit_block () && ! bitmap_bit_p (visited, dest->index))
 	{
 	  /* Mark that we have visited the destination.  */
 	  bitmap_set_bit (visited, dest->index);
@@ -842,7 +842,7 @@ pre_and_rev_post_order_compute (int *pre_order, int *rev_post_order,
 	}
       else
 	{
-	  if (ei_one_before_end_p (ei) && src != ENTRY_BLOCK_PTR
+	  if (ei_one_before_end_p (ei) && src != cfun->cfg->get_entry_block ()
 	      && rev_post_order)
 	    /* There are no more successors for the SRC node
 	       so assign its reverse completion number.  */
@@ -866,12 +866,12 @@ pre_and_rev_post_order_compute (int *pre_order, int *rev_post_order,
       if (rev_post_order)
 	rev_post_order[rev_post_order_num--] = EXIT_BLOCK;
       /* The number of nodes visited should be the number of blocks.  */
-      gcc_assert (pre_order_num == n_basic_blocks);
+      gcc_assert (pre_order_num == cfun->cfg->get_n_basic_blocks ());
     }
   else
     /* The number of nodes visited should be the number of blocks minus
        the entry and exit blocks which are not visited here.  */
-    gcc_assert (pre_order_num == n_basic_blocks - NUM_FIXED_BLOCKS);
+    gcc_assert (pre_order_num == cfun->cfg->get_n_basic_blocks () - NUM_FIXED_BLOCKS);
 
   return pre_order_num;
 }
@@ -910,11 +910,11 @@ static void
 flow_dfs_compute_reverse_init (depth_first_search_ds data)
 {
   /* Allocate stack for back-tracking up CFG.  */
-  data->stack = XNEWVEC (basic_block, n_basic_blocks);
+  data->stack = XNEWVEC (basic_block, cfun->cfg->get_n_basic_blocks ());
   data->sp = 0;
 
   /* Allocate bitmap to track nodes that have been visited.  */
-  data->visited_blocks = sbitmap_alloc (last_basic_block);
+  data->visited_blocks = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
 
   /* None of the nodes in the CFG have been visited yet.  */
   bitmap_clear (data->visited_blocks);
@@ -999,7 +999,7 @@ dfs_enumerate_from (basic_block bb, int reverse,
 #define VISITED_P(BB) (bitmap_bit_p (visited, (BB)->index))
 
   /* Resize the VISITED sbitmap if necessary.  */
-  size = last_basic_block;
+  size = cfun->cfg->get_last_basic_block ();
   if (size < 10)
     size = 10;
 
@@ -1088,7 +1088,7 @@ compute_dominance_frontiers_1 (bitmap_head *frontiers)
   edge p;
   edge_iterator ei;
   basic_block b;
-  FOR_EACH_BB (b)
+  FOR_EACH_BB_CFG (b, cfun->cfg)
     {
       if (EDGE_COUNT (b->preds) >= 2)
 	{
@@ -1096,7 +1096,7 @@ compute_dominance_frontiers_1 (bitmap_head *frontiers)
 	    {
 	      basic_block runner = p->src;
 	      basic_block domsb;
-	      if (runner == ENTRY_BLOCK_PTR)
+	      if (runner == cfun->cfg->get_entry_block ())
 		continue;
 
 	      domsb = get_immediate_dominator (CDI_DOMINATORS, b);
@@ -1142,7 +1142,7 @@ compute_idf (bitmap def_blocks, bitmap_head *dfs)
   bitmap phi_insertion_points;
 
   /* Each block can appear at most twice on the work-stack.  */
-  work_stack.create (2 * n_basic_blocks);
+  work_stack.create (2 * cfun->cfg->get_n_basic_blocks ());
   phi_insertion_points = BITMAP_ALLOC (NULL);
 
   /* Seed the work list with all the blocks in DEF_BLOCKS.  We use
@@ -1166,7 +1166,7 @@ compute_idf (bitmap def_blocks, bitmap_head *dfs)
 	 form, the basic blocks where new and/or old names are defined
 	 may have disappeared by CFG cleanup calls.  In this case,
 	 we may pull a non-existing block from the work stack.  */
-      gcc_checking_assert (bb_index < (unsigned) last_basic_block);
+      gcc_checking_assert (bb_index < (unsigned) cfun->cfg->get_last_basic_block ());
 
       EXECUTE_IF_AND_COMPL_IN_BITMAP (&dfs[bb_index], phi_insertion_points,
 	                              0, i, bi)
@@ -1203,7 +1203,7 @@ bitmap_intersection_of_succs (sbitmap dst, sbitmap *src, basic_block b)
   for (e = NULL, ix = 0; ix < EDGE_COUNT (b->succs); ix++)
     {
       e = EDGE_SUCC (b, ix);
-      if (e->dest == EXIT_BLOCK_PTR)
+      if (e->dest == cfun->cfg->get_exit_block ())
 	continue;
 
       bitmap_copy (dst, src[e->dest->index]);
@@ -1219,7 +1219,7 @@ bitmap_intersection_of_succs (sbitmap dst, sbitmap *src, basic_block b)
 	SBITMAP_ELT_TYPE *p, *r;
 
 	e = EDGE_SUCC (b, ix);
-	if (e->dest == EXIT_BLOCK_PTR)
+	if (e->dest == cfun->cfg->get_exit_block ())
 	  continue;
 
 	p = src[e->dest->index]->elms;
@@ -1244,7 +1244,7 @@ bitmap_intersection_of_preds (sbitmap dst, sbitmap *src, basic_block b)
   for (e = NULL, ix = 0; ix < EDGE_COUNT (b->preds); ix++)
     {
       e = EDGE_PRED (b, ix);
-      if (e->src == ENTRY_BLOCK_PTR)
+      if (e->src == cfun->cfg->get_entry_block ())
 	continue;
 
       bitmap_copy (dst, src[e->src->index]);
@@ -1260,7 +1260,7 @@ bitmap_intersection_of_preds (sbitmap dst, sbitmap *src, basic_block b)
 	SBITMAP_ELT_TYPE *p, *r;
 
 	e = EDGE_PRED (b, ix);
-	if (e->src == ENTRY_BLOCK_PTR)
+	if (e->src == cfun->cfg->get_entry_block ())
 	  continue;
 
 	p = src[e->src->index]->elms;
@@ -1285,7 +1285,7 @@ bitmap_union_of_succs (sbitmap dst, sbitmap *src, basic_block b)
   for (ix = 0; ix < EDGE_COUNT (b->succs); ix++)
     {
       e = EDGE_SUCC (b, ix);
-      if (e->dest == EXIT_BLOCK_PTR)
+      if (e->dest == cfun->cfg->get_exit_block ())
 	continue;
 
       bitmap_copy (dst, src[e->dest->index]);
@@ -1301,7 +1301,7 @@ bitmap_union_of_succs (sbitmap dst, sbitmap *src, basic_block b)
 	SBITMAP_ELT_TYPE *p, *r;
 
 	e = EDGE_SUCC (b, ix);
-	if (e->dest == EXIT_BLOCK_PTR)
+	if (e->dest == cfun->cfg->get_exit_block ())
 	  continue;
 
 	p = src[e->dest->index]->elms;
@@ -1326,7 +1326,7 @@ bitmap_union_of_preds (sbitmap dst, sbitmap *src, basic_block b)
   for (ix = 0; ix < EDGE_COUNT (b->preds); ix++)
     {
       e = EDGE_PRED (b, ix);
-      if (e->src== ENTRY_BLOCK_PTR)
+      if (e->src== cfun->cfg->get_entry_block ())
 	continue;
 
       bitmap_copy (dst, src[e->src->index]);
@@ -1342,7 +1342,7 @@ bitmap_union_of_preds (sbitmap dst, sbitmap *src, basic_block b)
 	SBITMAP_ELT_TYPE *p, *r;
 
 	e = EDGE_PRED (b, ix);
-	if (e->src == ENTRY_BLOCK_PTR)
+	if (e->src == cfun->cfg->get_entry_block ())
 	  continue;
 
 	p = src[e->src->index]->elms;
diff --git a/gcc/cfgbuild.c b/gcc/cfgbuild.c
index ac6aefb..19af792 100644
--- a/gcc/cfgbuild.c
+++ b/gcc/cfgbuild.c
@@ -209,12 +209,12 @@ make_edges (basic_block min, basic_block max, int update_p)
      nearly fully-connected CFGs.  In that case we spend a significant
      amount of time searching the edge lists for duplicates.  */
   if (forced_labels || cfun->cfg->max_jumptable_ents > 100)
-    edge_cache = sbitmap_alloc (last_basic_block);
+    edge_cache = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
 
   /* By nature of the way these get numbered, ENTRY_BLOCK_PTR->next_bb block
      is always the entry.  */
-  if (min == ENTRY_BLOCK_PTR->next_bb)
-    make_edge (ENTRY_BLOCK_PTR, min, EDGE_FALLTHRU);
+  if (min == cfun->cfg->get_entry_block ()->next_bb)
+    make_edge (cfun->cfg->get_entry_block (), min, EDGE_FALLTHRU);
 
   FOR_BB_BETWEEN (bb, min, max->next_bb, next_bb)
     {
@@ -233,14 +233,14 @@ make_edges (basic_block min, basic_block max, int update_p)
 	  if (update_p)
 	    {
 	      FOR_EACH_EDGE (e, ei, bb->succs)
-		if (e->dest != EXIT_BLOCK_PTR)
+		if (e->dest != cfun->cfg->get_exit_block ())
 		  bitmap_set_bit (edge_cache, e->dest->index);
 	    }
 	}
 
       if (LABEL_P (BB_HEAD (bb))
 	  && LABEL_ALT_ENTRY_P (BB_HEAD (bb)))
-	cached_make_edge (NULL, ENTRY_BLOCK_PTR, bb, 0);
+	cached_make_edge (NULL, cfun->cfg->get_entry_block (), bb, 0);
 
       /* Examine the last instruction of the block, and discover the
 	 ways we can leave the block.  */
@@ -294,7 +294,7 @@ make_edges (basic_block min, basic_block max, int update_p)
 
 	  /* Returns create an exit out.  */
 	  else if (returnjump_p (insn))
-	    cached_make_edge (edge_cache, bb, EXIT_BLOCK_PTR, 0);
+	    cached_make_edge (edge_cache, bb, cfun->cfg->get_exit_block (), 0);
 
 	  /* Recognize asm goto and do the right thing.  */
 	  else if ((tmp = extract_asm_operands (PATTERN (insn))) != NULL)
@@ -318,7 +318,7 @@ make_edges (basic_block min, basic_block max, int update_p)
 	 worry about EH edges, since we wouldn't have created the sibling call
 	 in the first place.  */
       if (code == CALL_INSN && SIBLING_CALL_P (insn))
-	cached_make_edge (edge_cache, bb, EXIT_BLOCK_PTR,
+	cached_make_edge (edge_cache, bb, cfun->cfg->get_exit_block (),
 			  EDGE_SIBCALL | EDGE_ABNORMAL);
 
       /* If this is a CALL_INSN, then mark it as reaching the active EH
@@ -359,7 +359,7 @@ make_edges (basic_block min, basic_block max, int update_p)
 
       /* Find out if we can drop through to the next block.  */
       insn = NEXT_INSN (insn);
-      e = find_edge (bb, EXIT_BLOCK_PTR);
+      e = find_edge (bb, cfun->cfg->get_exit_block ());
       if (e && e->flags & EDGE_FALLTHRU)
 	insn = NULL;
 
@@ -369,8 +369,8 @@ make_edges (basic_block min, basic_block max, int update_p)
 	insn = NEXT_INSN (insn);
 
       if (!insn)
-	cached_make_edge (edge_cache, bb, EXIT_BLOCK_PTR, EDGE_FALLTHRU);
-      else if (bb->next_bb != EXIT_BLOCK_PTR)
+	cached_make_edge (edge_cache, bb, cfun->cfg->get_exit_block (), EDGE_FALLTHRU);
+      else if (bb->next_bb != cfun->cfg->get_exit_block ())
 	{
 	  if (insn == BB_HEAD (bb->next_bb))
 	    cached_make_edge (edge_cache, bb, bb->next_bb, EDGE_FALLTHRU);
@@ -480,7 +480,7 @@ find_bb_boundaries (basic_block bb)
 	  remove_edge (fallthru);
 	  flow_transfer_insn = NULL_RTX;
 	  if (code == CODE_LABEL && LABEL_ALT_ENTRY_P (insn))
-	    make_edge (ENTRY_BLOCK_PTR, bb, 0);
+	    make_edge (cfun->cfg->get_entry_block (), bb, 0);
 	}
       else if (code == BARRIER)
 	{
@@ -594,20 +594,20 @@ find_many_sub_basic_blocks (sbitmap blocks)
 {
   basic_block bb, min, max;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     SET_STATE (bb,
 	       bitmap_bit_p (blocks, bb->index) ? BLOCK_TO_SPLIT : BLOCK_ORIGINAL);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     if (STATE (bb) == BLOCK_TO_SPLIT)
       find_bb_boundaries (bb);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     if (STATE (bb) != BLOCK_ORIGINAL)
       break;
 
   min = max = bb;
-  for (; bb != EXIT_BLOCK_PTR; bb = bb->next_bb)
+  for (; bb != cfun->cfg->get_exit_block (); bb = bb->next_bb)
     if (STATE (bb) != BLOCK_ORIGINAL)
       max = bb;
 
@@ -617,7 +617,7 @@ find_many_sub_basic_blocks (sbitmap blocks)
 
   /* Update branch probabilities.  Expect only (un)conditional jumps
      to be created with only the forward edges.  */
-  if (profile_status != PROFILE_ABSENT)
+  if (cfun->cfg->get_profile_status () != PROFILE_ABSENT)
     FOR_BB_BETWEEN (bb, min, max->next_bb, next_bb)
       {
 	edge e;
@@ -639,6 +639,6 @@ find_many_sub_basic_blocks (sbitmap blocks)
 	compute_outgoing_frequencies (bb);
       }
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     SET_STATE (bb, 0);
 }
diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c
index 1379cf7..d29358f 100644
--- a/gcc/cfgcleanup.c
+++ b/gcc/cfgcleanup.c
@@ -133,7 +133,7 @@ try_simplify_condjump (basic_block cbranch_block)
      unconditional jump.  */
   jump_block = cbranch_fallthru_edge->dest;
   if (!single_pred_p (jump_block)
-      || jump_block->next_bb == EXIT_BLOCK_PTR
+      || jump_block->next_bb == cfun->cfg->get_exit_block ()
       || !FORWARDER_BLOCK_P (jump_block))
     return false;
   jump_dest_block = single_succ (jump_block);
@@ -156,7 +156,7 @@ try_simplify_condjump (basic_block cbranch_block)
      unconditional branch.  */
   cbranch_dest_block = cbranch_jump_edge->dest;
 
-  if (cbranch_dest_block == EXIT_BLOCK_PTR
+  if (cbranch_dest_block == cfun->cfg->get_exit_block ()
       || !can_fallthru (jump_block, cbranch_dest_block))
     return false;
 
@@ -454,11 +454,11 @@ try_forward_edges (int mode, basic_block b)
 	 bb-reorder.c:partition_hot_cold_basic_blocks for complete
 	 details.  */
 
-      if (first != EXIT_BLOCK_PTR
+      if (first != cfun->cfg->get_exit_block ()
 	  && find_reg_note (BB_END (first), REG_CROSSING_JUMP, NULL_RTX))
 	return false;
 
-      while (counter < n_basic_blocks)
+      while (counter < cfun->cfg->get_n_basic_blocks ())
 	{
 	  basic_block new_target = NULL;
 	  bool new_target_threaded = false;
@@ -466,12 +466,12 @@ try_forward_edges (int mode, basic_block b)
 
 	  if (FORWARDER_BLOCK_P (target)
 	      && !(single_succ_edge (target)->flags & EDGE_CROSSING)
-	      && single_succ (target) != EXIT_BLOCK_PTR)
+	      && single_succ (target) != cfun->cfg->get_exit_block ())
 	    {
 	      /* Bypass trivial infinite loops.  */
 	      new_target = single_succ (target);
 	      if (target == new_target)
-		counter = n_basic_blocks;
+		counter = cfun->cfg->get_n_basic_blocks ();
 	      else if (!optimize)
 		{
 		  /* When not optimizing, ensure that edges or forwarder
@@ -520,7 +520,7 @@ try_forward_edges (int mode, basic_block b)
 	      if (t)
 		{
 		  if (!threaded_edges)
-		    threaded_edges = XNEWVEC (edge, n_basic_blocks);
+		    threaded_edges = XNEWVEC (edge, cfun->cfg->get_n_basic_blocks ());
 		  else
 		    {
 		      int i;
@@ -532,7 +532,7 @@ try_forward_edges (int mode, basic_block b)
 			  break;
 		      if (i < nthreaded_edges)
 			{
-			  counter = n_basic_blocks;
+			  counter = cfun->cfg->get_n_basic_blocks ();
 			  break;
 			}
 		    }
@@ -541,7 +541,7 @@ try_forward_edges (int mode, basic_block b)
 		  if (t->dest == b)
 		    break;
 
-		  gcc_assert (nthreaded_edges < n_basic_blocks - NUM_FIXED_BLOCKS);
+		  gcc_assert (nthreaded_edges < cfun->cfg->get_n_basic_blocks () - NUM_FIXED_BLOCKS);
 		  threaded_edges[nthreaded_edges++] = t;
 
 		  new_target = t->dest;
@@ -557,7 +557,7 @@ try_forward_edges (int mode, basic_block b)
 	  threaded |= new_target_threaded;
 	}
 
-      if (counter >= n_basic_blocks)
+      if (counter >= cfun->cfg->get_n_basic_blocks ())
 	{
 	  if (dump_file)
 	    fprintf (dump_file, "Infinite loop in BB %i.\n",
@@ -576,7 +576,7 @@ try_forward_edges (int mode, basic_block b)
 	  e->goto_locus = goto_locus;
 
 	  /* Don't force if target is exit block.  */
-	  if (threaded && target != EXIT_BLOCK_PTR)
+	  if (threaded && target != cfun->cfg->get_exit_block ())
 	    {
 	      notice_new_block (redirect_edge_and_branch_force (e, target));
 	      if (dump_file)
@@ -789,7 +789,7 @@ merge_blocks_move (edge e, basic_block b, basic_block c, int mode)
 	fprintf (dump_file, "Merged %d and %d without moving.\n",
 		 b_index, c_index);
 
-      return b->prev_bb == ENTRY_BLOCK_PTR ? b : b->prev_bb;
+      return b->prev_bb == cfun->cfg->get_entry_block () ? b : b->prev_bb;
     }
 
   /* Otherwise we will need to move code around.  Do that only if expensive
@@ -827,7 +827,7 @@ merge_blocks_move (edge e, basic_block b, basic_block c, int mode)
       if (! c_has_outgoing_fallthru)
 	{
 	  merge_blocks_move_successor_nojumps (b, c);
-	  return next == ENTRY_BLOCK_PTR ? next->next_bb : next;
+	  return next == cfun->cfg->get_entry_block () ? next->next_bb : next;
 	}
 
       /* If B does not have an incoming fallthru, then it can be moved
@@ -839,7 +839,7 @@ merge_blocks_move (edge e, basic_block b, basic_block c, int mode)
 	{
 	  basic_block bb;
 
-	  if (b_fallthru_edge->src == ENTRY_BLOCK_PTR)
+	  if (b_fallthru_edge->src == cfun->cfg->get_entry_block ())
 	    return NULL;
 	  bb = force_nonfallthru (b_fallthru_edge);
 	  if (bb)
@@ -847,7 +847,7 @@ merge_blocks_move (edge e, basic_block b, basic_block c, int mode)
 	}
 
       merge_blocks_move_predecessor_nojumps (b, c);
-      return next == ENTRY_BLOCK_PTR ? next->next_bb : next;
+      return next == cfun->cfg->get_entry_block () ? next->next_bb : next;
     }
 
   return NULL;
@@ -1518,7 +1518,7 @@ outgoing_edges_match (int mode, basic_block bb1, basic_block bb2)
      whether they went through the prologue.  Sibcalls are fine, we know
      that we either didn't need or inserted an epilogue before them.  */
   if (crtl->shrink_wrapped
-      && single_succ_p (bb1) && single_succ (bb1) == EXIT_BLOCK_PTR
+      && single_succ_p (bb1) && single_succ (bb1) == cfun->cfg->get_exit_block ()
       && !JUMP_P (BB_END (bb1))
       && !(CALL_P (BB_END (bb1)) && SIBLING_CALL_P (BB_END (bb1))))
     return false;
@@ -1880,7 +1880,7 @@ try_crossjump_to_edge (int mode, edge e1, edge e2,
     e2 = single_pred_edge (src2), src2 = e2->src;
 
   /* Nothing to do if we reach ENTRY, or a common source block.  */
-  if (src1 == ENTRY_BLOCK_PTR || src2 == ENTRY_BLOCK_PTR)
+  if (src1 == cfun->cfg->get_entry_block () || src2 == cfun->cfg->get_entry_block ())
     return false;
   if (src1 == src2)
     return false;
@@ -2124,7 +2124,7 @@ try_crossjump_bb (int mode, basic_block bb)
   /* Don't crossjump if this block ends in a computed jump,
      unless we are optimizing for size.  */
   if (optimize_bb_for_size_p (bb)
-      && bb != EXIT_BLOCK_PTR
+      && bb != cfun->cfg->get_exit_block ()
       && computed_jump_p (BB_END (bb)))
     return false;
 
@@ -2265,7 +2265,7 @@ try_head_merge_bb (basic_block bb)
   /* Don't crossjump if this block ends in a computed jump,
      unless we are optimizing for size.  */
   if (optimize_bb_for_size_p (bb)
-      && bb != EXIT_BLOCK_PTR
+      && bb != cfun->cfg->get_exit_block ()
       && computed_jump_p (BB_END (bb)))
     return false;
 
@@ -2281,7 +2281,7 @@ try_head_merge_bb (basic_block bb)
     }
 
   for (ix = 0; ix < nedges; ix++)
-    if (EDGE_SUCC (bb, ix)->dest == EXIT_BLOCK_PTR)
+    if (EDGE_SUCC (bb, ix)->dest == cfun->cfg->get_exit_block ())
       return false;
 
   for (ix = 0; ix < nedges; ix++)
@@ -2581,7 +2581,7 @@ try_optimize_cfg (int mode)
 
   crossjumps_occured = false;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     update_forwarder_flag (bb);
 
   if (! targetm.cannot_modify_jumps_p ())
@@ -2601,7 +2601,7 @@ try_optimize_cfg (int mode)
 		     "\n\ntry_optimize_cfg iteration %i\n\n",
 		     iterations);
 
-	  for (b = ENTRY_BLOCK_PTR->next_bb; b != EXIT_BLOCK_PTR;)
+	  for (b = cfun->cfg->get_entry_block ()->next_bb; b != cfun->cfg->get_exit_block ();)
 	    {
 	      basic_block c;
 	      edge s;
@@ -2618,7 +2618,7 @@ try_optimize_cfg (int mode)
 	      if (EDGE_COUNT (b->preds) == 0
 		  || (EDGE_COUNT (b->succs) == 0
 		      && trivially_empty_bb_p (b)
-		      && single_succ_edge (ENTRY_BLOCK_PTR)->dest != b))
+		      && single_succ_edge (cfun->cfg->get_entry_block ())->dest != b))
 		{
 		  c = b->prev_bb;
 		  if (EDGE_COUNT (b->preds) > 0)
@@ -2659,7 +2659,7 @@ try_optimize_cfg (int mode)
 		  delete_basic_block (b);
 		  changed = true;
 		  /* Avoid trying to remove ENTRY_BLOCK_PTR.  */
-		  b = (c == ENTRY_BLOCK_PTR ? c->next_bb : c);
+		  b = (c == cfun->cfg->get_entry_block () ? c->next_bb : c);
 		  continue;
 		}
 
@@ -2674,7 +2674,7 @@ try_optimize_cfg (int mode)
 		     if CASE_DROPS_THRU, this can be a tablejump with
 		     some element going to the same place as the
 		     default (fallthru).  */
-		  && (single_pred (b) == ENTRY_BLOCK_PTR
+		  && (single_pred (b) == cfun->cfg->get_entry_block ()
 		      || !JUMP_P (BB_END (single_pred (b)))
 		      || ! label_is_jump_target_p (BB_HEAD (b),
 						   BB_END (single_pred (b)))))
@@ -2694,14 +2694,14 @@ try_optimize_cfg (int mode)
 		  /* Note that forwarder_block_p true ensures that
 		     there is a successor for this block.  */
 		  && (single_succ_edge (b)->flags & EDGE_FALLTHRU)
-		  && n_basic_blocks > NUM_FIXED_BLOCKS + 1)
+		  && cfun->cfg->get_n_basic_blocks () > NUM_FIXED_BLOCKS + 1)
 		{
 		  if (dump_file)
 		    fprintf (dump_file,
 			     "Deleting fallthru block %i.\n",
 			     b->index);
 
-		  c = b->prev_bb == ENTRY_BLOCK_PTR ? b->next_bb : b->prev_bb;
+		  c = b->prev_bb == cfun->cfg->get_entry_block () ? b->next_bb : b->prev_bb;
 		  redirect_edge_succ_nodup (single_pred_edge (b),
 					    single_succ (b));
 		  delete_basic_block (b);
@@ -2714,7 +2714,7 @@ try_optimize_cfg (int mode)
 	      if (single_succ_p (b)
 		  && (s = single_succ_edge (b))
 		  && !(s->flags & EDGE_COMPLEX)
-		  && (c = s->dest) != EXIT_BLOCK_PTR
+		  && (c = s->dest) != cfun->cfg->get_exit_block ()
 		  && single_pred_p (c)
 		  && b != c)
 		{
@@ -2758,7 +2758,7 @@ try_optimize_cfg (int mode)
 		 can either delete the jump entirely, or replace it
 		 with a simple unconditional jump.  */
 	      if (single_succ_p (b)
-		  && single_succ (b) != EXIT_BLOCK_PTR
+		  && single_succ (b) != cfun->cfg->get_exit_block ()
 		  && onlyjump_p (BB_END (b))
 		  && !find_reg_note (BB_END (b), REG_CROSSING_JUMP, NULL_RTX)
 		  && try_redirect_by_replacing_jump (single_succ_edge (b),
@@ -2797,7 +2797,7 @@ try_optimize_cfg (int mode)
 	    }
 
 	  if ((mode & CLEANUP_CROSSJUMP)
-	      && try_crossjump_bb (mode, EXIT_BLOCK_PTR))
+	      && try_crossjump_bb (mode, cfun->cfg->get_exit_block ()))
 	    changed = true;
 
 	  if (block_was_dirty)
@@ -2818,7 +2818,7 @@ try_optimize_cfg (int mode)
       while (changed);
     }
 
-  FOR_ALL_BB (b)
+  FOR_ALL_BB_CFG (b, cfun->cfg)
     b->flags &= ~(BB_FORWARDER_BLOCK | BB_NONTHREADABLE_BLOCK);
 
   return changed_overall;
@@ -2843,7 +2843,7 @@ delete_unreachable_blocks (void)
   if (MAY_HAVE_DEBUG_INSNS && current_ir_type () == IR_GIMPLE
       && dom_info_available_p (CDI_DOMINATORS))
     {
-      for (b = EXIT_BLOCK_PTR->prev_bb; b != ENTRY_BLOCK_PTR; b = prev_bb)
+      for (b = cfun->cfg->get_exit_block ()->prev_bb; b != cfun->cfg->get_entry_block (); b = prev_bb)
 	{
 	  prev_bb = b->prev_bb;
 
@@ -2879,7 +2879,7 @@ delete_unreachable_blocks (void)
     }
   else
     {
-      for (b = EXIT_BLOCK_PTR->prev_bb; b != ENTRY_BLOCK_PTR; b = prev_bb)
+      for (b = cfun->cfg->get_exit_block ()->prev_bb; b != cfun->cfg->get_entry_block (); b = prev_bb)
 	{
 	  prev_bb = b->prev_bb;
 
@@ -2907,7 +2907,7 @@ delete_dead_jumptables (void)
 
   /* A dead jump table does not belong to any basic block.  Scan insns
      between two adjacent basic blocks.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       rtx insn, next;
 
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index c187273..fc1f589 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -464,10 +464,10 @@ add_scope_conflicts (void)
 
      We then do a mostly classical bitmap liveness algorithm.  */
 
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     bb->aux = BITMAP_ALLOC (&stack_var_bitmap_obstack);
 
-  rpo = XNEWVEC (int, last_basic_block);
+  rpo = XNEWVEC (int, cfun->cfg->get_last_basic_block ());
   n_bbs = pre_and_rev_post_order_compute (NULL, rpo, false);
 
   changed = true;
@@ -478,7 +478,7 @@ add_scope_conflicts (void)
       for (i = 0; i < n_bbs; i++)
 	{
 	  bitmap active;
-	  bb = BASIC_BLOCK (rpo[i]);
+	  bb = cfun->cfg->get_basic_block_by_idx (rpo[i]);
 	  active = (bitmap)bb->aux;
 	  add_scope_conflicts_1 (bb, work, false);
 	  if (bitmap_ior_into (active, work))
@@ -486,12 +486,12 @@ add_scope_conflicts (void)
 	}
     }
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     add_scope_conflicts_1 (bb, work, true);
 
   free (rpo);
   BITMAP_FREE (work);
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     BITMAP_FREE (bb->aux);
 }
 
@@ -2444,7 +2444,7 @@ expand_gimple_tailcall (basic_block bb, gimple stmt, bool *can_fallthru)
     {
       if (!(e->flags & (EDGE_ABNORMAL | EDGE_EH)))
 	{
-	  if (e->dest != EXIT_BLOCK_PTR)
+	  if (e->dest != cfun->cfg->get_exit_block ())
 	    {
 	      e->dest->count -= e->count;
 	      e->dest->frequency -= EDGE_FREQUENCY (e);
@@ -2480,7 +2480,7 @@ expand_gimple_tailcall (basic_block bb, gimple stmt, bool *can_fallthru)
       delete_insn (NEXT_INSN (last));
     }
 
-  e = make_edge (bb, EXIT_BLOCK_PTR, EDGE_ABNORMAL | EDGE_SIBCALL);
+  e = make_edge (bb, cfun->cfg->get_exit_block (), EDGE_ABNORMAL | EDGE_SIBCALL);
   e->probability += probability;
   e->count += count;
   BB_END (bb) = last;
@@ -3916,9 +3916,9 @@ expand_gimple_basic_block (basic_block bb, bool disable_tail_calls)
       gimple ret_stmt = gsi_stmt (gsi);
 
       gcc_assert (single_succ_p (bb));
-      gcc_assert (single_succ (bb) == EXIT_BLOCK_PTR);
+      gcc_assert (single_succ (bb) == cfun->cfg->get_exit_block ());
 
-      if (bb->next_bb == EXIT_BLOCK_PTR
+      if (bb->next_bb == cfun->cfg->get_exit_block ()
 	  && !gimple_return_retval (ret_stmt))
 	{
 	  gsi_remove (&gsi, false);
@@ -4260,17 +4260,17 @@ construct_init_block (void)
   int flags;
 
   /* Multiple entry points not supported yet.  */
-  gcc_assert (EDGE_COUNT (ENTRY_BLOCK_PTR->succs) == 1);
-  init_rtl_bb_info (ENTRY_BLOCK_PTR);
-  init_rtl_bb_info (EXIT_BLOCK_PTR);
-  ENTRY_BLOCK_PTR->flags |= BB_RTL;
-  EXIT_BLOCK_PTR->flags |= BB_RTL;
+  gcc_assert (EDGE_COUNT (cfun->cfg->get_entry_block ()->succs) == 1);
+  init_rtl_bb_info (cfun->cfg->get_entry_block ());
+  init_rtl_bb_info (cfun->cfg->get_exit_block ());
+  cfun->cfg->get_entry_block ()->flags |= BB_RTL;
+  cfun->cfg->get_exit_block ()->flags |= BB_RTL;
 
-  e = EDGE_SUCC (ENTRY_BLOCK_PTR, 0);
+  e = EDGE_SUCC (cfun->cfg->get_entry_block (), 0);
 
   /* When entry edge points to first basic block, we don't need jump,
      otherwise we have to jump into proper target.  */
-  if (e && e->dest != ENTRY_BLOCK_PTR->next_bb)
+  if (e && e->dest != cfun->cfg->get_entry_block ()->next_bb)
     {
       tree label = gimple_block_label (e->dest);
 
@@ -4282,11 +4282,11 @@ construct_init_block (void)
 
   init_block = create_basic_block (NEXT_INSN (get_insns ()),
 				   get_last_insn (),
-				   ENTRY_BLOCK_PTR);
-  init_block->frequency = ENTRY_BLOCK_PTR->frequency;
-  init_block->count = ENTRY_BLOCK_PTR->count;
-  if (current_loops && ENTRY_BLOCK_PTR->loop_father)
-    add_bb_to_loop (init_block, ENTRY_BLOCK_PTR->loop_father);
+				   cfun->cfg->get_entry_block ());
+  init_block->frequency = cfun->cfg->get_entry_block ()->frequency;
+  init_block->count = cfun->cfg->get_entry_block ()->count;
+  if (current_loops && cfun->cfg->get_entry_block ()->loop_father)
+    add_bb_to_loop (init_block, cfun->cfg->get_entry_block ()->loop_father);
   if (e)
     {
       first_block = e->dest;
@@ -4294,9 +4294,9 @@ construct_init_block (void)
       e = make_edge (init_block, first_block, flags);
     }
   else
-    e = make_edge (init_block, EXIT_BLOCK_PTR, EDGE_FALLTHRU);
+    e = make_edge (init_block, cfun->cfg->get_exit_block (), EDGE_FALLTHRU);
   e->probability = REG_BR_PROB_BASE;
-  e->count = ENTRY_BLOCK_PTR->count;
+  e->count = cfun->cfg->get_entry_block ()->count;
 
   update_bb_for_insn (init_block);
   return init_block;
@@ -4327,9 +4327,9 @@ construct_exit_block (void)
   edge e, e2;
   unsigned ix;
   edge_iterator ei;
-  rtx orig_end = BB_END (EXIT_BLOCK_PTR->prev_bb);
+  rtx orig_end = BB_END (cfun->cfg->get_exit_block ()->prev_bb);
 
-  rtl_profile_for_bb (EXIT_BLOCK_PTR);
+  rtl_profile_for_bb (cfun->cfg->get_exit_block ());
 
   /* Make sure the locus is set to the end of the function, so that
      epilogue line numbers and warnings are set properly.  */
@@ -4344,30 +4344,30 @@ construct_exit_block (void)
     return;
   /* While emitting the function end we could move end of the last basic block.
    */
-  BB_END (EXIT_BLOCK_PTR->prev_bb) = orig_end;
+  BB_END (cfun->cfg->get_exit_block ()->prev_bb) = orig_end;
   while (NEXT_INSN (head) && NOTE_P (NEXT_INSN (head)))
     head = NEXT_INSN (head);
   exit_block = create_basic_block (NEXT_INSN (head), end,
-				   EXIT_BLOCK_PTR->prev_bb);
-  exit_block->frequency = EXIT_BLOCK_PTR->frequency;
-  exit_block->count = EXIT_BLOCK_PTR->count;
-  if (current_loops && EXIT_BLOCK_PTR->loop_father)
-    add_bb_to_loop (exit_block, EXIT_BLOCK_PTR->loop_father);
+				   cfun->cfg->get_exit_block ()->prev_bb);
+  exit_block->frequency = cfun->cfg->get_exit_block ()->frequency;
+  exit_block->count = cfun->cfg->get_exit_block ()->count;
+  if (current_loops && cfun->cfg->get_exit_block ()->loop_father)
+    add_bb_to_loop (exit_block, cfun->cfg->get_exit_block ()->loop_father);
 
   ix = 0;
-  while (ix < EDGE_COUNT (EXIT_BLOCK_PTR->preds))
+  while (ix < EDGE_COUNT (cfun->cfg->get_exit_block ()->preds))
     {
-      e = EDGE_PRED (EXIT_BLOCK_PTR, ix);
+      e = EDGE_PRED (cfun->cfg->get_exit_block (), ix);
       if (!(e->flags & EDGE_ABNORMAL))
 	redirect_edge_succ (e, exit_block);
       else
 	ix++;
     }
 
-  e = make_edge (exit_block, EXIT_BLOCK_PTR, EDGE_FALLTHRU);
+  e = make_edge (exit_block, cfun->cfg->get_exit_block (), EDGE_FALLTHRU);
   e->probability = REG_BR_PROB_BASE;
-  e->count = EXIT_BLOCK_PTR->count;
-  FOR_EACH_EDGE (e2, ei, EXIT_BLOCK_PTR->preds)
+  e->count = cfun->cfg->get_exit_block ()->count;
+  FOR_EACH_EDGE (e2, ei, cfun->cfg->get_exit_block ()->preds)
     if (e2 != e)
       {
 	e->count -= e2->count;
@@ -4436,7 +4436,7 @@ discover_nonconstant_array_refs (void)
   basic_block bb;
   gimple_stmt_iterator gsi;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
       {
 	gimple stmt = gsi_stmt (gsi);
@@ -4551,7 +4551,7 @@ gimple_expand_cfg (void)
   /* Dominators are not kept up-to-date as we may create new basic-blocks.  */
   free_dominance_info (CDI_DOMINATORS);
 
-  rtl_profile_for_bb (ENTRY_BLOCK_PTR);
+  rtl_profile_for_bb (cfun->cfg->get_entry_block ());
 
   insn_locations_init ();
   if (!DECL_IS_BUILTIN (current_function_decl))
@@ -4715,11 +4715,11 @@ gimple_expand_cfg (void)
 
   /* Clear EDGE_EXECUTABLE on the entry edge(s).  It is cleaned from the
      remaining edges later.  */
-  FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR->succs)
+  FOR_EACH_EDGE (e, ei, cfun->cfg->get_entry_block ()->succs)
     e->flags &= ~EDGE_EXECUTABLE;
 
   lab_rtx_for_bb = pointer_map_create ();
-  FOR_BB_BETWEEN (bb, init_block->next_bb, EXIT_BLOCK_PTR, next_bb)
+  FOR_BB_BETWEEN (bb, init_block->next_bb, cfun->cfg->get_exit_block (), next_bb)
     bb = expand_gimple_basic_block (bb, var_ret_seq != NULL_RTX);
 
   if (MAY_HAVE_DEBUG_INSNS)
@@ -4764,7 +4764,7 @@ gimple_expand_cfg (void)
      split edges which edge insertions might do.  */
   rebuild_jump_labels (get_insns ());
 
-  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
+  FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block (), cfun->cfg->get_exit_block (), next_bb)
     {
       edge e;
       edge_iterator ei;
@@ -4774,8 +4774,8 @@ gimple_expand_cfg (void)
 	    {
 	      rebuild_jump_labels_chain (e->insns.r);
 	      /* Avoid putting insns before parm_birth_insn.  */
-	      if (e->src == ENTRY_BLOCK_PTR
-		  && single_succ_p (ENTRY_BLOCK_PTR)
+	      if (e->src == cfun->cfg->get_entry_block ()
+		  && single_succ_p (cfun->cfg->get_entry_block ())
 		  && parm_birth_insn)
 		{
 		  rtx insns = e->insns.r;
@@ -4793,7 +4793,7 @@ gimple_expand_cfg (void)
   /* We're done expanding trees to RTL.  */
   currently_expanding_to_rtl = 0;
 
-  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR->next_bb, EXIT_BLOCK_PTR, next_bb)
+  FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block ()->next_bb, cfun->cfg->get_exit_block (), next_bb)
     {
       edge e;
       edge_iterator ei;
@@ -4814,7 +4814,7 @@ gimple_expand_cfg (void)
 	}
     }
 
-  blocks = sbitmap_alloc (last_basic_block);
+  blocks = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
   bitmap_ones (blocks);
   find_many_sub_basic_blocks (blocks);
   sbitmap_free (blocks);
diff --git a/gcc/cfghooks.c b/gcc/cfghooks.c
index 8331fa0..391cd36 100644
--- a/gcc/cfghooks.c
+++ b/gcc/cfghooks.c
@@ -98,15 +98,15 @@ verify_flow_info (void)
   basic_block *last_visited;
 
   timevar_push (TV_CFG_VERIFY);
-  last_visited = XCNEWVEC (basic_block, last_basic_block);
-  edge_checksum = XCNEWVEC (size_t, last_basic_block);
+  last_visited = XCNEWVEC (basic_block, cfun->cfg->get_last_basic_block ());
+  edge_checksum = XCNEWVEC (size_t, cfun->cfg->get_last_basic_block ());
 
   /* Check bb chain & numbers.  */
-  last_bb_seen = ENTRY_BLOCK_PTR;
-  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR->next_bb, NULL, next_bb)
+  last_bb_seen = cfun->cfg->get_entry_block ();
+  FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block ()->next_bb, NULL, next_bb)
     {
-      if (bb != EXIT_BLOCK_PTR
-	  && bb != BASIC_BLOCK (bb->index))
+      if (bb != cfun->cfg->get_exit_block ()
+	  && bb != cfun->cfg->get_basic_block_by_idx (bb->index))
 	{
 	  error ("bb %d on wrong place", bb->index);
 	  err = 1;
@@ -123,7 +123,7 @@ verify_flow_info (void)
     }
 
   /* Now check the basic blocks (boundaries etc.) */
-  FOR_EACH_BB_REVERSE (bb)
+  FOR_EACH_BB_REVERSE_CFG (bb, cfun->cfg)
     {
       int n_fallthru = 0;
       edge e;
@@ -234,21 +234,21 @@ verify_flow_info (void)
     edge e;
     edge_iterator ei;
 
-    FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR->succs)
+    FOR_EACH_EDGE (e, ei, cfun->cfg->get_entry_block ()->succs)
       edge_checksum[e->dest->index] += (size_t) e;
 
-    FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
+    FOR_EACH_EDGE (e, ei, cfun->cfg->get_exit_block ()->preds)
       edge_checksum[e->dest->index] -= (size_t) e;
   }
 
-  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
+  FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block (), NULL, next_bb)
     if (edge_checksum[bb->index])
       {
 	error ("basic block %i edge lists are corrupted", bb->index);
 	err = 1;
       }
 
-  last_bb_seen = ENTRY_BLOCK_PTR;
+  last_bb_seen = cfun->cfg->get_entry_block ();
 
   /* Clean up.  */
   free (last_visited);
@@ -323,8 +323,8 @@ dump_flow_info (FILE *file, int flags)
 {
   basic_block bb;
 
-  fprintf (file, "\n%d basic blocks, %d edges.\n", n_basic_blocks, n_edges);
-  FOR_ALL_BB (bb)
+  fprintf (file, "\n%d basic blocks, %d edges.\n", cfun->cfg->get_n_basic_blocks (), cfun->cfg->get_n_edges ());
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     dump_bb (file, bb, 0, flags);
 
   putc ('\n', file);
@@ -937,10 +937,10 @@ tidy_fallthru_edges (void)
   if (!cfg_hooks->tidy_fallthru_edge)
     return;
 
-  if (ENTRY_BLOCK_PTR->next_bb == EXIT_BLOCK_PTR)
+  if (cfun->cfg->get_entry_block ()->next_bb == cfun->cfg->get_exit_block ())
     return;
 
-  FOR_BB_BETWEEN (b, ENTRY_BLOCK_PTR->next_bb, EXIT_BLOCK_PTR->prev_bb, next_bb)
+  FOR_BB_BETWEEN (b, cfun->cfg->get_entry_block ()->next_bb, cfun->cfg->get_exit_block ()->prev_bb, next_bb)
     {
       edge s;
 
@@ -1010,7 +1010,7 @@ can_duplicate_block_p (const_basic_block bb)
     internal_error ("%s does not support can_duplicate_block_p",
 		    cfg_hooks->name);
 
-  if (bb == EXIT_BLOCK_PTR || bb == ENTRY_BLOCK_PTR)
+  if (bb == cfun->cfg->get_exit_block () || bb == cfun->cfg->get_entry_block ())
     return false;
 
   return cfg_hooks->can_duplicate_block_p (bb);
@@ -1406,10 +1406,10 @@ account_profile_record (struct profile_record *record, int after_pass)
   int sum;
   gcov_type lsum;
 
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
    {
       if (bb != EXIT_BLOCK_PTR_FOR_FUNCTION (cfun)
-	  && profile_status != PROFILE_ABSENT)
+	  && cfun->cfg->get_profile_status () != PROFILE_ABSENT)
 	{
 	  sum = 0;
 	  FOR_EACH_EDGE (e, ei, bb->succs)
@@ -1424,7 +1424,7 @@ account_profile_record (struct profile_record *record, int after_pass)
 	    record->num_mismatched_count_out[after_pass]++;
 	}
       if (bb != ENTRY_BLOCK_PTR_FOR_FUNCTION (cfun)
-	  && profile_status != PROFILE_ABSENT)
+	  && cfun->cfg->get_profile_status () != PROFILE_ABSENT)
 	{
 	  sum = 0;
 	  FOR_EACH_EDGE (e, ei, bb->preds)
diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c
index 0128724..6d42155 100644
--- a/gcc/cfgloop.c
+++ b/gcc/cfgloop.c
@@ -45,7 +45,7 @@ flow_loops_cfg_dump (FILE *file)
   if (!file)
     return;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       edge succ;
       edge_iterator ei;
@@ -381,7 +381,7 @@ bb_loop_header_p (basic_block header)
   FOR_EACH_EDGE (e, ei, header->preds)
     {
       basic_block latch = e->src;
-      if (latch != ENTRY_BLOCK_PTR
+      if (latch != cfun->cfg->get_entry_block ()
 	  && dominated_by_p (CDI_DOMINATORS, latch, header))
 	return true;
     }
@@ -420,23 +420,23 @@ flow_loops_find (struct loops *loops)
 
   /* Taking care of this degenerate case makes the rest of
      this code simpler.  */
-  if (n_basic_blocks == NUM_FIXED_BLOCKS)
+  if (cfun->cfg->get_n_basic_blocks () == NUM_FIXED_BLOCKS)
     return loops;
 
   /* The root loop node contains all basic-blocks.  */
-  loops->tree_root->num_nodes = n_basic_blocks;
+  loops->tree_root->num_nodes = cfun->cfg->get_n_basic_blocks ();
 
   /* Compute depth first search order of the CFG so that outer
      natural loops will be found before inner natural loops.  */
-  rc_order = XNEWVEC (int, n_basic_blocks);
+  rc_order = XNEWVEC (int, cfun->cfg->get_n_basic_blocks ());
   pre_and_rev_post_order_compute (NULL, rc_order, false);
 
   /* Gather all loop headers in reverse completion order and allocate
      loop structures for loops that are not already present.  */
   larray.create (loops->larray->length());
-  for (b = 0; b < n_basic_blocks - NUM_FIXED_BLOCKS; b++)
+  for (b = 0; b < cfun->cfg->get_n_basic_blocks () - NUM_FIXED_BLOCKS; b++)
     {
-      basic_block header = BASIC_BLOCK (rc_order[b]);
+      basic_block header = cfun->cfg->get_basic_block_by_idx (rc_order[b]);
       if (bb_loop_header_p (header))
 	{
 	  struct loop *loop;
@@ -744,7 +744,7 @@ disambiguate_multiple_latches (struct loop *loop)
      block.  This would cause problems if the entry edge was the one from the
      entry block.  To avoid having to handle this case specially, split
      such entry edge.  */
-  e = find_edge (ENTRY_BLOCK_PTR, loop->header);
+  e = find_edge (cfun->cfg->get_entry_block (), loop->header);
   if (e)
     split_edge (e);
 
@@ -781,7 +781,7 @@ flow_bb_inside_loop_p (const struct loop *loop, const_basic_block bb)
 {
   struct loop *source_loop;
 
-  if (bb == ENTRY_BLOCK_PTR || bb == EXIT_BLOCK_PTR)
+  if (bb == cfun->cfg->get_entry_block () || bb == cfun->cfg->get_exit_block ())
     return 0;
 
   source_loop = bb->loop_father;
@@ -826,14 +826,14 @@ get_loop_body (const struct loop *loop)
 
   body = XNEWVEC (basic_block, loop->num_nodes);
 
-  if (loop->latch == EXIT_BLOCK_PTR)
+  if (loop->latch == cfun->cfg->get_exit_block ())
     {
       /* There may be blocks unreachable from EXIT_BLOCK, hence we need to
 	 special-case the fake loop that contains the whole function.  */
-      gcc_assert (loop->num_nodes == (unsigned) n_basic_blocks);
+      gcc_assert (loop->num_nodes == (unsigned) cfun->cfg->get_n_basic_blocks ());
       body[tv++] = loop->header;
-      body[tv++] = EXIT_BLOCK_PTR;
-      FOR_EACH_BB (bb)
+      body[tv++] = cfun->cfg->get_exit_block ();
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
 	body[tv++] = bb;
     }
   else
@@ -886,7 +886,7 @@ get_loop_body_in_dom_order (const struct loop *loop)
 
   tovisit = XNEWVEC (basic_block, loop->num_nodes);
 
-  gcc_assert (loop->latch != EXIT_BLOCK_PTR);
+  gcc_assert (loop->latch != cfun->cfg->get_exit_block ());
 
   tv = 0;
   fill_sons_in_loop (loop, loop->header, tovisit, &tv);
@@ -921,7 +921,7 @@ get_loop_body_in_bfs_order (const struct loop *loop)
   unsigned int vc = 1;
 
   gcc_assert (loop->num_nodes);
-  gcc_assert (loop->latch != EXIT_BLOCK_PTR);
+  gcc_assert (loop->latch != cfun->cfg->get_exit_block ());
 
   blocks = XNEWVEC (basic_block, loop->num_nodes);
   visited = BITMAP_ALLOC (NULL);
@@ -1081,7 +1081,7 @@ record_loop_exits (void)
 					  loop_exit_hash, loop_exit_eq,
 					  loop_exit_free);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       FOR_EACH_EDGE (e, ei, bb->succs)
 	{
@@ -1143,7 +1143,7 @@ get_loop_exit_edges (const struct loop *loop)
   edge_iterator ei;
   struct loop_exit *exit;
 
-  gcc_assert (loop->latch != EXIT_BLOCK_PTR);
+  gcc_assert (loop->latch != cfun->cfg->get_exit_block ());
 
   /* If we maintain the lists of exits, use them.  Otherwise we must
      scan the body of the loop.  */
@@ -1175,7 +1175,7 @@ num_loop_branches (const struct loop *loop)
   unsigned i, n;
   basic_block * body;
 
-  gcc_assert (loop->latch != EXIT_BLOCK_PTR);
+  gcc_assert (loop->latch != cfun->cfg->get_exit_block ());
 
   body = get_loop_body (loop);
   n = 0;
@@ -1343,7 +1343,7 @@ verify_loop_structure (void)
     verify_dominators (CDI_DOMINATORS);
 
   /* Check the headers.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     if (bb_loop_header_p (bb))
       {
 	if (bb->loop_father->header == NULL)
@@ -1364,9 +1364,9 @@ verify_loop_structure (void)
       }
 
   /* Check the recorded loop father and sizes of loops.  */
-  visited = sbitmap_alloc (last_basic_block);
+  visited = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
   bitmap_clear (visited);
-  bbs = XNEWVEC (basic_block, n_basic_blocks);
+  bbs = XNEWVEC (basic_block, cfun->cfg->get_n_basic_blocks ());
   FOR_EACH_LOOP (li, loop, LI_FROM_INNERMOST)
     {
       unsigned n;
@@ -1378,7 +1378,7 @@ verify_loop_structure (void)
 	  continue;
 	}
 
-      n = get_loop_body_with_size (loop, bbs, n_basic_blocks);
+      n = get_loop_body_with_size (loop, bbs, cfun->cfg->get_n_basic_blocks ());
       if (loop->num_nodes != n)
 	{
 	  error ("size of loop %d should be %d, not %d",
@@ -1478,8 +1478,8 @@ verify_loop_structure (void)
   if (loops_state_satisfies_p (LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS))
     {
       /* Record old info.  */
-      irreds = sbitmap_alloc (last_basic_block);
-      FOR_EACH_BB (bb)
+      irreds = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
 	{
 	  edge_iterator ei;
 	  if (bb->flags & BB_IRREDUCIBLE_LOOP)
@@ -1495,7 +1495,7 @@ verify_loop_structure (void)
       mark_irreducible_loops ();
 
       /* Compare.  */
-      FOR_EACH_BB (bb)
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
 	{
 	  edge_iterator ei;
 
@@ -1578,7 +1578,7 @@ verify_loop_structure (void)
 
       sizes = XCNEWVEC (unsigned, num);
       memset (sizes, 0, sizeof (unsigned) * num);
-      FOR_EACH_BB (bb)
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
 	{
 	  edge_iterator ei;
 	  if (bb->loop_father == current_loops->tree_root)
diff --git a/gcc/cfgloopanal.c b/gcc/cfgloopanal.c
index 9300237..b3b146a 100644
--- a/gcc/cfgloopanal.c
+++ b/gcc/cfgloopanal.c
@@ -64,7 +64,7 @@ just_once_each_iteration_p (const struct loop *loop, const_basic_block bb)
 
    LOOPS is the loop tree.  */
 
-#define LOOP_REPR(LOOP) ((LOOP)->num + last_basic_block)
+#define LOOP_REPR(LOOP) ((LOOP)->num + cfun->cfg->get_last_basic_block ())
 #define BB_REPR(BB) ((BB)->index + 1)
 
 bool
@@ -85,7 +85,7 @@ mark_irreducible_loops (void)
   gcc_assert (current_loops != NULL);
 
   /* Reset the flags.  */
-  FOR_BB_BETWEEN (act, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
+  FOR_BB_BETWEEN (act, cfun->cfg->get_entry_block (), cfun->cfg->get_exit_block (), next_bb)
     {
       act->flags &= ~BB_IRREDUCIBLE_LOOP;
       FOR_EACH_EDGE (e, ei, act->succs)
@@ -93,13 +93,13 @@ mark_irreducible_loops (void)
     }
 
   /* Create the edge lists.  */
-  g = new_graph (last_basic_block + num);
+  g = new_graph (cfun->cfg->get_last_basic_block () + num);
 
-  FOR_BB_BETWEEN (act, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
+  FOR_BB_BETWEEN (act, cfun->cfg->get_entry_block (), cfun->cfg->get_exit_block (), next_bb)
     FOR_EACH_EDGE (e, ei, act->succs)
       {
 	/* Ignore edges to exit.  */
-	if (e->dest == EXIT_BLOCK_PTR)
+	if (e->dest == cfun->cfg->get_exit_block ())
 	  continue;
 
 	src = BB_REPR (act);
@@ -430,7 +430,7 @@ mark_loop_exit_edges (void)
   if (number_of_loops (cfun) <= 1)
     return;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       edge_iterator ei;
 
@@ -468,7 +468,7 @@ single_likely_exit (struct loop *loop)
 	 ruled out by this test.  The static branch prediction algorithm
          will not assign such a low probability to conditionals for usual
          reasons.  */
-      if (profile_status != PROFILE_ABSENT
+      if (cfun->cfg->get_profile_status () != PROFILE_ABSENT
 	  && ex->probability < 5 && !ex->count)
 	continue;
       if (!found)
diff --git a/gcc/cfgloopmanip.c b/gcc/cfgloopmanip.c
index bc87755..5c55aea 100644
--- a/gcc/cfgloopmanip.c
+++ b/gcc/cfgloopmanip.c
@@ -67,9 +67,9 @@ find_path (edge e, basic_block **bbs)
   gcc_assert (EDGE_COUNT (e->dest->preds) <= 1);
 
   /* Find bbs in the path.  */
-  *bbs = XNEWVEC (basic_block, n_basic_blocks);
+  *bbs = XNEWVEC (basic_block, cfun->cfg->get_n_basic_blocks ());
   return dfs_enumerate_from (e->dest, 0, rpe_enum_p, *bbs,
-			     n_basic_blocks, e->dest);
+			     cfun->cfg->get_n_basic_blocks (), e->dest);
 }
 
 /* Fix placement of basic block BB inside loop hierarchy --
@@ -88,7 +88,7 @@ fix_bb_placement (basic_block bb)
 
   FOR_EACH_EDGE (e, ei, bb->succs)
     {
-      if (e->dest == EXIT_BLOCK_PTR)
+      if (e->dest == cfun->cfg->get_exit_block ())
 	continue;
 
       act = e->dest->loop_father;
@@ -196,7 +196,7 @@ fix_bb_placements (basic_block from,
       || from == base_loop->header)
     return;
 
-  in_queue = sbitmap_alloc (last_basic_block);
+  in_queue = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
   bitmap_clear (in_queue);
   bitmap_set_bit (in_queue, from->index);
   /* Prevent us from going out of the base_loop.  */
@@ -332,8 +332,8 @@ remove_path (edge e)
   nrem = find_path (e, &rem_bbs);
 
   n_bord_bbs = 0;
-  bord_bbs = XNEWVEC (basic_block, n_basic_blocks);
-  seen = sbitmap_alloc (last_basic_block);
+  bord_bbs = XNEWVEC (basic_block, cfun->cfg->get_n_basic_blocks ());
+  seen = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
   bitmap_clear (seen);
 
   /* Find "border" hexes -- i.e. those with predecessor in removed path.  */
@@ -341,14 +341,14 @@ remove_path (edge e)
     bitmap_set_bit (seen, rem_bbs[i]->index);
   if (!irred_invalidated)
     FOR_EACH_EDGE (ae, ei, e->src->succs)
-      if (ae != e && ae->dest != EXIT_BLOCK_PTR && !bitmap_bit_p (seen, ae->dest->index)
+      if (ae != e && ae->dest != cfun->cfg->get_exit_block () && !bitmap_bit_p (seen, ae->dest->index)
 	  && ae->flags & EDGE_IRREDUCIBLE_LOOP)
 	irred_invalidated = true;
   for (i = 0; i < nrem; i++)
     {
       bb = rem_bbs[i];
       FOR_EACH_EDGE (ae, ei, rem_bbs[i]->succs)
-	if (ae->dest != EXIT_BLOCK_PTR && !bitmap_bit_p (seen, ae->dest->index))
+	if (ae->dest != cfun->cfg->get_exit_block () && !bitmap_bit_p (seen, ae->dest->index))
 	  {
 	    bitmap_set_bit (seen, ae->dest->index);
 	    bord_bbs[n_bord_bbs++] = ae->dest;
@@ -435,8 +435,8 @@ add_loop (struct loop *loop, struct loop *outer)
   flow_loop_tree_node_add (outer, loop);
 
   /* Find its nodes.  */
-  bbs = XNEWVEC (basic_block, n_basic_blocks);
-  n = get_loop_body_with_size (loop, bbs, n_basic_blocks);
+  bbs = XNEWVEC (basic_block, cfun->cfg->get_n_basic_blocks ());
+  n = get_loop_body_with_size (loop, bbs, cfun->cfg->get_n_basic_blocks ());
 
   for (i = 0; i < n; i++)
     {
@@ -602,7 +602,7 @@ update_dominators_in_loop (struct loop *loop)
   basic_block *body;
   unsigned i;
 
-  seen = sbitmap_alloc (last_basic_block);
+  seen = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
   bitmap_clear (seen);
   body = get_loop_body (loop);
 
@@ -1504,7 +1504,7 @@ create_preheader (struct loop *loop, int flags)
 
       /* We do not allow entry block to be the loop preheader, since we
 	     cannot emit code there.  */
-      if (single_entry->src == ENTRY_BLOCK_PTR)
+      if (single_entry->src == cfun->cfg->get_entry_block ())
         need_forwarder_block = true;
       else
         {
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index 0ea297e..7a64a89 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -327,10 +327,10 @@ create_basic_block_structure (rtx head, rtx end, rtx bb_note, basic_block after)
 
   BB_HEAD (bb) = head;
   BB_END (bb) = end;
-  bb->index = last_basic_block++;
+  bb->index = cfun->cfg->get_last_basic_block ()++;
   bb->flags = BB_NEW | BB_RTL;
   link_block (bb, after);
-  SET_BASIC_BLOCK (bb->index, bb);
+  cfun->cfg->set_basic_block_by_idx (bb->index, bb);
   df_bb_refs_record (bb->index, false);
   update_bb_for_insn (bb);
   BB_SET_PARTITION (bb, BB_UNPARTITIONED);
@@ -354,13 +354,13 @@ rtl_create_basic_block (void *headp, void *endp, basic_block after)
   basic_block bb;
 
   /* Grow the basic block array if needed.  */
-  if ((size_t) last_basic_block >= basic_block_info->length ())
+  if ((size_t) cfun->cfg->get_last_basic_block () >= cfun->cfg->get_basic_block_info ()->length ())
     {
-      size_t new_size = last_basic_block + (last_basic_block + 3) / 4;
-      vec_safe_grow_cleared (basic_block_info, new_size);
+      size_t new_size = cfun->cfg->get_last_basic_block () + (cfun->cfg->get_last_basic_block () + 3) / 4;
+      vec_safe_grow_cleared (cfun->cfg->get_basic_block_info (), new_size);
     }
 
-  n_basic_blocks++;
+  cfun->cfg->get_n_basic_blocks ()++;
 
   bb = create_basic_block_structure (head, end, NULL, after);
   bb->aux = NULL;
@@ -412,7 +412,7 @@ compute_bb_for_insn (void)
 {
   basic_block bb;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       rtx end = BB_END (bb);
       rtx insn;
@@ -479,8 +479,8 @@ struct rtl_opt_pass pass_free_cfg =
 rtx
 entry_of_function (void)
 {
-  return (n_basic_blocks > NUM_FIXED_BLOCKS ?
-	  BB_HEAD (ENTRY_BLOCK_PTR->next_bb) : get_insns ());
+  return (cfun->cfg->get_n_basic_blocks () > NUM_FIXED_BLOCKS ?
+	  BB_HEAD (cfun->cfg->get_entry_block ()->next_bb) : get_insns ());
 }
 
 /* Emit INSN at the entry point of the function, ensuring that it is only
@@ -488,7 +488,7 @@ entry_of_function (void)
 void
 emit_insn_at_entry (rtx insn)
 {
-  edge_iterator ei = ei_start (ENTRY_BLOCK_PTR->succs);
+  edge_iterator ei = ei_start (cfun->cfg->get_entry_block ()->succs);
   edge e = ei_safe_edge (ei);
   gcc_assert (e->flags & EDGE_FALLTHRU);
 
@@ -552,7 +552,7 @@ contains_no_active_insn_p (const_basic_block bb)
 {
   rtx insn;
 
-  if (bb == EXIT_BLOCK_PTR || bb == ENTRY_BLOCK_PTR
+  if (bb == cfun->cfg->get_exit_block () || bb == cfun->cfg->get_entry_block ()
       || !single_succ_p (bb))
     return false;
 
@@ -599,12 +599,12 @@ can_fallthru (basic_block src, basic_block target)
   edge e;
   edge_iterator ei;
 
-  if (target == EXIT_BLOCK_PTR)
+  if (target == cfun->cfg->get_exit_block ())
     return true;
   if (src->next_bb != target)
     return 0;
   FOR_EACH_EDGE (e, ei, src->succs)
-    if (e->dest == EXIT_BLOCK_PTR
+    if (e->dest == cfun->cfg->get_exit_block ()
 	&& e->flags & EDGE_FALLTHRU)
       return 0;
 
@@ -625,10 +625,10 @@ could_fall_through (basic_block src, basic_block target)
   edge e;
   edge_iterator ei;
 
-  if (target == EXIT_BLOCK_PTR)
+  if (target == cfun->cfg->get_exit_block ())
     return true;
   FOR_EACH_EDGE (e, ei, src->succs)
-    if (e->dest == EXIT_BLOCK_PTR
+    if (e->dest == cfun->cfg->get_exit_block ()
 	&& e->flags & EDGE_FALLTHRU)
       return 0;
   return true;
@@ -933,7 +933,7 @@ rtl_can_merge_blocks (basic_block a, basic_block b)
 	  /* Must be simple edge.  */
 	  && !(single_succ_edge (a)->flags & EDGE_COMPLEX)
 	  && a->next_bb == b
-	  && a != ENTRY_BLOCK_PTR && b != EXIT_BLOCK_PTR
+	  && a != cfun->cfg->get_entry_block () && b != cfun->cfg->get_exit_block ()
 	  /* If the jump insn has side effects,
 	     we can't kill the edge.  */
 	  && (!JUMP_P (BB_END (a))
@@ -947,7 +947,7 @@ rtl_can_merge_blocks (basic_block a, basic_block b)
 rtx
 block_label (basic_block block)
 {
-  if (block == EXIT_BLOCK_PTR)
+  if (block == cfun->cfg->get_exit_block ())
     return NULL_RTX;
 
   if (!LABEL_P (BB_HEAD (block)))
@@ -1060,13 +1060,13 @@ try_redirect_by_replacing_jump (edge e, basic_block target, bool in_cfglayout)
 		 INSN_UID (insn), e->dest->index, target->index);
       if (!redirect_jump (insn, block_label (target), 0))
 	{
-	  gcc_assert (target == EXIT_BLOCK_PTR);
+	  gcc_assert (target == cfun->cfg->get_exit_block ());
 	  return NULL;
 	}
     }
 
   /* Cannot do anything for target exit block.  */
-  else if (target == EXIT_BLOCK_PTR)
+  else if (target == cfun->cfg->get_exit_block ())
     return NULL;
 
   /* Or replace possibly complicated jump insn by simple jump insn.  */
@@ -1154,7 +1154,7 @@ patch_jump_insn (rtx insn, rtx old_label, basic_block new_bb)
       int j;
       rtx new_label = block_label (new_bb);
 
-      if (new_bb == EXIT_BLOCK_PTR)
+      if (new_bb == cfun->cfg->get_exit_block ())
 	return false;
       if (GET_CODE (PATTERN (tmp)) == ADDR_VEC)
 	vec = XVEC (PATTERN (tmp), 0);
@@ -1187,7 +1187,7 @@ patch_jump_insn (rtx insn, rtx old_label, basic_block new_bb)
       int i, n = ASM_OPERANDS_LABEL_LENGTH (tmp);
       rtx new_label, note;
 
-      if (new_bb == EXIT_BLOCK_PTR)
+      if (new_bb == cfun->cfg->get_exit_block ())
 	return false;
       new_label = block_label (new_bb);
 
@@ -1244,7 +1244,7 @@ patch_jump_insn (rtx insn, rtx old_label, basic_block new_bb)
 	     target is exit block on some arches.  */
 	  if (!redirect_jump (insn, block_label (new_bb), 0))
 	    {
-	      gcc_assert (new_bb == EXIT_BLOCK_PTR);
+	      gcc_assert (new_bb == cfun->cfg->get_exit_block ());
 	      return false;
 	    }
 	}
@@ -1347,7 +1347,7 @@ force_nonfallthru_and_redirect (edge e, basic_block target, rtx jump_label)
   /* In the case the last instruction is conditional jump to the next
      instruction, first redirect the jump itself and then continue
      by creating a basic block afterwards to redirect fallthru edge.  */
-  if (e->src != ENTRY_BLOCK_PTR && e->dest != EXIT_BLOCK_PTR
+  if (e->src != cfun->cfg->get_entry_block () && e->dest != cfun->cfg->get_exit_block ()
       && any_condjump_p (BB_END (e->src))
       && JUMP_LABEL (BB_END (e->src)) == BB_HEAD (e->dest))
     {
@@ -1389,7 +1389,7 @@ force_nonfallthru_and_redirect (edge e, basic_block target, rtx jump_label)
   else
     {
       gcc_assert (e->flags & EDGE_FALLTHRU);
-      if (e->src == ENTRY_BLOCK_PTR)
+      if (e->src == cfun->cfg->get_entry_block ())
 	{
 	  /* We can't redirect the entry block.  Create an empty block
 	     at the start of the function which we use to add the new
@@ -1398,16 +1398,16 @@ force_nonfallthru_and_redirect (edge e, basic_block target, rtx jump_label)
 	  edge_iterator ei;
 	  bool found = false;
 
-	  basic_block bb = create_basic_block (BB_HEAD (e->dest), NULL, ENTRY_BLOCK_PTR);
+	  basic_block bb = create_basic_block (BB_HEAD (e->dest), NULL, cfun->cfg->get_entry_block ());
 
 	  /* Change the existing edge's source to be the new block, and add
 	     a new edge from the entry block to the new block.  */
 	  e->src = bb;
-	  for (ei = ei_start (ENTRY_BLOCK_PTR->succs); (tmp = ei_safe_edge (ei)); )
+	  for (ei = ei_start (cfun->cfg->get_entry_block ()->succs); (tmp = ei_safe_edge (ei)); )
 	    {
 	      if (tmp == e)
 		{
-		  ENTRY_BLOCK_PTR->succs->unordered_remove (ei.index);
+		  cfun->cfg->get_entry_block ()->succs->unordered_remove (ei.index);
 		  found = true;
 		  break;
 		}
@@ -1418,14 +1418,14 @@ force_nonfallthru_and_redirect (edge e, basic_block target, rtx jump_label)
 	  gcc_assert (found);
 
 	  vec_safe_push (bb->succs, e);
-	  make_single_succ_edge (ENTRY_BLOCK_PTR, bb, EDGE_FALLTHRU);
+	  make_single_succ_edge (cfun->cfg->get_entry_block (), bb, EDGE_FALLTHRU);
 	}
     }
 
   /* If e->src ends with asm goto, see if any of the ASM_OPERANDS_LABELs
      don't point to the target or fallthru label.  */
   if (JUMP_P (BB_END (e->src))
-      && target != EXIT_BLOCK_PTR
+      && target != cfun->cfg->get_exit_block ()
       && (e->flags & EDGE_FALLTHRU)
       && (note = extract_asm_operands (PATTERN (BB_END (e->src)))))
     {
@@ -1529,7 +1529,7 @@ force_nonfallthru_and_redirect (edge e, basic_block target, rtx jump_label)
 
   loc = e->goto_locus;
   e->flags &= ~EDGE_FALLTHRU;
-  if (target == EXIT_BLOCK_PTR)
+  if (target == cfun->cfg->get_exit_block ())
     {
       if (jump_label == ret_rtx)
 	{
@@ -1681,14 +1681,14 @@ rtl_split_edge (edge edge_in)
     }
 
   /* Create the basic block note.  */
-  if (edge_in->dest != EXIT_BLOCK_PTR)
+  if (edge_in->dest != cfun->cfg->get_exit_block ())
     before = BB_HEAD (edge_in->dest);
   else
     before = NULL_RTX;
 
   /* If this is a fall through edge to the exit block, the blocks might be
      not adjacent, and the right place is after the source.  */
-  if ((edge_in->flags & EDGE_FALLTHRU) && edge_in->dest == EXIT_BLOCK_PTR)
+  if ((edge_in->flags & EDGE_FALLTHRU) && edge_in->dest == cfun->cfg->get_exit_block ())
     {
       before = NEXT_INSN (BB_END (edge_in->src));
       bb = create_basic_block (before, NULL, edge_in->src);
@@ -1712,7 +1712,7 @@ rtl_split_edge (edge edge_in)
     }
   else
     {
-      if (edge_in->src != ENTRY_BLOCK_PTR)
+      if (edge_in->src != cfun->cfg->get_entry_block ())
 	{
 	  /* For asm goto even splitting of fallthru edge might
 	     need insn patching, as other labels might point to the
@@ -1720,7 +1720,7 @@ rtl_split_edge (edge edge_in)
 	  rtx last = BB_END (edge_in->src);
 	  if (last
 	      && JUMP_P (last)
-	      && edge_in->dest != EXIT_BLOCK_PTR
+	      && edge_in->dest != cfun->cfg->get_exit_block ()
 	      && extract_asm_operands (PATTERN (last)) != NULL_RTX
 	      && patch_jump_insn (last, before, bb))
 	    df_set_bb_dirty (edge_in->src);
@@ -1767,7 +1767,7 @@ commit_one_edge_insertion (edge e)
 
   /* Figure out where to put these insns.  If the destination has
      one predecessor, insert there.  Except for the exit block.  */
-  if (single_pred_p (e->dest) && e->dest != EXIT_BLOCK_PTR)
+  if (single_pred_p (e->dest) && e->dest != cfun->cfg->get_exit_block ())
     {
       bb = e->dest;
 
@@ -1790,7 +1790,7 @@ commit_one_edge_insertion (edge e)
      insert there.  Except for the entry block.  */
   else if ((e->flags & EDGE_ABNORMAL) == 0
 	   && single_succ_p (e->src)
-	   && e->src != ENTRY_BLOCK_PTR)
+	   && e->src != cfun->cfg->get_entry_block ())
     {
       bb = e->src;
 
@@ -1819,7 +1819,7 @@ commit_one_edge_insertion (edge e)
 
       if (flag_reorder_blocks_and_partition
 	  && targetm_common.have_named_sections
-	  && e->src != ENTRY_BLOCK_PTR
+	  && e->src != cfun->cfg->get_entry_block ()
 	  && BB_PARTITION (e->src) == BB_COLD_PARTITION
 	  && !(e->flags & EDGE_CROSSING)
 	  && JUMP_P (after)
@@ -1845,7 +1845,7 @@ commit_one_edge_insertion (edge e)
 	 to EXIT.  */
 
       e = single_succ_edge (bb);
-      gcc_assert (e->dest == EXIT_BLOCK_PTR
+      gcc_assert (e->dest == cfun->cfg->get_exit_block ()
 		  && single_succ_p (bb) && (e->flags & EDGE_FALLTHRU));
 
       e->flags &= ~EDGE_FALLTHRU;
@@ -1869,7 +1869,7 @@ commit_edge_insertions (void)
   verify_flow_info ();
 #endif
 
-  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
+  FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block (), cfun->cfg->get_exit_block (), next_bb)
     {
       edge e;
       edge_iterator ei;
@@ -1954,7 +1954,7 @@ print_rtl_with_bb (FILE *outf, const_rtx rtx_first, int flags)
 
       if (flags & TDF_BLOCKS)
 	{
-	  FOR_EACH_BB_REVERSE (bb)
+	  FOR_EACH_BB_REVERSE_CFG (bb, cfun->cfg)
 	    {
 	      rtx x;
 
@@ -2074,7 +2074,7 @@ verify_hot_cold_block_grouping (void)
   if (!crtl->bb_reorder_complete)
     return err;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       if (current_partition != BB_UNPARTITIONED
           && BB_PARTITION (bb) != current_partition)
@@ -2109,7 +2109,7 @@ rtl_verify_edges (void)
   int err = 0;
   basic_block bb;
 
-  FOR_EACH_BB_REVERSE (bb)
+  FOR_EACH_BB_REVERSE_CFG (bb, cfun->cfg)
     {
       int n_fallthru = 0, n_branch = 0, n_abnormal_call = 0, n_sibcall = 0;
       int n_eh = 0, n_abnormal = 0;
@@ -2123,7 +2123,7 @@ rtl_verify_edges (void)
 	  && any_condjump_p (BB_END (bb)))
 	{
 	  if (INTVAL (XEXP (note, 0)) != BRANCH_EDGE (bb)->probability
-	      && profile_status != PROFILE_ABSENT)
+	      && cfun->cfg->get_profile_status () != PROFILE_ABSENT)
 	    {
 	      error ("verify_flow_info: REG_BR_PROB does not match cfg %wi %i",
 		     INTVAL (XEXP (note, 0)), BRANCH_EDGE (bb)->probability);
@@ -2139,8 +2139,8 @@ rtl_verify_edges (void)
 	    n_fallthru++, fallthru = e;
 
 	  is_crossing = (BB_PARTITION (e->src) != BB_PARTITION (e->dest)
-			 && e->src != ENTRY_BLOCK_PTR
-			 && e->dest != EXIT_BLOCK_PTR);
+			 && e->src != cfun->cfg->get_entry_block ()
+			 && e->dest != cfun->cfg->get_exit_block ());
 	  if (e->flags & EDGE_CROSSING)
 	    {
 	      if (!is_crossing)
@@ -2261,7 +2261,7 @@ rtl_verify_bb_insns (void)
   int err = 0;
   basic_block bb;
 
-  FOR_EACH_BB_REVERSE (bb)
+  FOR_EACH_BB_REVERSE_CFG (bb, cfun->cfg)
     {
       /* Now check the header of basic
 	 block.  It ought to contain optional CODE_LABEL followed
@@ -2324,7 +2324,7 @@ rtl_verify_bb_pointers (void)
   basic_block bb;
 
   /* Check the general integrity of the basic blocks.  */
-  FOR_EACH_BB_REVERSE (bb)
+  FOR_EACH_BB_REVERSE_CFG (bb, cfun->cfg)
     {
       rtx insn;
 
@@ -2416,7 +2416,7 @@ rtl_verify_bb_insn_chain (void)
 
   bb_info = XCNEWVEC (basic_block, max_uid);
 
-  FOR_EACH_BB_REVERSE (bb)
+  FOR_EACH_BB_REVERSE_CFG (bb, cfun->cfg)
     {
       rtx head = BB_HEAD (bb);
       rtx end = BB_END (bb);
@@ -2498,7 +2498,7 @@ rtl_verify_fallthru (void)
   basic_block bb;
   int err = 0;
 
-  FOR_EACH_BB_REVERSE (bb)
+  FOR_EACH_BB_REVERSE_CFG (bb, cfun->cfg)
     {
       edge e;
 
@@ -2520,8 +2520,8 @@ rtl_verify_fallthru (void)
 		break;
 	    }
 	}
-      else if (e->src != ENTRY_BLOCK_PTR
-	       && e->dest != EXIT_BLOCK_PTR)
+      else if (e->src != cfun->cfg->get_entry_block ()
+	       && e->dest != cfun->cfg->get_exit_block ())
 	{
 	  rtx insn;
 
@@ -2560,10 +2560,10 @@ rtl_verify_bb_layout (void)
   rtx x;
   int num_bb_notes;
   const rtx rtx_first = get_insns ();
-  basic_block last_bb_seen = ENTRY_BLOCK_PTR, curr_bb = NULL;
+  basic_block last_bb_seen = cfun->cfg->get_entry_block (), curr_bb = NULL;
 
   num_bb_notes = 0;
-  last_bb_seen = ENTRY_BLOCK_PTR;
+  last_bb_seen = cfun->cfg->get_entry_block ();
 
   for (x = rtx_first; x; x = NEXT_INSN (x))
     {
@@ -2609,10 +2609,10 @@ rtl_verify_bb_layout (void)
 	curr_bb = NULL;
     }
 
-  if (num_bb_notes != n_basic_blocks - NUM_FIXED_BLOCKS)
+  if (num_bb_notes != cfun->cfg->get_n_basic_blocks () - NUM_FIXED_BLOCKS)
     internal_error
-      ("number of bb notes in insn chain (%d) != n_basic_blocks (%d)",
-       num_bb_notes, n_basic_blocks);
+      ("number of bb notes in insn chain (%d) != cfun->cfg->get_n_basic_blocks () (%d)",
+       num_bb_notes, cfun->cfg->get_n_basic_blocks ());
 
    return err;
 }
@@ -2747,7 +2747,7 @@ purge_dead_edges (basic_block bb)
 	      ei_next (&ei);
 	      continue;
 	    }
-	  else if (e->dest != EXIT_BLOCK_PTR
+	  else if (e->dest != cfun->cfg->get_exit_block ()
 		   && BB_HEAD (e->dest) == JUMP_LABEL (insn))
 	    /* If the destination block is the target of the jump,
 	       keep the edge.  */
@@ -2755,7 +2755,7 @@ purge_dead_edges (basic_block bb)
 	      ei_next (&ei);
 	      continue;
 	    }
-	  else if (e->dest == EXIT_BLOCK_PTR && returnjump_p (insn))
+	  else if (e->dest == cfun->cfg->get_exit_block () && returnjump_p (insn))
 	    /* If the destination block is the exit block, and this
 	       instruction is a return, then keep the edge.  */
 	    {
@@ -2874,7 +2874,7 @@ purge_all_dead_edges (void)
   int purged = false;
   basic_block bb;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       bool purged_here = purge_dead_edges (bb);
 
@@ -2899,7 +2899,7 @@ fixup_abnormal_edges (void)
   bool inserted = false;
   basic_block bb;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       edge e;
       edge_iterator ei;
@@ -3004,7 +3004,7 @@ skip_insns_after_block (basic_block bb)
   rtx insn, last_insn, next_head, prev;
 
   next_head = NULL_RTX;
-  if (bb->next_bb != EXIT_BLOCK_PTR)
+  if (bb->next_bb != cfun->cfg->get_exit_block ())
     next_head = BB_HEAD (bb->next_bb);
 
   for (last_insn = insn = BB_END (bb); (insn = NEXT_INSN (insn)) != 0; )
@@ -3122,7 +3122,7 @@ record_effective_endpoints (void)
     cfg_layout_function_header = NULL_RTX;
 
   next_insn = get_insns ();
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       rtx end;
 
@@ -3152,8 +3152,8 @@ outof_cfg_layout_mode (void)
 {
   basic_block bb;
 
-  FOR_EACH_BB (bb)
-    if (bb->next_bb != EXIT_BLOCK_PTR)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
+    if (bb->next_bb != cfun->cfg->get_exit_block ())
       bb->aux = bb->next_bb;
 
   cfg_layout_finalize ();
@@ -3228,7 +3228,7 @@ relink_block_chain (bool stay_in_cfglayout_mode)
   if (dump_file)
     {
       fprintf (dump_file, "Reordered sequence:\n");
-      for (bb = ENTRY_BLOCK_PTR->next_bb, index = NUM_FIXED_BLOCKS;
+      for (bb = cfun->cfg->get_entry_block ()->next_bb, index = NUM_FIXED_BLOCKS;
 	   bb;
 	   bb = (basic_block) bb->aux, index++)
 	{
@@ -3246,18 +3246,18 @@ relink_block_chain (bool stay_in_cfglayout_mode)
     }
 
   /* Now reorder the blocks.  */
-  prev_bb = ENTRY_BLOCK_PTR;
-  bb = ENTRY_BLOCK_PTR->next_bb;
+  prev_bb = cfun->cfg->get_entry_block ();
+  bb = cfun->cfg->get_entry_block ()->next_bb;
   for (; bb; prev_bb = bb, bb = (basic_block) bb->aux)
     {
       bb->prev_bb = prev_bb;
       prev_bb->next_bb = bb;
     }
-  prev_bb->next_bb = EXIT_BLOCK_PTR;
-  EXIT_BLOCK_PTR->prev_bb = prev_bb;
+  prev_bb->next_bb = cfun->cfg->get_exit_block ();
+  cfun->cfg->get_exit_block ()->prev_bb = prev_bb;
 
   /* Then, clean up the aux fields.  */
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       bb->aux = NULL;
       if (!stay_in_cfglayout_mode)
@@ -3295,7 +3295,7 @@ fixup_reorder_chain (void)
   /* First do the bulk reordering -- rechain the blocks without regard to
      the needed changes to jumps and labels.  */
 
-  for (bb = ENTRY_BLOCK_PTR->next_bb; bb; bb = (basic_block) bb->aux)
+  for (bb = cfun->cfg->get_entry_block ()->next_bb; bb; bb = (basic_block) bb->aux)
     {
       if (BB_HEADER (bb))
 	{
@@ -3338,7 +3338,7 @@ fixup_reorder_chain (void)
   /* Now add jumps and labels as needed to match the blocks new
      outgoing edges.  */
 
-  for (bb = ENTRY_BLOCK_PTR->next_bb; bb ; bb = (basic_block) bb->aux)
+  for (bb = cfun->cfg->get_entry_block ()->next_bb; bb ; bb = (basic_block) bb->aux)
     {
       edge e_fall, e_taken, e;
       rtx bb_end_insn;
@@ -3379,7 +3379,7 @@ fixup_reorder_chain (void)
 
 	      /* If the old fallthru is still next, nothing to do.  */
 	      if (bb->aux == e_fall->dest
-		  || e_fall->dest == EXIT_BLOCK_PTR)
+		  || e_fall->dest == cfun->cfg->get_exit_block ())
 		continue;
 
 	      /* The degenerated case of conditional jump jumping to the next
@@ -3400,7 +3400,7 @@ fixup_reorder_chain (void)
 		  if (note
 		      && INTVAL (XEXP (note, 0)) < REG_BR_PROB_BASE / 2
 		      && invert_jump (bb_end_insn,
-				      (e_fall->dest == EXIT_BLOCK_PTR
+				      (e_fall->dest == cfun->cfg->get_exit_block ()
 				       ? NULL_RTX
 				       : label_for_bb (e_fall->dest)), 0))
 		    {
@@ -3422,7 +3422,7 @@ fixup_reorder_chain (void)
 	      /* Otherwise we can try to invert the jump.  This will
 		 basically never fail, however, keep up the pretense.  */
 	      else if (invert_jump (bb_end_insn,
-				    (e_fall->dest == EXIT_BLOCK_PTR
+				    (e_fall->dest == cfun->cfg->get_exit_block ()
 				     ? NULL_RTX
 				     : label_for_bb (e_fall->dest)), 0))
 		{
@@ -3444,7 +3444,7 @@ fixup_reorder_chain (void)
 		 __builtin_unreachable ()), nothing to do.  */
 	      if (! e_fall
 		  || bb->aux == e_fall->dest
-		  || e_fall->dest == EXIT_BLOCK_PTR)
+		  || e_fall->dest == cfun->cfg->get_exit_block ())
 		continue;
 
 	      /* Otherwise we'll have to use the fallthru fixup below.  */
@@ -3471,7 +3471,7 @@ fixup_reorder_chain (void)
 	    continue;
 
 	  /* A fallthru to exit block.  */
-	  if (e_fall->dest == EXIT_BLOCK_PTR)
+	  if (e_fall->dest == cfun->cfg->get_exit_block ())
 	    continue;
 	}
 
@@ -3503,7 +3503,7 @@ fixup_reorder_chain (void)
   relink_block_chain (/*stay_in_cfglayout_mode=*/false);
 
   /* Annoying special case - jump around dead jumptables left in the code.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       edge e = find_fallthru_edge (bb->succs);
 
@@ -3514,7 +3514,7 @@ fixup_reorder_chain (void)
   /* Ensure goto_locus from edges has some instructions with that locus
      in RTL.  */
   if (!optimize)
-    FOR_EACH_BB (bb)
+    FOR_EACH_BB_CFG (bb, cfun->cfg)
       {
         edge e;
         edge_iterator ei;
@@ -3543,7 +3543,7 @@ fixup_reorder_chain (void)
 		  continue;
 		}
 	      dest = e->dest;
-	      if (dest == EXIT_BLOCK_PTR)
+	      if (dest == cfun->cfg->get_exit_block ())
 		{
 		  /* Non-fallthru edges to the exit block cannot be split.  */
 		  if (!(e->flags & EDGE_FALLTHRU))
@@ -3621,13 +3621,13 @@ fixup_fallthru_exit_predecessor (void)
      value.  */
   gcc_assert (reload_completed);
 
-  e = find_fallthru_edge (EXIT_BLOCK_PTR->preds);
+  e = find_fallthru_edge (cfun->cfg->get_exit_block ()->preds);
   if (e)
     bb = e->src;
 
   if (bb && bb->aux)
     {
-      basic_block c = ENTRY_BLOCK_PTR->next_bb;
+      basic_block c = cfun->cfg->get_entry_block ()->next_bb;
 
       /* If the very first block is the one with the fall-through exit
 	 edge, we have to split that block.  */
@@ -3663,7 +3663,7 @@ force_one_exit_fallthru (void)
   edge_iterator ei;
   basic_block forwarder, bb;
 
-  FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
+  FOR_EACH_EDGE (e, ei, cfun->cfg->get_exit_block ()->preds)
     if (e->flags & EDGE_FALLTHRU)
       {
 	if (predecessor == NULL)
@@ -3681,7 +3681,7 @@ force_one_exit_fallthru (void)
   /* Exit has several fallthru predecessors.  Create a forwarder block for
      them.  */
   forwarder = split_edge (predecessor);
-  for (ei = ei_start (EXIT_BLOCK_PTR->preds); (e = ei_safe_edge (ei)); )
+  for (ei = ei_start (cfun->cfg->get_exit_block ()->preds); (e = ei_safe_edge (ei)); )
     {
       if (e->src == forwarder
 	  || !(e->flags & EDGE_FALLTHRU))
@@ -3692,7 +3692,7 @@ force_one_exit_fallthru (void)
 
   /* Fix up the chain of blocks -- make FORWARDER immediately precede the
      exit block.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       if (bb->aux == NULL && bb != forwarder)
 	{
@@ -3828,7 +3828,7 @@ cfg_layout_duplicate_bb (basic_block bb)
   insn = duplicate_insn_chain (BB_HEAD (bb), BB_END (bb));
   new_bb = create_basic_block (insn,
 			       insn ? get_last_insn () : NULL,
-			       EXIT_BLOCK_PTR->prev_bb);
+			       cfun->cfg->get_exit_block ()->prev_bb);
 
   BB_COPY_PARTITION (new_bb, bb);
   if (BB_HEADER (bb))
@@ -3890,10 +3890,10 @@ break_superblocks (void)
   bool need = false;
   basic_block bb;
 
-  superblocks = sbitmap_alloc (last_basic_block);
+  superblocks = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
   bitmap_clear (superblocks);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     if (bb->flags & BB_SUPERBLOCK)
       {
 	bb->flags &= ~BB_SUPERBLOCK;
@@ -3966,14 +3966,14 @@ cfg_layout_redirect_edge_and_branch (edge e, basic_block dest)
   if (e->dest == dest)
     return e;
 
-  if (e->src != ENTRY_BLOCK_PTR
+  if (e->src != cfun->cfg->get_entry_block ()
       && (ret = try_redirect_by_replacing_jump (e, dest, true)))
     {
       df_set_bb_dirty (src);
       return ret;
     }
 
-  if (e->src == ENTRY_BLOCK_PTR
+  if (e->src == cfun->cfg->get_entry_block ()
       && (e->flags & EDGE_FALLTHRU) && !(e->flags & EDGE_COMPLEX))
     {
       if (dump_file)
@@ -4100,7 +4100,7 @@ cfg_layout_delete_block (basic_block bb)
 	    set_last_insn (insn);
 	}
     }
-  if (bb->next_bb != EXIT_BLOCK_PTR)
+  if (bb->next_bb != cfun->cfg->get_exit_block ())
     to = &BB_HEADER (bb->next_bb);
   else
     to = &cfg_layout_function_footer;
@@ -4157,7 +4157,7 @@ cfg_layout_can_merge_blocks_p (basic_block a, basic_block b)
   if (NEXT_INSN (BB_END (a)) != BB_HEAD (b))
     {
       edge e = find_fallthru_edge (b->succs);
-      if (e && e->dest == EXIT_BLOCK_PTR)
+      if (e && e->dest == cfun->cfg->get_exit_block ())
 	return false;
     }
 
@@ -4168,7 +4168,7 @@ cfg_layout_can_merge_blocks_p (basic_block a, basic_block b)
 	  && a != b
 	  /* Must be simple edge.  */
 	  && !(single_succ_edge (a)->flags & EDGE_COMPLEX)
-	  && a != ENTRY_BLOCK_PTR && b != EXIT_BLOCK_PTR
+	  && a != cfun->cfg->get_entry_block () && b != cfun->cfg->get_exit_block ()
 	  /* If the jump insn has side effects, we can't kill the edge.
 	     When not optimizing, try_redirect_by_replacing_jump will
 	     not allow us to redirect an edge by replacing a table jump.  */
@@ -4287,11 +4287,11 @@ static basic_block
 cfg_layout_split_edge (edge e)
 {
   basic_block new_bb =
-    create_basic_block (e->src != ENTRY_BLOCK_PTR
+    create_basic_block (e->src != cfun->cfg->get_entry_block ()
 			? NEXT_INSN (BB_END (e->src)) : get_insns (),
 			NULL_RTX, e->src);
 
-  if (e->dest == EXIT_BLOCK_PTR)
+  if (e->dest == cfun->cfg->get_exit_block ())
     BB_COPY_PARTITION (new_bb, e->src);
   else
     BB_COPY_PARTITION (new_bb, e->dest);
@@ -4316,7 +4316,7 @@ rtl_block_empty_p (basic_block bb)
 {
   rtx insn;
 
-  if (bb == ENTRY_BLOCK_PTR || bb == EXIT_BLOCK_PTR)
+  if (bb == cfun->cfg->get_entry_block () || bb == cfun->cfg->get_exit_block ())
     return true;
 
   FOR_BB_INSNS (bb, insn)
@@ -4414,16 +4414,16 @@ rtl_flow_call_edges_add (sbitmap blocks)
 {
   int i;
   int blocks_split = 0;
-  int last_bb = last_basic_block;
+  int last_bb = cfun->cfg->get_last_basic_block ();
   bool check_last_block = false;
 
-  if (n_basic_blocks == NUM_FIXED_BLOCKS)
+  if (cfun->cfg->get_n_basic_blocks () == NUM_FIXED_BLOCKS)
     return 0;
 
   if (! blocks)
     check_last_block = true;
   else
-    check_last_block = bitmap_bit_p (blocks, EXIT_BLOCK_PTR->prev_bb->index);
+    check_last_block = bitmap_bit_p (blocks, cfun->cfg->get_exit_block ()->prev_bb->index);
 
   /* In the last basic block, before epilogue generation, there will be
      a fallthru edge to EXIT.  Special care is required if the last insn
@@ -4439,7 +4439,7 @@ rtl_flow_call_edges_add (sbitmap blocks)
      Handle this by adding a dummy instruction in a new last basic block.  */
   if (check_last_block)
     {
-      basic_block bb = EXIT_BLOCK_PTR->prev_bb;
+      basic_block bb = cfun->cfg->get_exit_block ()->prev_bb;
       rtx insn = BB_END (bb);
 
       /* Back up past insns that must be kept in the same block as a call.  */
@@ -4451,7 +4451,7 @@ rtl_flow_call_edges_add (sbitmap blocks)
 	{
 	  edge e;
 
-	  e = find_edge (bb, EXIT_BLOCK_PTR);
+	  e = find_edge (bb, cfun->cfg->get_exit_block ());
 	  if (e)
 	    {
 	      insert_insn_on_edge (gen_use (const0_rtx), e);
@@ -4466,7 +4466,7 @@ rtl_flow_call_edges_add (sbitmap blocks)
 
   for (i = NUM_FIXED_BLOCKS; i < last_bb; i++)
     {
-      basic_block bb = BASIC_BLOCK (i);
+      basic_block bb = cfun->cfg->get_basic_block_by_idx (i);
       rtx insn;
       rtx prev_insn;
 
@@ -4499,7 +4499,7 @@ rtl_flow_call_edges_add (sbitmap blocks)
 #ifdef ENABLE_CHECKING
 	      if (split_at_insn == BB_END (bb))
 		{
-		  e = find_edge (bb, EXIT_BLOCK_PTR);
+		  e = find_edge (bb, cfun->cfg->get_exit_block ());
 		  gcc_assert (e == NULL);
 		}
 #endif
@@ -4513,7 +4513,7 @@ rtl_flow_call_edges_add (sbitmap blocks)
 		    blocks_split++;
 		}
 
-	      make_edge (bb, EXIT_BLOCK_PTR, EDGE_FAKE);
+	      make_edge (bb, cfun->cfg->get_exit_block (), EDGE_FAKE);
 	    }
 
 	  if (insn == BB_HEAD (bb))
@@ -4605,7 +4605,7 @@ rtl_can_remove_branch_p (const_edge e)
   const_rtx insn = BB_END (src), set;
 
   /* The conditions are taken from try_redirect_by_replacing_jump.  */
-  if (target == EXIT_BLOCK_PTR)
+  if (target == cfun->cfg->get_exit_block ())
     return false;
 
   if (e->flags & (EDGE_ABNORMAL_CALL | EDGE_EH))
@@ -4647,10 +4647,10 @@ rtl_account_profile_record (basic_block bb, int after_pass,
       {
 	record->size[after_pass]
 	  += insn_rtx_cost (PATTERN (insn), false);
-	if (profile_status == PROFILE_READ)
+	if (cfun->cfg->get_profile_status () == PROFILE_READ)
 	  record->time[after_pass]
 	    += insn_rtx_cost (PATTERN (insn), true) * bb->count;
-	else if (profile_status == PROFILE_GUESSED)
+	else if (cfun->cfg->get_profile_status () == PROFILE_GUESSED)
 	  record->time[after_pass]
 	    += insn_rtx_cost (PATTERN (insn), true) * bb->frequency;
       }
diff --git a/gcc/cgraphbuild.c b/gcc/cgraphbuild.c
index fb1515d..a79c9b0 100644
--- a/gcc/cgraphbuild.c
+++ b/gcc/cgraphbuild.c
@@ -311,7 +311,7 @@ build_cgraph_edges (void)
 
   /* Create the callgraph edges and record the nodes referenced by the function.
      body.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	{
@@ -421,9 +421,9 @@ rebuild_cgraph_edges (void)
   cgraph_node_remove_callees (node);
   ipa_remove_all_references (&node->symbol.ref_list);
 
-  node->count = ENTRY_BLOCK_PTR->count;
+  node->count = cfun->cfg->get_entry_block ()->count;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	{
@@ -466,9 +466,9 @@ cgraph_rebuild_references (void)
 
   ipa_remove_all_references (&node->symbol.ref_list);
 
-  node->count = ENTRY_BLOCK_PTR->count;
+  node->count = cfun->cfg->get_entry_block ()->count;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	ipa_record_stmt_references (node, gsi_stmt (gsi));
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 6ebf8d4..837575c 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -1271,9 +1271,9 @@ init_lowered_empty_function (tree decl, bool in_ssa)
     (PROP_gimple_lcf | PROP_gimple_leh | PROP_cfg | PROP_ssa | PROP_gimple_any);
 
   /* Create BB for body of the function and connect it properly.  */
-  bb = create_basic_block (NULL, (void *) 0, ENTRY_BLOCK_PTR);
-  make_edge (ENTRY_BLOCK_PTR, bb, 0);
-  make_edge (bb, EXIT_BLOCK_PTR, 0);
+  bb = create_basic_block (NULL, (void *) 0, cfun->cfg->get_entry_block ());
+  make_edge (cfun->cfg->get_entry_block (), bb, 0);
+  make_edge (bb, cfun->cfg->get_exit_block (), 0);
 
   return bb;
 }
@@ -1526,7 +1526,7 @@ assemble_thunk (struct cgraph_node *node)
 	      gsi_insert_after (&bsi, stmt, GSI_NEW_STMT);
 	      make_edge (bb, then_bb, EDGE_TRUE_VALUE);
 	      make_edge (bb, else_bb, EDGE_FALSE_VALUE);
-	      make_edge (return_bb, EXIT_BLOCK_PTR, 0);
+	      make_edge (return_bb, cfun->cfg->get_exit_block (), 0);
 	      make_edge (then_bb, return_bb, EDGE_FALLTHRU);
 	      make_edge (else_bb, return_bb, EDGE_FALLTHRU);
 	      bsi = gsi_last_bb (then_bb);
diff --git a/gcc/combine-stack-adj.c b/gcc/combine-stack-adj.c
index 7392b92..16fadc8 100644
--- a/gcc/combine-stack-adj.c
+++ b/gcc/combine-stack-adj.c
@@ -95,7 +95,7 @@ combine_stack_adjustments (void)
 {
   basic_block bb;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     combine_stack_adjustments_for_block (bb);
 }
 
diff --git a/gcc/combine.c b/gcc/combine.c
index b737bc5..9f79aeb 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -959,7 +959,7 @@ delete_noop_moves (void)
   rtx insn, next;
   basic_block bb;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       for (insn = BB_HEAD (bb); insn != NEXT_INSN (BB_END (bb)); insn = next)
 	{
@@ -996,7 +996,7 @@ create_log_links (void)
      usage -- these are taken from original flow.c did. Don't ask me why it is
      done this way; I don't know and if it works, I don't want to know.  */
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       FOR_BB_INSNS_REVERSE (bb, insn)
         {
@@ -1156,10 +1156,10 @@ combine_instructions (rtx f, unsigned int nregs)
   setup_incoming_promotions (first);
   /* Allow the entry block and the first block to fall into the same EBB.
      Conceptually the incoming promotions are assigned to the entry block.  */
-  last_bb = ENTRY_BLOCK_PTR;
+  last_bb = cfun->cfg->get_entry_block ();
 
   create_log_links ();
-  FOR_EACH_BB (this_basic_block)
+  FOR_EACH_BB_CFG (this_basic_block, cfun->cfg)
     {
       optimize_this_for_speed_p = optimize_bb_for_speed_p (this_basic_block);
       last_call_luid = 0;
@@ -1208,9 +1208,9 @@ combine_instructions (rtx f, unsigned int nregs)
   label_tick = label_tick_ebb_start = 1;
   init_reg_last ();
   setup_incoming_promotions (first);
-  last_bb = ENTRY_BLOCK_PTR;
+  last_bb = cfun->cfg->get_entry_block ();
 
-  FOR_EACH_BB (this_basic_block)
+  FOR_EACH_BB_CFG (this_basic_block, cfun->cfg)
     {
       rtx last_combined_insn = NULL_RTX;
       optimize_this_for_speed_p = optimize_bb_for_speed_p (this_basic_block);
@@ -1591,7 +1591,7 @@ set_nonzero_bits_and_sign_copies (rtx x, const_rtx set, void *data)
       /* If this register is undefined at the start of the file, we can't
 	 say what its contents were.  */
       && ! REGNO_REG_SET_P
-           (DF_LR_IN (ENTRY_BLOCK_PTR->next_bb), REGNO (x))
+           (DF_LR_IN (cfun->cfg->get_entry_block ()->next_bb), REGNO (x))
       && HWI_COMPUTABLE_MODE_P (GET_MODE (x)))
     {
       reg_stat_type *rsp = &reg_stat[REGNO (x)];
@@ -3924,7 +3924,7 @@ try_combine (rtx i3, rtx i2, rtx i1, rtx i0, int *new_direct_jump_p,
 	ni2dest = SET_DEST (newi2pat);
 
       for (insn = NEXT_INSN (i3);
-	   insn && (this_basic_block->next_bb == EXIT_BLOCK_PTR
+	   insn && (this_basic_block->next_bb == cfun->cfg->get_exit_block ()
 		    || insn != BB_HEAD (this_basic_block->next_bb));
 	   insn = NEXT_INSN (insn))
 	{
@@ -4040,7 +4040,7 @@ try_combine (rtx i3, rtx i2, rtx i1, rtx i0, int *new_direct_jump_p,
 	      && ! find_reg_note (i2, REG_UNUSED,
 				  SET_DEST (XVECEXP (PATTERN (i2), 0, i))))
 	    for (temp = NEXT_INSN (i2);
-		 temp && (this_basic_block->next_bb == EXIT_BLOCK_PTR
+		 temp && (this_basic_block->next_bb == cfun->cfg->get_exit_block ()
 			  || BB_HEAD (this_basic_block) != temp);
 		 temp = NEXT_INSN (temp))
 	      if (temp != i3 && INSN_P (temp))
@@ -9441,7 +9441,7 @@ reg_nonzero_bits_for_combine (const_rtx x, enum machine_mode mode,
 	  || (REGNO (x) >= FIRST_PSEUDO_REGISTER
 	      && REG_N_SETS (REGNO (x)) == 1
 	      && !REGNO_REG_SET_P
-	          (DF_LR_IN (ENTRY_BLOCK_PTR->next_bb), REGNO (x)))))
+	          (DF_LR_IN (cfun->cfg->get_entry_block ()->next_bb), REGNO (x)))))
     {
       *nonzero &= rsp->last_set_nonzero_bits;
       return NULL;
@@ -9508,7 +9508,7 @@ reg_num_sign_bit_copies_for_combine (const_rtx x, enum machine_mode mode,
 	  || (REGNO (x) >= FIRST_PSEUDO_REGISTER
 	      && REG_N_SETS (REGNO (x)) == 1
 	      && !REGNO_REG_SET_P
-	          (DF_LR_IN (ENTRY_BLOCK_PTR->next_bb), REGNO (x)))))
+	          (DF_LR_IN (cfun->cfg->get_entry_block ()->next_bb), REGNO (x)))))
     {
       *result = rsp->last_set_sign_bit_copies;
       return NULL;
@@ -12528,7 +12528,7 @@ get_last_value_validate (rtx *loc, rtx insn, int tick, int replace)
 	      || (! (regno >= FIRST_PSEUDO_REGISTER
 		     && REG_N_SETS (regno) == 1
 		     && (!REGNO_REG_SET_P
-			 (DF_LR_IN (ENTRY_BLOCK_PTR->next_bb), regno)))
+			 (DF_LR_IN (cfun->cfg->get_entry_block ()->next_bb), regno)))
 		  && rsp->last_set_label > tick))
 	  {
 	    if (replace)
@@ -12643,7 +12643,7 @@ get_last_value (const_rtx x)
 	  && (regno < FIRST_PSEUDO_REGISTER
 	      || REG_N_SETS (regno) != 1
 	      || REGNO_REG_SET_P
-		 (DF_LR_IN (ENTRY_BLOCK_PTR->next_bb), regno))))
+		 (DF_LR_IN (cfun->cfg->get_entry_block ()->next_bb), regno))))
     return 0;
 
   /* If the value was set in a later insn than the ones we are processing,
@@ -13702,7 +13702,7 @@ distribute_links (struct insn_link *links)
 	 since most links don't point very far away.  */
 
       for (insn = NEXT_INSN (link->insn);
-	   (insn && (this_basic_block->next_bb == EXIT_BLOCK_PTR
+	   (insn && (this_basic_block->next_bb == cfun->cfg->get_exit_block ()
 		     || BB_HEAD (this_basic_block->next_bb) != insn));
 	   insn = NEXT_INSN (insn))
 	if (DEBUG_INSN_P (insn))
diff --git a/gcc/compare-elim.c b/gcc/compare-elim.c
index 367cd8e..a27c180 100644
--- a/gcc/compare-elim.c
+++ b/gcc/compare-elim.c
@@ -412,7 +412,7 @@ find_comparisons (void)
   calculate_dominance_info (CDI_DOMINATORS);
 
   init_walk_dominator_tree (&data);
-  walk_dominator_tree (&data, ENTRY_BLOCK_PTR);
+  walk_dominator_tree (&data, cfun->cfg->get_entry_block ());
   fini_walk_dominator_tree (&data);
 
   clear_aux_for_blocks ();
diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c
index 096ef3b..7cf4daa 100644
--- a/gcc/config/alpha/alpha.c
+++ b/gcc/config/alpha/alpha.c
@@ -4827,7 +4827,7 @@ alpha_gp_save_rtx (void)
 	 label.  Emit the sequence properly on the edge.  We are only
 	 invoked from dw2_build_landing_pads and finish_eh_generation
 	 will call commit_edge_insertions thanks to a kludge.  */
-      insert_insn_on_edge (seq, single_succ_edge (ENTRY_BLOCK_PTR));
+      insert_insn_on_edge (seq, single_succ_edge (cfun->cfg->get_entry_block ()));
 
       cfun->machine->gp_save_rtx = m;
     }
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 43dfe27..f401d72 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -5504,7 +5504,7 @@ require_pic_register (void)
 	         we can't yet emit instructions directly in the final
 		 insn stream.  Queue the insns on the entry edge, they will
 		 be committed after everything else is expanded.  */
-	      insert_insn_on_edge (seq, single_succ_edge (ENTRY_BLOCK_PTR));
+	      insert_insn_on_edge (seq, single_succ_edge (cfun->cfg->get_entry_block ()));
 	    }
 	}
     }
@@ -14169,7 +14169,7 @@ thumb1_reorg (void)
 {
   basic_block bb;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       rtx set, dest, src;
       rtx pat, op0;
@@ -14233,7 +14233,7 @@ thumb2_reorg (void)
   compute_bb_for_insn ();
   df_analyze ();
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       rtx insn;
 
@@ -17595,7 +17595,7 @@ any_sibcall_could_use_r3 (void)
 
   if (!crtl->tail_call_emit)
     return false;
-  FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
+  FOR_EACH_EDGE (e, ei, cfun->cfg->get_exit_block ()->preds)
     if (e->flags & EDGE_SIBCALL)
       {
 	rtx call = BB_END (e->src);
diff --git a/gcc/config/bfin/bfin.c b/gcc/config/bfin/bfin.c
index 7fab975..b7e0bbe 100644
--- a/gcc/config/bfin/bfin.c
+++ b/gcc/config/bfin/bfin.c
@@ -3581,7 +3581,7 @@ hwloop_optimize (hwloop_info loop)
 
       if (single_pred_p (bb)
 	  && single_pred_edge (bb)->flags & EDGE_FALLTHRU
-	  && single_pred (bb) != ENTRY_BLOCK_PTR)
+	  && single_pred (bb) != cfun->cfg->get_entry_block ())
 	{
 	  bb = single_pred (bb);
 	  last_insn = BB_END (bb);
@@ -3938,7 +3938,7 @@ static void
 bfin_gen_bundles (void)
 {
   basic_block bb;
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       rtx insn, next;
       rtx slot[3];
@@ -4017,7 +4017,7 @@ static void
 reorder_var_tracking_notes (void)
 {
   basic_block bb;
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       rtx insn, next;
       rtx queue = NULL_RTX;
diff --git a/gcc/config/c6x/c6x.c b/gcc/config/c6x/c6x.c
index a7c3683..7f38003 100644
--- a/gcc/config/c6x/c6x.c
+++ b/gcc/config/c6x/c6x.c
@@ -4624,7 +4624,7 @@ c6x_gen_bundles (void)
   basic_block bb;
   rtx insn, next, last_call;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       rtx insn, next;
       /* The machine is eight insns wide.  We can have up to six shadow
@@ -5378,7 +5378,7 @@ conditionalize_after_sched (void)
 {
   basic_block bb;
   rtx insn;
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     FOR_BB_INSNS (bb, insn)
       {
 	unsigned uid = INSN_UID (insn);
@@ -5954,7 +5954,7 @@ c6x_reorg (void)
 
   if (c6x_flag_schedule_insns2)
     {
-      FOR_EACH_BB (bb)
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
 	if ((bb->flags & BB_DISABLE_SCHEDULE) == 0)
 	  assign_reservations (BB_HEAD (bb), BB_END (bb));
     }
diff --git a/gcc/config/epiphany/resolve-sw-modes.c b/gcc/config/epiphany/resolve-sw-modes.c
index 729a0ff..ec25c6f 100644
--- a/gcc/config/epiphany/resolve-sw-modes.c
+++ b/gcc/config/epiphany/resolve-sw-modes.c
@@ -61,15 +61,15 @@ resolve_sw_modes (void)
   bool need_commit = false;
   bool finalize_fp_sets = (MACHINE_FUNCTION (cfun)->unknown_mode_sets == 0);
 
-  todo.create (last_basic_block);
-  pushed = sbitmap_alloc (last_basic_block);
+  todo.create (cfun->cfg->get_last_basic_block ());
+  pushed = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
   bitmap_clear (pushed);
   if (!finalize_fp_sets)
     {
       df_note_add_problem ();
       df_analyze ();
     }
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     FOR_BB_INSNS (bb, insn)
       {
 	enum attr_fp_mode selected_mode;
diff --git a/gcc/config/frv/frv.c b/gcc/config/frv/frv.c
index b0e8c91..4c8c1ce 100644
--- a/gcc/config/frv/frv.c
+++ b/gcc/config/frv/frv.c
@@ -8024,7 +8024,7 @@ frv_optimize_membar_global (basic_block bb, struct frv_io *first_io,
   /* We need to keep the membar if there is an edge to the exit block.  */
   FOR_EACH_EDGE (succ, ei, bb->succs)
   /* for (succ = bb->succ; succ != 0; succ = succ->succ_next) */
-    if (succ->dest == EXIT_BLOCK_PTR)
+    if (succ->dest == cfun->cfg->get_exit_block ())
       return;
 
   /* Work out the union of all successor blocks.  */
@@ -8064,14 +8064,14 @@ frv_optimize_membar (void)
   rtx *last_membar;
 
   compute_bb_for_insn ();
-  first_io = XCNEWVEC (struct frv_io, last_basic_block);
-  last_membar = XCNEWVEC (rtx, last_basic_block);
+  first_io = XCNEWVEC (struct frv_io, cfun->cfg->get_last_basic_block ());
+  last_membar = XCNEWVEC (rtx, cfun->cfg->get_last_basic_block ());
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     frv_optimize_membar_local (bb, &first_io[bb->index],
 			       &last_membar[bb->index]);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     if (last_membar[bb->index] != 0)
       frv_optimize_membar_global (bb, first_io, last_membar[bb->index]);
 
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 20163b1..9dee40b 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -5313,7 +5313,7 @@ ix86_eax_live_at_start_p (void)
      to correct at this point.  This gives false positives for broken
      functions that might use uninitialized data that happens to be
      allocated in eax, but who cares?  */
-  return REGNO_REG_SET_P (df_get_live_out (ENTRY_BLOCK_PTR), 0);
+  return REGNO_REG_SET_P (df_get_live_out (cfun->cfg->get_entry_block ()), 0);
 }
 
 static bool
@@ -9008,7 +9008,7 @@ ix86_compute_frame_layout (struct ix86_frame *frame)
      Recompute the value as needed.  Do not recompute when amount of registers
      didn't change as reload does multiple calls to the function and does not
      expect the decision to change within single iteration.  */
-  else if (!optimize_bb_for_size_p (ENTRY_BLOCK_PTR)
+  else if (!optimize_bb_for_size_p (cfun->cfg->get_entry_block ())
            && cfun->machine->use_fast_prologue_epilogue_nregs != frame->nregs)
     {
       int count = frame->nregs;
@@ -10131,7 +10131,7 @@ ix86_finalize_stack_realign_flags (void)
       add_to_hard_reg_set (&set_up_by_prologue, Pmode, ARG_POINTER_REGNUM);
       add_to_hard_reg_set (&set_up_by_prologue, Pmode,
 			   HARD_FRAME_POINTER_REGNUM);
-      FOR_EACH_BB (bb)
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
         {
           rtx insn;
 	  FOR_BB_INSNS (bb, insn)
@@ -11076,7 +11076,7 @@ ix86_expand_epilogue (int style)
       /* Leave results in shorter dependency chains on CPUs that are
 	 able to grok it fast.  */
       else if (TARGET_USE_LEAVE
-	       || optimize_bb_for_size_p (EXIT_BLOCK_PTR)
+	       || optimize_bb_for_size_p (cfun->cfg->get_exit_block ())
 	       || !cfun->machine->use_fast_prologue_epilogue)
 	ix86_emit_leave ();
       else
@@ -28738,7 +28738,7 @@ add_condition_to_bb (tree function_decl, tree version_decl,
   make_edge (bb1, bb3, EDGE_FALSE_VALUE); 
 
   remove_edge (e23);
-  make_edge (bb2, EXIT_BLOCK_PTR, 0);
+  make_edge (bb2, cfun->cfg->get_exit_block (), 0);
 
   pop_cfun ();
 
@@ -35407,7 +35407,7 @@ ix86_pad_returns (void)
   edge e;
   edge_iterator ei;
 
-  FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
+  FOR_EACH_EDGE (e, ei, cfun->cfg->get_exit_block ()->preds)
     {
       basic_block bb = e->src;
       rtx ret = BB_END (bb);
@@ -35504,14 +35504,14 @@ ix86_count_insn (basic_block bb)
       edge prev_e;
       edge_iterator prev_ei;
 
-      if (e->src == ENTRY_BLOCK_PTR)
+      if (e->src == cfun->cfg->get_entry_block ())
 	{
 	  min_prev_count = 0;
 	  break;
 	}
       FOR_EACH_EDGE (prev_e, prev_ei, e->src->preds)
 	{
-	  if (prev_e->src == ENTRY_BLOCK_PTR)
+	  if (prev_e->src == cfun->cfg->get_entry_block ())
 	    {
 	      int count = ix86_count_insn_bb (e->src);
 	      if (count < min_prev_count)
@@ -35535,7 +35535,7 @@ ix86_pad_short_function (void)
   edge e;
   edge_iterator ei;
 
-  FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
+  FOR_EACH_EDGE (e, ei, cfun->cfg->get_exit_block ()->preds)
     {
       rtx ret = BB_END (e->src);
       if (JUMP_P (ret) && ANY_RETURN_P (PATTERN (ret)))
@@ -35575,7 +35575,7 @@ ix86_seh_fixup_eh_fallthru (void)
   edge e;
   edge_iterator ei;
 
-  FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
+  FOR_EACH_EDGE (e, ei, cfun->cfg->get_exit_block ()->preds)
     {
       rtx insn, next;
 
diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
index 144cf7e..9a34390 100644
--- a/gcc/config/ia64/ia64.c
+++ b/gcc/config/ia64/ia64.c
@@ -3469,7 +3469,7 @@ ia64_expand_prologue (void)
       edge e;
       edge_iterator ei;
 
-      FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
+      FOR_EACH_EDGE (e, ei, cfun->cfg->get_exit_block ()->preds)
 	if ((e->flags & EDGE_FAKE) == 0
 	    && (e->flags & EDGE_FALLTHRU) != 0)
 	  break;
@@ -9579,7 +9579,7 @@ emit_predicate_relation_info (void)
 {
   basic_block bb;
 
-  FOR_EACH_BB_REVERSE (bb)
+  FOR_EACH_BB_REVERSE_CFG (bb, cfun->cfg)
     {
       int r;
       rtx head = BB_HEAD (bb);
@@ -9607,7 +9607,7 @@ emit_predicate_relation_info (void)
      relations around them.  Otherwise the assembler will assume the call
      returns, and complain about uses of call-clobbered predicates after
      the call.  */
-  FOR_EACH_BB_REVERSE (bb)
+  FOR_EACH_BB_REVERSE_CFG (bb, cfun->cfg)
     {
       rtx insn = BB_HEAD (bb);
 
@@ -9654,7 +9654,7 @@ ia64_reorg (void)
 
       /* We can't let modulo-sched prevent us from scheduling any bbs,
 	 since we need the final schedule to produce bundle information.  */
-      FOR_EACH_BB (bb)
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
 	bb->flags &= ~BB_DISABLE_SCHEDULE;
 
       initiate_bundle_states ();
@@ -10164,7 +10164,7 @@ ia64_asm_unwind_emit (FILE *asm_out_file, rtx insn)
 
   if (NOTE_INSN_BASIC_BLOCK_P (insn))
     {
-      last_block = NOTE_BASIC_BLOCK (insn)->next_bb == EXIT_BLOCK_PTR;
+      last_block = NOTE_BASIC_BLOCK (insn)->next_bb == cfun->cfg->get_exit_block ();
 
       /* Restore unwind state from immediately before the epilogue.  */
       if (need_copy_state)
diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index 1f27746..27ca46f 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -14780,7 +14780,7 @@ r10k_simplify_address (rtx x, rtx insn)
 	      /* Replace the incoming value of $sp with
 		 virtual_incoming_args_rtx.  */
 	      if (x == stack_pointer_rtx
-		  && DF_REF_BB (def) == ENTRY_BLOCK_PTR)
+		  && DF_REF_BB (def) == cfun->cfg->get_entry_block ())
 		newx = virtual_incoming_args_rtx;
 	    }
 	  else if (dominated_by_p (CDI_DOMINATORS, DF_REF_BB (use),
@@ -15000,15 +15000,15 @@ r10k_insert_cache_barriers (void)
 
   /* Bit X of PROTECTED_BBS is set if the last operation in basic block
      X is protected by a cache barrier.  */
-  protected_bbs = sbitmap_alloc (last_basic_block);
+  protected_bbs = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
   bitmap_clear (protected_bbs);
 
   /* Iterate over the basic blocks in reverse post-order.  */
-  rev_post_order = XNEWVEC (int, last_basic_block);
+  rev_post_order = XNEWVEC (int, cfun->cfg->get_last_basic_block ());
   n = pre_and_rev_post_order_compute (NULL, rev_post_order, false);
   for (i = 0; i < n; i++)
     {
-      bb = BASIC_BLOCK (rev_post_order[i]);
+      bb = cfun->cfg->get_basic_block_by_idx (rev_post_order[i]);
 
       /* If this block is only reached by unconditional edges, and if the
 	 source of every edge is protected, the beginning of the block is
@@ -15261,7 +15261,7 @@ mips_annotate_pic_calls (void)
   basic_block bb;
   rtx insn;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     FOR_BB_INSNS (bb, insn)
     {
       rtx call, reg, symbol, second_call;
diff --git a/gcc/config/picochip/picochip.c b/gcc/config/picochip/picochip.c
index e5d30c6..1bd6b43 100644
--- a/gcc/config/picochip/picochip.c
+++ b/gcc/config/picochip/picochip.c
@@ -3169,7 +3169,7 @@ reorder_var_tracking_notes (void)
 {
   basic_block bb;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       rtx insn, next, last_insn = NULL_RTX;
       rtx queue = NULL_RTX;
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 7963bf4..0b6c469 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -14583,7 +14583,7 @@ rs6000_alloc_sdmode_stack_slot (void)
   if (TARGET_NO_SDMODE_STACK)
     return;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
       {
 	tree ret = walk_gimple_op (gsi_stmt (gsi), rs6000_check_sdmode, NULL);
@@ -20719,7 +20719,7 @@ rs6000_emit_prologue (void)
 				      && DEFAULT_ABI != ABI_AIX
 				      && flag_pic
 				      && ! info->lr_save_p
-				      && EDGE_COUNT (EXIT_BLOCK_PTR->preds) > 0);
+				      && EDGE_COUNT (cfun->cfg->get_exit_block ()->preds) > 0);
       if (save_LR_around_toc_setup)
 	{
 	  rtx lr = gen_rtx_REG (Pmode, LR_REGNO);
diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index 30c3490..23dc02d 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -7395,7 +7395,7 @@ s390_regs_ever_clobbered (int *regs_ever_clobbered)
       if (!call_really_used_regs[i])
 	regs_ever_clobbered[i] = 1;
 
-  FOR_EACH_BB (cur_bb)
+  FOR_EACH_BB_CFG (cur_bb, cfun->cfg)
     {
       FOR_BB_INSNS (cur_bb, cur_insn)
 	{
diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c
index 5976206..959dddf 100644
--- a/gcc/config/sh/sh.c
+++ b/gcc/config/sh/sh.c
@@ -11168,7 +11168,7 @@ sh_md_init_global (FILE *dump ATTRIBUTE_UNUSED,
   regmode_weight[1] = (short *) xcalloc (old_max_uid, sizeof (short));
   r0_life_regions = 0;
 
-  FOR_EACH_BB_REVERSE (b)
+  FOR_EACH_BB_REVERSE_CFG (b, cfun->cfg)
   {
     find_regmode_weight (b, SImode);
     find_regmode_weight (b, SFmode);
diff --git a/gcc/config/spu/spu.c b/gcc/config/spu/spu.c
index 6cbd3f8..0fd1c33 100644
--- a/gcc/config/spu/spu.c
+++ b/gcc/config/spu/spu.c
@@ -2456,7 +2456,7 @@ spu_machine_dependent_reorg (void)
       return;
     }
 
-  blocks = sbitmap_alloc (last_basic_block);
+  blocks = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
   bitmap_clear (blocks);
 
   in_spu_reorg = 1;
@@ -2469,15 +2469,15 @@ spu_machine_dependent_reorg (void)
   compact_blocks ();
 
   spu_bb_info =
-    (struct spu_bb_info *) xcalloc (n_basic_blocks,
+    (struct spu_bb_info *) xcalloc (cfun->cfg->get_n_basic_blocks (),
 				    sizeof (struct spu_bb_info));
 
   /* We need exact insn addresses and lengths.  */
   shorten_branches (get_insns ());
 
-  for (i = n_basic_blocks - 1; i >= 0; i--)
+  for (i = cfun->cfg->get_n_basic_blocks () - 1; i >= 0; i--)
     {
-      bb = BASIC_BLOCK (i);
+      bb = cfun->cfg->get_basic_block_by_idx (i);
       branch = 0;
       if (spu_bb_info[i].prop_jump)
 	{
@@ -2632,7 +2632,7 @@ spu_machine_dependent_reorg (void)
     find_many_sub_basic_blocks (blocks);
 
   /* We have to schedule to make sure alignment is ok. */
-  FOR_EACH_BB (bb) bb->flags &= ~BB_DISABLE_SCHEDULE;
+  FOR_EACH_BB_CFG (bb, cfun->cfg) bb->flags &= ~BB_DISABLE_SCHEDULE;
 
   /* The hints need to be scheduled, so call it again. */
   schedule_insns ();
diff --git a/gcc/config/tilegx/tilegx.c b/gcc/config/tilegx/tilegx.c
index beb1012..319a0b8 100644
--- a/gcc/config/tilegx/tilegx.c
+++ b/gcc/config/tilegx/tilegx.c
@@ -4366,7 +4366,7 @@ static void
 tilegx_gen_bundles (void)
 {
   basic_block bb;
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       rtx insn, next;
       rtx end = NEXT_INSN (BB_END (bb));
@@ -4692,7 +4692,7 @@ static void
 reorder_var_tracking_notes (void)
 {
   basic_block bb;
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
   {
     rtx insn, next;
     rtx queue = NULL_RTX;
diff --git a/gcc/config/tilepro/tilepro.c b/gcc/config/tilepro/tilepro.c
index 59618e4..105b765 100644
--- a/gcc/config/tilepro/tilepro.c
+++ b/gcc/config/tilepro/tilepro.c
@@ -3971,7 +3971,7 @@ static void
 tilepro_gen_bundles (void)
 {
   basic_block bb;
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
   {
     rtx insn, next;
     rtx end = NEXT_INSN (BB_END (bb));
@@ -4242,7 +4242,7 @@ static void
 reorder_var_tracking_notes (void)
 {
   basic_block bb;
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
   {
     rtx insn, next;
     rtx queue = NULL_RTX;
diff --git a/gcc/coverage.c b/gcc/coverage.c
index 7c395f4..0af9776 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -553,9 +553,9 @@ unsigned
 coverage_compute_cfg_checksum (void)
 {
   basic_block bb;
-  unsigned chksum = n_basic_blocks;
+  unsigned chksum = cfun->cfg->get_n_basic_blocks ();
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       edge e;
       edge_iterator ei;
diff --git a/gcc/cprop.c b/gcc/cprop.c
index 6a6b5f1..eec5ee8 100644
--- a/gcc/cprop.c
+++ b/gcc/cprop.c
@@ -399,7 +399,7 @@ compute_hash_table_work (struct hash_table_d *table)
   /* Allocate vars to track sets of regs.  */
   reg_set_bitmap = ALLOC_REG_SET (NULL);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       rtx insn;
 
@@ -594,8 +594,8 @@ compute_local_properties (sbitmap *kill, sbitmap *comp,
   unsigned int i;
 
   /* Initialize the bitmaps that were passed in.  */
-  bitmap_vector_clear (kill, last_basic_block);
-  bitmap_vector_clear (comp, last_basic_block);
+  bitmap_vector_clear (kill, cfun->cfg->get_last_basic_block ());
+  bitmap_vector_clear (comp, cfun->cfg->get_last_basic_block ());
 
   for (i = 0; i < table->size; i++)
     {
@@ -648,7 +648,7 @@ compute_cprop_data (void)
      aren't recorded for the local pass so they cannot be propagated within
      their basic block by this pass and 2) the global pass would otherwise
      propagate them only in the successors of their basic block.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       int index = implicit_set_indexes[bb->index];
       if (index != -1)
@@ -966,7 +966,7 @@ cprop_jump (basic_block bb, rtx setcc, rtx jump, rtx from, rtx src)
       edge_iterator ei;
 
       FOR_EACH_EDGE (e, ei, bb->succs)
-	if (e->dest != EXIT_BLOCK_PTR
+	if (e->dest != cfun->cfg->get_exit_block ()
 	    && BB_HEAD (e->dest) == JUMP_LABEL (jump))
 	  {
 	    e->flags |= EDGE_FALLTHRU;
@@ -1233,7 +1233,7 @@ local_cprop_pass (void)
   unsigned i;
 
   cselib_init (0);
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       FOR_BB_INSNS (bb, insn)
 	{
@@ -1354,11 +1354,11 @@ find_implicit_sets (void)
   rtx cond, new_rtx;
   unsigned int count = 0;
   bool edges_split = false;
-  size_t implicit_sets_size = last_basic_block + 10;
+  size_t implicit_sets_size = cfun->cfg->get_last_basic_block () + 10;
 
   implicit_sets = XCNEWVEC (rtx, implicit_sets_size);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       /* Check for more than one successor.  */
       if (EDGE_COUNT (bb->succs) <= 1)
@@ -1375,7 +1375,7 @@ find_implicit_sets (void)
 	? BRANCH_EDGE (bb)->dest : FALLTHRU_EDGE (bb)->dest;
 
       /* If DEST doesn't go anywhere, ignore it.  */
-      if (! dest || dest == EXIT_BLOCK_PTR)
+      if (! dest || dest == cfun->cfg->get_exit_block ())
 	continue;
 
       /* We have found a suitable implicit set.  Try to record it now as
@@ -1611,7 +1611,7 @@ bypass_block (basic_block bb, rtx setcc, rtx jump)
 	  old_dest = e->dest;
 	  if (dest != NULL
 	      && dest != old_dest
-	      && dest != EXIT_BLOCK_PTR)
+	      && dest != cfun->cfg->get_exit_block ())
             {
 	      redirect_edge_and_branch_force (e, dest);
 
@@ -1663,15 +1663,15 @@ bypass_conditional_jumps (void)
   rtx dest;
 
   /* Note we start at block 1.  */
-  if (ENTRY_BLOCK_PTR->next_bb == EXIT_BLOCK_PTR)
+  if (cfun->cfg->get_entry_block ()->next_bb == cfun->cfg->get_exit_block ())
     return 0;
 
-  bypass_last_basic_block = last_basic_block;
+  bypass_last_basic_block = cfun->cfg->get_last_basic_block ();
   mark_dfs_back_edges ();
 
   changed = 0;
-  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR->next_bb->next_bb,
-		  EXIT_BLOCK_PTR, next_bb)
+  FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block ()->next_bb->next_bb,
+		  cfun->cfg->get_exit_block (), next_bb)
     {
       /* Check for more than one predecessor.  */
       if (!single_pred_p (bb))
@@ -1728,24 +1728,24 @@ is_too_expensive (const char *pass)
      which have a couple switch statements.  Rather than simply
      threshold the number of blocks, uses something with a more
      graceful degradation.  */
-  if (n_edges > 20000 + n_basic_blocks * 4)
+  if (cfun->cfg->get_n_edges () > 20000 + cfun->cfg->get_n_basic_blocks () * 4)
     {
       warning (OPT_Wdisabled_optimization,
 	       "%s: %d basic blocks and %d edges/basic block",
-	       pass, n_basic_blocks, n_edges / n_basic_blocks);
+	       pass, cfun->cfg->get_n_basic_blocks (), cfun->cfg->get_n_edges () / cfun->cfg->get_n_basic_blocks ());
 
       return true;
     }
 
   /* If allocating memory for the cprop bitmap would take up too much
      storage it's better just to disable the optimization.  */
-  if ((n_basic_blocks
+  if ((cfun->cfg->get_n_basic_blocks ()
        * SBITMAP_SET_SIZE (max_reg_num ())
        * sizeof (SBITMAP_ELT_TYPE)) > MAX_GCSE_MEMORY)
     {
       warning (OPT_Wdisabled_optimization,
 	       "%s: %d basic blocks and %d registers",
-	       pass, n_basic_blocks, max_reg_num ());
+	       pass, cfun->cfg->get_n_basic_blocks (), max_reg_num ());
 
       return true;
     }
@@ -1762,7 +1762,7 @@ one_cprop_pass (void)
   int changed = 0;
 
   /* Return if there's nothing to do, or it is too expensive.  */
-  if (n_basic_blocks <= NUM_FIXED_BLOCKS + 1
+  if (cfun->cfg->get_n_basic_blocks () <= NUM_FIXED_BLOCKS + 1
       || is_too_expensive (_ ("const/copy propagation disabled")))
     return 0;
 
@@ -1807,8 +1807,8 @@ one_cprop_pass (void)
     df_analyze ();
 
   /* Initialize implicit_set_indexes array.  */
-  implicit_set_indexes = XNEWVEC (int, last_basic_block);
-  for (i = 0; i < last_basic_block; i++)
+  implicit_set_indexes = XNEWVEC (int, cfun->cfg->get_last_basic_block ());
+  for (i = 0; i < cfun->cfg->get_last_basic_block (); i++)
     implicit_set_indexes[i] = -1;
 
   alloc_hash_table (&set_hash_table);
@@ -1825,7 +1825,7 @@ one_cprop_pass (void)
       basic_block bb;
       rtx insn;
 
-      alloc_cprop_mem (last_basic_block, set_hash_table.n_elems);
+      alloc_cprop_mem (cfun->cfg->get_last_basic_block (), set_hash_table.n_elems);
       compute_cprop_data ();
 
       free (implicit_set_indexes);
@@ -1834,7 +1834,7 @@ one_cprop_pass (void)
       /* Allocate vars to track sets of regs.  */
       reg_set_bitmap = ALLOC_REG_SET (NULL);
 
-      FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR->next_bb->next_bb, EXIT_BLOCK_PTR,
+      FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block ()->next_bb->next_bb, cfun->cfg->get_exit_block (),
 		      next_bb)
 	{
 	  /* Reset tables used to keep track of what's still valid [since
@@ -1872,7 +1872,7 @@ one_cprop_pass (void)
   if (dump_file)
     {
       fprintf (dump_file, "CPROP of %s, %d basic blocks, %d bytes needed, ",
-	       current_function_name (), n_basic_blocks, bytes_used);
+	       current_function_name (), cfun->cfg->get_n_basic_blocks (), bytes_used);
       fprintf (dump_file, "%d local const props, %d local copy props, ",
 	       local_const_prop_count, local_copy_prop_count);
       fprintf (dump_file, "%d global const props, %d global copy props\n\n",
diff --git a/gcc/cse.c b/gcc/cse.c
index f2c8f63..3978443 100644
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -6192,7 +6192,7 @@ cse_find_path (basic_block first_bb, struct cse_basic_block_data *data,
 	      && e == BRANCH_EDGE (previous_bb_in_path))
 	    {
 	      bb = FALLTHRU_EDGE (previous_bb_in_path)->dest;
-	      if (bb != EXIT_BLOCK_PTR
+	      if (bb != cfun->cfg->get_exit_block ()
 		  && single_pred_p (bb)
 		  /* We used to assert here that we would only see blocks
 		     that we have not visited yet.  But we may end up
@@ -6246,7 +6246,7 @@ cse_find_path (basic_block first_bb, struct cse_basic_block_data *data,
 
 	  if (e
 	      && !((e->flags & EDGE_ABNORMAL_CALL) && cfun->has_nonlocal_label)
-	      && e->dest != EXIT_BLOCK_PTR
+	      && e->dest != cfun->cfg->get_exit_block ()
 	      && single_pred_p (e->dest)
 	      /* Avoid visiting basic blocks twice.  The large comment
 		 above explains why this can happen.  */
@@ -6514,7 +6514,7 @@ cse_main (rtx f ATTRIBUTE_UNUSED, int nregs)
 {
   struct cse_basic_block_data ebb_data;
   basic_block bb;
-  int *rc_order = XNEWVEC (int, last_basic_block);
+  int *rc_order = XNEWVEC (int, cfun->cfg->get_last_basic_block ());
   int i, n_blocks;
 
   df_set_flags (DF_LR_RUN_DCE);
@@ -6543,7 +6543,7 @@ cse_main (rtx f ATTRIBUTE_UNUSED, int nregs)
   reg_eqv_table = XNEWVEC (struct reg_eqv_elem, nregs);
 
   /* Set up the table of already visited basic blocks.  */
-  cse_visited_basic_blocks = sbitmap_alloc (last_basic_block);
+  cse_visited_basic_blocks = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
   bitmap_clear (cse_visited_basic_blocks);
 
   /* Loop over basic blocks in reverse completion order (RPO),
@@ -6556,7 +6556,7 @@ cse_main (rtx f ATTRIBUTE_UNUSED, int nregs)
 	 processed before.  */
       do
 	{
-	  bb = BASIC_BLOCK (rc_order[i++]);
+	  bb = cfun->cfg->get_basic_block_by_idx (rc_order[i++]);
 	}
       while (bitmap_bit_p (cse_visited_basic_blocks, bb->index)
 	     && i < n_blocks);
@@ -7157,7 +7157,7 @@ cse_cc_succs (basic_block bb, basic_block orig_bb, rtx cc_reg, rtx cc_src,
 	continue;
 
       if (EDGE_COUNT (e->dest->preds) != 1
-	  || e->dest == EXIT_BLOCK_PTR
+	  || e->dest == cfun->cfg->get_exit_block ()
 	  /* Avoid endless recursion on unreachable blocks.  */
 	  || e->dest == orig_bb)
 	continue;
@@ -7326,7 +7326,7 @@ cse_condition_code_reg (void)
   else
     cc_reg_2 = NULL_RTX;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       rtx last_insn;
       rtx cc_reg;
diff --git a/gcc/dce.c b/gcc/dce.c
index 64ed81e..93e866a 100644
--- a/gcc/dce.c
+++ b/gcc/dce.c
@@ -511,7 +511,7 @@ reset_unmarked_insns_debug_uses (void)
   basic_block bb;
   rtx insn, next;
 
-  FOR_EACH_BB_REVERSE (bb)
+  FOR_EACH_BB_REVERSE_CFG (bb, cfun->cfg)
     FOR_BB_INSNS_REVERSE_SAFE (bb, insn, next)
       if (DEBUG_INSN_P (insn))
 	{
@@ -550,7 +550,7 @@ delete_unmarked_insns (void)
   rtx insn, next;
   bool must_clean = false;
 
-  FOR_EACH_BB_REVERSE (bb)
+  FOR_EACH_BB_REVERSE_CFG (bb, cfun->cfg)
     FOR_BB_INSNS_REVERSE_SAFE (bb, insn, next)
       if (NONDEBUG_INSN_P (insn))
 	{
@@ -623,7 +623,7 @@ prescan_insns_for_dce (bool fast)
   if (!df_in_progress && ACCUMULATE_OUTGOING_ARGS)
     arg_stores = BITMAP_ALLOC (NULL);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       FOR_BB_INSNS_REVERSE_SAFE (bb, insn, prev)
 	if (NONDEBUG_INSN_P (insn))
@@ -663,7 +663,7 @@ mark_artificial_uses (void)
   struct df_link *defs;
   df_ref *use_rec;
 
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       for (use_rec = df_get_artificial_uses (bb->index);
 	   *use_rec; use_rec++)
@@ -1047,7 +1047,7 @@ fast_dce (bool word_level)
       for (i = 0; i < n_blocks; i++)
 	{
 	  int index = postorder[i];
-	  basic_block bb = BASIC_BLOCK (index);
+	  basic_block bb = cfun->cfg->get_basic_block_by_idx (index);
 	  bool local_changed;
 
 	  if (index < NUM_FIXED_BLOCKS)
diff --git a/gcc/df-core.c b/gcc/df-core.c
index e602290..f9f4f99 100644
--- a/gcc/df-core.c
+++ b/gcc/df-core.c
@@ -520,7 +520,7 @@ df_set_blocks (bitmap blocks)
 
 		  EXECUTE_IF_SET_IN_BITMAP (&diff, 0, bb_index, bi)
 		    {
-		      basic_block bb = BASIC_BLOCK (bb_index);
+		      basic_block bb = cfun->cfg->get_basic_block_by_idx (bb_index);
 		      if (bb)
 			{
 			  void *bb_info = df_get_bb_info (dflow, bb_index);
@@ -549,7 +549,7 @@ df_set_blocks (bitmap blocks)
 		    {
 		      basic_block bb;
 		      bitmap_initialize (&blocks_to_reset, &df_bitmap_obstack);
-		      FOR_ALL_BB(bb)
+		      FOR_ALL_BB_CFG (bb, cfun->cfg)
 			{
 			  bitmap_set_bit (&blocks_to_reset, bb->index);
 			}
@@ -721,8 +721,8 @@ rest_of_handle_df_initialize (void)
   if (optimize > 1)
     df_live_add_problem ();
 
-  df->postorder = XNEWVEC (int, last_basic_block);
-  df->postorder_inverted = XNEWVEC (int, last_basic_block);
+  df->postorder = XNEWVEC (int, cfun->cfg->get_last_basic_block ());
+  df->postorder_inverted = XNEWVEC (int, cfun->cfg->get_last_basic_block ());
   df->n_blocks = post_order_compute (df->postorder, true, true);
   df->n_blocks_inverted = inverted_post_order_compute (df->postorder_inverted);
   gcc_assert (df->n_blocks == df->n_blocks_inverted);
@@ -880,7 +880,7 @@ df_worklist_propagate_forward (struct dataflow *dataflow,
 {
   edge e;
   edge_iterator ei;
-  basic_block bb = BASIC_BLOCK (bb_index);
+  basic_block bb = cfun->cfg->get_basic_block_by_idx (bb_index);
   bool changed = !age;
 
   /*  Calculate <conf_op> of incoming edges.  */
@@ -925,7 +925,7 @@ df_worklist_propagate_backward (struct dataflow *dataflow,
 {
   edge e;
   edge_iterator ei;
-  basic_block bb = BASIC_BLOCK (bb_index);
+  basic_block bb = cfun->cfg->get_basic_block_by_idx (bb_index);
   bool changed = !age;
 
   /*  Calculate <conf_op> of incoming edges.  */
@@ -1014,7 +1014,7 @@ df_worklist_dataflow_doublequeue (struct dataflow *dataflow,
 
 	  bitmap_clear_bit (pending, index);
 	  bb_index = blocks_in_postorder[index];
-	  bb = BASIC_BLOCK (bb_index);
+	  bb = cfun->cfg->get_basic_block_by_idx (bb_index);
 	  prev_age = last_visit_age[index];
 	  if (dir == DF_FORWARD)
 	    changed = df_worklist_propagate_forward (dataflow, bb_index,
@@ -1033,7 +1033,7 @@ df_worklist_dataflow_doublequeue (struct dataflow *dataflow,
       bitmap_clear (worklist);
     }
   for (i = 0; i < n_blocks; i++)
-    BASIC_BLOCK (blocks_in_postorder[i])->aux = NULL;
+    cfun->cfg->get_basic_block_by_idx (blocks_in_postorder[i])->aux = NULL;
 
   BITMAP_FREE (worklist);
   BITMAP_FREE (pending);
@@ -1042,10 +1042,10 @@ df_worklist_dataflow_doublequeue (struct dataflow *dataflow,
   /* Dump statistics. */
   if (dump_file)
     fprintf (dump_file, "df_worklist_dataflow_doublequeue:"
-	     "n_basic_blocks %d n_edges %d"
+	     "cfun->cfg->get_n_basic_blocks () %d cfun->cfg->get_n_edges () %d"
 	     " count %d (%5.2g)\n",
-	     n_basic_blocks, n_edges,
-	     dcount, dcount / (float)n_basic_blocks);
+	     cfun->cfg->get_n_basic_blocks (), cfun->cfg->get_n_edges (),
+	     dcount, dcount / (float)cfun->cfg->get_n_basic_blocks ());
 }
 
 /* Worklist-based dataflow solver. It uses sbitmap as a worklist,
@@ -1062,7 +1062,7 @@ df_worklist_dataflow (struct dataflow *dataflow,
                       int n_blocks)
 {
   bitmap pending = BITMAP_ALLOC (&df_bitmap_obstack);
-  sbitmap considered = sbitmap_alloc (last_basic_block);
+  sbitmap considered = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
   bitmap_iterator bi;
   unsigned int *bbindex_to_postorder;
   int i;
@@ -1072,11 +1072,11 @@ df_worklist_dataflow (struct dataflow *dataflow,
   gcc_assert (dir != DF_NONE);
 
   /* BBINDEX_TO_POSTORDER maps the bb->index to the reverse postorder.  */
-  bbindex_to_postorder = XNEWVEC (unsigned int, last_basic_block);
+  bbindex_to_postorder = XNEWVEC (unsigned int, cfun->cfg->get_last_basic_block ());
 
   /* Initialize the array to an out-of-bound value.  */
-  for (i = 0; i < last_basic_block; i++)
-    bbindex_to_postorder[i] = last_basic_block;
+  for (i = 0; i < cfun->cfg->get_last_basic_block (); i++)
+    bbindex_to_postorder[i] = cfun->cfg->get_last_basic_block ();
 
   /* Initialize the considered map.  */
   bitmap_clear (considered);
@@ -1183,8 +1183,8 @@ df_analyze (void)
 
   free (df->postorder);
   free (df->postorder_inverted);
-  df->postorder = XNEWVEC (int, last_basic_block);
-  df->postorder_inverted = XNEWVEC (int, last_basic_block);
+  df->postorder = XNEWVEC (int, cfun->cfg->get_last_basic_block ());
+  df->postorder_inverted = XNEWVEC (int, cfun->cfg->get_last_basic_block ());
   df->n_blocks = post_order_compute (df->postorder, true, true);
   df->n_blocks_inverted = inverted_post_order_compute (df->postorder_inverted);
 
@@ -1428,7 +1428,7 @@ df_set_bb_dirty (basic_block bb)
 void
 df_grow_bb_info (struct dataflow *dflow)
 {
-  unsigned int new_size = last_basic_block + 1;
+  unsigned int new_size = cfun->cfg->get_last_basic_block () + 1;
   if (dflow->block_info_size < new_size)
     {
       new_size += new_size / 4;
@@ -1489,7 +1489,7 @@ df_compact_blocks (void)
 	    bitmap_set_bit (dflow->out_of_date_transfer_functions, EXIT_BLOCK);
 
 	  i = NUM_FIXED_BLOCKS;
-	  FOR_EACH_BB (bb)
+	  FOR_EACH_BB_CFG (bb, cfun->cfg)
 	    {
 	      if (bitmap_bit_p (&tmp, bb->index))
 		bitmap_set_bit (dflow->out_of_date_transfer_functions, i);
@@ -1500,7 +1500,7 @@ df_compact_blocks (void)
       /* Now shuffle the block info for the problem.  */
       if (dflow->problem->free_bb_fun)
 	{
-	  int size = last_basic_block * dflow->problem->block_info_elt_size;
+	  int size = cfun->cfg->get_last_basic_block () * dflow->problem->block_info_elt_size;
 	  problem_temps = XNEWVAR (char, size);
 	  df_grow_bb_info (dflow);
 	  memcpy (problem_temps, dflow->block_info, size);
@@ -1509,7 +1509,7 @@ df_compact_blocks (void)
 	     place in the block_info vector.  Null out the copied
 	     item.  The entry and exit blocks never move.  */
 	  i = NUM_FIXED_BLOCKS;
-	  FOR_EACH_BB (bb)
+	  FOR_EACH_BB_CFG (bb, cfun->cfg)
 	    {
 	      df_set_bb_info (dflow, i,
 			      (char *)problem_temps
@@ -1518,7 +1518,7 @@ df_compact_blocks (void)
 	    }
 	  memset ((char *)dflow->block_info
 		  + i * dflow->problem->block_info_elt_size, 0,
-		  (last_basic_block - i)
+		  (cfun->cfg->get_last_basic_block () - i)
 		  * dflow->problem->block_info_elt_size);
 	  free (problem_temps);
 	}
@@ -1535,7 +1535,7 @@ df_compact_blocks (void)
       bitmap_copy (&tmp, df->blocks_to_analyze);
       bitmap_clear (df->blocks_to_analyze);
       i = NUM_FIXED_BLOCKS;
-      FOR_EACH_BB (bb)
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
 	{
 	  if (bitmap_bit_p (&tmp, bb->index))
 	    bitmap_set_bit (df->blocks_to_analyze, i);
@@ -1546,17 +1546,17 @@ df_compact_blocks (void)
   bitmap_clear (&tmp);
 
   i = NUM_FIXED_BLOCKS;
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
-      SET_BASIC_BLOCK (i, bb);
+      cfun->cfg->set_basic_block_by_idx (i, bb);
       bb->index = i;
       i++;
     }
 
-  gcc_assert (i == n_basic_blocks);
+  gcc_assert (i == cfun->cfg->get_n_basic_blocks ());
 
-  for (; i < last_basic_block; i++)
-    SET_BASIC_BLOCK (i, NULL);
+  for (; i < cfun->cfg->get_last_basic_block (); i++)
+    cfun->cfg->set_basic_block_by_idx (i, NULL);
 
 #ifdef DF_DEBUG_CFG
   if (!df_lr->solutions_dirty)
@@ -1578,7 +1578,7 @@ df_bb_replace (int old_index, basic_block new_block)
     fprintf (dump_file, "shoving block %d into %d\n", new_block_index, old_index);
 
   gcc_assert (df);
-  gcc_assert (BASIC_BLOCK (old_index) == NULL);
+  gcc_assert (cfun->cfg->get_basic_block_by_idx (old_index) == NULL);
 
   for (p = 0; p < df->num_problems_defined; p++)
     {
@@ -1592,10 +1592,10 @@ df_bb_replace (int old_index, basic_block new_block)
     }
 
   df_clear_bb_dirty (new_block);
-  SET_BASIC_BLOCK (old_index, new_block);
+  cfun->cfg->set_basic_block_by_idx (old_index, new_block);
   new_block->index = old_index;
-  df_set_bb_dirty (BASIC_BLOCK (old_index));
-  SET_BASIC_BLOCK (new_block_index, NULL);
+  df_set_bb_dirty (cfun->cfg->get_basic_block_by_idx (old_index));
+  cfun->cfg->set_basic_block_by_idx (new_block_index, NULL);
 }
 
 
@@ -1606,7 +1606,7 @@ df_bb_replace (int old_index, basic_block new_block)
 void
 df_bb_delete (int bb_index)
 {
-  basic_block bb = BASIC_BLOCK (bb_index);
+  basic_block bb = cfun->cfg->get_basic_block_by_idx (bb_index);
   int i;
 
   if (!df)
@@ -1661,11 +1661,11 @@ static int *
 df_compute_cfg_image (void)
 {
   basic_block bb;
-  int size = 2 + (2 * n_basic_blocks);
+  int size = 2 + (2 * cfun->cfg->get_n_basic_blocks ());
   int i;
   int * map;
 
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       size += EDGE_COUNT (bb->succs);
     }
@@ -1673,7 +1673,7 @@ df_compute_cfg_image (void)
   map = XNEWVEC (int, size);
   map[0] = size;
   i = 1;
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       edge_iterator ei;
       edge e;
@@ -1966,7 +1966,7 @@ df_dump (FILE *file)
   basic_block bb;
   df_dump_start (file);
 
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       df_print_bb_index (bb, file);
       df_dump_top (bb, file);
@@ -1992,7 +1992,7 @@ df_dump_region (FILE *file)
 
       EXECUTE_IF_SET_IN_BITMAP (df->blocks_to_analyze, 0, bb_index, bi)
 	{
-	  basic_block bb = BASIC_BLOCK (bb_index);
+	  basic_block bb = cfun->cfg->get_basic_block_by_idx (bb_index);
 	  dump_bb (file, bb, 0, TDF_DETAILS);
 	}
       fprintf (file, "\n");
diff --git a/gcc/df-problems.c b/gcc/df-problems.c
index abe6958..71256a7 100644
--- a/gcc/df-problems.c
+++ b/gcc/df-problems.c
@@ -353,7 +353,7 @@ df_rd_bb_local_compute_process_def (struct df_rd_bb_info *bb_info,
 static void
 df_rd_bb_local_compute (unsigned int bb_index)
 {
-  basic_block bb = BASIC_BLOCK (bb_index);
+  basic_block bb = cfun->cfg->get_basic_block_by_idx (bb_index);
   struct df_rd_bb_info *bb_info = df_rd_get_bb_info (bb_index);
   rtx insn;
 
@@ -835,7 +835,7 @@ df_lr_reset (bitmap all_blocks)
 static void
 df_lr_bb_local_compute (unsigned int bb_index)
 {
-  basic_block bb = BASIC_BLOCK (bb_index);
+  basic_block bb = cfun->cfg->get_basic_block_by_idx (bb_index);
   struct df_lr_bb_info *bb_info = df_lr_get_bb_info (bb_index);
   rtx insn;
   df_ref *def_rec;
@@ -1007,7 +1007,7 @@ static void
 df_lr_confluence_0 (basic_block bb)
 {
   bitmap op1 = &df_lr_get_bb_info (bb->index)->out;
-  if (bb != EXIT_BLOCK_PTR)
+  if (bb != cfun->cfg->get_exit_block ())
     bitmap_copy (op1, &df->hardware_regs_used);
 }
 
@@ -1173,10 +1173,10 @@ df_lr_verify_solution_start (void)
   df_lr->solutions_dirty = true;
 
   problem_data = (struct df_lr_problem_data *)df_lr->problem_data;
-  problem_data->in = XNEWVEC (bitmap_head, last_basic_block);
-  problem_data->out = XNEWVEC (bitmap_head, last_basic_block);
+  problem_data->in = XNEWVEC (bitmap_head, cfun->cfg->get_last_basic_block ());
+  problem_data->out = XNEWVEC (bitmap_head, cfun->cfg->get_last_basic_block ());
 
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       bitmap_initialize (&problem_data->in[bb->index], &problem_data->lr_bitmaps);
       bitmap_initialize (&problem_data->out[bb->index], &problem_data->lr_bitmaps);
@@ -1205,7 +1205,7 @@ df_lr_verify_solution_end (void)
        in df_lr_finalize for details.  */
     df_lr->solutions_dirty = false;
   else
-    FOR_ALL_BB (bb)
+    FOR_ALL_BB_CFG (bb, cfun->cfg)
       {
 	if ((!bitmap_equal_p (&problem_data->in[bb->index], DF_LR_IN (bb)))
 	    || (!bitmap_equal_p (&problem_data->out[bb->index], DF_LR_OUT (bb))))
@@ -1217,7 +1217,7 @@ df_lr_verify_solution_end (void)
 
   /* Cannot delete them immediately because you may want to dump them
      if the comparison fails.  */
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       bitmap_clear (&problem_data->in[bb->index]);
       bitmap_clear (&problem_data->out[bb->index]);
@@ -1294,7 +1294,7 @@ df_lr_verify_transfer_functions (void)
   bitmap_initialize (&saved_use, &bitmap_default_obstack);
   bitmap_initialize (&all_blocks, &bitmap_default_obstack);
 
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       struct df_lr_bb_info *bb_info = df_lr_get_bb_info (bb->index);
       bitmap_set_bit (&all_blocks, bb->index);
@@ -1462,7 +1462,7 @@ df_live_reset (bitmap all_blocks)
 static void
 df_live_bb_local_compute (unsigned int bb_index)
 {
-  basic_block bb = BASIC_BLOCK (bb_index);
+  basic_block bb = cfun->cfg->get_basic_block_by_idx (bb_index);
   struct df_live_bb_info *bb_info = df_live_get_bb_info (bb_index);
   rtx insn;
   df_ref *def_rec;
@@ -1710,10 +1710,10 @@ df_live_verify_solution_start (void)
   df_live->solutions_dirty = true;
 
   problem_data = (struct df_live_problem_data *)df_live->problem_data;
-  problem_data->in = XNEWVEC (bitmap_head, last_basic_block);
-  problem_data->out = XNEWVEC (bitmap_head, last_basic_block);
+  problem_data->in = XNEWVEC (bitmap_head, cfun->cfg->get_last_basic_block ());
+  problem_data->out = XNEWVEC (bitmap_head, cfun->cfg->get_last_basic_block ());
 
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       bitmap_initialize (&problem_data->in[bb->index], &problem_data->live_bitmaps);
       bitmap_initialize (&problem_data->out[bb->index], &problem_data->live_bitmaps);
@@ -1736,7 +1736,7 @@ df_live_verify_solution_end (void)
   if (!problem_data->out)
     return;
 
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       if ((!bitmap_equal_p (&problem_data->in[bb->index], DF_LIVE_IN (bb)))
 	  || (!bitmap_equal_p (&problem_data->out[bb->index], DF_LIVE_OUT (bb))))
@@ -1748,7 +1748,7 @@ df_live_verify_solution_end (void)
 
   /* Cannot delete them immediately because you may want to dump them
      if the comparison fails.  */
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       bitmap_clear (&problem_data->in[bb->index]);
       bitmap_clear (&problem_data->out[bb->index]);
@@ -1814,7 +1814,7 @@ void
 df_live_set_all_dirty (void)
 {
   basic_block bb;
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     bitmap_set_bit (df_live->out_of_date_transfer_functions,
 		    bb->index);
 }
@@ -1840,7 +1840,7 @@ df_live_verify_transfer_functions (void)
 
   df_grow_insn_info ();
 
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       struct df_live_bb_info *bb_info = df_live_get_bb_info (bb->index);
       bitmap_set_bit (&all_blocks, bb->index);
@@ -1987,7 +1987,7 @@ df_chain_remove_problem (void)
       rtx insn;
       df_ref *def_rec;
       df_ref *use_rec;
-      basic_block bb = BASIC_BLOCK (bb_index);
+      basic_block bb = cfun->cfg->get_basic_block_by_idx (bb_index);
 
       if (df_chain_problem_p (DF_DU_CHAIN))
 	for (def_rec = df_get_artificial_defs (bb->index); *def_rec; def_rec++)
@@ -2105,7 +2105,7 @@ df_chain_create_bb_process_use (bitmap local_rd,
 static void
 df_chain_create_bb (unsigned int bb_index)
 {
-  basic_block bb = BASIC_BLOCK (bb_index);
+  basic_block bb = cfun->cfg->get_basic_block_by_idx (bb_index);
   struct df_rd_bb_info *bb_info = df_rd_get_bb_info (bb_index);
   rtx insn;
   bitmap_head cpy;
@@ -2427,7 +2427,7 @@ df_word_lr_alloc (bitmap all_blocks ATTRIBUTE_UNUSED)
 
   bitmap_obstack_initialize (&problem_data->word_lr_bitmaps);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     bitmap_set_bit (df_word_lr->out_of_date_transfer_functions, bb->index);
 
   bitmap_set_bit (df_word_lr->out_of_date_transfer_functions, ENTRY_BLOCK);
@@ -2531,7 +2531,7 @@ df_word_lr_mark_ref (df_ref ref, bool is_set, regset live)
 static void
 df_word_lr_bb_local_compute (unsigned int bb_index)
 {
-  basic_block bb = BASIC_BLOCK (bb_index);
+  basic_block bb = cfun->cfg->get_basic_block_by_idx (bb_index);
   struct df_word_lr_bb_info *bb_info = df_word_lr_get_bb_info (bb_index);
   rtx insn;
   df_ref *def_rec;
@@ -3154,7 +3154,7 @@ static void
 df_note_bb_compute (unsigned int bb_index,
 		    bitmap live, bitmap do_not_gen, bitmap artificial_uses)
 {
-  basic_block bb = BASIC_BLOCK (bb_index);
+  basic_block bb = cfun->cfg->get_basic_block_by_idx (bb_index);
   rtx insn;
   df_ref *def_rec;
   df_ref *use_rec;
@@ -4268,7 +4268,7 @@ df_md_bb_local_compute_process_def (struct df_md_bb_info *bb_info,
 static void
 df_md_bb_local_compute (unsigned int bb_index)
 {
-  basic_block bb = BASIC_BLOCK (bb_index);
+  basic_block bb = cfun->cfg->get_basic_block_by_idx (bb_index);
   struct df_md_bb_info *bb_info = df_md_get_bb_info (bb_index);
   rtx insn;
 
@@ -4312,8 +4312,8 @@ df_md_local_compute (bitmap all_blocks)
 
   bitmap_clear (&seen_in_insn);
 
-  frontiers = XNEWVEC (bitmap_head, last_basic_block);
-  FOR_ALL_BB (bb)
+  frontiers = XNEWVEC (bitmap_head, cfun->cfg->get_last_basic_block ());
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     bitmap_initialize (&frontiers[bb->index], &bitmap_default_obstack);
 
   compute_dominance_frontiers (frontiers);
@@ -4324,14 +4324,14 @@ df_md_local_compute (bitmap all_blocks)
       bitmap kill = &df_md_get_bb_info (bb_index)->kill;
       EXECUTE_IF_SET_IN_BITMAP (&frontiers[bb_index], 0, df_bb_index, bi2)
 	{
-	  basic_block bb = BASIC_BLOCK (df_bb_index);
+	  basic_block bb = cfun->cfg->get_basic_block_by_idx (df_bb_index);
 	  if (bitmap_bit_p (all_blocks, df_bb_index))
 	    bitmap_ior_and_into (&df_md_get_bb_info (df_bb_index)->init, kill,
 				 df_get_live_in (bb));
 	}
     }
 
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     bitmap_clear (&frontiers[bb->index]);
   free (frontiers);
 }
@@ -4357,7 +4357,7 @@ df_md_reset (bitmap all_blocks)
 static bool
 df_md_transfer_function (int bb_index)
 {
-  basic_block bb = BASIC_BLOCK (bb_index);
+  basic_block bb = cfun->cfg->get_basic_block_by_idx (bb_index);
   struct df_md_bb_info *bb_info = df_md_get_bb_info (bb_index);
   bitmap in = &bb_info->in;
   bitmap out = &bb_info->out;
diff --git a/gcc/df-scan.c b/gcc/df-scan.c
index 3a8e9ca..bb027e8 100644
--- a/gcc/df-scan.c
+++ b/gcc/df-scan.c
@@ -205,7 +205,7 @@ df_scan_free_internal (void)
 	}
     }
 
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       unsigned int bb_index = bb->index;
       struct df_scan_bb_info *bb_info = df_scan_get_bb_info (bb_index);
@@ -347,7 +347,7 @@ df_scan_alloc (bitmap all_blocks ATTRIBUTE_UNUSED)
   df_grow_insn_info ();
   df_grow_bb_info (df_scan);
 
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       unsigned int bb_index = bb->index;
       struct df_scan_bb_info *bb_info = df_scan_get_bb_info (bb_index);
@@ -441,7 +441,7 @@ df_scan_start_dump (FILE *file ATTRIBUTE_UNUSED)
 	fprintf (file, "} ");
       }
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     FOR_BB_INSNS (bb, insn)
       if (INSN_P (insn))
 	{
@@ -661,11 +661,11 @@ df_scan_blocks (void)
   df_record_entry_block_defs (df->entry_block_defs);
   df_get_exit_block_use_set (df->exit_block_uses);
   df_record_exit_block_uses (df->exit_block_uses);
-  df_set_bb_dirty (BASIC_BLOCK (ENTRY_BLOCK));
-  df_set_bb_dirty (BASIC_BLOCK (EXIT_BLOCK));
+  df_set_bb_dirty (cfun->cfg->get_basic_block_by_idx (ENTRY_BLOCK));
+  df_set_bb_dirty (cfun->cfg->get_basic_block_by_idx (EXIT_BLOCK));
 
   /* Regular blocks */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       unsigned int bb_index = bb->index;
       df_bb_refs_record (bb_index, true);
@@ -1417,7 +1417,7 @@ df_insn_rescan_all (void)
   bitmap_clear (&df->insns_to_rescan);
   bitmap_clear (&df->insns_to_notes_rescan);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       rtx insn;
       FOR_BB_INSNS (bb, insn)
@@ -1639,7 +1639,7 @@ df_reorganize_refs_by_reg_by_insn (struct df_ref_info *ref_info,
 
   EXECUTE_IF_SET_IN_BITMAP (df->blocks_to_analyze, 0, bb_index, bi)
     {
-      basic_block bb = BASIC_BLOCK (bb_index);
+      basic_block bb = cfun->cfg->get_basic_block_by_idx (bb_index);
       rtx insn;
       df_ref *ref_rec;
 
@@ -1693,7 +1693,7 @@ df_reorganize_refs_by_reg_by_insn (struct df_ref_info *ref_info,
 
   EXECUTE_IF_SET_IN_BITMAP (df->blocks_to_analyze, 0, bb_index, bi)
     {
-      basic_block bb = BASIC_BLOCK (bb_index);
+      basic_block bb = cfun->cfg->get_basic_block_by_idx (bb_index);
       rtx insn;
       df_ref *ref_rec;
 
@@ -1878,7 +1878,7 @@ df_reorganize_refs_by_insn (struct df_ref_info *ref_info,
 
       EXECUTE_IF_SET_IN_BITMAP (df->blocks_to_analyze, 0, index, bi)
 	{
-	  offset = df_reorganize_refs_by_insn_bb (BASIC_BLOCK (index), offset, ref_info,
+	  offset = df_reorganize_refs_by_insn_bb (cfun->cfg->get_basic_block_by_idx (index), offset, ref_info,
 						  include_defs, include_uses,
 						  include_eq_uses);
 	}
@@ -1887,7 +1887,7 @@ df_reorganize_refs_by_insn (struct df_ref_info *ref_info,
     }
   else
     {
-      FOR_ALL_BB (bb)
+      FOR_ALL_BB_CFG (bb, cfun->cfg)
 	offset = df_reorganize_refs_by_insn_bb (bb, offset, ref_info,
 						include_defs, include_uses,
 						include_eq_uses);
@@ -3630,7 +3630,7 @@ df_bb_refs_collect (struct df_collection_rec *collection_rec, basic_block bb)
 void
 df_bb_refs_record (int bb_index, bool scan_insns)
 {
-  basic_block bb = BASIC_BLOCK (bb_index);
+  basic_block bb = cfun->cfg->get_basic_block_by_idx (bb_index);
   rtx insn;
   int luid = 0;
   struct df_collection_rec collection_rec;
@@ -3897,7 +3897,7 @@ df_entry_block_defs_collect (struct df_collection_rec *collection_rec,
   EXECUTE_IF_SET_IN_BITMAP (entry_block_defs, 0, i, bi)
     {
       df_ref_record (DF_REF_ARTIFICIAL, collection_rec, regno_reg_rtx[i], NULL,
-		     ENTRY_BLOCK_PTR, NULL, DF_REF_REG_DEF, 0);
+		     cfun->cfg->get_entry_block (), NULL, DF_REF_REG_DEF, 0);
     }
 
   df_canonize_collection_rec (collection_rec);
@@ -3916,7 +3916,7 @@ df_record_entry_block_defs (bitmap entry_block_defs)
   df_entry_block_defs_collect (&collection_rec, entry_block_defs);
 
   /* Process bb_refs chain */
-  df_refs_add_to_chains (&collection_rec, BASIC_BLOCK (ENTRY_BLOCK), NULL);
+  df_refs_add_to_chains (&collection_rec, cfun->cfg->get_basic_block_by_idx (ENTRY_BLOCK), NULL);
   collection_rec.def_vec.release ();
 }
 
@@ -3955,7 +3955,7 @@ df_update_entry_block_defs (void)
     {
       df_record_entry_block_defs (&refs);
       bitmap_copy (df->entry_block_defs, &refs);
-      df_set_bb_dirty (BASIC_BLOCK (ENTRY_BLOCK));
+      df_set_bb_dirty (cfun->cfg->get_basic_block_by_idx (ENTRY_BLOCK));
     }
   bitmap_clear (&refs);
 }
@@ -4060,17 +4060,17 @@ df_exit_block_uses_collect (struct df_collection_rec *collection_rec, bitmap exi
 
   EXECUTE_IF_SET_IN_BITMAP (exit_block_uses, 0, i, bi)
     df_ref_record (DF_REF_ARTIFICIAL, collection_rec, regno_reg_rtx[i], NULL,
-		   EXIT_BLOCK_PTR, NULL, DF_REF_REG_USE, 0);
+		   cfun->cfg->get_exit_block (), NULL, DF_REF_REG_USE, 0);
 
 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
   /* It is deliberate that this is not put in the exit block uses but
      I do not know why.  */
   if (reload_completed
       && !bitmap_bit_p (exit_block_uses, ARG_POINTER_REGNUM)
-      && bb_has_eh_pred (EXIT_BLOCK_PTR)
+      && bb_has_eh_pred (cfun->cfg->get_exit_block ())
       && fixed_regs[ARG_POINTER_REGNUM])
     df_ref_record (DF_REF_ARTIFICIAL, collection_rec, regno_reg_rtx[ARG_POINTER_REGNUM], NULL,
-		   EXIT_BLOCK_PTR, NULL, DF_REF_REG_USE, 0);
+		   cfun->cfg->get_exit_block (), NULL, DF_REF_REG_USE, 0);
 #endif
 
   df_canonize_collection_rec (collection_rec);
@@ -4089,7 +4089,7 @@ df_record_exit_block_uses (bitmap exit_block_uses)
   df_exit_block_uses_collect (&collection_rec, exit_block_uses);
 
   /* Process bb_refs chain */
-  df_refs_add_to_chains (&collection_rec, BASIC_BLOCK (EXIT_BLOCK), NULL);
+  df_refs_add_to_chains (&collection_rec, cfun->cfg->get_basic_block_by_idx (EXIT_BLOCK), NULL);
   collection_rec.use_vec.release ();
 }
 
@@ -4128,7 +4128,7 @@ df_update_exit_block_uses (void)
     {
       df_record_exit_block_uses (&refs);
       bitmap_copy (df->exit_block_uses,& refs);
-      df_set_bb_dirty (BASIC_BLOCK (EXIT_BLOCK));
+      df_set_bb_dirty (cfun->cfg->get_basic_block_by_idx (EXIT_BLOCK));
     }
   bitmap_clear (&refs);
 }
@@ -4176,7 +4176,7 @@ df_update_entry_exit_and_calls (void)
 
   /* The call insns need to be rescanned because there may be changes
      in the set of registers clobbered across the call.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       rtx insn;
       FOR_BB_INSNS (bb, insn)
@@ -4597,7 +4597,7 @@ df_scan_verify (void)
      clear a mark that has not been set as this means that the ref in
      the block or insn was not in the reg chain.  */
 
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     df_bb_verify (bb);
 
   /* (4) See if all reg chains are traversed a second time.  This time
diff --git a/gcc/dominance.c b/gcc/dominance.c
index 5c96dad..9fc0e8d 100644
--- a/gcc/dominance.c
+++ b/gcc/dominance.c
@@ -146,7 +146,7 @@ static void
 init_dom_info (struct dom_info *di, enum cdi_direction dir)
 {
   /* We need memory for n_basic_blocks nodes.  */
-  unsigned int num = n_basic_blocks;
+  unsigned int num = cfun->cfg->get_n_basic_blocks ();
   init_ar (di->dfs_parent, TBB, num, 0);
   init_ar (di->path_min, TBB, num, i);
   init_ar (di->key, TBB, num, i);
@@ -159,7 +159,7 @@ init_dom_info (struct dom_info *di, enum cdi_direction dir)
   init_ar (di->set_size, unsigned int, num, 1);
   init_ar (di->set_child, TBB, num, 0);
 
-  init_ar (di->dfs_order, TBB, (unsigned int) last_basic_block + 1, 0);
+  init_ar (di->dfs_order, TBB, (unsigned int) cfun->cfg->get_last_basic_block () + 1, 0);
   init_ar (di->dfs_to_bb, basic_block, num, 0);
 
   di->dfsnum = 1;
@@ -233,21 +233,21 @@ calc_dfs_tree_nonrec (struct dom_info *di, basic_block bb, bool reverse)
   /* Ending block.  */
   basic_block ex_block;
 
-  stack = XNEWVEC (edge_iterator, n_basic_blocks + 1);
+  stack = XNEWVEC (edge_iterator, cfun->cfg->get_n_basic_blocks () + 1);
   sp = 0;
 
   /* Initialize our border blocks, and the first edge.  */
   if (reverse)
     {
       ei = ei_start (bb->preds);
-      en_block = EXIT_BLOCK_PTR;
-      ex_block = ENTRY_BLOCK_PTR;
+      en_block = cfun->cfg->get_exit_block ();
+      ex_block = cfun->cfg->get_entry_block ();
     }
   else
     {
       ei = ei_start (bb->succs);
-      en_block = ENTRY_BLOCK_PTR;
-      ex_block = EXIT_BLOCK_PTR;
+      en_block = cfun->cfg->get_entry_block ();
+      ex_block = cfun->cfg->get_exit_block ();
     }
 
   /* When the stack is empty we break out of this loop.  */
@@ -296,7 +296,7 @@ calc_dfs_tree_nonrec (struct dom_info *di, basic_block bb, bool reverse)
 	  if (bb != en_block)
 	    my_i = di->dfs_order[bb->index];
 	  else
-	    my_i = di->dfs_order[last_basic_block];
+	    my_i = di->dfs_order[cfun->cfg->get_last_basic_block ()];
 	  child_i = di->dfs_order[bn->index] = di->dfsnum++;
 	  di->dfs_to_bb[child_i] = bn;
 	  di->dfs_parent[child_i] = my_i;
@@ -333,8 +333,8 @@ static void
 calc_dfs_tree (struct dom_info *di, bool reverse)
 {
   /* The first block is the ENTRY_BLOCK (or EXIT_BLOCK if REVERSE).  */
-  basic_block begin = reverse ? EXIT_BLOCK_PTR : ENTRY_BLOCK_PTR;
-  di->dfs_order[last_basic_block] = di->dfsnum;
+  basic_block begin = reverse ? cfun->cfg->get_exit_block () : cfun->cfg->get_entry_block ();
+  di->dfs_order[cfun->cfg->get_last_basic_block ()] = di->dfsnum;
   di->dfs_to_bb[di->dfsnum] = begin;
   di->dfsnum++;
 
@@ -355,7 +355,7 @@ calc_dfs_tree (struct dom_info *di, bool reverse)
       basic_block b;
       bool saw_unconnected = false;
 
-      FOR_EACH_BB_REVERSE (b)
+      FOR_EACH_BB_REVERSE_CFG (b, cfun->cfg)
 	{
 	  if (EDGE_COUNT (b->succs) > 0)
 	    {
@@ -366,14 +366,14 @@ calc_dfs_tree (struct dom_info *di, bool reverse)
 	  bitmap_set_bit (di->fake_exit_edge, b->index);
 	  di->dfs_order[b->index] = di->dfsnum;
 	  di->dfs_to_bb[di->dfsnum] = b;
-	  di->dfs_parent[di->dfsnum] = di->dfs_order[last_basic_block];
+	  di->dfs_parent[di->dfsnum] = di->dfs_order[cfun->cfg->get_last_basic_block ()];
 	  di->dfsnum++;
 	  calc_dfs_tree_nonrec (di, b, reverse);
 	}
 
       if (saw_unconnected)
 	{
-	  FOR_EACH_BB_REVERSE (b)
+	  FOR_EACH_BB_REVERSE_CFG (b, cfun->cfg)
 	    {
 	      basic_block b2;
 	      if (di->dfs_order[b->index])
@@ -383,7 +383,7 @@ calc_dfs_tree (struct dom_info *di, bool reverse)
 	      bitmap_set_bit (di->fake_exit_edge, b2->index);
 	      di->dfs_order[b2->index] = di->dfsnum;
 	      di->dfs_to_bb[di->dfsnum] = b2;
-	      di->dfs_parent[di->dfsnum] = di->dfs_order[last_basic_block];
+	      di->dfs_parent[di->dfsnum] = di->dfs_order[cfun->cfg->get_last_basic_block ()];
 	      di->dfsnum++;
 	      calc_dfs_tree_nonrec (di, b2, reverse);
 	      gcc_checking_assert (di->dfs_order[b->index]);
@@ -394,7 +394,7 @@ calc_dfs_tree (struct dom_info *di, bool reverse)
   di->nodes = di->dfsnum - 1;
 
   /* This aborts e.g. when there is _no_ path from ENTRY to EXIT at all.  */
-  gcc_assert (di->nodes == (unsigned int) n_basic_blocks - 1);
+  gcc_assert (di->nodes == (unsigned int) cfun->cfg->get_n_basic_blocks () - 1);
 }
 
 /* Compress the path from V to the root of its set and update path_min at the
@@ -501,9 +501,9 @@ calc_idoms (struct dom_info *di, bool reverse)
   edge_iterator ei, einext;
 
   if (reverse)
-    en_block = EXIT_BLOCK_PTR;
+    en_block = cfun->cfg->get_exit_block ();
   else
-    en_block = ENTRY_BLOCK_PTR;
+    en_block = cfun->cfg->get_entry_block ();
 
   /* Go backwards in DFS order, to first look at the leafs.  */
   v = di->nodes;
@@ -545,7 +545,7 @@ calc_idoms (struct dom_info *di, bool reverse)
 	  if (b == en_block)
 	    {
 	    do_fake_exit_edge:
-	      k1 = di->dfs_order[last_basic_block];
+	      k1 = di->dfs_order[cfun->cfg->get_last_basic_block ()];
 	    }
 	  else
 	    k1 = di->dfs_order[b->index];
@@ -620,7 +620,7 @@ compute_dom_fast_query (enum cdi_direction dir)
   if (dom_computed[dir_index] == DOM_OK)
     return;
 
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       if (!bb->dom[dir_index]->father)
 	assign_dfs_numbers (bb->dom[dir_index], &num);
@@ -648,17 +648,17 @@ calculate_dominance_info (enum cdi_direction dir)
     {
       gcc_assert (!n_bbs_in_dom_tree[dir_index]);
 
-      FOR_ALL_BB (b)
+      FOR_ALL_BB_CFG (b, cfun->cfg)
 	{
 	  b->dom[dir_index] = et_new_tree (b);
 	}
-      n_bbs_in_dom_tree[dir_index] = n_basic_blocks;
+      n_bbs_in_dom_tree[dir_index] = cfun->cfg->get_n_basic_blocks ();
 
       init_dom_info (&di, dir);
       calc_dfs_tree (&di, reverse);
       calc_idoms (&di, reverse);
 
-      FOR_EACH_BB (b)
+      FOR_EACH_BB_CFG (b, cfun->cfg)
 	{
 	  TBB d = di.dom[di.dfs_order[b->index]];
 
@@ -685,7 +685,7 @@ free_dominance_info (enum cdi_direction dir)
   if (!dom_info_available_p (dir))
     return;
 
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       et_free_tree_force (bb->dom[dir_index]);
       bb->dom[dir_index] = NULL;
@@ -883,10 +883,10 @@ nearest_common_dominator_for_set (enum cdi_direction dir, bitmap blocks)
   basic_block dom;
 
   first = bitmap_first_set_bit (blocks);
-  dom = BASIC_BLOCK (first);
+  dom = cfun->cfg->get_basic_block_by_idx (first);
   EXECUTE_IF_SET_IN_BITMAP (blocks, 0, i, bi)
-    if (dom != BASIC_BLOCK (i))
-      dom = nearest_common_dominator (dir, dom, BASIC_BLOCK (i));
+    if (dom != cfun->cfg->get_basic_block_by_idx (i))
+      dom = nearest_common_dominator (dir, dom, cfun->cfg->get_basic_block_by_idx (i));
 
   return dom;
 }
@@ -1021,7 +1021,7 @@ verify_dominators (enum cdi_direction dir)
   calc_dfs_tree (&di, reverse);
   calc_idoms (&di, reverse);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       imm_bb = get_immediate_dominator (dir, bb);
       if (!imm_bb)
@@ -1097,7 +1097,7 @@ prune_bbs_to_update_dominators (vec<basic_block> bbs,
 
   for (i = 0; bbs.iterate (i, &bb);)
     {
-      if (bb == ENTRY_BLOCK_PTR)
+      if (bb == cfun->cfg->get_entry_block ())
 	goto succeed;
 
       if (single_pred_p (bb))
@@ -1171,7 +1171,7 @@ determine_dominators_for_sons (struct graph *g, vec<basic_block> bbs,
   if (son[y] == -1)
     return;
   if (y == (int) bbs.length ())
-    ybb = ENTRY_BLOCK_PTR;
+    ybb = cfun->cfg->get_entry_block ();
   else
     ybb = bbs[y];
 
@@ -1344,7 +1344,7 @@ iterate_fix_dominators (enum cdi_direction dir, vec<basic_block> bbs,
 	set_immediate_dominator (CDI_DOMINATORS, bb, NULL);
       *pointer_map_insert (map, bb) = (void *) (size_t) i;
     }
-  *pointer_map_insert (map, ENTRY_BLOCK_PTR) = (void *) (size_t) n;
+  *pointer_map_insert (map, cfun->cfg->get_entry_block ()) = (void *) (size_t) n;
 
   g = new_graph (n + 1);
   for (y = 0; y < g->n_vertices; y++)
@@ -1488,7 +1488,7 @@ DEBUG_FUNCTION void
 debug_dominance_info (enum cdi_direction dir)
 {
   basic_block bb, bb2;
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     if ((bb2 = get_immediate_dominator (dir, bb)))
       fprintf (stderr, "%i %i\n", bb->index, bb2->index);
 }
diff --git a/gcc/domwalk.c b/gcc/domwalk.c
index 8c1ddc6..b63ee5f 100644
--- a/gcc/domwalk.c
+++ b/gcc/domwalk.c
@@ -156,15 +156,15 @@ walk_dominator_tree (struct dom_walk_data *walk_data, basic_block bb)
 {
   void *bd = NULL;
   basic_block dest;
-  basic_block *worklist = XNEWVEC (basic_block, n_basic_blocks * 2);
+  basic_block *worklist = XNEWVEC (basic_block, cfun->cfg->get_n_basic_blocks () * 2);
   int sp = 0;
   int *postorder, postorder_num;
 
   if (walk_data->dom_direction == CDI_DOMINATORS)
     {
-      postorder = XNEWVEC (int, n_basic_blocks);
+      postorder = XNEWVEC (int, cfun->cfg->get_n_basic_blocks ());
       postorder_num = inverted_post_order_compute (postorder);
-      bb_postorder = XNEWVEC (int, last_basic_block);
+      bb_postorder = XNEWVEC (int, cfun->cfg->get_last_basic_block ());
       for (int i = 0; i < postorder_num; ++i)
 	bb_postorder[postorder[i]] = i;
       free (postorder);
@@ -174,8 +174,8 @@ walk_dominator_tree (struct dom_walk_data *walk_data, basic_block bb)
     {
       /* Don't worry about unreachable blocks.  */
       if (EDGE_COUNT (bb->preds) > 0
-	  || bb == ENTRY_BLOCK_PTR
-	  || bb == EXIT_BLOCK_PTR)
+	  || bb == cfun->cfg->get_entry_block ()
+	  || bb == cfun->cfg->get_exit_block ())
 	{
 	  /* Callback to initialize the local data structure.  */
 	  if (walk_data->initialize_block_local_data)
diff --git a/gcc/dse.c b/gcc/dse.c
index d643cb0..62e0a7d 100644
--- a/gcc/dse.c
+++ b/gcc/dse.c
@@ -765,7 +765,7 @@ dse_step0 (void)
 
   rtx_group_table.create (11);
 
-  bb_table = XNEWVEC (bb_info_t, last_basic_block);
+  bb_table = XNEWVEC (bb_info_t, cfun->cfg->get_last_basic_block ());
   rtx_group_next_id = 0;
 
   stores_off_frame_dead_at_return = !cfun->stdarg;
@@ -2701,7 +2701,7 @@ dse_step1 (void)
   bitmap_set_bit (all_blocks, ENTRY_BLOCK);
   bitmap_set_bit (all_blocks, EXIT_BLOCK);
 
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       insn_info_t ptr;
       bb_info_t bb_info = (bb_info_t) pool_alloc (bb_info_pool);
@@ -2749,7 +2749,7 @@ dse_step1 (void)
 	  if (stores_off_frame_dead_at_return
 	      && (EDGE_COUNT (bb->succs) == 0
 		  || (single_succ_p (bb)
-		      && single_succ (bb) == EXIT_BLOCK_PTR
+		      && single_succ (bb) == cfun->cfg->get_exit_block ()
 		      && ! crtl->calls_eh_return)))
 	    {
 	      insn_info_t i_ptr = active_local_stores;
@@ -3276,14 +3276,14 @@ static void
 dse_step3 (bool for_spills)
 {
   basic_block bb;
-  sbitmap unreachable_blocks = sbitmap_alloc (last_basic_block);
+  sbitmap unreachable_blocks = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
   sbitmap_iterator sbi;
   bitmap all_ones = NULL;
   unsigned int i;
 
   bitmap_ones (unreachable_blocks);
 
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       bb_info_t bb_info = bb_table[bb->index];
       if (bb_info->gen)
@@ -3462,7 +3462,7 @@ dse_step4 (void)
       basic_block bb;
 
       fprintf (dump_file, "\n\n*** Global dataflow info after analysis.\n");
-      FOR_ALL_BB (bb)
+      FOR_ALL_BB_CFG (bb, cfun->cfg)
 	{
 	  bb_info_t bb_info = bb_table[bb->index];
 
@@ -3500,7 +3500,7 @@ static void
 dse_step5_nospill (void)
 {
   basic_block bb;
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       bb_info_t bb_info = bb_table[bb->index];
       insn_info_t insn_info = bb_info->last_insn;
@@ -3610,7 +3610,7 @@ dse_step6 (void)
 {
   basic_block bb;
 
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       bb_info_t bb_info = bb_table[bb->index];
       insn_info_t insn_info = bb_info->last_insn;
diff --git a/gcc/except.c b/gcc/except.c
index b25207b..9915b63 100644
--- a/gcc/except.c
+++ b/gcc/except.c
@@ -1239,7 +1239,7 @@ sjlj_emit_function_enter (rtx dispatch_label)
       }
 
   if (fn_begin_outside_block)
-    insert_insn_on_edge (seq, single_succ_edge (ENTRY_BLOCK_PTR));
+    insert_insn_on_edge (seq, single_succ_edge (cfun->cfg->get_entry_block ()));
   else
     emit_insn_after (seq, fn_begin);
 }
@@ -1507,11 +1507,11 @@ finish_eh_generation (void)
 
   if (targetm_common.except_unwind_info (&global_options) == UI_SJLJ
       /* Kludge for Alpha (see alpha_gp_save_rtx).  */
-      || single_succ_edge (ENTRY_BLOCK_PTR)->insns.r)
+      || single_succ_edge (cfun->cfg->get_entry_block ())->insns.r)
     commit_edge_insertions ();
 
   /* Redirect all EH edges from the post_landing_pad to the landing pad.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       eh_landing_pad lp;
       edge_iterator ei;
diff --git a/gcc/final.c b/gcc/final.c
index c836e5d..08bdf4b 100644
--- a/gcc/final.c
+++ b/gcc/final.c
@@ -698,14 +698,14 @@ compute_alignments (void)
       flow_loops_dump (dump_file, NULL, 1);
     }
   loop_optimizer_init (AVOID_CFG_MODIFICATIONS);
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     if (bb->frequency > freq_max)
       freq_max = bb->frequency;
   freq_threshold = freq_max / PARAM_VALUE (PARAM_ALIGN_THRESHOLD);
 
   if (dump_file)
     fprintf(dump_file, "freq_max: %i\n",freq_max);
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       rtx label = BB_HEAD (bb);
       int fallthru_frequency = 0, branch_frequency = 0, has_fallthru = 0;
@@ -758,7 +758,7 @@ compute_alignments (void)
 	  && (branch_frequency > freq_threshold
 	      || (bb->frequency > bb->prev_bb->frequency * 10
 		  && (bb->prev_bb->frequency
-		      <= ENTRY_BLOCK_PTR->frequency / 2))))
+		      <= cfun->cfg->get_entry_block ()->frequency / 2))))
 	{
 	  log = JUMP_ALIGN (label);
 	  if (dump_file)
@@ -1929,7 +1929,7 @@ final (rtx first, FILE *file, int optimize_p)
 
       /* There is no cfg for a thunk.  */
       if (!cfun->is_thunk)
-	FOR_EACH_BB_REVERSE (bb)
+	FOR_EACH_BB_REVERSE_CFG (bb, cfun->cfg)
 	  {
 	    start_to_bb[INSN_UID (BB_HEAD (bb))] = bb;
 	    end_to_bb[INSN_UID (BB_END (bb))] = bb;
diff --git a/gcc/function.c b/gcc/function.c
index 36c874f..c3a8cd1 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -3966,7 +3966,7 @@ regno_clobbered_at_setjmp (bitmap setjmp_crosses, int regno)
     return false;
 
   return ((REG_N_SETS (regno) > 1
-	   || REGNO_REG_SET_P (df_get_live_out (ENTRY_BLOCK_PTR), regno))
+	   || REGNO_REG_SET_P (df_get_live_out (cfun->cfg->get_entry_block ()), regno))
 	  && REGNO_REG_SET_P (setjmp_crosses, regno));
 }
 
@@ -4019,7 +4019,7 @@ generate_setjmp_warnings (void)
 {
   bitmap setjmp_crosses = regstat_get_setjmp_crosses ();
 
-  if (n_basic_blocks == NUM_FIXED_BLOCKS
+  if (cfun->cfg->get_n_basic_blocks () == NUM_FIXED_BLOCKS
       || bitmap_empty_p (setjmp_crosses))
     return;
 
@@ -5437,7 +5437,7 @@ next_block_for_reg (basic_block bb, int regno, int end_regno)
 
   /* We can sometimes encounter dead code.  Don't try to move it
      into the exit block.  */
-  if (!live_edge || live_edge->dest == EXIT_BLOCK_PTR)
+  if (!live_edge || live_edge->dest == cfun->cfg->get_exit_block ())
     return NULL;
 
   /* Reject targets of abnormal edges.  This is needed for correctness
@@ -5739,7 +5739,7 @@ convert_jumps_to_returns (basic_block last_bb, bool simple_p,
 
   src_bbs.create (EDGE_COUNT (last_bb->preds));
   FOR_EACH_EDGE (e, ei, last_bb->preds)
-    if (e->src != ENTRY_BLOCK_PTR)
+    if (e->src != cfun->cfg->get_entry_block ())
       src_bbs.quick_push (e->src);
 
   label = BB_HEAD (last_bb);
@@ -5819,7 +5819,7 @@ convert_jumps_to_returns (basic_block last_bb, bool simple_p,
 	}
 
       /* Fix up the CFG for the successful change we just made.  */
-      redirect_edge_succ (e, EXIT_BLOCK_PTR);
+      redirect_edge_succ (e, cfun->cfg->get_exit_block ());
       e->flags &= ~EDGE_CROSSING;
     }
   src_bbs.release ();
@@ -5911,7 +5911,7 @@ thread_prologue_and_epilogue_insns (void)
 
   df_analyze ();
 
-  rtl_profile_for_bb (ENTRY_BLOCK_PTR);
+  rtl_profile_for_bb (cfun->cfg->get_entry_block ());
 
   inserted = false;
   seq = NULL_RTX;
@@ -5921,8 +5921,8 @@ thread_prologue_and_epilogue_insns (void)
   /* Can't deal with multiple successors of the entry block at the
      moment.  Function should always have at least one entry
      point.  */
-  gcc_assert (single_succ_p (ENTRY_BLOCK_PTR));
-  entry_edge = single_succ_edge (ENTRY_BLOCK_PTR);
+  gcc_assert (single_succ_p (cfun->cfg->get_entry_block ()));
+  entry_edge = single_succ_edge (cfun->cfg->get_entry_block ());
   orig_entry_edge = entry_edge;
 
   split_prologue_seq = NULL_RTX;
@@ -6032,7 +6032,7 @@ thread_prologue_and_epilogue_insns (void)
       /* Find the set of basic blocks that require a stack frame,
 	 and blocks that are too big to be duplicated.  */
 
-      vec.create (n_basic_blocks);
+      vec.create (cfun->cfg->get_n_basic_blocks ());
 
       CLEAR_HARD_REG_SET (set_up_by_prologue.set);
       add_to_hard_reg_set (&set_up_by_prologue.set, Pmode,
@@ -6058,7 +6058,7 @@ thread_prologue_and_epilogue_insns (void)
       max_grow_size = get_uncond_jump_length ();
       max_grow_size *= PARAM_VALUE (PARAM_MAX_GROW_COPY_BB_INSNS);
 
-      FOR_EACH_BB (bb)
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
 	{
 	  rtx insn;
 	  unsigned size = 0;
@@ -6095,7 +6095,7 @@ thread_prologue_and_epilogue_insns (void)
 	  basic_block tmp_bb = vec.pop ();
 
 	  FOR_EACH_EDGE (e, ei, tmp_bb->succs)
-	    if (e->dest != EXIT_BLOCK_PTR
+	    if (e->dest != cfun->cfg->get_exit_block ()
 		&& bitmap_set_bit (&bb_flags, e->dest->index))
 	      vec.quick_push (e->dest);
 	}
@@ -6103,7 +6103,7 @@ thread_prologue_and_epilogue_insns (void)
       /* Find the set of basic blocks that need no prologue, have a
 	 single successor, can be duplicated, meet a max size
 	 requirement, and go to the exit via like blocks.  */
-      vec.quick_push (EXIT_BLOCK_PTR);
+      vec.quick_push (cfun->cfg->get_exit_block ());
       while (!vec.is_empty ())
 	{
 	  basic_block tmp_bb = vec.pop ();
@@ -6135,7 +6135,7 @@ thread_prologue_and_epilogue_insns (void)
 	 needing a prologue.  */
       bitmap_clear (&bb_on_list);
       bitmap_and_compl (&bb_antic_flags, &bb_flags, &bb_tail);
-      FOR_EACH_BB (bb)
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
 	{
 	  if (!bitmap_bit_p (&bb_antic_flags, bb->index))
 	    continue;
@@ -6169,7 +6169,7 @@ thread_prologue_and_epilogue_insns (void)
       /* Find exactly one edge that leads to a block in ANTIC from
 	 a block that isn't.  */
       if (!bitmap_bit_p (&bb_antic_flags, entry_edge->dest->index))
-	FOR_EACH_BB (bb)
+	FOR_EACH_BB_CFG (bb, cfun->cfg)
 	  {
 	    if (!bitmap_bit_p (&bb_antic_flags, bb->index))
 	      continue;
@@ -6217,7 +6217,7 @@ thread_prologue_and_epilogue_insns (void)
 	  /* Find tail blocks reachable from both blocks needing a
 	     prologue and blocks not needing a prologue.  */
 	  if (!bitmap_empty_p (&bb_tail))
-	    FOR_EACH_BB (bb)
+	    FOR_EACH_BB_CFG (bb, cfun->cfg)
 	      {
 		bool some_pro, some_no_pro;
 		if (!bitmap_bit_p (&bb_tail, bb->index))
@@ -6251,7 +6251,7 @@ thread_prologue_and_epilogue_insns (void)
 	    }
 	  /* Now duplicate the tails.  */
 	  if (!bitmap_empty_p (&bb_tail))
-	    FOR_EACH_BB_REVERSE (bb)
+	    FOR_EACH_BB_REVERSE_CFG (bb, cfun->cfg)
 	      {
 		basic_block copy_bb, tbb;
 		rtx insert_point;
@@ -6278,7 +6278,7 @@ thread_prologue_and_epilogue_insns (void)
 		  {
 		    /* Otherwise put the copy at the end of the function.  */
 		    copy_bb = create_basic_block (NULL_RTX, NULL_RTX,
-						  EXIT_BLOCK_PTR->prev_bb);
+						  cfun->cfg->get_exit_block ()->prev_bb);
 		    BB_COPY_PARTITION (copy_bb, bb);
 		  }
 
@@ -6292,7 +6292,7 @@ thread_prologue_and_epilogue_insns (void)
 		    dup_block_and_redirect (tbb, copy_bb, insert_point,
 					    &bb_flags);
 		    tbb = single_succ (tbb);
-		    if (tbb == EXIT_BLOCK_PTR)
+		    if (tbb == cfun->cfg->get_exit_block ())
 		      break;
 		    e = split_block (copy_bb, PREV_INSN (insert_point));
 		    copy_bb = e->dest;
@@ -6306,7 +6306,7 @@ thread_prologue_and_epilogue_insns (void)
 		if (CALL_P (PREV_INSN (insert_point))
 		    && SIBLING_CALL_P (PREV_INSN (insert_point)))
 		  eflags = EDGE_SIBCALL | EDGE_ABNORMAL;
-		make_single_succ_edge (copy_bb, EXIT_BLOCK_PTR, eflags);
+		make_single_succ_edge (copy_bb, cfun->cfg->get_exit_block (), eflags);
 
 		/* verify_flow_info doesn't like a note after a
 		   sibling call.  */
@@ -6337,15 +6337,15 @@ thread_prologue_and_epilogue_insns (void)
 
   /* If the exit block has no non-fake predecessors, we don't need
      an epilogue.  */
-  FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
+  FOR_EACH_EDGE (e, ei, cfun->cfg->get_exit_block ()->preds)
     if ((e->flags & EDGE_FAKE) == 0)
       break;
   if (e == NULL)
     goto epilogue_done;
 
-  rtl_profile_for_bb (EXIT_BLOCK_PTR);
+  rtl_profile_for_bb (cfun->cfg->get_exit_block ());
 
-  exit_fallthru_edge = find_fallthru_edge (EXIT_BLOCK_PTR->preds);
+  exit_fallthru_edge = find_fallthru_edge (cfun->cfg->get_exit_block ()->preds);
 
   /* If we're allowed to generate a simple return instruction, then by
      definition we don't need a full epilogue.  If the last basic
@@ -6361,10 +6361,10 @@ thread_prologue_and_epilogue_insns (void)
 
 	  /* convert_jumps_to_returns may add to EXIT_BLOCK_PTR->preds
 	     (but won't remove).  Stop at end of current preds.  */
-	  last = EDGE_COUNT (EXIT_BLOCK_PTR->preds);
+	  last = EDGE_COUNT (cfun->cfg->get_exit_block ()->preds);
 	  for (i = 0; i < last; i++)
 	    {
-	      e = EDGE_I (EXIT_BLOCK_PTR->preds, i);
+	      e = EDGE_I (cfun->cfg->get_exit_block ()->preds, i);
 	      if (LABEL_P (BB_HEAD (e->src))
 		  && !bitmap_bit_p (&bb_flags, e->src->index)
 		  && !active_insn_between (BB_HEAD (e->src), BB_END (e->src)))
@@ -6428,7 +6428,7 @@ thread_prologue_and_epilogue_insns (void)
      code.  In order to be able to properly annotate these with unwind
      info, try to split them now.  If we get a valid split, drop an
      EPILOGUE_BEG note and mark the insns as epilogue insns.  */
-  FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
+  FOR_EACH_EDGE (e, ei, cfun->cfg->get_exit_block ()->preds)
     {
       rtx prev, last, trial;
 
@@ -6492,7 +6492,7 @@ thread_prologue_and_epilogue_insns (void)
 	 we take advantage of cfg_layout_finalize using
 	 fixup_fallthru_exit_predecessor.  */
       cfg_layout_initialize (0);
-      FOR_EACH_BB (cur_bb)
+      FOR_EACH_BB_CFG (cur_bb, cfun->cfg)
 	if (cur_bb->index >= NUM_FIXED_BLOCKS
 	    && cur_bb->next_bb->index >= NUM_FIXED_BLOCKS)
 	  cur_bb->aux = cur_bb->next_bb;
@@ -6510,7 +6510,7 @@ epilogue_done:
       commit_edge_insertions ();
 
       /* Look for basic blocks within the prologue insns.  */
-      blocks = sbitmap_alloc (last_basic_block);
+      blocks = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
       bitmap_clear (blocks);
       bitmap_set_bit (blocks, entry_edge->dest->index);
       bitmap_set_bit (blocks, orig_entry_edge->dest->index);
@@ -6519,7 +6519,7 @@ epilogue_done:
 
       /* The epilogue insns we inserted may cause the exit edge to no longer
 	 be fallthru.  */
-      FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
+      FOR_EACH_EDGE (e, ei, cfun->cfg->get_exit_block ()->preds)
 	{
 	  if (((e->flags & EDGE_FALLTHRU) != 0)
 	      && returnjump_p (BB_END (e->src)))
@@ -6538,7 +6538,7 @@ epilogue_done:
       basic_block simple_return_block_cold = NULL;
       edge pending_edge_hot = NULL;
       edge pending_edge_cold = NULL;
-      basic_block exit_pred = EXIT_BLOCK_PTR->prev_bb;
+      basic_block exit_pred = cfun->cfg->get_exit_block ()->prev_bb;
       int i;
 
       gcc_assert (entry_edge != orig_entry_edge);
@@ -6556,7 +6556,7 @@ epilogue_done:
 	}
 
       /* Also check returns we might need to add to tail blocks.  */
-      FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
+      FOR_EACH_EDGE (e, ei, cfun->cfg->get_exit_block ()->preds)
 	if (EDGE_COUNT (e->src->preds) != 0
 	    && (e->flags & EDGE_FAKE) != 0
 	    && !bitmap_bit_p (&bb_flags, e->src->index))
@@ -6602,7 +6602,7 @@ epilogue_done:
 	      emit_barrier_after (start);
 
 	      *pdest_bb = bb;
-	      make_edge (bb, EXIT_BLOCK_PTR, 0);
+	      make_edge (bb, cfun->cfg->get_exit_block (), 0);
 	    }
 	  redirect_edge_and_branch_force (e, *pdest_bb);
 	}
@@ -6611,7 +6611,7 @@ epilogue_done:
 
   if (entry_edge != orig_entry_edge)
     {
-      FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
+      FOR_EACH_EDGE (e, ei, cfun->cfg->get_exit_block ()->preds)
 	if (EDGE_COUNT (e->src->preds) != 0
 	    && (e->flags & EDGE_FAKE) != 0
 	    && !bitmap_bit_p (&bb_flags, e->src->index))
@@ -6624,7 +6624,7 @@ epilogue_done:
 
 #ifdef HAVE_sibcall_epilogue
   /* Emit sibling epilogues before any sibling call sites.  */
-  for (ei = ei_start (EXIT_BLOCK_PTR->preds); (e = ei_safe_edge (ei)); )
+  for (ei = ei_start (cfun->cfg->get_exit_block ()->preds); (e = ei_safe_edge (ei)); )
     {
       basic_block bb = e->src;
       rtx insn = BB_END (bb);
@@ -6755,7 +6755,7 @@ reposition_prologue_and_epilogue_notes (void)
       edge_iterator ei;
       edge e;
 
-      FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
+      FOR_EACH_EDGE (e, ei, cfun->cfg->get_exit_block ()->preds)
 	{
 	  rtx insn, first = NULL, note = NULL;
 	  basic_block bb = e->src;
@@ -7160,7 +7160,7 @@ rest_of_match_asm_constraints (void)
     return 0;
 
   df_set_flags (DF_DEFER_INSN_RESCAN);
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       FOR_BB_INSNS (bb, insn)
 	{
diff --git a/gcc/fwprop.c b/gcc/fwprop.c
index 17cc62a..dd88a56 100644
--- a/gcc/fwprop.c
+++ b/gcc/fwprop.c
@@ -285,7 +285,7 @@ build_single_def_use_links (void)
   reg_defs.create (max_reg_num ());
   reg_defs.safe_grow_cleared (max_reg_num ());
 
-  reg_defs_stack.create (n_basic_blocks * 10);
+  reg_defs_stack.create (cfun->cfg->get_n_basic_blocks () * 10);
   local_md = BITMAP_ALLOC (NULL);
   local_lr = BITMAP_ALLOC (NULL);
 
@@ -297,7 +297,7 @@ build_single_def_use_links (void)
   walk_data.after_dom_children = single_def_use_leave_block;
 
   init_walk_dominator_tree (&walk_data);
-  walk_dominator_tree (&walk_data, ENTRY_BLOCK_PTR);
+  walk_dominator_tree (&walk_data, cfun->cfg->get_entry_block ());
   fini_walk_dominator_tree (&walk_data);
 
   BITMAP_FREE (local_lr);
diff --git a/gcc/gcse.c b/gcc/gcse.c
index e485985..92d6178 100644
--- a/gcc/gcse.c
+++ b/gcc/gcse.c
@@ -633,8 +633,8 @@ alloc_gcse_mem (void)
      pre-processor limitation with template types in macro arguments.  */
   typedef vec<rtx> vec_rtx_heap;
   typedef vec<modify_pair> vec_modify_pair_heap;
-  modify_mem_list = GCNEWVEC (vec_rtx_heap, last_basic_block);
-  canon_modify_mem_list = GCNEWVEC (vec_modify_pair_heap, last_basic_block);
+  modify_mem_list = GCNEWVEC (vec_rtx_heap, cfun->cfg->get_last_basic_block ());
+  canon_modify_mem_list = GCNEWVEC (vec_modify_pair_heap, cfun->cfg->get_last_basic_block ());
   modify_mem_list_set = BITMAP_ALLOC (NULL);
   blocks_with_calls = BITMAP_ALLOC (NULL);
 }
@@ -685,13 +685,13 @@ compute_local_properties (sbitmap *transp, sbitmap *comp, sbitmap *antloc,
   /* Initialize any bitmaps that were passed in.  */
   if (transp)
     {
-      bitmap_vector_ones (transp, last_basic_block);
+      bitmap_vector_ones (transp, cfun->cfg->get_last_basic_block ());
     }
 
   if (comp)
-    bitmap_vector_clear (comp, last_basic_block);
+    bitmap_vector_clear (comp, cfun->cfg->get_last_basic_block ());
   if (antloc)
-    bitmap_vector_clear (antloc, last_basic_block);
+    bitmap_vector_clear (antloc, cfun->cfg->get_last_basic_block ());
 
   for (i = 0; i < table->size; i++)
     {
@@ -1558,7 +1558,7 @@ compute_hash_table_work (struct hash_table_d *table)
   for (i = 0; i < max_reg_num (); ++i)
     reg_avail_info[i].last_bb = NULL;
 
-  FOR_EACH_BB (current_bb)
+  FOR_EACH_BB_CFG (current_bb, cfun->cfg)
     {
       rtx insn;
       unsigned int regno;
@@ -1898,7 +1898,7 @@ prune_expressions (bool pre_p)
 	}
     }
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       edge e;
       edge_iterator ei;
@@ -1964,7 +1964,7 @@ prune_insertions_deletions (int n_elems)
 
   /* Iterate over the edges counting the number of times each expression
      needs to be inserted.  */
-  for (i = 0; i < (unsigned) n_edges; i++)
+  for (i = 0; i < (unsigned) cfun->cfg->get_n_edges (); i++)
     {
       EXECUTE_IF_SET_IN_BITMAP (pre_insert_map[i], 0, j, sbi)
 	insertions[j]++;
@@ -1972,7 +1972,7 @@ prune_insertions_deletions (int n_elems)
 
   /* Similarly for deletions, but those occur in blocks rather than on
      edges.  */
-  for (i = 0; i < (unsigned) last_basic_block; i++)
+  for (i = 0; i < (unsigned) cfun->cfg->get_last_basic_block (); i++)
     {
       EXECUTE_IF_SET_IN_BITMAP (pre_delete_map[i], 0, j, sbi)
 	deletions[j]++;
@@ -1990,10 +1990,10 @@ prune_insertions_deletions (int n_elems)
   /* Now prune PRE_INSERT_MAP and PRE_DELETE_MAP based on PRUNE_EXPRS.  */
   EXECUTE_IF_SET_IN_BITMAP (prune_exprs, 0, j, sbi)
     {
-      for (i = 0; i < (unsigned) n_edges; i++)
+      for (i = 0; i < (unsigned) cfun->cfg->get_n_edges (); i++)
 	bitmap_clear_bit (pre_insert_map[i], j);
 
-      for (i = 0; i < (unsigned) last_basic_block; i++)
+      for (i = 0; i < (unsigned) cfun->cfg->get_last_basic_block (); i++)
 	bitmap_clear_bit (pre_delete_map[i], j);
     }
 
@@ -2012,14 +2012,14 @@ compute_pre_data (void)
 
   compute_local_properties (transp, comp, antloc, &expr_hash_table);
   prune_expressions (true);
-  bitmap_vector_clear (ae_kill, last_basic_block);
+  bitmap_vector_clear (ae_kill, cfun->cfg->get_last_basic_block ());
 
   /* Compute ae_kill for each basic block using:
 
      ~(TRANSP | COMP)
   */
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       bitmap_ior (ae_kill[bb->index], transp[bb->index], comp[bb->index]);
       bitmap_not (ae_kill[bb->index], ae_kill[bb->index]);
@@ -2063,7 +2063,7 @@ pre_expr_reaches_here_p_work (basic_block occr_bb, struct expr *expr,
     {
       basic_block pred_bb = pred->src;
 
-      if (pred->src == ENTRY_BLOCK_PTR
+      if (pred->src == cfun->cfg->get_entry_block ()
 	  /* Has predecessor has already been visited?  */
 	  || visited[pred_bb->index])
 	;/* Nothing to do.  */
@@ -2103,7 +2103,7 @@ static int
 pre_expr_reaches_here_p (basic_block occr_bb, struct expr *expr, basic_block bb)
 {
   int rval;
-  char *visited = XCNEWVEC (char, last_basic_block);
+  char *visited = XCNEWVEC (char, cfun->cfg->get_last_basic_block ());
 
   rval = pre_expr_reaches_here_p_work (occr_bb, expr, bb, visited);
 
@@ -2662,7 +2662,7 @@ one_pre_gcse_pass (void)
   gcse_create_count = 0;
 
   /* Return if there's nothing to do, or it is too expensive.  */
-  if (n_basic_blocks <= NUM_FIXED_BLOCKS + 1
+  if (cfun->cfg->get_n_basic_blocks () <= NUM_FIXED_BLOCKS + 1
       || is_too_expensive (_("PRE disabled")))
     return 0;
 
@@ -2687,7 +2687,7 @@ one_pre_gcse_pass (void)
   if (expr_hash_table.n_elems > 0)
     {
       struct edge_list *edge_list;
-      alloc_pre_mem (last_basic_block, expr_hash_table.n_elems);
+      alloc_pre_mem (cfun->cfg->get_last_basic_block (), expr_hash_table.n_elems);
       edge_list = compute_pre_data ();
       changed |= pre_gcse (edge_list);
       free_edge_list (edge_list);
@@ -2708,7 +2708,7 @@ one_pre_gcse_pass (void)
   if (dump_file)
     {
       fprintf (dump_file, "PRE GCSE of %s, %d basic blocks, %d bytes needed, ",
-	       current_function_name (), n_basic_blocks, bytes_used);
+	       current_function_name (), cfun->cfg->get_n_basic_blocks (), bytes_used);
       fprintf (dump_file, "%d substs, %d insns created\n",
 	       gcse_subst_count, gcse_create_count);
     }
@@ -2815,8 +2815,8 @@ compute_code_hoist_vbeinout (void)
   int changed, passes;
   basic_block bb;
 
-  bitmap_vector_clear (hoist_vbeout, last_basic_block);
-  bitmap_vector_clear (hoist_vbein, last_basic_block);
+  bitmap_vector_clear (hoist_vbeout, cfun->cfg->get_last_basic_block ());
+  bitmap_vector_clear (hoist_vbein, cfun->cfg->get_last_basic_block ());
 
   passes = 0;
   changed = 1;
@@ -2827,9 +2827,9 @@ compute_code_hoist_vbeinout (void)
 
       /* We scan the blocks in the reverse order to speed up
 	 the convergence.  */
-      FOR_EACH_BB_REVERSE (bb)
+      FOR_EACH_BB_REVERSE_CFG (bb, cfun->cfg)
 	{
-	  if (bb->next_bb != EXIT_BLOCK_PTR)
+	  if (bb->next_bb != cfun->cfg->get_exit_block ())
 	    {
 	      bitmap_intersection_of_succs (hoist_vbeout[bb->index],
 					    hoist_vbein, bb);
@@ -2853,7 +2853,7 @@ compute_code_hoist_vbeinout (void)
     {
       fprintf (dump_file, "hoisting vbeinout computation: %d passes\n", passes);
 
-      FOR_EACH_BB (bb)
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
         {
 	  fprintf (dump_file, "vbein (%d): ", bb->index);
 	  dump_bitmap_file (dump_file, hoist_vbein[bb->index]);
@@ -2907,7 +2907,7 @@ update_bb_reg_pressure (basic_block bb, rtx from)
       FOR_EACH_EDGE (succ, ei, bb->succs)
 	{
 	  succ_bb = succ->dest;
-	  if (succ_bb == EXIT_BLOCK_PTR)
+	  if (succ_bb == cfun->cfg->get_exit_block ())
 	    continue;
 
 	  if (bitmap_bit_p (BB_DATA (succ_bb)->live_in, REGNO (dreg)))
@@ -3032,7 +3032,7 @@ should_hoist_expr_to_dom (basic_block expr_bb, struct expr *expr,
   if (visited == NULL)
     {
       visited_allocated_locally = 1;
-      visited = sbitmap_alloc (last_basic_block);
+      visited = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
       bitmap_clear (visited);
     }
 
@@ -3040,7 +3040,7 @@ should_hoist_expr_to_dom (basic_block expr_bb, struct expr *expr,
     {
       basic_block pred_bb = pred->src;
 
-      if (pred->src == ENTRY_BLOCK_PTR)
+      if (pred->src == cfun->cfg->get_entry_block ())
 	break;
       else if (pred_bb == expr_bb)
 	continue;
@@ -3165,9 +3165,9 @@ hoist_code (void)
      data to restrict distance an expression can travel.  */
 
   to_bb_head = XCNEWVEC (int, get_max_uid ());
-  bb_size = XCNEWVEC (int, last_basic_block);
+  bb_size = XCNEWVEC (int, cfun->cfg->get_last_basic_block ());
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       rtx insn;
       int to_head;
@@ -3184,16 +3184,16 @@ hoist_code (void)
       bb_size[bb->index] = to_head;
     }
 
-  gcc_assert (EDGE_COUNT (ENTRY_BLOCK_PTR->succs) == 1
-	      && (EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->dest
-		  == ENTRY_BLOCK_PTR->next_bb));
+  gcc_assert (EDGE_COUNT (cfun->cfg->get_entry_block ()->succs) == 1
+	      && (EDGE_SUCC (cfun->cfg->get_entry_block (), 0)->dest
+		  == cfun->cfg->get_entry_block ()->next_bb));
 
   from_bbs = BITMAP_ALLOC (NULL);
   if (flag_ira_hoist_pressure)
     hoisted_bbs = BITMAP_ALLOC (NULL);
 
   dom_tree_walk = get_all_dominated_blocks (CDI_DOMINATORS,
-					    ENTRY_BLOCK_PTR->next_bb);
+					    cfun->cfg->get_entry_block ()->next_bb);
 
   /* Walk over each basic block looking for potentially hoistable
      expressions, nothing gets hoisted from the entry block.  */
@@ -3336,7 +3336,7 @@ hoist_code (void)
 		  data->max_reg_pressure[pressure_class] += nregs;
 		  EXECUTE_IF_SET_IN_BITMAP (hoisted_bbs, 0, k, bi)
 		    {
-		      data = BB_DATA (BASIC_BLOCK (k));
+		      data = BB_DATA (cfun->cfg->get_basic_block_by_idx (k));
 		      data->max_reg_pressure[pressure_class] += nregs;
 		    }
 		}
@@ -3347,7 +3347,7 @@ hoist_code (void)
 		     hoisted.  */
 		  EXECUTE_IF_SET_IN_BITMAP (hoisted_bbs, 0, k, bi)
 		    {
-		      data = BB_DATA (BASIC_BLOCK (k));
+		      data = BB_DATA (cfun->cfg->get_basic_block_by_idx (k));
 		      bitmap_copy (data->live_in, data->backup);
 		      data->max_reg_pressure[pressure_class]
 			  = data->old_pressure;
@@ -3510,7 +3510,7 @@ calculate_bb_reg_pressure (void)
 
   ira_setup_eliminable_regset (false);
   curr_regs_live = BITMAP_ALLOC (&reg_obstack);
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       curr_bb = bb;
       BB_DATA (bb)->live_in = BITMAP_ALLOC (NULL);
@@ -3560,7 +3560,7 @@ calculate_bb_reg_pressure (void)
     return;
 
   fprintf (dump_file, "\nRegister Pressure: \n");
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       fprintf (dump_file, "  Basic block %d: \n", bb->index);
       for (i = 0; (int) i < ira_pressure_classes_num; i++)
@@ -3591,7 +3591,7 @@ one_code_hoisting_pass (void)
   gcse_create_count = 0;
 
   /* Return if there's nothing to do, or it is too expensive.  */
-  if (n_basic_blocks <= NUM_FIXED_BLOCKS + 1
+  if (cfun->cfg->get_n_basic_blocks () <= NUM_FIXED_BLOCKS + 1
       || is_too_expensive (_("GCSE disabled")))
     return 0;
 
@@ -3621,7 +3621,7 @@ one_code_hoisting_pass (void)
 
   if (expr_hash_table.n_elems > 0)
     {
-      alloc_code_hoist_mem (last_basic_block, expr_hash_table.n_elems);
+      alloc_code_hoist_mem (cfun->cfg->get_last_basic_block (), expr_hash_table.n_elems);
       compute_code_hoist_data ();
       changed = hoist_code ();
       free_code_hoist_mem ();
@@ -3642,7 +3642,7 @@ one_code_hoisting_pass (void)
   if (dump_file)
     {
       fprintf (dump_file, "HOIST of %s, %d basic blocks, %d bytes needed, ",
-	       current_function_name (), n_basic_blocks, bytes_used);
+	       current_function_name (), cfun->cfg->get_n_basic_blocks (), bytes_used);
       fprintf (dump_file, "%d substs, %d insns created\n",
 	       gcse_subst_count, gcse_create_count);
     }
@@ -3884,7 +3884,7 @@ compute_ld_motion_mems (void)
   pre_ldst_mems = NULL;
   pre_ldst_table.create (13);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       FOR_BB_INSNS (bb, insn)
 	{
@@ -4067,24 +4067,24 @@ is_too_expensive (const char *pass)
      which have a couple switch statements.  Rather than simply
      threshold the number of blocks, uses something with a more
      graceful degradation.  */
-  if (n_edges > 20000 + n_basic_blocks * 4)
+  if (cfun->cfg->get_n_edges () > 20000 + cfun->cfg->get_n_basic_blocks () * 4)
     {
       warning (OPT_Wdisabled_optimization,
 	       "%s: %d basic blocks and %d edges/basic block",
-	       pass, n_basic_blocks, n_edges / n_basic_blocks);
+	       pass, cfun->cfg->get_n_basic_blocks (), cfun->cfg->get_n_edges () / cfun->cfg->get_n_basic_blocks ());
 
       return true;
     }
 
   /* If allocating memory for the dataflow bitmaps would take up too much
      storage it's better just to disable the optimization.  */
-  if ((n_basic_blocks
+  if ((cfun->cfg->get_n_basic_blocks ()
        * SBITMAP_SET_SIZE (max_reg_num ())
        * sizeof (SBITMAP_ELT_TYPE)) > MAX_GCSE_MEMORY)
     {
       warning (OPT_Wdisabled_optimization,
 	       "%s: %d basic blocks and %d registers",
-	       pass, n_basic_blocks, max_reg_num ());
+	       pass, cfun->cfg->get_n_basic_blocks (), max_reg_num ());
 
       return true;
     }
diff --git a/gcc/gimple-iterator.c b/gcc/gimple-iterator.c
index 0b0151f..773be27 100644
--- a/gcc/gimple-iterator.c
+++ b/gcc/gimple-iterator.c
@@ -707,7 +707,7 @@ gimple_find_edge_insert_loc (edge e, gimple_stmt_iterator *gsi,
  restart:
   if (single_pred_p (dest)
       && gimple_seq_empty_p (phi_nodes (dest))
-      && dest != EXIT_BLOCK_PTR)
+      && dest != cfun->cfg->get_exit_block ())
     {
       *gsi = gsi_start_bb (dest);
       if (gsi_end_p (*gsi))
@@ -738,7 +738,7 @@ gimple_find_edge_insert_loc (edge e, gimple_stmt_iterator *gsi,
   src = e->src;
   if ((e->flags & EDGE_ABNORMAL) == 0
       && single_succ_p (src)
-      && src != ENTRY_BLOCK_PTR)
+      && src != cfun->cfg->get_entry_block ())
     {
       *gsi = gsi_last_bb (src);
       if (gsi_end_p (*gsi))
@@ -824,9 +824,9 @@ gsi_commit_edge_inserts (void)
   edge e;
   edge_iterator ei;
 
-  gsi_commit_one_edge_insert (single_succ_edge (ENTRY_BLOCK_PTR), NULL);
+  gsi_commit_one_edge_insert (single_succ_edge (cfun->cfg->get_entry_block ()), NULL);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     FOR_EACH_EDGE (e, ei, bb->succs)
       gsi_commit_one_edge_insert (e, NULL);
 }
diff --git a/gcc/gimple-ssa-strength-reduction.c b/gcc/gimple-ssa-strength-reduction.c
index dcd3180..c872ad4 100644
--- a/gcc/gimple-ssa-strength-reduction.c
+++ b/gcc/gimple-ssa-strength-reduction.c
@@ -724,7 +724,7 @@ slsr_process_phi (gimple phi, bool speed)
 	  derived_base_name = arg;
 
 	  if (SSA_NAME_IS_DEFAULT_DEF (arg))
-	    arg_bb = single_succ (ENTRY_BLOCK_PTR);
+	    arg_bb = single_succ (cfun->cfg->get_entry_block ());
 	  else
 	    gimple_bb (SSA_NAME_DEF_STMT (arg));
 	}
@@ -3435,7 +3435,7 @@ execute_strength_reduction (void)
 
   /* Walk the CFG in predominator order looking for strength reduction
      candidates.  */
-  walk_dominator_tree (&walk_data, ENTRY_BLOCK_PTR);
+  walk_dominator_tree (&walk_data, cfun->cfg->get_entry_block ());
 
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
diff --git a/gcc/gimple.c b/gcc/gimple.c
index f507419..c20f282 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -2038,17 +2038,17 @@ gimple_set_bb (gimple stmt, basic_block bb)
       uid = LABEL_DECL_UID (t);
       if (uid == -1)
 	{
-	  unsigned old_len = vec_safe_length (label_to_block_map);
+	  unsigned old_len = vec_safe_length (cfun->cfg->get_label_to_block_map ());
 	  LABEL_DECL_UID (t) = uid = cfun->cfg->last_label_uid++;
 	  if (old_len <= (unsigned) uid)
 	    {
 	      unsigned new_len = 3 * uid / 2 + 1;
 
-	      vec_safe_grow_cleared (label_to_block_map, new_len);
+	      vec_safe_grow_cleared (cfun->cfg->get_label_to_block_map (), new_len);
 	    }
 	}
 
-      (*label_to_block_map)[uid] = bb;
+      (*cfun->cfg->get_label_to_block_map ())[uid] = bb;
     }
 }
 
diff --git a/gcc/graph.c b/gcc/graph.c
index 97930d0..992d7b1 100644
--- a/gcc/graph.c
+++ b/gcc/graph.c
@@ -177,14 +177,14 @@ draw_cfg_nodes_no_loops (pretty_printer *pp, struct function *fun)
   int i, n;
   sbitmap visited;
 
-  visited = sbitmap_alloc (last_basic_block);
+  visited = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
   bitmap_clear (visited);
 
   /* FIXME: pre_and_rev_post_order_compute only works if fun == cfun.  */
   n = pre_and_rev_post_order_compute (NULL, rpo, true);
   for (i = 0; i < n; i++)
     {
-      basic_block bb = BASIC_BLOCK (rpo[i]);
+      basic_block bb = cfun->cfg->get_basic_block_by_idx (rpo[i]);
       draw_cfg_node (pp, fun->funcdef_no, bb);
       bitmap_set_bit (visited, bb->index);
     }
@@ -215,7 +215,7 @@ draw_cfg_nodes_for_loop (pretty_printer *pp, int funcdef_no,
   const char *fillcolors[3] = { "grey88", "grey77", "grey66" };
 
   if (loop->header != NULL
-      && loop->latch != EXIT_BLOCK_PTR)
+      && loop->latch != cfun->cfg->get_exit_block ())
     pp_printf (pp,
 	       "\tsubgraph cluster_%d_%d {\n"
 	       "\tstyle=\"filled\";\n"
@@ -234,7 +234,7 @@ draw_cfg_nodes_for_loop (pretty_printer *pp, int funcdef_no,
   if (loop->header == NULL)
     return;
 
-  if (loop->latch == EXIT_BLOCK_PTR)
+  if (loop->latch == cfun->cfg->get_exit_block ())
     body = get_loop_body (loop);
   else
     body = get_loop_body_in_bfs_order (loop);
@@ -248,7 +248,7 @@ draw_cfg_nodes_for_loop (pretty_printer *pp, int funcdef_no,
 
   free (body);
 
-  if (loop->latch != EXIT_BLOCK_PTR)
+  if (loop->latch != cfun->cfg->get_exit_block ())
     pp_printf (pp, "\t}\n");
 }
 
@@ -275,7 +275,7 @@ draw_cfg_edges (pretty_printer *pp, struct function *fun)
 {
   basic_block bb;
   mark_dfs_back_edges ();
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     draw_cfg_node_succ_edges (pp, fun->funcdef_no, bb);
 
   /* Add an invisible edge from ENTRY to EXIT, to improve the graph layout.  */
diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c
index 82cae2f..b177ac7 100644
--- a/gcc/graphite-clast-to-gimple.c
+++ b/gcc/graphite-clast-to-gimple.c
@@ -1091,7 +1091,7 @@ translate_clast_user (struct clast_user_stmt *stmt, edge next_e,
   gimple_bb_p gbb = PBB_BLACK_BOX (pbb);
   vec<tree> iv_map;
 
-  if (GBB_BB (gbb) == ENTRY_BLOCK_PTR)
+  if (GBB_BB (gbb) == cfun->cfg->get_entry_block ())
     return next_e;
 
   nb_loops = number_of_loops (cfun);
diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c
index ab2897d..5c73c54 100644
--- a/gcc/graphite-scop-detection.c
+++ b/gcc/graphite-scop-detection.c
@@ -437,7 +437,7 @@ scopdet_basic_block_info (basic_block bb, loop_p outermost_loop,
   gimple stmt;
 
   /* XXX: ENTRY_BLOCK_PTR could be optimized in later steps.  */
-  basic_block entry_block = ENTRY_BLOCK_PTR;
+  basic_block entry_block = cfun->cfg->get_entry_block ();
   stmt = harmful_stmt_in_bb (entry_block, outermost_loop, bb);
   result.difficult = (stmt != NULL);
   result.exit = NULL;
@@ -1022,7 +1022,7 @@ create_sese_edges (vec<sd_region> regions)
   FOR_EACH_VEC_ELT (regions, i, s)
     /* Don't handle multiple edges exiting the function.  */
     if (!find_single_exit_edge (s)
-	&& s->exit != EXIT_BLOCK_PTR)
+	&& s->exit != cfun->cfg->get_exit_block ())
       create_single_exit_edge (s);
 
   unmark_exit_edges (regions);
@@ -1101,7 +1101,7 @@ print_graphite_scop_statistics (FILE* file, scop_p scop)
 
   basic_block bb;
 
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator psi;
       loop_p loop = bb->loop_father;
@@ -1398,7 +1398,7 @@ build_scops (vec<scop_p> *scops)
   regions.create (3);
 
   canonicalize_loop_closed_ssa_form ();
-  build_scops_1 (single_succ (ENTRY_BLOCK_PTR), ENTRY_BLOCK_PTR->loop_father,
+  build_scops_1 (single_succ (cfun->cfg->get_entry_block ()), cfun->cfg->get_entry_block ()->loop_father,
 		 &regions, loop);
   create_sese_edges (regions);
   build_graphite_scops (regions, scops);
@@ -1440,7 +1440,7 @@ dot_all_scops_1 (FILE *file, vec<scop_p> scops)
 
   fprintf (file, "digraph all {\n");
 
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       int part_of_scop = false;
 
@@ -1547,7 +1547,7 @@ dot_all_scops_1 (FILE *file, vec<scop_p> scops)
       fprintf (file, "  </TABLE>>, shape=box, style=\"setlinewidth(0)\"]\n");
     }
 
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       FOR_EACH_EDGE (e, ei, bb->succs)
 	      fprintf (file, "%d -> %d;\n", bb->index, e->dest->index);
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index c4c3eb4..f05343d 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -403,7 +403,7 @@ build_scop_bbs_1 (scop_p scop, sbitmap visited, basic_block bb)
 static void
 build_scop_bbs (scop_p scop)
 {
-  sbitmap visited = sbitmap_alloc (last_basic_block);
+  sbitmap visited = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
   sese region = SCOP_REGION (scop);
 
   bitmap_clear (visited);
@@ -2315,7 +2315,7 @@ rewrite_reductions_out_of_ssa (scop_p scop)
   gimple_stmt_iterator psi;
   sese region = SCOP_REGION (scop);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     if (bb_in_sese_p (bb, region))
       for (psi = gsi_start_phis (bb); !gsi_end_p (psi);)
 	{
@@ -2510,7 +2510,7 @@ rewrite_cross_bb_scalar_deps_out_of_ssa (scop_p scop)
   /* Create an extra empty BB after the scop.  */
   split_edge (SESE_EXIT (region));
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     if (bb_in_sese_p (bb, region))
       for (psi = gsi_start_bb (bb); !gsi_end_p (psi); gsi_next (&psi))
 	changed |= rewrite_cross_bb_scalar_deps (scop, &psi);
diff --git a/gcc/graphite.c b/gcc/graphite.c
index f953663..c609929 100644
--- a/gcc/graphite.c
+++ b/gcc/graphite.c
@@ -82,7 +82,7 @@ print_global_statistics (FILE* file)
 
   basic_block bb;
 
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator psi;
 
@@ -138,7 +138,7 @@ print_graphite_scop_statistics (FILE* file, scop_p scop)
 
   basic_block bb;
 
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator psi;
       loop_p loop = bb->loop_father;
@@ -201,7 +201,7 @@ graphite_initialize (isl_ctx *ctx)
   if (number_of_loops (cfun) <= 1
       /* FIXME: This limit on the number of basic blocks of a function
 	 should be removed when the SCOP detection is faster.  */
-      || n_basic_blocks > PARAM_VALUE (PARAM_GRAPHITE_MAX_BBS_PER_FUNCTION))
+      || cfun->cfg->get_n_basic_blocks () > PARAM_VALUE (PARAM_GRAPHITE_MAX_BBS_PER_FUNCTION))
     {
       if (dump_file && (dump_flags & TDF_DETAILS))
 	print_global_statistics (dump_file);
@@ -232,7 +232,7 @@ graphite_finalize (bool need_cfg_cleanup_p)
     {
       scev_reset ();
       cleanup_tree_cfg ();
-      profile_status = PROFILE_ABSENT;
+      cfun->cfg->set_profile_status (PROFILE_ABSENT);
       release_recorded_exits ();
       tree_estimate_probability ();
     }
diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c
index 61eaaef..a49f5c4 100644
--- a/gcc/haifa-sched.c
+++ b/gcc/haifa-sched.c
@@ -1597,7 +1597,7 @@ priority (rtx insn)
 
           /* Selective scheduling does not define RECOVERY_BLOCK macro.  */
 	  rec = sel_sched_p () ? NULL : RECOVERY_BLOCK (insn);
-	  if (!rec || rec == EXIT_BLOCK_PTR)
+	  if (!rec || rec == cfun->cfg->get_exit_block ())
 	    {
 	      prev_first = PREV_INSN (insn);
 	      twin = insn;
@@ -6668,12 +6668,12 @@ haifa_sched_init (void)
      whole function.  */
   {
     bb_vec_t bbs;
-    bbs.create (n_basic_blocks);
+    bbs.create (cfun->cfg->get_n_basic_blocks ());
     basic_block bb;
 
     sched_init_bbs ();
 
-    FOR_EACH_BB (bb)
+    FOR_EACH_BB_CFG (bb, cfun->cfg)
       bbs.quick_push (bb);
     sched_init_luids (bbs);
     sched_deps_init (true);
@@ -7436,7 +7436,7 @@ static void
 sched_extend_bb (void)
 {
   /* The following is done to keep current_sched_info->next_tail non null.  */
-  rtx end = BB_END (EXIT_BLOCK_PTR->prev_bb);
+  rtx end = BB_END (cfun->cfg->get_exit_block ()->prev_bb);
   rtx insn = DEBUG_INSN_P (end) ? prev_nondebug_insn (end) : end;
   if (NEXT_INSN (end) == 0
       || (!NOTE_P (insn)
@@ -7447,7 +7447,7 @@ sched_extend_bb (void)
       rtx note = emit_note_after (NOTE_INSN_DELETED, end);
       /* Make note appear outside BB.  */
       set_block_for_insn (note, NULL);
-      BB_END (EXIT_BLOCK_PTR->prev_bb) = end;
+      BB_END (cfun->cfg->get_exit_block ()->prev_bb) = end;
     }
 }
 
@@ -7465,7 +7465,7 @@ init_before_recovery (basic_block *before_recovery_ptr)
   basic_block last;
   edge e;
 
-  last = EXIT_BLOCK_PTR->prev_bb;
+  last = cfun->cfg->get_exit_block ()->prev_bb;
   e = find_fallthru_edge_from (last);
 
   if (e)
@@ -7505,7 +7505,7 @@ init_before_recovery (basic_block *before_recovery_ptr)
 
       redirect_edge_succ (e, single);
       make_single_succ_edge (single, empty, 0);
-      make_single_succ_edge (empty, EXIT_BLOCK_PTR, EDGE_FALLTHRU);
+      make_single_succ_edge (empty, cfun->cfg->get_exit_block (), EDGE_FALLTHRU);
 
       label = block_label (empty);
       x = emit_jump_insn_after (gen_jump (label), BB_END (single));
@@ -7648,14 +7648,14 @@ create_check_block_twin (rtx insn, bool mutate_p)
     }
   else
     {
-      rec = EXIT_BLOCK_PTR;
+      rec = cfun->cfg->get_exit_block ();
       label = NULL_RTX;
     }
 
   /* Emit CHECK.  */
   check = targetm.sched.gen_spec_check (insn, label, todo_spec);
 
-  if (rec != EXIT_BLOCK_PTR)
+  if (rec != cfun->cfg->get_exit_block ())
     {
       /* To have mem_reg alive at the beginning of second_bb,
 	 we emit check BEFORE insn, so insn after splitting
@@ -7688,7 +7688,7 @@ create_check_block_twin (rtx insn, bool mutate_p)
 
   /* Initialize TWIN (twin is a duplicate of original instruction
      in the recovery block).  */
-  if (rec != EXIT_BLOCK_PTR)
+  if (rec != cfun->cfg->get_exit_block ())
     {
       sd_iterator_def sd_it;
       dep_t dep;
@@ -7725,7 +7725,7 @@ create_check_block_twin (rtx insn, bool mutate_p)
      provide correct value for INSN_TICK (TWIN).  */
   sd_copy_back_deps (twin, insn, true);
 
-  if (rec != EXIT_BLOCK_PTR)
+  if (rec != cfun->cfg->get_exit_block ())
     /* In case of branchy check, fix CFG.  */
     {
       basic_block first_bb, second_bb;
@@ -7737,7 +7737,7 @@ create_check_block_twin (rtx insn, bool mutate_p)
       sched_create_recovery_edges (first_bb, rec, second_bb);
 
       sched_init_only_bb (second_bb, first_bb);
-      sched_init_only_bb (rec, EXIT_BLOCK_PTR);
+      sched_init_only_bb (rec, cfun->cfg->get_exit_block ());
 
       jump = BB_END (rec);
       haifa_init_insn (jump);
@@ -7778,7 +7778,7 @@ create_check_block_twin (rtx insn, bool mutate_p)
       init_dep_1 (new_dep, pro, check, DEP_TYPE (dep), ds);
       sd_add_dep (new_dep, false);
 
-      if (rec != EXIT_BLOCK_PTR)
+      if (rec != cfun->cfg->get_exit_block ())
 	{
 	  DEP_CON (new_dep) = twin;
 	  sd_add_dep (new_dep, false);
@@ -7827,7 +7827,7 @@ create_check_block_twin (rtx insn, bool mutate_p)
   /* Future speculations: call the helper.  */
   process_insn_forw_deps_be_in_spec (insn, twin, fs);
 
-  if (rec != EXIT_BLOCK_PTR)
+  if (rec != cfun->cfg->get_exit_block ())
     {
       /* Which types of dependencies should we use here is,
 	 generally, machine-dependent question...  But, for now,
@@ -8038,10 +8038,10 @@ unlink_bb_notes (basic_block first, basic_block last)
   if (first == last)
     return;
 
-  bb_header = XNEWVEC (rtx, last_basic_block);
+  bb_header = XNEWVEC (rtx, cfun->cfg->get_last_basic_block ());
 
   /* Make a sentinel.  */
-  if (last->next_bb != EXIT_BLOCK_PTR)
+  if (last->next_bb != cfun->cfg->get_exit_block ())
     bb_header[last->next_bb->index] = 0;
 
   first = first->next_bb;
@@ -8085,7 +8085,7 @@ restore_bb_notes (basic_block first)
   first = first->next_bb;
   /* Remember: FIRST is actually a second basic block in the ebb.  */
 
-  while (first != EXIT_BLOCK_PTR
+  while (first != cfun->cfg->get_exit_block ()
 	 && bb_header[first->index])
     {
       rtx prev, label, note, next;
diff --git a/gcc/hw-doloop.c b/gcc/hw-doloop.c
index 9b59f5d..e7dd830 100644
--- a/gcc/hw-doloop.c
+++ b/gcc/hw-doloop.c
@@ -261,7 +261,7 @@ discover_loop (hwloop_info loop, basic_block tail_bb, rtx tail_insn, rtx reg)
     {
       edge e;
       edge_iterator ei;
-      if (bb == EXIT_BLOCK_PTR)
+      if (bb == cfun->cfg->get_exit_block ())
 	{
 	  /* We've reached the exit block.  The loop must be bad. */
 	  if (dump_file)
@@ -360,7 +360,7 @@ discover_loops (bitmap_obstack *loop_stack, struct hw_doloop_hooks *hooks)
   /* Find all the possible loop tails.  This means searching for every
      loop_end instruction.  For each one found, create a hwloop_info
      structure and add the head block to the work list. */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       rtx tail = BB_END (bb);
       rtx insn, reg;
@@ -483,7 +483,7 @@ set_bb_indices (void)
   intptr_t index;
 
   index = 0;
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     bb->aux = (void *) index++;
 }
 
@@ -540,9 +540,9 @@ reorder_loops (hwloop_info loops)
       loops = loops->next;
     }
   
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
-      if (bb->next_bb != EXIT_BLOCK_PTR)
+      if (bb->next_bb != cfun->cfg->get_exit_block ())
 	bb->aux = bb->next_bb;
       else
 	bb->aux = NULL;
diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
index 4057577..bedb183 100644
--- a/gcc/ifcvt.c
+++ b/gcc/ifcvt.c
@@ -3165,7 +3165,7 @@ merge_if_block (struct ce_if_block * ce_info)
       /* There should still be something at the end of the THEN or ELSE
          blocks taking us to our final destination.  */
 	gcc_assert (JUMP_P (last)
-		    || (EDGE_SUCC (combo_bb, 0)->dest == EXIT_BLOCK_PTR
+		    || (EDGE_SUCC (combo_bb, 0)->dest == cfun->cfg->get_exit_block ()
 			&& CALL_P (last)
 			&& SIBLING_CALL_P (last))
 		    || ((EDGE_SUCC (combo_bb, 0)->flags & EDGE_EH)
@@ -3179,7 +3179,7 @@ merge_if_block (struct ce_if_block * ce_info)
      may be zero incoming edges if the THEN block didn't actually join
      back up (as with a call to a non-return function).  */
   else if (EDGE_COUNT (join_bb->preds) < 2
-	   && join_bb != EXIT_BLOCK_PTR)
+	   && join_bb != cfun->cfg->get_exit_block ())
     {
       /* We can merge the JOIN cleanly and update the dataflow try
 	 again on this pass.*/
@@ -3196,7 +3196,7 @@ merge_if_block (struct ce_if_block * ce_info)
 		  && single_succ (combo_bb) == join_bb);
 
       /* Remove the jump and cruft from the end of the COMBO block.  */
-      if (join_bb != EXIT_BLOCK_PTR)
+      if (join_bb != cfun->cfg->get_exit_block ())
 	tidy_fallthru_edge (single_succ_edge (combo_bb));
     }
 
@@ -3475,7 +3475,7 @@ cond_exec_find_if_block (struct ce_if_block * ce_info)
      code processing.  ??? we should fix this in the future.  */
   if (EDGE_COUNT (then_bb->succs) == 0)
     {
-      if (single_pred_p (else_bb) && else_bb != EXIT_BLOCK_PTR)
+      if (single_pred_p (else_bb) && else_bb != cfun->cfg->get_exit_block ())
 	{
 	  rtx last_insn = BB_END (then_bb);
 
@@ -3566,7 +3566,7 @@ cond_exec_find_if_block (struct ce_if_block * ce_info)
   next = then_bb;
   if (else_bb && (next = next->next_bb) != else_bb)
     return FALSE;
-  if ((next = next->next_bb) != join_bb && join_bb != EXIT_BLOCK_PTR)
+  if ((next = next->next_bb) != join_bb && join_bb != cfun->cfg->get_exit_block ())
     {
       if (else_bb)
 	join_bb = NULL;
@@ -3705,7 +3705,7 @@ block_has_only_trap (basic_block bb)
   rtx trap;
 
   /* We're not the exit block.  */
-  if (bb == EXIT_BLOCK_PTR)
+  if (bb == cfun->cfg->get_exit_block ())
     return NULL_RTX;
 
   /* The block must have no successors.  */
@@ -3861,7 +3861,7 @@ find_if_case_1 (basic_block test_bb, edge then_edge, edge else_edge)
 				    predictable_edge_p (then_edge)))))
     return FALSE;
 
-  if (else_bb == EXIT_BLOCK_PTR)
+  if (else_bb == cfun->cfg->get_exit_block ())
     {
       rtx jump = BB_END (else_edge->src);
       gcc_assert (JUMP_P (jump));
@@ -3882,12 +3882,12 @@ find_if_case_1 (basic_block test_bb, edge then_edge, edge else_edge)
 
   if (then_bb->next_bb == else_bb
       && then_bb->prev_bb == test_bb
-      && else_bb != EXIT_BLOCK_PTR)
+      && else_bb != cfun->cfg->get_exit_block ())
     {
       redirect_edge_succ (FALLTHRU_EDGE (test_bb), else_bb);
       new_bb = 0;
     }
-  else if (else_bb == EXIT_BLOCK_PTR)
+  else if (else_bb == cfun->cfg->get_exit_block ())
     new_bb = force_nonfallthru_and_redirect (FALLTHRU_EDGE (test_bb),
 					     else_bb, else_target);
   else
@@ -4178,9 +4178,9 @@ dead_or_predicable (basic_block test_bb, basic_block merge_bb,
 	 saved in caller-saved regs.  A caller-saved reg requires the
 	 prologue, killing a shrink-wrap opportunity.  */
       if ((flag_shrink_wrap && HAVE_simple_return && !epilogue_completed)
-	  && ENTRY_BLOCK_PTR->next_bb == test_bb
+	  && cfun->cfg->get_entry_block ()->next_bb == test_bb
 	  && single_succ_p (new_dest)
-	  && single_succ (new_dest) == EXIT_BLOCK_PTR
+	  && single_succ (new_dest) == cfun->cfg->get_exit_block ()
 	  && bitmap_intersect_p (df_get_live_in (new_dest), merge_set))
 	{
 	  regset return_regs;
@@ -4195,8 +4195,8 @@ dead_or_predicable (basic_block test_bb, basic_block merge_bb,
 		&& targetm.calls.function_value_regno_p (i))
 	      bitmap_set_bit (return_regs, INCOMING_REGNO (i));
 
-	  bitmap_and_into (return_regs, df_get_live_out (ENTRY_BLOCK_PTR));
-	  bitmap_and_into (return_regs, df_get_live_in (EXIT_BLOCK_PTR));
+	  bitmap_and_into (return_regs, df_get_live_out (cfun->cfg->get_entry_block ()));
+	  bitmap_and_into (return_regs, df_get_live_in (cfun->cfg->get_exit_block ()));
 	  if (!bitmap_empty_p (return_regs))
 	    {
 	      FOR_BB_INSNS_REVERSE (new_dest, insn)
@@ -4241,7 +4241,7 @@ dead_or_predicable (basic_block test_bb, basic_block merge_bb,
     {
       if (JUMP_P (BB_END (dest_edge->src)))
 	new_dest_label = JUMP_LABEL (BB_END (dest_edge->src));
-      else if (new_dest == EXIT_BLOCK_PTR)
+      else if (new_dest == cfun->cfg->get_exit_block ())
 	new_dest_label = ret_rtx;
       else
 	new_dest_label = block_label (new_dest);
@@ -4383,7 +4383,7 @@ if_convert (void)
 	fprintf (dump_file, "\n\n========== Pass %d ==========\n", pass);
 #endif
 
-      FOR_EACH_BB (bb)
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
 	{
           basic_block new_bb;
           while (!df_get_bb_dirty (bb)
diff --git a/gcc/init-regs.c b/gcc/init-regs.c
index 270d39b..03f6c6d 100644
--- a/gcc/init-regs.c
+++ b/gcc/init-regs.c
@@ -59,7 +59,7 @@ initialize_uninitialized_regs (void)
 
   df_analyze ();
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       rtx insn;
       bitmap lr = DF_LR_IN (bb);
diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c
index c6f127e..436d0e5 100644
--- a/gcc/ipa-inline-analysis.c
+++ b/gcc/ipa-inline-analysis.c
@@ -2050,7 +2050,7 @@ record_modified (ao_ref *ao ATTRIBUTE_UNUSED, tree vdef, void *data)
     return false;
   bitmap_set_bit (info->bb_set,
 		  SSA_NAME_IS_DEFAULT_DEF (vdef)
-		  ? ENTRY_BLOCK_PTR->index
+		  ? cfun->cfg->get_entry_block ()->index
 		  : gimple_bb (SSA_NAME_DEF_STMT (vdef))->index);
   return false;
 }
@@ -2086,7 +2086,7 @@ param_change_prob (gimple stmt, int i)
 	return REG_BR_PROB_BASE;
 
       if (SSA_NAME_IS_DEFAULT_DEF (op))
-	init_freq = ENTRY_BLOCK_PTR->frequency;
+	init_freq = cfun->cfg->get_entry_block ()->frequency;
       else
 	init_freq = gimple_bb (SSA_NAME_DEF_STMT (op))->frequency;
 
@@ -2125,13 +2125,13 @@ param_change_prob (gimple stmt, int i)
       /* Assume that every memory is initialized at entry.
          TODO: Can we easilly determine if value is always defined
          and thus we may skip entry block?  */
-      if (ENTRY_BLOCK_PTR->frequency)
-	max = ENTRY_BLOCK_PTR->frequency;
+      if (cfun->cfg->get_entry_block ()->frequency)
+	max = cfun->cfg->get_entry_block ()->frequency;
       else
 	max = 1;
 
       EXECUTE_IF_SET_IN_BITMAP (info.bb_set, 0, index, bi)
-	max = MIN (max, BASIC_BLOCK (index)->frequency);
+	max = MIN (max, cfun->cfg->get_basic_block_by_idx (index)->frequency);
 
       BITMAP_FREE (info.bb_set);
       if (max < bb->frequency)
@@ -2311,11 +2311,11 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early)
   if (parms_info)
     compute_bb_predicates (node, parms_info, info);
   gcc_assert (cfun == my_function);
-  order = XNEWVEC (int, n_basic_blocks);
+  order = XNEWVEC (int, cfun->cfg->get_n_basic_blocks ());
   nblocks = pre_and_rev_post_order_compute (NULL, order, false);
   for (n = 0; n < nblocks; n++)
     {
-      bb = BASIC_BLOCK (order[n]);
+      bb = cfun->cfg->get_basic_block_by_idx (order[n]);
       freq = compute_call_stmt_bb_frequency (node->symbol.decl, bb);
 
       /* TODO: Obviously predicates can be propagated down across CFG.  */
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index 7c3987e..7735e21 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -4252,7 +4252,7 @@ ipcp_transform_function (struct cgraph_node *node)
   descriptors.safe_grow_cleared (param_count);
   ipa_populate_param_decls (node, descriptors);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
       {
 	struct ipa_agg_replacement_value *v;
diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c
index 0dd6838..3624895 100644
--- a/gcc/ipa-pure-const.c
+++ b/gcc/ipa-pure-const.c
@@ -753,7 +753,7 @@ analyze_function (struct cgraph_node *fn, bool ipa)
 
   push_cfun (DECL_STRUCT_FUNCTION (decl));
 
-  FOR_EACH_BB (this_block)
+  FOR_EACH_BB_CFG (this_block, cfun->cfg)
     {
       gimple_stmt_iterator gsi;
       struct walk_stmt_info wi;
@@ -1570,7 +1570,7 @@ local_pure_const (void)
 
   /* Do NORETURN discovery.  */
   if (!skip && !TREE_THIS_VOLATILE (current_function_decl)
-      && EDGE_COUNT (EXIT_BLOCK_PTR->preds) == 0)
+      && EDGE_COUNT (cfun->cfg->get_exit_block ()->preds) == 0)
     {
       warn_function_noreturn (cfun->decl);
       if (dump_file)
diff --git a/gcc/ipa-split.c b/gcc/ipa-split.c
index 107c7a9..3786bcf 100644
--- a/gcc/ipa-split.c
+++ b/gcc/ipa-split.c
@@ -196,7 +196,7 @@ verify_non_ssa_vars (struct split_point *current, bitmap non_ssa_vars,
   bool ok = true;
 
   FOR_EACH_EDGE (e, ei, current->entry_bb->preds)
-    if (e->src != ENTRY_BLOCK_PTR
+    if (e->src != cfun->cfg->get_entry_block ()
 	&& !bitmap_bit_p (current->split_bbs, e->src->index))
       {
         worklist.safe_push (e->src);
@@ -209,7 +209,7 @@ verify_non_ssa_vars (struct split_point *current, bitmap non_ssa_vars,
       basic_block bb = worklist.pop ();
 
       FOR_EACH_EDGE (e, ei, bb->preds)
-	if (e->src != ENTRY_BLOCK_PTR
+	if (e->src != cfun->cfg->get_entry_block ()
 	    && bitmap_set_bit (seen, e->src->index))
 	  {
 	    gcc_checking_assert (!bitmap_bit_p (current->split_bbs,
@@ -343,7 +343,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, BASIC_BLOCK (dom_bb)))
+      if (dominated_by_p (CDI_DOMINATORS, bb, cfun->cfg->get_basic_block_by_idx (dom_bb)))
 	return true;
     }
 
@@ -377,7 +377,7 @@ consider_split (struct split_point *current, bitmap non_ssa_vars,
 
   /* Do not split when we would end up calling function anyway.  */
   if (incoming_freq
-      >= (ENTRY_BLOCK_PTR->frequency
+      >= (cfun->cfg->get_entry_block ()->frequency
 	  * PARAM_VALUE (PARAM_PARTIAL_INLINING_ENTRY_PROBABILITY) / 100))
     {
       if (dump_file && (dump_flags & TDF_DETAILS))
@@ -546,7 +546,7 @@ consider_split (struct split_point *current, bitmap non_ssa_vars,
 
   /* split_function fixes up at most one PHI non-virtual PHI node in return_bb,
      for the return value.  If there are other PHIs, give up.  */
-  if (return_bb != EXIT_BLOCK_PTR)
+  if (return_bb != cfun->cfg->get_exit_block ())
     {
       gimple_stmt_iterator psi;
 
@@ -613,15 +613,15 @@ static basic_block
 find_return_bb (void)
 {
   edge e;
-  basic_block return_bb = EXIT_BLOCK_PTR;
+  basic_block return_bb = cfun->cfg->get_exit_block ();
   gimple_stmt_iterator bsi;
   bool found_return = false;
   tree retval = NULL_TREE;
 
-  if (!single_pred_p (EXIT_BLOCK_PTR))
+  if (!single_pred_p (cfun->cfg->get_exit_block ()))
     return return_bb;
 
-  e = single_pred_edge (EXIT_BLOCK_PTR);
+  e = single_pred_edge (cfun->cfg->get_exit_block ());
   for (bsi = gsi_last_bb (e->src); !gsi_end_p (bsi); gsi_prev (&bsi))
     {
       gimple stmt = gsi_stmt (bsi);
@@ -900,7 +900,7 @@ find_split_points (int overall_time, int overall_size)
   current.split_size = 0;
   current.ssa_names_to_pass = BITMAP_ALLOC (NULL);
 
-  first.bb = ENTRY_BLOCK_PTR;
+  first.bb = cfun->cfg->get_entry_block ();
   first.edge_num = 0;
   first.overall_time = 0;
   first.overall_size = 0;
@@ -909,7 +909,7 @@ find_split_points (int overall_time, int overall_size)
   first.used_ssa_names = 0;
   first.bbs_visited = 0;
   stack.safe_push (first);
-  ENTRY_BLOCK_PTR->aux = (void *)(intptr_t)-1;
+  cfun->cfg->get_entry_block ()->aux = (void *)(intptr_t)-1;
 
   while (!stack.is_empty ())
     {
@@ -920,7 +920,7 @@ find_split_points (int overall_time, int overall_size)
          articulation, we want to have processed everything reachable
 	 from articulation but nothing that reaches into it.  */
       if (entry->edge_num == EDGE_COUNT (entry->bb->succs)
-	  && entry->bb != ENTRY_BLOCK_PTR)
+	  && entry->bb != cfun->cfg->get_entry_block ())
 	{
 	  int pos = stack.length ();
 	  entry->can_split &= visit_bb (entry->bb, return_bb,
@@ -972,7 +972,7 @@ find_split_points (int overall_time, int overall_size)
 	  entry->edge_num++;
 
 	  /* New BB to visit, push it to the stack.  */
-	  if (dest != return_bb && dest != EXIT_BLOCK_PTR
+	  if (dest != return_bb && dest != cfun->cfg->get_exit_block ()
 	      && !dest->aux)
 	    {
 	      stack_entry new_entry;
@@ -1000,7 +1000,7 @@ find_split_points (int overall_time, int overall_size)
 	}
       /* We are done with examining the edges.  Pop off the value from stack
 	 and merge stuff we accumulate during the walk.  */
-      else if (entry->bb != ENTRY_BLOCK_PTR)
+      else if (entry->bb != cfun->cfg->get_entry_block ())
 	{
 	  stack_entry *prev = &stack[stack.length () - 2];
 
@@ -1026,8 +1026,8 @@ find_split_points (int overall_time, int overall_size)
       else
         stack.pop ();
     }
-  ENTRY_BLOCK_PTR->aux = NULL;
-  FOR_EACH_BB (bb)
+  cfun->cfg->get_entry_block ()->aux = NULL;
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     bb->aux = NULL;
   stack.release ();
   BITMAP_FREE (current.ssa_names_to_pass);
@@ -1102,7 +1102,7 @@ split_function (struct split_point *split_point)
   if (!split_part_return_p)
     ;
   /* We have no return block, so nothing is needed.  */
-  else if (return_bb == EXIT_BLOCK_PTR)
+  else if (return_bb == cfun->cfg->get_exit_block ())
     ;
   /* When we do not want to return value, we need to construct
      new return block with empty return statement.
@@ -1129,7 +1129,7 @@ split_function (struct split_point *split_point)
 		break;
 	      }
 	}
-      e = make_edge (new_return_bb, EXIT_BLOCK_PTR, 0);
+      e = make_edge (new_return_bb, cfun->cfg->get_exit_block (), 0);
       e->probability = REG_BR_PROB_BASE;
       e->count = new_return_bb->count;
       if (current_loops)
@@ -1146,7 +1146,7 @@ split_function (struct split_point *split_point)
 
      Note this can happen whether or not we have a return value.  If we have
      a return value, then RETURN_BB may have PHIs for real operands too.  */
-  if (return_bb != EXIT_BLOCK_PTR)
+  if (return_bb != cfun->cfg->get_exit_block ())
     {
       bool phi_p = false;
       for (gsi = gsi_start_phis (return_bb); !gsi_end_p (gsi);)
@@ -1284,7 +1284,7 @@ split_function (struct split_point *split_point)
       push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl));
       var = BLOCK_VARS (DECL_INITIAL (node->symbol.decl));
       i = vec_safe_length (*debug_args);
-      cgsi = gsi_after_labels (single_succ (ENTRY_BLOCK_PTR));
+      cgsi = gsi_after_labels (single_succ (cfun->cfg->get_entry_block ()));
       do
 	{
 	  i -= 2;
@@ -1325,13 +1325,13 @@ split_function (struct split_point *split_point)
   else
     {
       e = make_edge (call_bb, return_bb,
-		     return_bb == EXIT_BLOCK_PTR ? 0 : EDGE_FALLTHRU);
+		     return_bb == cfun->cfg->get_exit_block () ? 0 : EDGE_FALLTHRU);
       e->count = call_bb->count;
       e->probability = REG_BR_PROB_BASE;
 
       /* If there is return basic block, see what value we need to store
          return value into and put call just before it.  */
-      if (return_bb != EXIT_BLOCK_PTR)
+      if (return_bb != cfun->cfg->get_exit_block ())
 	{
 	  real_retval = retval = find_retval (return_bb);
 
@@ -1538,9 +1538,9 @@ execute_split_functions (void)
   calculate_dominance_info (CDI_DOMINATORS);
 
   /* Compute local info about basic blocks and determine function size/time.  */
-  bb_info_vec.safe_grow_cleared (last_basic_block + 1);
+  bb_info_vec.safe_grow_cleared (cfun->cfg->get_last_basic_block () + 1);
   memset (&best_split_point, 0, sizeof (best_split_point));
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       int time = 0;
       int size = 0;
diff --git a/gcc/ira-build.c b/gcc/ira-build.c
index 0e2fd0c..1933b8c 100644
--- a/gcc/ira-build.c
+++ b/gcc/ira-build.c
@@ -131,9 +131,9 @@ create_loop_tree_nodes (void)
 
   ira_bb_nodes
     = ((struct ira_loop_tree_node *)
-       ira_allocate (sizeof (struct ira_loop_tree_node) * last_basic_block));
-  last_basic_block_before_change = last_basic_block;
-  for (i = 0; i < (unsigned int) last_basic_block; i++)
+       ira_allocate (sizeof (struct ira_loop_tree_node) * cfun->cfg->get_last_basic_block ()));
+  last_basic_block_before_change = cfun->cfg->get_last_basic_block ();
+  for (i = 0; i < (unsigned int) cfun->cfg->get_last_basic_block (); i++)
     {
       ira_bb_nodes[i].regno_allocno_map = NULL;
       memset (ira_bb_nodes[i].reg_pressure, 0,
@@ -333,7 +333,7 @@ form_loop_tree (void)
   /* We can not use loop/bb node access macros because of potential
      checking and because the nodes are not initialized enough
      yet.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       bb_node = &ira_bb_nodes[bb->index];
       bb_node->bb = bb;
@@ -1548,7 +1548,7 @@ ira_loop_tree_body_rev_postorder (ira_loop_tree_node_t loop_node ATTRIBUTE_UNUSE
 		  ira_loop_tree_node_t pred_node;
 		  basic_block pred_bb = e->src;
 
-		  if (e->src == ENTRY_BLOCK_PTR)
+		  if (e->src == cfun->cfg->get_entry_block ())
 		    continue;
 
 		  pred_node = IRA_BB_NODE_BY_INDEX (pred_bb->index);
@@ -2408,8 +2408,8 @@ remove_unnecessary_regions (bool all_p)
     mark_all_loops_for_removal ();
   else
     mark_loops_for_removal ();
-  children_vec.create(last_basic_block + number_of_loops (cfun));
-  removed_loop_vec.create(last_basic_block + number_of_loops (cfun));
+  children_vec.create(cfun->cfg->get_last_basic_block () + number_of_loops (cfun));
+  removed_loop_vec.create(cfun->cfg->get_last_basic_block () + number_of_loops (cfun));
   remove_uneccesary_loop_nodes_from_loop_tree (ira_loop_tree_root);
   children_vec.release ();
   if (all_p)
@@ -3291,7 +3291,7 @@ ira_build (void)
 	}
       fprintf (ira_dump_file, "  regions=%d, blocks=%d, points=%d\n",
 	       current_loops == NULL ? 1 : number_of_loops (cfun),
-	       n_basic_blocks, ira_max_point);
+	       cfun->cfg->get_n_basic_blocks (), ira_max_point);
       fprintf (ira_dump_file,
 	       "    allocnos=%d (big %d), copies=%d, conflicts=%d, ranges=%d\n",
 	       ira_allocnos_num, nr_big, ira_copies_num, n, nr);
diff --git a/gcc/ira-color.c b/gcc/ira-color.c
index 0ee3157..64977db 100644
--- a/gcc/ira-color.c
+++ b/gcc/ira-color.c
@@ -2668,7 +2668,7 @@ print_loop_title (ira_loop_tree_node_t loop_tree_node)
       {
 	fprintf (ira_dump_file, " %d", subloop_node->bb->index);
 	FOR_EACH_EDGE (e, ei, subloop_node->bb->succs)
-	  if (e->dest != EXIT_BLOCK_PTR
+	  if (e->dest != cfun->cfg->get_exit_block ()
 	      && ((dest_loop_node = IRA_BB_NODE (e->dest)->parent)
 		  != loop_tree_node))
 	    fprintf (ira_dump_file, "(->%d:l%d)",
diff --git a/gcc/ira-costs.c b/gcc/ira-costs.c
index 5f998f7..412bbd7 100644
--- a/gcc/ira-costs.c
+++ b/gcc/ira-costs.c
@@ -1563,7 +1563,7 @@ find_costs_and_classes (FILE *dump_file)
 	{
 	  basic_block bb;
 
-	  FOR_EACH_BB (bb)
+	  FOR_EACH_BB_CFG (bb, cfun->cfg)
 	    process_bb_for_costs (bb);
 	}
 
diff --git a/gcc/ira-emit.c b/gcc/ira-emit.c
index cdd6941..00f4744 100644
--- a/gcc/ira-emit.c
+++ b/gcc/ira-emit.c
@@ -403,7 +403,7 @@ entered_from_non_parent_p (ira_loop_tree_node_t loop_node)
     if (bb_node->bb != NULL)
       {
 	FOR_EACH_EDGE (e, ei, bb_node->bb->preds)
-	  if (e->src != ENTRY_BLOCK_PTR
+	  if (e->src != cfun->cfg->get_entry_block ()
 	      && (src_loop_node = IRA_BB_NODE (e->src)->parent) != loop_node)
 	    {
 	      for (parent = src_loop_node->parent;
@@ -986,7 +986,7 @@ emit_moves (void)
   edge e;
   rtx insns, tmp;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       if (at_bb_start[bb->index] != NULL)
 	{
@@ -1203,7 +1203,7 @@ add_ranges_and_copies (void)
   bitmap live_through;
 
   live_through = ira_allocate_bitmap ();
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       /* It does not matter what loop_tree_node (of source or
 	 destination block) to use for searching allocnos by their
@@ -1244,10 +1244,10 @@ ira_emit (bool loops_p)
     ALLOCNO_EMIT_DATA (a)->reg = regno_reg_rtx[ALLOCNO_REGNO (a)];
   if (! loops_p)
     return;
-  at_bb_start = (move_t *) ira_allocate (sizeof (move_t) * last_basic_block);
-  memset (at_bb_start, 0, sizeof (move_t) * last_basic_block);
-  at_bb_end = (move_t *) ira_allocate (sizeof (move_t) * last_basic_block);
-  memset (at_bb_end, 0, sizeof (move_t) * last_basic_block);
+  at_bb_start = (move_t *) ira_allocate (sizeof (move_t) * cfun->cfg->get_last_basic_block ());
+  memset (at_bb_start, 0, sizeof (move_t) * cfun->cfg->get_last_basic_block ());
+  at_bb_end = (move_t *) ira_allocate (sizeof (move_t) * cfun->cfg->get_last_basic_block ());
+  memset (at_bb_end, 0, sizeof (move_t) * cfun->cfg->get_last_basic_block ());
   local_allocno_bitmap = ira_allocate_bitmap ();
   used_regno_bitmap = ira_allocate_bitmap ();
   renamed_regno_bitmap = ira_allocate_bitmap ();
@@ -1258,12 +1258,12 @@ ira_emit (bool loops_p)
   ira_free_bitmap (renamed_regno_bitmap);
   ira_free_bitmap (local_allocno_bitmap);
   setup_entered_from_non_parent_p ();
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       at_bb_start[bb->index] = NULL;
       at_bb_end[bb->index] = NULL;
       FOR_EACH_EDGE (e, ei, bb->succs)
-	if (e->dest != EXIT_BLOCK_PTR)
+	if (e->dest != cfun->cfg->get_exit_block ())
 	  generate_edge_moves (e);
     }
   allocno_last_set
@@ -1273,15 +1273,15 @@ ira_emit (bool loops_p)
   memset (allocno_last_set_check, 0, sizeof (int) * max_reg_num ());
   memset (hard_regno_last_set_check, 0, sizeof (hard_regno_last_set_check));
   curr_tick = 0;
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     unify_moves (bb, true);
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     unify_moves (bb, false);
   move_vec.create (ira_allocnos_num);
   emit_moves ();
   add_ranges_and_copies ();
   /* Clean up: */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       free_move_list (at_bb_start[bb->index]);
       free_move_list (at_bb_end[bb->index]);
@@ -1299,7 +1299,7 @@ ira_emit (bool loops_p)
      reload assumes initial insn codes defined.  The insn codes can be
      invalidated by CFG infrastructure for example in jump
      redirection.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     FOR_BB_INSNS_REVERSE (bb, insn)
       if (INSN_P (insn))
 	recog_memoized (insn);
diff --git a/gcc/ira-int.h b/gcc/ira-int.h
index 519f656..8e2160c 100644
--- a/gcc/ira-int.h
+++ b/gcc/ira-int.h
@@ -43,7 +43,7 @@ along with GCC; see the file COPYING3.  If not see
    executed, frequency is always equivalent.  Otherwise rescale the
    edge frequency.  */
 #define REG_FREQ_FROM_EDGE_FREQ(freq)					   \
-  (optimize_size || (flag_branch_probabilities && !ENTRY_BLOCK_PTR->count) \
+  (optimize_size || (flag_branch_probabilities && !cfun->cfg->get_entry_block ()->count) \
    ? REG_FREQ_MAX : (freq * REG_FREQ_MAX / BB_FREQ_MAX)			   \
    ? (freq * REG_FREQ_MAX / BB_FREQ_MAX) : 1)
 
diff --git a/gcc/ira.c b/gcc/ira.c
index ff901aa..bd2fa06 100644
--- a/gcc/ira.c
+++ b/gcc/ira.c
@@ -1829,7 +1829,7 @@ compute_regs_asm_clobbered (void)
 {
   basic_block bb;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       rtx insn;
       FOR_BB_INSNS_REVERSE (bb, insn)
@@ -2420,7 +2420,7 @@ mark_elimination (int from, int to)
   basic_block bb;
   bitmap r;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       r = DF_LR_IN (bb);
       if (bitmap_bit_p (r, from))
@@ -2914,7 +2914,7 @@ update_equiv_regs (void)
   /* Scan the insns and find which registers have equivalences.  Do this
      in a separate scan of the insns because (due to -fcse-follow-jumps)
      a register can be set below its use.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       loop_depth = bb_loop_depth (bb);
 
@@ -3197,7 +3197,7 @@ update_equiv_regs (void)
      within the same loop (or in an inner loop), then move the register
      initialization just before the use, so that they are in the same
      basic block.  */
-  FOR_EACH_BB_REVERSE (bb)
+  FOR_EACH_BB_REVERSE_CFG (bb, cfun->cfg)
     {
       loop_depth = bb_loop_depth (bb);
       for (insn = BB_END (bb);
@@ -3329,7 +3329,7 @@ update_equiv_regs (void)
 
   if (!bitmap_empty_p (cleared_regs))
     {
-      FOR_EACH_BB (bb)
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
 	{
 	  bitmap_and_compl_into (DF_LR_IN (bb), cleared_regs);
 	  bitmap_and_compl_into (DF_LR_OUT (bb), cleared_regs);
@@ -3550,7 +3550,7 @@ build_insn_chain (void)
   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
     if (TEST_HARD_REG_BIT (eliminable_regset, i))
       bitmap_set_bit (elim_regset, i);
-  FOR_EACH_BB_REVERSE (bb)
+  FOR_EACH_BB_REVERSE_CFG (bb, cfun->cfg)
     {
       bitmap_iterator bi;
       rtx insn;
@@ -3930,12 +3930,12 @@ find_moveable_pseudos (void)
   int *uid_luid = XNEWVEC (int, max_uid);
   rtx *closest_uses = XNEWVEC (rtx, max_regs);
   /* A set of registers which are live but not modified throughout a block.  */
-  bitmap_head *bb_transp_live = XNEWVEC (bitmap_head, last_basic_block);
+  bitmap_head *bb_transp_live = XNEWVEC (bitmap_head, cfun->cfg->get_last_basic_block ());
   /* A set of registers which only exist in a given basic block.  */
-  bitmap_head *bb_local = XNEWVEC (bitmap_head, last_basic_block);
+  bitmap_head *bb_local = XNEWVEC (bitmap_head, cfun->cfg->get_last_basic_block ());
   /* A set of registers which are set once, in an instruction that can be
      moved freely downwards, but are otherwise transparent to a block.  */
-  bitmap_head *bb_moveable_reg_sets = XNEWVEC (bitmap_head, last_basic_block);
+  bitmap_head *bb_moveable_reg_sets = XNEWVEC (bitmap_head, cfun->cfg->get_last_basic_block ());
   bitmap_head live, used, set, interesting, unusable_as_input;
   bitmap_iterator bi;
   bitmap_initialize (&interesting, 0);
@@ -3952,7 +3952,7 @@ find_moveable_pseudos (void)
   bitmap_initialize (&used, 0);
   bitmap_initialize (&set, 0);
   bitmap_initialize (&unusable_as_input, 0);
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       rtx insn;
       bitmap transp = bb_transp_live + bb->index;
@@ -4015,7 +4015,7 @@ find_moveable_pseudos (void)
   bitmap_clear (&used);
   bitmap_clear (&set);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       bitmap local = bb_local + bb->index;
       rtx insn;
@@ -4244,7 +4244,7 @@ find_moveable_pseudos (void)
 	}
     }
   
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       bitmap_clear (bb_local + bb->index);
       bitmap_clear (bb_transp_live + bb->index);
@@ -4344,7 +4344,7 @@ allocate_initial_values (void)
 		     fixed regs are accepted.  */
 		  SET_REGNO (preg, new_regno);
 		  /* Update global register liveness information.  */
-		  FOR_EACH_BB (bb)
+		  FOR_EACH_BB_CFG (bb, cfun->cfg)
 		    {
 		      if (REGNO_REG_SET_P(df_get_live_in (bb), regno))
 			SET_REGNO_REG_SET (df_get_live_in (bb), new_regno);
@@ -4389,7 +4389,7 @@ ira (FILE *f)
      pseudos and 10K blocks or 100K pseudos and 1K blocks), we will
      use simplified and faster algorithms in LRA.  */
   lra_simple_p
-    = (ira_use_lra_p && max_reg_num () >= (1 << 26) / last_basic_block);
+    = (ira_use_lra_p && max_reg_num () >= (1 << 26) / cfun->cfg->get_last_basic_block ());
   if (lra_simple_p)
     {
       /* It permits to skip live range splitting in LRA.  */
@@ -4629,7 +4629,7 @@ do_reload (void)
 	  loop_optimizer_finalize ();
 	  free_dominance_info (CDI_DOMINATORS);
 	}
-      FOR_ALL_BB (bb)
+      FOR_ALL_BB_CFG (bb, cfun->cfg)
 	bb->loop_father = NULL;
       current_loops = NULL;
       
@@ -4678,7 +4678,7 @@ do_reload (void)
 	  loop_optimizer_finalize ();
 	  free_dominance_info (CDI_DOMINATORS);
 	}
-      FOR_ALL_BB (bb)
+      FOR_ALL_BB_CFG (bb, cfun->cfg)
 	bb->loop_father = NULL;
       current_loops = NULL;
       
diff --git a/gcc/jump.c b/gcc/jump.c
index 4fb1e6e..b994fec 100644
--- a/gcc/jump.c
+++ b/gcc/jump.c
@@ -258,7 +258,7 @@ mark_all_labels (rtx f)
   if (current_ir_type () == IR_RTL_CFGLAYOUT)
     {
       basic_block bb;
-      FOR_EACH_BB (bb)
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
 	{
 	  /* In cfglayout mode, we don't bother with trivial next-insn
 	     propagation of LABEL_REFs into JUMP_LABEL.  This will be
diff --git a/gcc/lcm.c b/gcc/lcm.c
index c13d2a6..b282ca3 100644
--- a/gcc/lcm.c
+++ b/gcc/lcm.c
@@ -101,28 +101,28 @@ compute_antinout_edge (sbitmap *antloc, sbitmap *transp, sbitmap *antin,
   /* Allocate a worklist array/queue.  Entries are only added to the
      list if they were not already on the list.  So the size is
      bounded by the number of basic blocks.  */
-  qin = qout = worklist = XNEWVEC (basic_block, n_basic_blocks);
+  qin = qout = worklist = XNEWVEC (basic_block, cfun->cfg->get_n_basic_blocks ());
 
   /* We want a maximal solution, so make an optimistic initialization of
      ANTIN.  */
-  bitmap_vector_ones (antin, last_basic_block);
+  bitmap_vector_ones (antin, cfun->cfg->get_last_basic_block ());
 
   /* Put every block on the worklist; this is necessary because of the
      optimistic initialization of ANTIN above.  */
-  FOR_EACH_BB_REVERSE (bb)
+  FOR_EACH_BB_REVERSE_CFG (bb, cfun->cfg)
     {
       *qin++ = bb;
       bb->aux = bb;
     }
 
   qin = worklist;
-  qend = &worklist[n_basic_blocks - NUM_FIXED_BLOCKS];
-  qlen = n_basic_blocks - NUM_FIXED_BLOCKS;
+  qend = &worklist[cfun->cfg->get_n_basic_blocks () - NUM_FIXED_BLOCKS];
+  qlen = cfun->cfg->get_n_basic_blocks () - NUM_FIXED_BLOCKS;
 
   /* Mark blocks which are predecessors of the exit block so that we
      can easily identify them below.  */
-  FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
-    e->src->aux = EXIT_BLOCK_PTR;
+  FOR_EACH_EDGE (e, ei, cfun->cfg->get_exit_block ()->preds)
+    e->src->aux = cfun->cfg->get_exit_block ();
 
   /* Iterate until the worklist is empty.  */
   while (qlen)
@@ -134,7 +134,7 @@ compute_antinout_edge (sbitmap *antloc, sbitmap *transp, sbitmap *antin,
       if (qout >= qend)
 	qout = worklist;
 
-      if (bb->aux == EXIT_BLOCK_PTR)
+      if (bb->aux == cfun->cfg->get_exit_block ())
 	/* Do not clear the aux field for blocks which are predecessors of
 	   the EXIT block.  That way we never add then to the worklist
 	   again.  */
@@ -153,7 +153,7 @@ compute_antinout_edge (sbitmap *antloc, sbitmap *transp, sbitmap *antin,
 	   to add the predecessors of this block to the worklist
 	   if they are not already on the worklist.  */
 	FOR_EACH_EDGE (e, ei, bb->preds)
-	  if (!e->src->aux && e->src != ENTRY_BLOCK_PTR)
+	  if (!e->src->aux && e->src != cfun->cfg->get_entry_block ())
 	    {
 	      *qin++ = e->src;
 	      e->src->aux = e;
@@ -188,11 +188,11 @@ compute_earliest (struct edge_list *edge_list, int n_exprs, sbitmap *antin,
     {
       pred = INDEX_EDGE_PRED_BB (edge_list, x);
       succ = INDEX_EDGE_SUCC_BB (edge_list, x);
-      if (pred == ENTRY_BLOCK_PTR)
+      if (pred == cfun->cfg->get_entry_block ())
 	bitmap_copy (earliest[x], antin[succ->index]);
       else
 	{
-	  if (succ == EXIT_BLOCK_PTR)
+	  if (succ == cfun->cfg->get_exit_block ())
 	    bitmap_clear (earliest[x]);
 	  else
 	    {
@@ -254,7 +254,7 @@ compute_laterin (struct edge_list *edge_list, sbitmap *earliest,
      list if they were not already on the list.  So the size is
      bounded by the number of basic blocks.  */
   qin = qout = worklist
-    = XNEWVEC (basic_block, n_basic_blocks);
+    = XNEWVEC (basic_block, cfun->cfg->get_n_basic_blocks ());
 
   /* Initialize a mapping from each edge to its index.  */
   for (i = 0; i < num_edges; i++)
@@ -276,12 +276,12 @@ compute_laterin (struct edge_list *edge_list, sbitmap *earliest,
      do not want to be overly optimistic.  Consider an outgoing edge from
      the entry block.  That edge should always have a LATER value the
      same as EARLIEST for that edge.  */
-  FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR->succs)
+  FOR_EACH_EDGE (e, ei, cfun->cfg->get_entry_block ()->succs)
     bitmap_copy (later[(size_t) e->aux], earliest[(size_t) e->aux]);
 
   /* Add all the blocks to the worklist.  This prevents an early exit from
      the loop given our optimistic initialization of LATER above.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       *qin++ = bb;
       bb->aux = bb;
@@ -290,8 +290,8 @@ compute_laterin (struct edge_list *edge_list, sbitmap *earliest,
   /* Note that we do not use the last allocated element for our queue,
      as EXIT_BLOCK is never inserted into it. */
   qin = worklist;
-  qend = &worklist[n_basic_blocks - NUM_FIXED_BLOCKS];
-  qlen = n_basic_blocks - NUM_FIXED_BLOCKS;
+  qend = &worklist[cfun->cfg->get_n_basic_blocks () - NUM_FIXED_BLOCKS];
+  qlen = cfun->cfg->get_n_basic_blocks () - NUM_FIXED_BLOCKS;
 
   /* Iterate until the worklist is empty.  */
   while (qlen)
@@ -317,7 +317,7 @@ compute_laterin (struct edge_list *edge_list, sbitmap *earliest,
 				      antloc[e->src->index])
 	    /* If LATER for an outgoing edge was changed, then we need
 	       to add the target of the outgoing edge to the worklist.  */
-	    && e->dest != EXIT_BLOCK_PTR && e->dest->aux == 0)
+	    && e->dest != cfun->cfg->get_exit_block () && e->dest->aux == 0)
 	  {
 	    *qin++ = e->dest;
 	    e->dest->aux = e;
@@ -330,10 +330,10 @@ compute_laterin (struct edge_list *edge_list, sbitmap *earliest,
   /* Computation of insertion and deletion points requires computing LATERIN
      for the EXIT block.  We allocated an extra entry in the LATERIN array
      for just this purpose.  */
-  bitmap_ones (laterin[last_basic_block]);
-  FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
-    bitmap_and (laterin[last_basic_block],
-		     laterin[last_basic_block],
+  bitmap_ones (laterin[cfun->cfg->get_last_basic_block ()]);
+  FOR_EACH_EDGE (e, ei, cfun->cfg->get_exit_block ()->preds)
+    bitmap_and (laterin[cfun->cfg->get_last_basic_block ()],
+		     laterin[cfun->cfg->get_last_basic_block ()],
 		     later[(size_t) e->aux]);
 
   clear_aux_for_edges ();
@@ -350,7 +350,7 @@ compute_insert_delete (struct edge_list *edge_list, sbitmap *antloc,
   int x;
   basic_block bb;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     bitmap_and_compl (del[bb->index], antloc[bb->index],
 			laterin[bb->index]);
 
@@ -358,8 +358,8 @@ compute_insert_delete (struct edge_list *edge_list, sbitmap *antloc,
     {
       basic_block b = INDEX_EDGE_SUCC_BB (edge_list, x);
 
-      if (b == EXIT_BLOCK_PTR)
-	bitmap_and_compl (insert[x], later[x], laterin[last_basic_block]);
+      if (b == cfun->cfg->get_exit_block ())
+	bitmap_and_compl (insert[x], later[x], laterin[cfun->cfg->get_last_basic_block ()]);
       else
 	bitmap_and_compl (insert[x], later[x], laterin[b->index]);
     }
@@ -389,29 +389,29 @@ pre_edge_lcm (int n_exprs, sbitmap *transp,
       fprintf (dump_file, "Edge List:\n");
       verify_edge_list (dump_file, edge_list);
       print_edge_list (dump_file, edge_list);
-      dump_bitmap_vector (dump_file, "transp", "", transp, last_basic_block);
-      dump_bitmap_vector (dump_file, "antloc", "", antloc, last_basic_block);
-      dump_bitmap_vector (dump_file, "avloc", "", avloc, last_basic_block);
-      dump_bitmap_vector (dump_file, "kill", "", kill, last_basic_block);
+      dump_bitmap_vector (dump_file, "transp", "", transp, cfun->cfg->get_last_basic_block ());
+      dump_bitmap_vector (dump_file, "antloc", "", antloc, cfun->cfg->get_last_basic_block ());
+      dump_bitmap_vector (dump_file, "avloc", "", avloc, cfun->cfg->get_last_basic_block ());
+      dump_bitmap_vector (dump_file, "kill", "", kill, cfun->cfg->get_last_basic_block ());
     }
 #endif
 
   /* Compute global availability.  */
-  avin = sbitmap_vector_alloc (last_basic_block, n_exprs);
-  avout = sbitmap_vector_alloc (last_basic_block, n_exprs);
+  avin = sbitmap_vector_alloc (cfun->cfg->get_last_basic_block (), n_exprs);
+  avout = sbitmap_vector_alloc (cfun->cfg->get_last_basic_block (), n_exprs);
   compute_available (avloc, kill, avout, avin);
   sbitmap_vector_free (avin);
 
   /* Compute global anticipatability.  */
-  antin = sbitmap_vector_alloc (last_basic_block, n_exprs);
-  antout = sbitmap_vector_alloc (last_basic_block, n_exprs);
+  antin = sbitmap_vector_alloc (cfun->cfg->get_last_basic_block (), n_exprs);
+  antout = sbitmap_vector_alloc (cfun->cfg->get_last_basic_block (), n_exprs);
   compute_antinout_edge (antloc, transp, antin, antout);
 
 #ifdef LCM_DEBUG_INFO
   if (dump_file)
     {
-      dump_bitmap_vector (dump_file, "antin", "", antin, last_basic_block);
-      dump_bitmap_vector (dump_file, "antout", "", antout, last_basic_block);
+      dump_bitmap_vector (dump_file, "antin", "", antin, cfun->cfg->get_last_basic_block ());
+      dump_bitmap_vector (dump_file, "antout", "", antout, cfun->cfg->get_last_basic_block ());
     }
 #endif
 
@@ -431,13 +431,13 @@ pre_edge_lcm (int n_exprs, sbitmap *transp,
   later = sbitmap_vector_alloc (num_edges, n_exprs);
 
   /* Allocate an extra element for the exit block in the laterin vector.  */
-  laterin = sbitmap_vector_alloc (last_basic_block + 1, n_exprs);
+  laterin = sbitmap_vector_alloc (cfun->cfg->get_last_basic_block () + 1, n_exprs);
   compute_laterin (edge_list, earliest, antloc, later, laterin);
 
 #ifdef LCM_DEBUG_INFO
   if (dump_file)
     {
-      dump_bitmap_vector (dump_file, "laterin", "", laterin, last_basic_block + 1);
+      dump_bitmap_vector (dump_file, "laterin", "", laterin, cfun->cfg->get_last_basic_block () + 1);
       dump_bitmap_vector (dump_file, "later", "", later, num_edges);
     }
 #endif
@@ -445,9 +445,9 @@ pre_edge_lcm (int n_exprs, sbitmap *transp,
   sbitmap_vector_free (earliest);
 
   *insert = sbitmap_vector_alloc (num_edges, n_exprs);
-  *del = sbitmap_vector_alloc (last_basic_block, n_exprs);
+  *del = sbitmap_vector_alloc (cfun->cfg->get_last_basic_block (), n_exprs);
   bitmap_vector_clear (*insert, num_edges);
-  bitmap_vector_clear (*del, last_basic_block);
+  bitmap_vector_clear (*del, cfun->cfg->get_last_basic_block ());
   compute_insert_delete (edge_list, antloc, later, laterin, *insert, *del);
 
   sbitmap_vector_free (laterin);
@@ -458,7 +458,7 @@ pre_edge_lcm (int n_exprs, sbitmap *transp,
     {
       dump_bitmap_vector (dump_file, "pre_insert_map", "", *insert, num_edges);
       dump_bitmap_vector (dump_file, "pre_delete_map", "", *del,
-			   last_basic_block);
+			   cfun->cfg->get_last_basic_block ());
     }
 #endif
 
@@ -481,27 +481,27 @@ compute_available (sbitmap *avloc, sbitmap *kill, sbitmap *avout,
      list if they were not already on the list.  So the size is
      bounded by the number of basic blocks.  */
   qin = qout = worklist =
-    XNEWVEC (basic_block, n_basic_blocks - NUM_FIXED_BLOCKS);
+    XNEWVEC (basic_block, cfun->cfg->get_n_basic_blocks () - NUM_FIXED_BLOCKS);
 
   /* We want a maximal solution.  */
-  bitmap_vector_ones (avout, last_basic_block);
+  bitmap_vector_ones (avout, cfun->cfg->get_last_basic_block ());
 
   /* Put every block on the worklist; this is necessary because of the
      optimistic initialization of AVOUT above.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       *qin++ = bb;
       bb->aux = bb;
     }
 
   qin = worklist;
-  qend = &worklist[n_basic_blocks - NUM_FIXED_BLOCKS];
-  qlen = n_basic_blocks - NUM_FIXED_BLOCKS;
+  qend = &worklist[cfun->cfg->get_n_basic_blocks () - NUM_FIXED_BLOCKS];
+  qlen = cfun->cfg->get_n_basic_blocks () - NUM_FIXED_BLOCKS;
 
   /* Mark blocks which are successors of the entry block so that we
      can easily identify them below.  */
-  FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR->succs)
-    e->dest->aux = ENTRY_BLOCK_PTR;
+  FOR_EACH_EDGE (e, ei, cfun->cfg->get_entry_block ()->succs)
+    e->dest->aux = cfun->cfg->get_entry_block ();
 
   /* Iterate until the worklist is empty.  */
   while (qlen)
@@ -516,7 +516,7 @@ compute_available (sbitmap *avloc, sbitmap *kill, sbitmap *avout,
       /* If one of the predecessor blocks is the ENTRY block, then the
 	 intersection of avouts is the null set.  We can identify such blocks
 	 by the special value in the AUX field in the block structure.  */
-      if (bb->aux == ENTRY_BLOCK_PTR)
+      if (bb->aux == cfun->cfg->get_entry_block ())
 	/* Do not clear the aux field for blocks which are successors of the
 	   ENTRY block.  That way we never add then to the worklist again.  */
 	bitmap_clear (avin[bb->index]);
@@ -534,7 +534,7 @@ compute_available (sbitmap *avloc, sbitmap *kill, sbitmap *avout,
 	   to add the successors of this block to the worklist
 	   if they are not already on the worklist.  */
 	FOR_EACH_EDGE (e, ei, bb->succs)
-	  if (!e->dest->aux && e->dest != EXIT_BLOCK_PTR)
+	  if (!e->dest->aux && e->dest != cfun->cfg->get_exit_block ())
 	    {
 	      *qin++ = e->dest;
 	      e->dest->aux = e;
@@ -570,11 +570,11 @@ compute_farthest (struct edge_list *edge_list, int n_exprs,
     {
       pred = INDEX_EDGE_PRED_BB (edge_list, x);
       succ = INDEX_EDGE_SUCC_BB (edge_list, x);
-      if (succ == EXIT_BLOCK_PTR)
+      if (succ == cfun->cfg->get_exit_block ())
 	bitmap_copy (farthest[x], st_avout[pred->index]);
       else
 	{
-	  if (pred == ENTRY_BLOCK_PTR)
+	  if (pred == cfun->cfg->get_entry_block ())
 	    bitmap_clear (farthest[x]);
 	  else
 	    {
@@ -610,7 +610,7 @@ compute_nearerout (struct edge_list *edge_list, sbitmap *farthest,
   /* Allocate a worklist array/queue.  Entries are only added to the
      list if they were not already on the list.  So the size is
      bounded by the number of basic blocks.  */
-  tos = worklist = XNEWVEC (basic_block, n_basic_blocks + 1);
+  tos = worklist = XNEWVEC (basic_block, cfun->cfg->get_n_basic_blocks () + 1);
 
   /* Initialize NEARER for each edge and build a mapping from an edge to
      its index.  */
@@ -624,12 +624,12 @@ compute_nearerout (struct edge_list *edge_list, sbitmap *farthest,
      do not want to be overly optimistic.  Consider an incoming edge to
      the exit block.  That edge should always have a NEARER value the
      same as FARTHEST for that edge.  */
-  FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
+  FOR_EACH_EDGE (e, ei, cfun->cfg->get_exit_block ()->preds)
     bitmap_copy (nearer[(size_t)e->aux], farthest[(size_t)e->aux]);
 
   /* Add all the blocks to the worklist.  This prevents an early exit
      from the loop given our optimistic initialization of NEARER.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       *tos++ = bb;
       bb->aux = bb;
@@ -656,7 +656,7 @@ compute_nearerout (struct edge_list *edge_list, sbitmap *farthest,
 				      st_avloc[e->dest->index])
 	    /* If NEARER for an incoming edge was changed, then we need
 	       to add the source of the incoming edge to the worklist.  */
-	    && e->src != ENTRY_BLOCK_PTR && e->src->aux == 0)
+	    && e->src != cfun->cfg->get_entry_block () && e->src->aux == 0)
 	  {
 	    *tos++ = e->src;
 	    e->src->aux = e;
@@ -666,10 +666,10 @@ compute_nearerout (struct edge_list *edge_list, sbitmap *farthest,
   /* Computation of insertion and deletion points requires computing NEAREROUT
      for the ENTRY block.  We allocated an extra entry in the NEAREROUT array
      for just this purpose.  */
-  bitmap_ones (nearerout[last_basic_block]);
-  FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR->succs)
-    bitmap_and (nearerout[last_basic_block],
-		     nearerout[last_basic_block],
+  bitmap_ones (nearerout[cfun->cfg->get_last_basic_block ()]);
+  FOR_EACH_EDGE (e, ei, cfun->cfg->get_entry_block ()->succs)
+    bitmap_and (nearerout[cfun->cfg->get_last_basic_block ()],
+		     nearerout[cfun->cfg->get_last_basic_block ()],
 		     nearer[(size_t) e->aux]);
 
   clear_aux_for_edges ();
@@ -686,15 +686,15 @@ compute_rev_insert_delete (struct edge_list *edge_list, sbitmap *st_avloc,
   int x;
   basic_block bb;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     bitmap_and_compl (del[bb->index], st_avloc[bb->index],
 			nearerout[bb->index]);
 
   for (x = 0; x < NUM_EDGES (edge_list); x++)
     {
       basic_block b = INDEX_EDGE_PRED_BB (edge_list, x);
-      if (b == ENTRY_BLOCK_PTR)
-	bitmap_and_compl (insert[x], nearer[x], nearerout[last_basic_block]);
+      if (b == cfun->cfg->get_entry_block ())
+	bitmap_and_compl (insert[x], nearer[x], nearerout[cfun->cfg->get_last_basic_block ()]);
       else
 	bitmap_and_compl (insert[x], nearer[x], nearerout[b->index]);
     }
@@ -719,15 +719,15 @@ pre_edge_rev_lcm (int n_exprs, sbitmap *transp,
   edge_list = create_edge_list ();
   num_edges = NUM_EDGES (edge_list);
 
-  st_antin = sbitmap_vector_alloc (last_basic_block, n_exprs);
-  st_antout = sbitmap_vector_alloc (last_basic_block, n_exprs);
-  bitmap_vector_clear (st_antin, last_basic_block);
-  bitmap_vector_clear (st_antout, last_basic_block);
+  st_antin = sbitmap_vector_alloc (cfun->cfg->get_last_basic_block (), n_exprs);
+  st_antout = sbitmap_vector_alloc (cfun->cfg->get_last_basic_block (), n_exprs);
+  bitmap_vector_clear (st_antin, cfun->cfg->get_last_basic_block ());
+  bitmap_vector_clear (st_antout, cfun->cfg->get_last_basic_block ());
   compute_antinout_edge (st_antloc, transp, st_antin, st_antout);
 
   /* Compute global anticipatability.  */
-  st_avout = sbitmap_vector_alloc (last_basic_block, n_exprs);
-  st_avin = sbitmap_vector_alloc (last_basic_block, n_exprs);
+  st_avout = sbitmap_vector_alloc (cfun->cfg->get_last_basic_block (), n_exprs);
+  st_avin = sbitmap_vector_alloc (cfun->cfg->get_last_basic_block (), n_exprs);
   compute_available (st_avloc, kill, st_avout, st_avin);
 
 #ifdef LCM_DEBUG_INFO
@@ -736,20 +736,20 @@ pre_edge_rev_lcm (int n_exprs, sbitmap *transp,
       fprintf (dump_file, "Edge List:\n");
       verify_edge_list (dump_file, edge_list);
       print_edge_list (dump_file, edge_list);
-      dump_bitmap_vector (dump_file, "transp", "", transp, last_basic_block);
-      dump_bitmap_vector (dump_file, "st_avloc", "", st_avloc, last_basic_block);
-      dump_bitmap_vector (dump_file, "st_antloc", "", st_antloc, last_basic_block);
-      dump_bitmap_vector (dump_file, "st_antin", "", st_antin, last_basic_block);
-      dump_bitmap_vector (dump_file, "st_antout", "", st_antout, last_basic_block);
-      dump_bitmap_vector (dump_file, "st_kill", "", kill, last_basic_block);
+      dump_bitmap_vector (dump_file, "transp", "", transp, cfun->cfg->get_last_basic_block ());
+      dump_bitmap_vector (dump_file, "st_avloc", "", st_avloc, cfun->cfg->get_last_basic_block ());
+      dump_bitmap_vector (dump_file, "st_antloc", "", st_antloc, cfun->cfg->get_last_basic_block ());
+      dump_bitmap_vector (dump_file, "st_antin", "", st_antin, cfun->cfg->get_last_basic_block ());
+      dump_bitmap_vector (dump_file, "st_antout", "", st_antout, cfun->cfg->get_last_basic_block ());
+      dump_bitmap_vector (dump_file, "st_kill", "", kill, cfun->cfg->get_last_basic_block ());
     }
 #endif
 
 #ifdef LCM_DEBUG_INFO
   if (dump_file)
     {
-      dump_bitmap_vector (dump_file, "st_avout", "", st_avout, last_basic_block);
-      dump_bitmap_vector (dump_file, "st_avin", "", st_avin, last_basic_block);
+      dump_bitmap_vector (dump_file, "st_avout", "", st_avout, cfun->cfg->get_last_basic_block ());
+      dump_bitmap_vector (dump_file, "st_avin", "", st_avin, cfun->cfg->get_last_basic_block ());
     }
 #endif
 
@@ -772,14 +772,14 @@ pre_edge_rev_lcm (int n_exprs, sbitmap *transp,
   nearer = sbitmap_vector_alloc (num_edges, n_exprs);
 
   /* Allocate an extra element for the entry block.  */
-  nearerout = sbitmap_vector_alloc (last_basic_block + 1, n_exprs);
+  nearerout = sbitmap_vector_alloc (cfun->cfg->get_last_basic_block () + 1, n_exprs);
   compute_nearerout (edge_list, farthest, st_avloc, nearer, nearerout);
 
 #ifdef LCM_DEBUG_INFO
   if (dump_file)
     {
       dump_bitmap_vector (dump_file, "nearerout", "", nearerout,
-			   last_basic_block + 1);
+			   cfun->cfg->get_last_basic_block () + 1);
       dump_bitmap_vector (dump_file, "nearer", "", nearer, num_edges);
     }
 #endif
@@ -787,7 +787,7 @@ pre_edge_rev_lcm (int n_exprs, sbitmap *transp,
   sbitmap_vector_free (farthest);
 
   *insert = sbitmap_vector_alloc (num_edges, n_exprs);
-  *del = sbitmap_vector_alloc (last_basic_block, n_exprs);
+  *del = sbitmap_vector_alloc (cfun->cfg->get_last_basic_block (), n_exprs);
   compute_rev_insert_delete (edge_list, st_avloc, nearer, nearerout,
 			     *insert, *del);
 
@@ -799,7 +799,7 @@ pre_edge_rev_lcm (int n_exprs, sbitmap *transp,
     {
       dump_bitmap_vector (dump_file, "pre_insert_map", "", *insert, num_edges);
       dump_bitmap_vector (dump_file, "pre_delete_map", "", *del,
-			   last_basic_block);
+			   cfun->cfg->get_last_basic_block ());
     }
 #endif
   return edge_list;
diff --git a/gcc/loop-init.c b/gcc/loop-init.c
index 65f9c6c..9858b84 100644
--- a/gcc/loop-init.c
+++ b/gcc/loop-init.c
@@ -171,7 +171,7 @@ loop_optimizer_finalize (void)
   ggc_free (current_loops);
   current_loops = NULL;
 
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       bb->loop_father = NULL;
     }
@@ -216,7 +216,7 @@ fix_loop_structure (bitmap changed_bbs)
   /* Remember the depth of the blocks in the loop hierarchy, so that we can
      recognize blocks whose loop nesting relationship has changed.  */
   if (changed_bbs)
-    FOR_EACH_BB (bb)
+    FOR_EACH_BB_CFG (bb, cfun->cfg)
       bb->aux = (void *) (size_t) loop_depth (bb->loop_father);
 
   /* Remove the dead loops from structures.  We start from the innermost
@@ -259,7 +259,7 @@ fix_loop_structure (bitmap changed_bbs)
   /* Mark the blocks whose loop has changed.  */
   if (changed_bbs)
     {
-      FOR_EACH_BB (bb)
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
 	{
 	  if ((void *) (size_t) loop_depth (bb->loop_father) != bb->aux)
 	    bitmap_set_bit (changed_bbs, bb->index);
diff --git a/gcc/loop-invariant.c b/gcc/loop-invariant.c
index 73200e1..e359e36 100644
--- a/gcc/loop-invariant.c
+++ b/gcc/loop-invariant.c
@@ -1826,7 +1826,7 @@ calculate_loop_reg_pressure (void)
       }
   ira_setup_eliminable_regset (false);
   bitmap_initialize (&curr_regs_live, &reg_obstack);
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       curr_loop = bb->loop_father;
       if (curr_loop == current_loops->tree_root)
diff --git a/gcc/loop-iv.c b/gcc/loop-iv.c
index 3248b56..c8f574e 100644
--- a/gcc/loop-iv.c
+++ b/gcc/loop-iv.c
@@ -1929,7 +1929,7 @@ simplify_using_initial_values (struct loop *loop, enum rtx_code op, rtx *expr)
     return;
 
   e = loop_preheader_edge (loop);
-  if (e->src == ENTRY_BLOCK_PTR)
+  if (e->src == cfun->cfg->get_entry_block ())
     return;
 
   altered = ALLOC_REG_SET (&reg_obstack);
@@ -2060,7 +2060,7 @@ simplify_using_initial_values (struct loop *loop, enum rtx_code op, rtx *expr)
 	}
 
       if (!single_pred_p (e->src)
-	  || single_pred (e->src) == ENTRY_BLOCK_PTR)
+	  || single_pred (e->src) == cfun->cfg->get_entry_block ())
 	break;
       e = single_pred_edge (e->src);
     }
diff --git a/gcc/loop-unroll.c b/gcc/loop-unroll.c
index d03dc3d..738301c 100644
--- a/gcc/loop-unroll.c
+++ b/gcc/loop-unroll.c
@@ -1378,7 +1378,7 @@ decide_peel_simple (struct loop *loop, int flags)
      also branch from branch prediction POV (and probably better reason
      to not unroll/peel).  */
   if (num_loop_branches (loop) > 1
-      && profile_status != PROFILE_READ)
+      && cfun->cfg->get_profile_status () != PROFILE_READ)
     {
       if (dump_file)
 	fprintf (dump_file, ";; Not peeling, contains branches\n");
@@ -2014,7 +2014,7 @@ static void
 opt_info_start_duplication (struct opt_info *opt_info)
 {
   if (opt_info)
-    opt_info->first_new_block = last_basic_block;
+    opt_info->first_new_block = cfun->cfg->get_last_basic_block ();
 }
 
 /* Determine the number of iterations between initialization of the base
@@ -2375,9 +2375,9 @@ apply_opt_in_copies (struct opt_info *opt_info,
     for (ivts = opt_info->iv_to_split_head; ivts; ivts = ivts->next)
       allocate_basic_variable (ivts);
 
-  for (i = opt_info->first_new_block; i < (unsigned) last_basic_block; i++)
+  for (i = opt_info->first_new_block; i < (unsigned) cfun->cfg->get_last_basic_block (); i++)
     {
-      bb = BASIC_BLOCK (i);
+      bb = cfun->cfg->get_basic_block_by_idx (i);
       orig_bb = get_bb_original (bb);
 
       /* bb->aux holds position in copy sequence initialized by
@@ -2451,9 +2451,9 @@ apply_opt_in_copies (struct opt_info *opt_info,
   /* Rewrite also the original loop body.  Find them as originals of the blocks
      in the last copied iteration, i.e. those that have
      get_bb_copy (get_bb_original (bb)) == bb.  */
-  for (i = opt_info->first_new_block; i < (unsigned) last_basic_block; i++)
+  for (i = opt_info->first_new_block; i < (unsigned) cfun->cfg->get_last_basic_block (); i++)
     {
-      bb = BASIC_BLOCK (i);
+      bb = cfun->cfg->get_basic_block_by_idx (i);
       orig_bb = get_bb_original (bb);
       if (get_bb_copy (orig_bb) != bb)
 	continue;
diff --git a/gcc/loop-unswitch.c b/gcc/loop-unswitch.c
index 213e74d..884f607 100644
--- a/gcc/loop-unswitch.c
+++ b/gcc/loop-unswitch.c
@@ -429,7 +429,7 @@ unswitch_loop (struct loop *loop, basic_block unswitch_on, rtx cond, rtx cinsn)
 
   /* Create a block with the condition.  */
   prob = true_edge->probability;
-  switch_bb = create_empty_bb (EXIT_BLOCK_PTR->prev_bb);
+  switch_bb = create_empty_bb (cfun->cfg->get_exit_block ()->prev_bb);
   seq = compare_and_jump_seq (XEXP (cond, 0), XEXP (cond, 1), GET_CODE (cond),
 			      block_label (true_edge->dest),
 			      prob, cinsn);
diff --git a/gcc/lower-subreg.c b/gcc/lower-subreg.c
index eb22d8c..630b4b6 100644
--- a/gcc/lower-subreg.c
+++ b/gcc/lower-subreg.c
@@ -1439,7 +1439,7 @@ decompose_multiword_subregs (bool decompose_copies)
   memset (reg_copy_graph.address (), 0, sizeof (bitmap) * max);
 
   speed_p = optimize_function_for_speed_p (cfun);
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       rtx insn;
 
@@ -1513,13 +1513,13 @@ decompose_multiword_subregs (bool decompose_copies)
 
       propagate_pseudo_copies ();
 
-      sub_blocks = sbitmap_alloc (last_basic_block);
+      sub_blocks = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
       bitmap_clear (sub_blocks);
 
       EXECUTE_IF_SET_IN_BITMAP (decomposable_context, 0, regno, iter)
 	decompose_register (regno);
 
-      FOR_EACH_BB (bb)
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
 	{
 	  rtx insn;
 
@@ -1623,7 +1623,7 @@ decompose_multiword_subregs (bool decompose_copies)
 	  rtx insn, end;
 	  edge fallthru;
 
-	  bb = BASIC_BLOCK (i);
+	  bb = cfun->cfg->get_basic_block_by_idx (i);
 	  insn = BB_HEAD (bb);
 	  end = BB_END (bb);
 
diff --git a/gcc/lra-assigns.c b/gcc/lra-assigns.c
index 78bc2e7..be88049 100644
--- a/gcc/lra-assigns.c
+++ b/gcc/lra-assigns.c
@@ -598,7 +598,7 @@ find_hard_regno_for (int regno, int *cost, int try_only_hard_regno)
 		&& ! df_regs_ever_live_p (hard_regno + j))
 	      /* It needs save restore.	 */
 	      hard_regno_costs[hard_regno]
-		+= 2 * ENTRY_BLOCK_PTR->next_bb->frequency + 1;
+		+= 2 * cfun->cfg->get_entry_block ()->next_bb->frequency + 1;
 	  priority = targetm.register_priority (hard_regno);
 	  if (best_hard_regno < 0 || hard_regno_costs[hard_regno] < best_cost
 	      || (hard_regno_costs[hard_regno] == best_cost
@@ -1291,7 +1291,7 @@ assign_by_spills (void)
 
       /* FIXME: Look up the changed insns in the cached LRA insn data using
 	 an EXECUTE_IF_SET_IN_BITMAP over changed_insns.  */
-      FOR_EACH_BB (bb)
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
 	FOR_BB_INSNS (bb, insn)
 	if (bitmap_bit_p (&changed_insns, INSN_UID (insn)))
 	  {
diff --git a/gcc/lra-coalesce.c b/gcc/lra-coalesce.c
index 859e02f..7569ae6 100644
--- a/gcc/lra-coalesce.c
+++ b/gcc/lra-coalesce.c
@@ -239,7 +239,7 @@ lra_coalesce (void)
   mv_num = 0;
   /* Collect moves.  */
   coalesced_moves = 0;
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       FOR_BB_INSNS_SAFE (bb, insn, next)
 	if (INSN_P (insn)
@@ -297,7 +297,7 @@ lra_coalesce (void)
 	}
     }
   bitmap_initialize (&used_pseudos_bitmap, &reg_obstack);
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       update_live_info (df_get_live_in (bb));
       update_live_info (df_get_live_out (bb));
diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c
index ef6e07e..c2f73fa 100644
--- a/gcc/lra-constraints.c
+++ b/gcc/lra-constraints.c
@@ -5020,7 +5020,7 @@ lra_inheritance (void)
   bitmap_initialize (&live_regs, &reg_obstack);
   bitmap_initialize (&temp_bitmap, &reg_obstack);
   bitmap_initialize (&ebb_global_regs, &reg_obstack);
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       start_bb = bb;
       if (lra_dump_file != NULL)
@@ -5032,7 +5032,7 @@ lra_inheritance (void)
 	{
 	  if (lra_dump_file != NULL)
 	    fprintf (lra_dump_file, " %d", bb->index);
-	  if (bb->next_bb == EXIT_BLOCK_PTR || LABEL_P (BB_HEAD (bb->next_bb)))
+	  if (bb->next_bb == cfun->cfg->get_exit_block () || LABEL_P (BB_HEAD (bb->next_bb)))
 	    break;
 	  e = find_fallthru_edge (bb->succs);
 	  if (! e)
@@ -5120,7 +5120,7 @@ remove_inheritance_pseudos (bitmap remove_pseudos)
      because we need to marks insns affected by previous
      inheritance/split pass for processing by the subsequent
      constraint pass.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       fix_bb_live_info (df_get_live_in (bb), remove_pseudos);
       fix_bb_live_info (df_get_live_out (bb), remove_pseudos);
diff --git a/gcc/lra-eliminations.c b/gcc/lra-eliminations.c
index a59ab6e..d88fb65 100644
--- a/gcc/lra-eliminations.c
+++ b/gcc/lra-eliminations.c
@@ -1200,7 +1200,7 @@ lra_init_elimination (void)
   rtx insn;
 
   init_elim_table ();
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     FOR_BB_INSNS (bb, insn)
     if (NONDEBUG_INSN_P (insn))
       mark_not_eliminable (PATTERN (insn));
diff --git a/gcc/lra-lives.c b/gcc/lra-lives.c
index 6eaeb2d..3fc6a4e 100644
--- a/gcc/lra-lives.c
+++ b/gcc/lra-lives.c
@@ -990,13 +990,13 @@ lra_create_live_ranges (bool all_p)
   curr_point = 0;
   point_freq_vec.create (get_max_uid () * 2);
   lra_point_freq = point_freq_vec.address ();
-  int *post_order_rev_cfg = XNEWVEC (int, last_basic_block);
+  int *post_order_rev_cfg = XNEWVEC (int, cfun->cfg->get_last_basic_block ());
   int n_blocks_inverted = inverted_post_order_compute (post_order_rev_cfg);
-  lra_assert (n_blocks_inverted == n_basic_blocks);
+  lra_assert (n_blocks_inverted == cfun->cfg->get_n_basic_blocks ());
   for (i = n_blocks_inverted - 1; i >= 0; --i)
     {
-      bb = BASIC_BLOCK (post_order_rev_cfg[i]);
-      if (bb == EXIT_BLOCK_PTR || bb == ENTRY_BLOCK_PTR)
+      bb = cfun->cfg->get_basic_block_by_idx (post_order_rev_cfg[i]);
+      if (bb == cfun->cfg->get_exit_block () || bb == cfun->cfg->get_entry_block ())
 	continue;
       process_bb_lives (bb, curr_point);
     }
diff --git a/gcc/lra-spills.c b/gcc/lra-spills.c
index 7c0c630..b25a1e0 100644
--- a/gcc/lra-spills.c
+++ b/gcc/lra-spills.c
@@ -281,7 +281,7 @@ assign_spill_hard_regs (int *pseudo_regnos, int n)
 	  add_to_hard_reg_set (&reserved_hard_regs[p],
 			       lra_reg_info[i].biggest_mode, hard_regno);
   bitmap_initialize (&ok_insn_bitmap, &reg_obstack);
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     FOR_BB_INSNS (bb, insn)
       if (DEBUG_INSN_P (insn)
 	  || ((set = single_set (insn)) != NULL_RTX
@@ -472,7 +472,7 @@ spill_pseudos (void)
 	  bitmap_ior_into (&changed_insns, &lra_reg_info[i].insn_bitmap);
 	}
     }
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       FOR_BB_INSNS (bb, insn)
 	if (bitmap_bit_p (&changed_insns, INSN_UID (insn)))
@@ -632,7 +632,7 @@ lra_final_code_change (void)
     if (lra_reg_info[i].nrefs != 0
 	&& (hard_regno = lra_get_regno_hard_regno (i)) >= 0)
       SET_REGNO (regno_reg_rtx[i], hard_regno);
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     FOR_BB_INSNS_SAFE (bb, insn, curr)
       if (INSN_P (insn))
 	{
diff --git a/gcc/lra.c b/gcc/lra.c
index 7c6bff1..0e1ae20 100644
--- a/gcc/lra.c
+++ b/gcc/lra.c
@@ -1896,7 +1896,7 @@ remove_scratches (void)
   scratches.create (get_max_uid ());
   bitmap_initialize (&scratch_bitmap, &reg_obstack);
   bitmap_initialize (&scratch_operand_bitmap, &reg_obstack);
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     FOR_BB_INSNS (bb, insn)
     if (INSN_P (insn))
       {
@@ -1987,7 +1987,7 @@ check_rtl (bool final_p)
   lra_insn_recog_data_t id;
 
   lra_assert (! final_p || reload_completed);
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     FOR_BB_INSNS (bb, insn)
     if (NONDEBUG_INSN_P (insn)
 	&& GET_CODE (PATTERN (insn)) != USE
@@ -2043,14 +2043,14 @@ has_nonexceptional_receiver (void)
     return true;
 
   /* First determine which blocks can reach exit via normal paths.  */
-  tos = worklist = XNEWVEC (basic_block, n_basic_blocks + 1);
+  tos = worklist = XNEWVEC (basic_block, cfun->cfg->get_n_basic_blocks () + 1);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     bb->flags &= ~BB_REACHABLE;
 
   /* Place the exit block on our worklist.  */
-  EXIT_BLOCK_PTR->flags |= BB_REACHABLE;
-  *tos++ = EXIT_BLOCK_PTR;
+  cfun->cfg->get_exit_block ()->flags |= BB_REACHABLE;
+  *tos++ = cfun->cfg->get_exit_block ();
 
   /* Iterate: find everything reachable from what we've already seen.  */
   while (tos != worklist)
@@ -2120,7 +2120,7 @@ update_inc_notes (void)
   basic_block bb;
   rtx insn;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     FOR_BB_INSNS (bb, insn)
     if (NONDEBUG_INSN_P (insn))
       {
@@ -2366,7 +2366,7 @@ lra (FILE *f)
   if (cfun->can_throw_non_call_exceptions)
     {
       sbitmap blocks;
-      blocks = sbitmap_alloc (last_basic_block);
+      blocks = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
       bitmap_ones (blocks);
       find_many_sub_basic_blocks (blocks);
       sbitmap_free (blocks);
diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c
index 02889a9..ae95dc0 100644
--- a/gcc/lto-streamer-in.c
+++ b/gcc/lto-streamer-in.c
@@ -891,7 +891,7 @@ input_function (tree fn_decl, struct data_in *data_in,
   /* Fix up the call statements that are mentioned in the callgraph
      edges.  */
   set_gimple_stmt_max_uid (cfun, 0);
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator gsi;
       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
@@ -901,7 +901,7 @@ input_function (tree fn_decl, struct data_in *data_in,
 	}
     }
   stmts = (gimple *) xcalloc (gimple_stmt_max_uid (fn), sizeof (gimple));
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator bsi = gsi_start_bb (bb);
       while (!gsi_end_p (bsi))
@@ -931,7 +931,7 @@ input_function (tree fn_decl, struct data_in *data_in,
      of a gimple body is used by the cgraph routines, but we should
      really use the presence of the CFG.  */
   {
-    edge_iterator ei = ei_start (ENTRY_BLOCK_PTR->succs);
+    edge_iterator ei = ei_start (cfun->cfg->get_entry_block ()->succs);
     gimple_set_body (fn_decl, bb_seq (ei_edge (ei)->dest));
   }
 
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index dfaf280..f67e37b 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -651,7 +651,7 @@ output_cfg (struct output_block *ob, struct function *fn)
 
   streamer_write_hwi (ob, -1);
 
-  bb = ENTRY_BLOCK_PTR;
+  bb = cfun->cfg->get_entry_block ();
   while (bb->next_bb)
     {
       streamer_write_hwi (ob, bb->next_bb->index);
@@ -847,7 +847,7 @@ output_function (struct cgraph_node *node)
      virtual PHIs get re-computed on-the-fly which would make numbers
      inconsistent.  */
   set_gimple_stmt_max_uid (cfun, 0);
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator gsi;
       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
diff --git a/gcc/mcf.c b/gcc/mcf.c
index 7a716f5..f0ad41a 100644
--- a/gcc/mcf.c
+++ b/gcc/mcf.c
@@ -471,12 +471,12 @@ create_fixup_graph (fixup_graph_type *fixup_graph)
   int fnum_edges;
 
   /* Each basic_block will be split into 2 during vertex transformation.  */
-  int fnum_vertices_after_transform =  2 * n_basic_blocks;
-  int fnum_edges_after_transform = n_edges + n_basic_blocks;
+  int fnum_vertices_after_transform =  2 * cfun->cfg->get_n_basic_blocks ();
+  int fnum_edges_after_transform = cfun->cfg->get_n_edges () + cfun->cfg->get_n_basic_blocks ();
 
   /* Count the new SOURCE and EXIT vertices to be added.  */
   int fmax_num_vertices =
-    fnum_vertices_after_transform + n_edges + n_basic_blocks + 2;
+    fnum_vertices_after_transform + cfun->cfg->get_n_edges () + cfun->cfg->get_n_basic_blocks () + 2;
 
   /* In create_fixup_graph: Each basic block and edge can be split into 3
      edges. Number of balance edges = n_basic_blocks. So after
@@ -486,10 +486,10 @@ create_fixup_graph (fixup_graph_type *fixup_graph)
      max_edges = 2 * (4 * n_basic_blocks + 3 * n_edges)
      = 8 * n_basic_blocks + 6 * n_edges
      < 8 * n_basic_blocks + 8 * n_edges.  */
-  int fmax_num_edges = 8 * (n_basic_blocks + n_edges);
+  int fmax_num_edges = 8 * (cfun->cfg->get_n_basic_blocks () + cfun->cfg->get_n_edges ());
 
   /* Initial num of vertices in the fixup graph.  */
-  fixup_graph->num_vertices = n_basic_blocks;
+  fixup_graph->num_vertices = cfun->cfg->get_n_basic_blocks ();
 
   /* Fixup graph vertex list.  */
   fixup_graph->vertex_list =
@@ -505,10 +505,10 @@ create_fixup_graph (fixup_graph_type *fixup_graph)
 
   /* Compute constants b, k_pos, k_neg used in the cost function calculation.
      b = sqrt(avg_vertex_weight(cfg)); k_pos = b; k_neg = 50b.  */
-  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
+  FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block (), NULL, next_bb)
     total_vertex_weight += bb->count;
 
-  sqrt_avg_vertex_weight = mcf_sqrt (total_vertex_weight / n_basic_blocks);
+  sqrt_avg_vertex_weight = mcf_sqrt (total_vertex_weight / cfun->cfg->get_n_basic_blocks ());
 
   k_pos = K_POS (sqrt_avg_vertex_weight);
   k_neg = K_NEG (sqrt_avg_vertex_weight);
@@ -519,7 +519,7 @@ create_fixup_graph (fixup_graph_type *fixup_graph)
   if (dump_file)
     fprintf (dump_file, "\nVertex transformation:\n");
 
-  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
+  FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block (), NULL, next_bb)
   {
     /* v'->v'': index1->(index1+1).  */
     i = 2 * bb->index;
@@ -1121,7 +1121,7 @@ adjust_cfg_counts (fixup_graph_type *fixup_graph)
   if (dump_file)
     fprintf (dump_file, "\nadjust_cfg_counts():\n");
 
-  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
+  FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block (), cfun->cfg->get_exit_block (), next_bb)
     {
       i = 2 * bb->index;
 
@@ -1234,11 +1234,11 @@ adjust_cfg_counts (fixup_graph_type *fixup_graph)
         }
     }
 
-  ENTRY_BLOCK_PTR->count = sum_edge_counts (ENTRY_BLOCK_PTR->succs);
-  EXIT_BLOCK_PTR->count = sum_edge_counts (EXIT_BLOCK_PTR->preds);
+  cfun->cfg->get_entry_block ()->count = sum_edge_counts (cfun->cfg->get_entry_block ()->succs);
+  cfun->cfg->get_exit_block ()->count = sum_edge_counts (cfun->cfg->get_exit_block ()->preds);
 
   /* Compute edge probabilities.  */
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       if (bb->count)
         {
@@ -1274,7 +1274,7 @@ adjust_cfg_counts (fixup_graph_type *fixup_graph)
     {
       fprintf (dump_file, "\nCheck %s() CFG flow conservation:\n",
 	       current_function_name ());
-      FOR_EACH_BB (bb)
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
         {
           if ((bb->count != sum_edge_counts (bb->preds))
                || (bb->count != sum_edge_counts (bb->succs)))
diff --git a/gcc/mode-switching.c b/gcc/mode-switching.c
index 70a77d0..0dc2e0f 100644
--- a/gcc/mode-switching.c
+++ b/gcc/mode-switching.c
@@ -211,7 +211,7 @@ create_pre_exit (int n_entities, int *entity_map, const int *num_modes)
      fallthrough edge; there can be at most one, but there could be
      none at all, e.g. when exit is called.  */
   pre_exit = 0;
-  FOR_EACH_EDGE (eg, ei, EXIT_BLOCK_PTR->preds)
+  FOR_EACH_EDGE (eg, ei, cfun->cfg->get_exit_block ()->preds)
     if (eg->flags & EDGE_FALLTHRU)
       {
 	basic_block src_bb = eg->src;
@@ -221,7 +221,7 @@ create_pre_exit (int n_entities, int *entity_map, const int *num_modes)
 	/* If this function returns a value at the end, we have to
 	   insert the final mode switch before the return value copy
 	   to its hard register.  */
-	if (EDGE_COUNT (EXIT_BLOCK_PTR->preds) == 1
+	if (EDGE_COUNT (cfun->cfg->get_exit_block ()->preds) == 1
 	    && NONJUMP_INSN_P ((last_insn = BB_END (src_bb)))
 	    && GET_CODE (PATTERN (last_insn)) == USE
 	    && GET_CODE ((ret_reg = XEXP (PATTERN (last_insn), 0))) == REG)
@@ -477,7 +477,7 @@ optimize_mode_switching (void)
 	entry_exit_extra = 3;
 #endif
 	bb_info[n_entities]
-	  = XCNEWVEC (struct bb_info, last_basic_block + entry_exit_extra);
+	  = XCNEWVEC (struct bb_info, cfun->cfg->get_last_basic_block () + entry_exit_extra);
 	entity_map[n_entities++] = e;
 	if (num_modes[e] > max_num_modes)
 	  max_num_modes = num_modes[e];
@@ -489,7 +489,7 @@ optimize_mode_switching (void)
 #if defined (MODE_ENTRY) && defined (MODE_EXIT)
   /* Split the edge from the entry block, so that we can note that
      there NORMAL_MODE is supplied.  */
-  post_entry = split_edge (single_succ_edge (ENTRY_BLOCK_PTR));
+  post_entry = split_edge (single_succ_edge (cfun->cfg->get_entry_block ()));
   pre_exit = create_pre_exit (n_entities, entity_map, num_modes);
 #endif
 
@@ -497,11 +497,11 @@ optimize_mode_switching (void)
 
   /* Create the bitmap vectors.  */
 
-  antic = sbitmap_vector_alloc (last_basic_block, n_entities);
-  transp = sbitmap_vector_alloc (last_basic_block, n_entities);
-  comp = sbitmap_vector_alloc (last_basic_block, n_entities);
+  antic = sbitmap_vector_alloc (cfun->cfg->get_last_basic_block (), n_entities);
+  transp = sbitmap_vector_alloc (cfun->cfg->get_last_basic_block (), n_entities);
+  comp = sbitmap_vector_alloc (cfun->cfg->get_last_basic_block (), n_entities);
 
-  bitmap_vector_ones (transp, last_basic_block);
+  bitmap_vector_ones (transp, cfun->cfg->get_last_basic_block ());
 
   for (j = n_entities - 1; j >= 0; j--)
     {
@@ -512,7 +512,7 @@ optimize_mode_switching (void)
       /* Determine what the first use (if any) need for a mode of entity E is.
 	 This will be the mode that is anticipatable for this block.
 	 Also compute the initial transparency settings.  */
-      FOR_EACH_BB (bb)
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
 	{
 	  struct seginfo *ptr;
 	  int last_mode = no_mode;
@@ -602,7 +602,7 @@ optimize_mode_switching (void)
 #endif /* NORMAL_MODE */
     }
 
-  kill = sbitmap_vector_alloc (last_basic_block, n_entities);
+  kill = sbitmap_vector_alloc (cfun->cfg->get_last_basic_block (), n_entities);
   for (i = 0; i < max_num_modes; i++)
     {
       int current_mode[N_ENTITIES];
@@ -610,14 +610,14 @@ optimize_mode_switching (void)
       sbitmap *insert;
 
       /* Set the anticipatable and computing arrays.  */
-      bitmap_vector_clear (antic, last_basic_block);
-      bitmap_vector_clear (comp, last_basic_block);
+      bitmap_vector_clear (antic, cfun->cfg->get_last_basic_block ());
+      bitmap_vector_clear (comp, cfun->cfg->get_last_basic_block ());
       for (j = n_entities - 1; j >= 0; j--)
 	{
 	  int m = current_mode[j] = MODE_PRIORITY_TO_MODE (entity_map[j], i);
 	  struct bb_info *info = bb_info[j];
 
-	  FOR_EACH_BB (bb)
+	  FOR_EACH_BB_CFG (bb, cfun->cfg)
 	    {
 	      if (info[bb->index].seginfo->mode == m)
 		bitmap_set_bit (antic[bb->index], j);
@@ -630,7 +630,7 @@ optimize_mode_switching (void)
       /* Calculate the optimal locations for the
 	 placement mode switches to modes with priority I.  */
 
-      FOR_EACH_BB (bb)
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
 	bitmap_not (kill[bb->index], transp[bb->index]);
       edge_list = pre_edge_lcm (n_entities, transp, comp, antic,
 				kill, &insert, &del);
@@ -685,7 +685,7 @@ optimize_mode_switching (void)
 	      insert_insn_on_edge (mode_set, eg);
 	    }
 
-	  FOR_EACH_BB_REVERSE (bb)
+	  FOR_EACH_BB_REVERSE_CFG (bb, cfun->cfg)
 	    if (bitmap_bit_p (del[bb->index], j))
 	      {
 		make_preds_opaque (bb, j);
@@ -705,7 +705,7 @@ optimize_mode_switching (void)
     {
       int no_mode = num_modes[entity_map[j]];
 
-      FOR_EACH_BB_REVERSE (bb)
+      FOR_EACH_BB_REVERSE_CFG (bb, cfun->cfg)
 	{
 	  struct seginfo *ptr, *next;
 	  for (ptr = bb_info[j][bb->index].seginfo; ptr; ptr = next)
diff --git a/gcc/modulo-sched.c b/gcc/modulo-sched.c
index 1e9b16c..004a91d 100644
--- a/gcc/modulo-sched.c
+++ b/gcc/modulo-sched.c
@@ -1307,7 +1307,7 @@ canon_loop (struct loop *loop)
 
   /* Avoid annoying special cases of edges going to exit
      block.  */
-  FOR_EACH_EDGE (e, i, EXIT_BLOCK_PTR->preds)
+  FOR_EACH_EDGE (e, i, cfun->cfg->get_exit_block ()->preds)
     if ((e->flags & EDGE_FALLTHRU) && (EDGE_COUNT (e->src->succs) > 1))
       split_edge (e);
 
@@ -3342,8 +3342,8 @@ rest_of_handle_sms (void)
   max_regno = max_reg_num ();
 
   /* Finalize layout changes.  */
-  FOR_EACH_BB (bb)
-    if (bb->next_bb != EXIT_BLOCK_PTR)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
+    if (bb->next_bb != cfun->cfg->get_exit_block ())
       bb->aux = bb->next_bb;
   free_dominance_info (CDI_DOMINATORS);
   cfg_layout_finalize ();
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 2cae478..ad353ca 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -3348,7 +3348,7 @@ optimize_omp_library_calls (gimple entry_stmt)
 		      && find_omp_clause (gimple_omp_task_clauses (entry_stmt),
 					  OMP_CLAUSE_UNTIED) != NULL);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
       {
 	gimple call = gsi_stmt (gsi);
@@ -3634,7 +3634,7 @@ expand_omp_taskreg (struct omp_region *region)
 	  basic_block bb;
 	  bool changed = false;
 
-	  FOR_EACH_BB (bb)
+	  FOR_EACH_BB_CFG (bb, cfun->cfg)
 	    changed |= gimple_purge_dead_eh_edges (bb);
 	  if (changed)
 	    cleanup_tree_cfg ();
@@ -5979,7 +5979,7 @@ build_omp_regions (void)
 {
   gcc_assert (root_omp_region == NULL);
   calculate_dominance_info (CDI_DOMINATORS);
-  build_omp_regions_1 (ENTRY_BLOCK_PTR, NULL, false);
+  build_omp_regions_1 (cfun->cfg->get_entry_block (), NULL, false);
 }
 
 /* Main entry point for expanding OMP-GIMPLE into runtime calls.  */
diff --git a/gcc/optabs.c b/gcc/optabs.c
index a3051ad..b93b89f 100644
--- a/gcc/optabs.c
+++ b/gcc/optabs.c
@@ -4278,7 +4278,7 @@ emit_cmp_and_jump_insn_1 (rtx test, enum machine_mode mode, rtx label, int prob)
   insn = emit_jump_insn (GEN_FCN (icode) (test, XEXP (test, 0),
                                           XEXP (test, 1), label));
   if (prob != -1
-      && profile_status != PROFILE_ABSENT
+      && cfun->cfg->get_profile_status () != PROFILE_ABSENT
       && insn
       && JUMP_P (insn)
       && any_condjump_p (insn)
diff --git a/gcc/postreload-gcse.c b/gcc/postreload-gcse.c
index aeffc14..0274636 100644
--- a/gcc/postreload-gcse.c
+++ b/gcc/postreload-gcse.c
@@ -266,7 +266,7 @@ alloc_mem (void)
   /* Find the largest UID and create a mapping from UIDs to CUIDs.  */
   uid_cuid = XCNEWVEC (int, get_max_uid () + 1);
   i = 1;
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     FOR_BB_INSNS (bb, insn)
       {
         if (INSN_P (insn))
@@ -828,7 +828,7 @@ compute_hash_table (void)
 {
   basic_block bb;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       rtx insn;
 
@@ -1158,12 +1158,12 @@ eliminate_partially_redundant_loads (void)
 
   /* Note we start at block 1.  */
 
-  if (ENTRY_BLOCK_PTR->next_bb == EXIT_BLOCK_PTR)
+  if (cfun->cfg->get_entry_block ()->next_bb == cfun->cfg->get_exit_block ())
     return;
 
   FOR_BB_BETWEEN (bb,
-		  ENTRY_BLOCK_PTR->next_bb->next_bb,
-		  EXIT_BLOCK_PTR,
+		  cfun->cfg->get_entry_block ()->next_bb->next_bb,
+		  cfun->cfg->get_exit_block (),
 		  next_bb)
     {
       /* Don't try anything on basic blocks with strange predecessors.  */
diff --git a/gcc/postreload.c b/gcc/postreload.c
index 33462e4..3495012 100644
--- a/gcc/postreload.c
+++ b/gcc/postreload.c
@@ -213,7 +213,7 @@ reload_cse_regs_1 (void)
   cselib_init (CSELIB_RECORD_MEMORY);
   init_alias_analysis ();
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     FOR_BB_INSNS (bb, insn)
       {
 	if (INSN_P (insn))
@@ -1281,7 +1281,7 @@ reload_combine (void)
   label_live = XNEWVEC (HARD_REG_SET, n_labels);
   CLEAR_HARD_REG_SET (ever_live_at_start);
 
-  FOR_EACH_BB_REVERSE (bb)
+  FOR_EACH_BB_REVERSE_CFG (bb, cfun->cfg)
     {
       insn = BB_HEAD (bb);
       if (LABEL_P (insn))
diff --git a/gcc/predict.c b/gcc/predict.c
index 9a15c87..96ebf30 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -220,7 +220,7 @@ cgraph_maybe_hot_edge_p (struct cgraph_edge *edge)
 bool
 maybe_hot_edge_p (edge e)
 {
-  if (profile_status == PROFILE_READ)
+  if (cfun->cfg->get_profile_status () == PROFILE_READ)
     return maybe_hot_count_p (cfun, e->count);
   return maybe_hot_frequency_p (cfun, EDGE_FREQUENCY (e));
 }
@@ -380,7 +380,7 @@ optimize_loop_nest_for_size_p (struct loop *loop)
 bool
 predictable_edge_p (edge e)
 {
-  if (profile_status == PROFILE_ABSENT)
+  if (cfun->cfg->get_profile_status () == PROFILE_ABSENT)
     return false;
   if ((e->probability
        <= PARAM_VALUE (PARAM_PREDICTABLE_BRANCH_OUTCOME) * REG_BR_PROB_BASE / 100)
@@ -481,8 +481,8 @@ gimple_predicted_by_p (const_basic_block bb, enum br_predictor predictor)
 static bool
 probability_reliable_p (int prob)
 {
-  return (profile_status == PROFILE_READ
-	  || (profile_status == PROFILE_GUESSED
+  return (cfun->cfg->get_profile_status () == PROFILE_READ
+	  || (cfun->cfg->get_profile_status () == PROFILE_GUESSED
 	      && (prob <= HITRATE (1) || prob >= HITRATE (99))));
 }
 
@@ -552,8 +552,8 @@ rtl_predict_edge (edge e, enum br_predictor predictor, int probability)
 void
 gimple_predict_edge (edge e, enum br_predictor predictor, int probability)
 {
-  gcc_assert (profile_status != PROFILE_GUESSED);
-  if ((e->src != ENTRY_BLOCK_PTR && EDGE_COUNT (e->src->succs) > 1)
+  gcc_assert (cfun->cfg->get_profile_status () != PROFILE_GUESSED);
+  if ((e->src != cfun->cfg->get_entry_block () && EDGE_COUNT (e->src->succs) > 1)
       && flag_guess_branch_prob && optimize)
     {
       struct edge_prediction *i = XNEW (struct edge_prediction);
@@ -1897,7 +1897,7 @@ strip_predict_hints (void)
   gimple ass_stmt;
   tree var;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator bi;
       for (bi = gsi_start_bb (bb); !gsi_end_p (bi);)
@@ -2110,7 +2110,7 @@ apply_return_prediction (void)
   enum prediction direction;
   edge_iterator ei;
 
-  FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
+  FOR_EACH_EDGE (e, ei, cfun->cfg->get_exit_block ()->preds)
     {
       return_stmt = last_stmt (e->src);
       if (return_stmt
@@ -2158,7 +2158,7 @@ tree_bb_level_predictions (void)
   edge e;
   edge_iterator ei;
 
-  FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
+  FOR_EACH_EDGE (e, ei, cfun->cfg->get_exit_block ()->preds)
     if (!(e->flags & (EDGE_ABNORMAL | EDGE_FAKE | EDGE_EH)))
       {
         has_return_edges = true;
@@ -2167,7 +2167,7 @@ tree_bb_level_predictions (void)
 
   apply_return_prediction ();
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator gsi;
 
@@ -2226,7 +2226,7 @@ tree_estimate_probability_bb (basic_block bb)
   FOR_EACH_EDGE (e, ei, bb->succs)
     {
       /* Predict edges to user labels with attributes.  */
-      if (e->dest != EXIT_BLOCK_PTR)
+      if (e->dest != cfun->cfg->get_exit_block ())
 	{
 	  gimple_stmt_iterator gi;
 	  for (gi = gsi_start_bb (e->dest); !gsi_end_p (gi); gsi_next (&gi))
@@ -2264,9 +2264,9 @@ tree_estimate_probability_bb (basic_block bb)
 	 return_block:
 	 return_stmt.  */
       if (e->dest != bb->next_bb
-	  && e->dest != EXIT_BLOCK_PTR
+	  && e->dest != cfun->cfg->get_exit_block ()
 	  && single_succ_p (e->dest)
-	  && single_succ_edge (e->dest)->dest == EXIT_BLOCK_PTR
+	  && single_succ_edge (e->dest)->dest == cfun->cfg->get_exit_block ()
 	  && (last = last_stmt (e->dest)) != NULL
 	  && gimple_code (last) == GIMPLE_RETURN)
 	{
@@ -2290,7 +2290,7 @@ 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 && e->dest != bb
+      if (e->dest != cfun->cfg->get_exit_block () && e->dest != bb
 	  && dominated_by_p (CDI_DOMINATORS, e->dest, e->src)
 	  && !dominated_by_p (CDI_POST_DOMINATORS, e->src, e->dest))
 	{
@@ -2341,10 +2341,10 @@ tree_estimate_probability (void)
   if (number_of_loops (cfun) > 1)
     predict_loops ();
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     tree_estimate_probability_bb (bb);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     combine_predictions_for_bb (bb);
 
 #ifdef ENABLE_CHECKING
@@ -2384,8 +2384,8 @@ tree_estimate_probability_driver (void)
   loop_optimizer_finalize ();
   if (dump_file && (dump_flags & TDF_DETAILS))
     gimple_dump_cfg (dump_file, dump_flags);
-  if (profile_status == PROFILE_ABSENT)
-    profile_status = PROFILE_GUESSED;
+  if (cfun->cfg->get_profile_status () == PROFILE_ABSENT)
+    cfun->cfg->set_profile_status (PROFILE_GUESSED);
   return 0;
 }
 
@@ -2537,7 +2537,7 @@ propagate_freq (basic_block head, bitmap tovisit)
       edge_iterator ei;
       int count = 0;
 
-      bb = BASIC_BLOCK (i);
+      bb = cfun->cfg->get_basic_block_by_idx (i);
 
       FOR_EACH_EDGE (e, ei, bb->preds)
 	{
@@ -2552,7 +2552,7 @@ propagate_freq (basic_block head, bitmap tovisit)
 	}
       BLOCK_INFO (bb)->npredecessors = count;
       /* When function never returns, we will never process exit block.  */
-      if (!count && bb == EXIT_BLOCK_PTR)
+      if (!count && bb == cfun->cfg->get_exit_block ())
 	bb->count = bb->frequency = 0;
     }
 
@@ -2698,11 +2698,11 @@ estimate_loops (void)
     estimate_loops_at_level (current_loops->tree_root->inner);
 
   /* Now propagate the frequencies through all the blocks.  */
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       bitmap_set_bit (tovisit, bb->index);
     }
-  propagate_freq (ENTRY_BLOCK_PTR, tovisit);
+  propagate_freq (cfun->cfg->get_entry_block (), tovisit);
   BITMAP_FREE (tovisit);
 }
 
@@ -2715,11 +2715,11 @@ counts_to_freqs (void)
   gcov_type count_max, true_count_max = 0;
   basic_block bb;
 
-  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
+  FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block (), NULL, next_bb)
     true_count_max = MAX (bb->count, true_count_max);
 
   count_max = MAX (true_count_max, 1);
-  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
+  FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block (), NULL, next_bb)
     bb->frequency = (bb->count * BB_FREQ_MAX + count_max / 2) / count_max;
 
   return true_count_max;
@@ -2744,12 +2744,12 @@ expensive_function_p (int threshold)
   /* Frequencies are out of range.  This either means that function contains
      internal loop executing more than BB_FREQ_MAX times or profile feedback
      is available and function has not been executed at all.  */
-  if (ENTRY_BLOCK_PTR->frequency == 0)
+  if (cfun->cfg->get_entry_block ()->frequency == 0)
     return true;
 
   /* Maximally BB_FREQ_MAX^2 so overflow won't happen.  */
-  limit = ENTRY_BLOCK_PTR->frequency * threshold;
-  FOR_EACH_BB (bb)
+  limit = cfun->cfg->get_entry_block ()->frequency * threshold;
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       rtx insn;
 
@@ -2773,7 +2773,7 @@ estimate_bb_frequencies (void)
   basic_block bb;
   sreal freq_max;
 
-  if (profile_status != PROFILE_READ || !counts_to_freqs ())
+  if (cfun->cfg->get_profile_status () != PROFILE_READ || !counts_to_freqs ())
     {
       static int real_values_initialized = 0;
 
@@ -2791,12 +2791,12 @@ estimate_bb_frequencies (void)
 
       mark_dfs_back_edges ();
 
-      single_succ_edge (ENTRY_BLOCK_PTR)->probability = REG_BR_PROB_BASE;
+      single_succ_edge (cfun->cfg->get_entry_block ())->probability = REG_BR_PROB_BASE;
 
       /* Set up block info for each basic block.  */
       alloc_aux_for_blocks (sizeof (struct block_info_def));
       alloc_aux_for_edges (sizeof (struct edge_info_def));
-      FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
+      FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block (), NULL, next_bb)
 	{
 	  edge e;
 	  edge_iterator ei;
@@ -2815,12 +2815,12 @@ estimate_bb_frequencies (void)
       estimate_loops ();
 
       memcpy (&freq_max, &real_zero, sizeof (real_zero));
-      FOR_EACH_BB (bb)
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
 	if (sreal_compare (&freq_max, &BLOCK_INFO (bb)->frequency) < 0)
 	  memcpy (&freq_max, &BLOCK_INFO (bb)->frequency, sizeof (freq_max));
 
       sreal_div (&freq_max, &real_bb_freq_max, &freq_max);
-      FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
+      FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block (), NULL, next_bb)
 	{
 	  sreal tmp;
 
@@ -2866,7 +2866,7 @@ compute_function_frequency (void)
       return;
     }
   node->frequency = NODE_FREQUENCY_UNLIKELY_EXECUTED;
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       if (maybe_hot_bb_p (cfun, bb))
 	{
@@ -2949,7 +2949,7 @@ void
 rebuild_frequencies (void)
 {
   timevar_push (TV_REBUILD_FREQUENCIES);
-  if (profile_status == PROFILE_GUESSED)
+  if (cfun->cfg->get_profile_status () == PROFILE_GUESSED)
     {
       loop_optimizer_init (0);
       add_noreturn_fake_exit_edges ();
@@ -2959,7 +2959,7 @@ rebuild_frequencies (void)
       remove_fake_exit_edges ();
       loop_optimizer_finalize ();
     }
-  else if (profile_status == PROFILE_READ)
+  else if (cfun->cfg->get_profile_status () == PROFILE_READ)
     counts_to_freqs ();
   else
     gcc_unreachable ();
diff --git a/gcc/profile.c b/gcc/profile.c
index b833398..381f39a 100644
--- a/gcc/profile.c
+++ b/gcc/profile.c
@@ -114,7 +114,7 @@ instrument_edges (struct edge_list *el)
   int num_edges = NUM_EDGES (el);
   basic_block bb;
 
-  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
+  FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block (), NULL, next_bb)
     {
       edge e;
       edge_iterator ei;
@@ -260,7 +260,7 @@ get_exec_counts (unsigned cfg_checksum, unsigned lineno_checksum)
   gcov_type *counts;
 
   /* Count the edges to be (possibly) instrumented.  */
-  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
+  FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block (), NULL, next_bb)
     {
       edge e;
       edge_iterator ei;
@@ -320,7 +320,7 @@ correct_negative_edge_counts (void)
   edge e;
   edge_iterator ei;
 
-  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
+  FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block (), NULL, next_bb)
     {
       FOR_EACH_EDGE (e, ei, bb->succs)
         {
@@ -337,7 +337,7 @@ is_inconsistent (void)
 {
   basic_block bb;
   bool inconsistent = false;
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       inconsistent |= is_edge_inconsistent (bb->preds);
       if (!dump_file && inconsistent)
@@ -371,7 +371,7 @@ is_inconsistent (void)
 	  inconsistent = true;
 	}
       if (bb->count != sum_edge_counts (bb->succs) &&
-          ! (find_edge (bb, EXIT_BLOCK_PTR) != NULL && block_ends_with_call_p (bb)))
+          ! (find_edge (bb, cfun->cfg->get_exit_block ()) != NULL && block_ends_with_call_p (bb)))
 	{
 	  if (dump_file)
 	    {
@@ -396,7 +396,7 @@ static void
 set_bb_counts (void)
 {
   basic_block bb;
-  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
+  FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block (), NULL, next_bb)
     {
       bb->count = sum_edge_counts (bb->succs);
       gcc_assert (bb->count >= 0);
@@ -415,7 +415,7 @@ read_profile_edge_counts (gcov_type *exec_counts)
   /* The first count in the .da file is the number of times that the function
      was entered.  This is the exec_count for block zero.  */
 
-  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
+  FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block (), NULL, next_bb)
     {
       edge e;
       edge_iterator ei;
@@ -478,7 +478,7 @@ compute_frequency_overlap (void)
   int overlap = 0;
   basic_block bb;
 
-  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
+  FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block (), NULL, next_bb)
     {
       count_total += bb->count;
       freq_total += bb->frequency;
@@ -487,7 +487,7 @@ compute_frequency_overlap (void)
   if (count_total == 0 || freq_total == 0)
     return 0;
 
-  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
+  FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block (), NULL, next_bb)
     overlap += MIN (bb->count * OVERLAP_BASE / count_total,
 		    bb->frequency * OVERLAP_BASE / freq_total);
 
@@ -529,7 +529,7 @@ compute_branch_probabilities (unsigned cfg_checksum, unsigned lineno_checksum)
 
   /* Attach extra info block to each bb.  */
   alloc_aux_for_blocks (sizeof (struct bb_info));
-  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
+  FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block (), NULL, next_bb)
     {
       edge e;
       edge_iterator ei;
@@ -543,8 +543,8 @@ compute_branch_probabilities (unsigned cfg_checksum, unsigned lineno_checksum)
     }
 
   /* Avoid predicting entry on exit nodes.  */
-  BB_INFO (EXIT_BLOCK_PTR)->succ_count = 2;
-  BB_INFO (ENTRY_BLOCK_PTR)->pred_count = 2;
+  BB_INFO (cfun->cfg->get_exit_block ())->succ_count = 2;
+  BB_INFO (cfun->cfg->get_entry_block ())->pred_count = 2;
 
   num_edges = read_profile_edge_counts (exec_counts);
 
@@ -574,7 +574,7 @@ compute_branch_probabilities (unsigned cfg_checksum, unsigned lineno_checksum)
     {
       passes++;
       changes = 0;
-      FOR_BB_BETWEEN (bb, EXIT_BLOCK_PTR, NULL, prev_bb)
+      FOR_BB_BETWEEN (bb, cfun->cfg->get_exit_block (), NULL, prev_bb)
 	{
 	  struct bb_info *bi = BB_INFO (bb);
 	  if (! bi->count_valid)
@@ -678,7 +678,7 @@ compute_branch_probabilities (unsigned cfg_checksum, unsigned lineno_checksum)
 
   /* If the graph has been correctly solved, every block will have a
      succ and pred count of zero.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gcc_assert (!BB_INFO (bb)->succ_count && !BB_INFO (bb)->pred_count);
     }
@@ -715,7 +715,7 @@ compute_branch_probabilities (unsigned cfg_checksum, unsigned lineno_checksum)
     hist_br_prob[i] = 0;
   num_branches = 0;
 
-  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
+  FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block (), NULL, next_bb)
     {
       edge e;
       edge_iterator ei;
@@ -734,9 +734,9 @@ compute_branch_probabilities (unsigned cfg_checksum, unsigned lineno_checksum)
 	     already present.  We get negative frequency from the entry
 	     point.  */
 	  if ((e->count < 0
-	       && e->dest == EXIT_BLOCK_PTR)
+	       && e->dest == cfun->cfg->get_exit_block ())
 	      || (e->count > bb->count
-		  && e->dest != EXIT_BLOCK_PTR))
+		  && e->dest != cfun->cfg->get_exit_block ()))
 	    {
 	      if (block_ends_with_call_p (bb))
 		e->count = e->count < 0 ? 0 : bb->count;
@@ -782,7 +782,7 @@ compute_branch_probabilities (unsigned cfg_checksum, unsigned lineno_checksum)
 	 give all abnormals frequency of 0, otherwise distribute the
 	 frequency over abnormals (this is the case of noreturn
 	 calls).  */
-      else if (profile_status == PROFILE_ABSENT)
+      else if (cfun->cfg->get_profile_status () == PROFILE_ABSENT)
 	{
 	  int total = 0;
 
@@ -810,7 +810,7 @@ compute_branch_probabilities (unsigned cfg_checksum, unsigned lineno_checksum)
 	}
     }
   counts_to_freqs ();
-  profile_status = PROFILE_READ;
+  cfun->cfg->set_profile_status (PROFILE_READ);
   compute_function_frequency ();
 
   if (dump_file)
@@ -987,7 +987,7 @@ branch_prob (void)
      We also add fake exit edges for each call and asm statement in the
      basic, since it may not return.  */
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       int need_exit_edge = 0, need_entry_edge = 0;
       int have_exit_edge = 0, have_entry_edge = 0;
@@ -1036,17 +1036,17 @@ branch_prob (void)
 	      ne->goto_locus = e->goto_locus;
 	    }
 	  if ((e->flags & (EDGE_ABNORMAL | EDGE_ABNORMAL_CALL))
-	       && e->dest != EXIT_BLOCK_PTR)
+	       && e->dest != cfun->cfg->get_exit_block ())
 	    need_exit_edge = 1;
-	  if (e->dest == EXIT_BLOCK_PTR)
+	  if (e->dest == cfun->cfg->get_exit_block ())
 	    have_exit_edge = 1;
 	}
       FOR_EACH_EDGE (e, ei, bb->preds)
 	{
 	  if ((e->flags & (EDGE_ABNORMAL | EDGE_ABNORMAL_CALL))
-	       && e->src != ENTRY_BLOCK_PTR)
+	       && e->src != cfun->cfg->get_entry_block ())
 	    need_entry_edge = 1;
-	  if (e->src == ENTRY_BLOCK_PTR)
+	  if (e->src == cfun->cfg->get_entry_block ())
 	    have_entry_edge = 1;
 	}
 
@@ -1055,14 +1055,14 @@ branch_prob (void)
 	  if (dump_file)
 	    fprintf (dump_file, "Adding fake exit edge to bb %i\n",
 		     bb->index);
-	  make_edge (bb, EXIT_BLOCK_PTR, EDGE_FAKE);
+	  make_edge (bb, cfun->cfg->get_exit_block (), EDGE_FAKE);
 	}
       if (need_entry_edge && !have_entry_edge)
 	{
 	  if (dump_file)
 	    fprintf (dump_file, "Adding fake entry edge to bb %i\n",
 		     bb->index);
-	  make_edge (ENTRY_BLOCK_PTR, bb, EDGE_FAKE);
+	  make_edge (cfun->cfg->get_entry_block (), bb, EDGE_FAKE);
 	  /* Avoid bbs that have both fake entry edge and also some
 	     exit edge.  One of those edges wouldn't be added to the
 	     spanning tree, but we can't instrument any of them.  */
@@ -1118,7 +1118,7 @@ branch_prob (void)
 
       /* Mark edges we've replaced by fake edges above as ignored.  */
       if ((e->flags & (EDGE_ABNORMAL | EDGE_ABNORMAL_CALL))
-	  && e->src != ENTRY_BLOCK_PTR && e->dest != EXIT_BLOCK_PTR)
+	  && e->src != cfun->cfg->get_entry_block () && e->dest != cfun->cfg->get_exit_block ())
 	{
 	  EDGE_INFO (e)->ignore = 1;
 	  ignored_edges++;
@@ -1149,9 +1149,9 @@ branch_prob (void)
 	num_instrumented++;
     }
 
-  total_num_blocks += n_basic_blocks;
+  total_num_blocks += cfun->cfg->get_n_basic_blocks ();
   if (dump_file)
-    fprintf (dump_file, "%d basic blocks\n", n_basic_blocks);
+    fprintf (dump_file, "%d basic blocks\n", cfun->cfg->get_n_basic_blocks ());
 
   total_num_edges += num_edges;
   if (dump_file)
@@ -1180,12 +1180,12 @@ branch_prob (void)
 
       /* Basic block flags */
       offset = gcov_write_tag (GCOV_TAG_BLOCKS);
-      for (i = 0; i != (unsigned) (n_basic_blocks); i++)
+      for (i = 0; i != (unsigned) (cfun->cfg->get_n_basic_blocks ()); i++)
 	gcov_write_unsigned (0);
       gcov_write_length (offset);
 
       /* Arcs */
-      FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
+      FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block (), cfun->cfg->get_exit_block (), next_bb)
 	{
 	  edge e;
 	  edge_iterator ei;
@@ -1224,12 +1224,12 @@ branch_prob (void)
       /* Initialize the output.  */
       output_location (NULL, 0, NULL, NULL);
 
-      FOR_EACH_BB (bb)
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
 	{
 	  gimple_stmt_iterator gsi;
 	  gcov_position_t offset = 0;
 
-	  if (bb == ENTRY_BLOCK_PTR->next_bb)
+	  if (bb == cfun->cfg->get_entry_block ()->next_bb)
 	    {
 	      expanded_location curr_location =
 		expand_location (DECL_SOURCE_LOCATION (current_function_decl));
@@ -1353,11 +1353,11 @@ find_spanning_tree (struct edge_list *el)
   basic_block bb;
 
   /* We use aux field for standard union-find algorithm.  */
-  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
+  FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block (), NULL, next_bb)
     bb->aux = bb;
 
   /* Add fake edge exit to entry we can't instrument.  */
-  union_groups (EXIT_BLOCK_PTR, ENTRY_BLOCK_PTR);
+  union_groups (cfun->cfg->get_exit_block (), cfun->cfg->get_entry_block ());
 
   /* First add all abnormal edges to the tree unless they form a cycle. Also
      add all edges to EXIT_BLOCK_PTR to avoid inserting profiling code behind
@@ -1366,7 +1366,7 @@ find_spanning_tree (struct edge_list *el)
     {
       edge e = INDEX_EDGE (el, i);
       if (((e->flags & (EDGE_ABNORMAL | EDGE_ABNORMAL_CALL | EDGE_FAKE))
-	   || e->dest == EXIT_BLOCK_PTR)
+	   || e->dest == cfun->cfg->get_exit_block ())
 	  && !EDGE_INFO (e)->ignore
 	  && (find_group (e->src) != find_group (e->dest)))
 	{
diff --git a/gcc/recog.c b/gcc/recog.c
index 0e6277d..0122af4 100644
--- a/gcc/recog.c
+++ b/gcc/recog.c
@@ -2892,11 +2892,11 @@ split_all_insns (void)
   bool changed;
   basic_block bb;
 
-  blocks = sbitmap_alloc (last_basic_block);
+  blocks = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
   bitmap_clear (blocks);
   changed = false;
 
-  FOR_EACH_BB_REVERSE (bb)
+  FOR_EACH_BB_REVERSE_CFG (bb, cfun->cfg)
     {
       rtx insn, next;
       bool finish = false;
@@ -3525,7 +3525,7 @@ peephole2_optimize (void)
     peep2_insn_data[i].live_before = BITMAP_ALLOC (&reg_obstack);
   live = BITMAP_ALLOC (&reg_obstack);
 
-  FOR_EACH_BB_REVERSE (bb)
+  FOR_EACH_BB_REVERSE_CFG (bb, cfun->cfg)
     {
       bool past_end = false;
       int pos;
diff --git a/gcc/ree.c b/gcc/ree.c
index c0d43c8..c2b92de 100644
--- a/gcc/ree.c
+++ b/gcc/ree.c
@@ -834,7 +834,7 @@ find_removable_extensions (void)
   rtx insn, set;
   unsigned *def_map = XCNEWVEC (unsigned, max_insn_uid);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     FOR_BB_INSNS (bb, insn)
       {
 	if (!NONDEBUG_INSN_P (insn))
diff --git a/gcc/reg-stack.c b/gcc/reg-stack.c
index 2dd9289..f1b8f0b 100644
--- a/gcc/reg-stack.c
+++ b/gcc/reg-stack.c
@@ -2646,7 +2646,7 @@ convert_regs_entry (void)
      Note that we are inserting converted code here.  This code is
      never seen by the convert_regs pass.  */
 
-  FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR->succs)
+  FOR_EACH_EDGE (e, ei, cfun->cfg->get_entry_block ()->succs)
     {
       basic_block block = e->dest;
       block_info bi = BLOCK_INFO (block);
@@ -2690,7 +2690,7 @@ convert_regs_exit (void)
       value_reg_high = END_HARD_REGNO (retvalue) - 1;
     }
 
-  output_stack = &BLOCK_INFO (EXIT_BLOCK_PTR)->stack_in;
+  output_stack = &BLOCK_INFO (cfun->cfg->get_exit_block ())->stack_in;
   if (value_reg_low == -1)
     output_stack->top = -1;
   else
@@ -2843,8 +2843,8 @@ compensate_edges (void)
 
   starting_stack_p = false;
 
-  FOR_EACH_BB (bb)
-    if (bb != ENTRY_BLOCK_PTR)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
+    if (bb != cfun->cfg->get_entry_block ())
       {
         edge e;
         edge_iterator ei;
@@ -3078,7 +3078,7 @@ convert_regs_2 (basic_block block)
      is only processed after all its predecessors.  The number of predecessors
      of every block has already been computed.  */
 
-  stack = XNEWVEC (basic_block, n_basic_blocks);
+  stack = XNEWVEC (basic_block, cfun->cfg->get_n_basic_blocks ());
   sp = stack;
 
   *sp++ = block;
@@ -3138,19 +3138,19 @@ convert_regs (void)
 
   /* Construct the desired stack for function exit.  */
   convert_regs_exit ();
-  BLOCK_INFO (EXIT_BLOCK_PTR)->done = 1;
+  BLOCK_INFO (cfun->cfg->get_exit_block ())->done = 1;
 
   /* ??? Future: process inner loops first, and give them arbitrary
      initial stacks which emit_swap_insn can modify.  This ought to
      prevent double fxch that often appears at the head of a loop.  */
 
   /* Process all blocks reachable from all entry points.  */
-  FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR->succs)
+  FOR_EACH_EDGE (e, ei, cfun->cfg->get_entry_block ()->succs)
     cfg_altered |= convert_regs_2 (e->dest);
 
   /* ??? Process all unreachable blocks.  Though there's no excuse
      for keeping these even when not optimizing.  */
-  FOR_EACH_BB (b)
+  FOR_EACH_BB_CFG (b, cfun->cfg)
     {
       block_info bi = BLOCK_INFO (b);
 
@@ -3209,7 +3209,7 @@ reg_to_stack (void)
 
   /* Set up block info for each basic block.  */
   alloc_aux_for_blocks (sizeof (struct block_info_def));
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       block_info bi = BLOCK_INFO (bb);
       edge_iterator ei;
@@ -3218,7 +3218,7 @@ reg_to_stack (void)
 
       FOR_EACH_EDGE (e, ei, bb->preds)
 	if (!(e->flags & EDGE_DFS_BACK)
-	    && e->src != ENTRY_BLOCK_PTR)
+	    && e->src != cfun->cfg->get_entry_block ())
 	  bi->predecessors++;
 
       /* Set current register status at last instruction `uninitialized'.  */
diff --git a/gcc/regcprop.c b/gcc/regcprop.c
index 896902f..f1c365d 100644
--- a/gcc/regcprop.c
+++ b/gcc/regcprop.c
@@ -1048,9 +1048,9 @@ copyprop_hardreg_forward (void)
   sbitmap visited;
   bool analyze_called = false;
 
-  all_vd = XNEWVEC (struct value_data, last_basic_block);
+  all_vd = XNEWVEC (struct value_data, cfun->cfg->get_last_basic_block ());
 
-  visited = sbitmap_alloc (last_basic_block);
+  visited = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
   bitmap_clear (visited);
 
   if (MAY_HAVE_DEBUG_INSNS)
@@ -1058,7 +1058,7 @@ copyprop_hardreg_forward (void)
       = create_alloc_pool ("debug insn changes pool",
 			   sizeof (struct queued_debug_insn_change), 256);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       bitmap_set_bit (visited, bb->index);
 
@@ -1094,7 +1094,7 @@ copyprop_hardreg_forward (void)
 
   if (MAY_HAVE_DEBUG_INSNS)
     {
-      FOR_EACH_BB (bb)
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
 	if (bitmap_bit_p (visited, bb->index)
 	    && all_vd[bb->index].n_debug_insn_changes)
 	  {
diff --git a/gcc/reginfo.c b/gcc/reginfo.c
index 0153cd9..1abaa64 100644
--- a/gcc/reginfo.c
+++ b/gcc/reginfo.c
@@ -1252,7 +1252,7 @@ init_subregs_of_mode (void)
   bitmap_obstack_initialize (&srom_obstack);
   subregs_of_mode = BITMAP_ALLOC (&srom_obstack);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     FOR_BB_INSNS (bb, insn)
       if (NONDEBUG_INSN_P (insn))
         find_subregs_of_mode (PATTERN (insn), subregs_of_mode);
diff --git a/gcc/regmove.c b/gcc/regmove.c
index 1ce8a7e..e02ba76 100644
--- a/gcc/regmove.c
+++ b/gcc/regmove.c
@@ -707,7 +707,7 @@ reg_is_remote_constant_p (rtx reg, rtx insn)
       max_reg_computed = max = max_reg_num ();
       reg_set_in_bb = XCNEWVEC (basic_block, max);
 
-      FOR_EACH_BB (bb)
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
 	FOR_BB_INSNS (bb, p)
 	  {
 	    rtx s;
@@ -880,7 +880,7 @@ regmove_forward_pass (void)
   if (dump_file)
     fprintf (dump_file, "Starting forward pass...\n");
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       FOR_BB_INSNS (bb, insn)
 	{
@@ -932,7 +932,7 @@ regmove_backward_pass (void)
   if (dump_file)
     fprintf (dump_file, "Starting backward pass...\n");
 
-  FOR_EACH_BB_REVERSE (bb)
+  FOR_EACH_BB_REVERSE_CFG (bb, cfun->cfg)
     {
       /* ??? Use the safe iterator because fixup_match_2 can remove
 	     insns via try_auto_increment.  */
diff --git a/gcc/regrename.c b/gcc/regrename.c
index 20e2ae9..9308fbd 100644
--- a/gcc/regrename.c
+++ b/gcc/regrename.c
@@ -668,13 +668,13 @@ regrename_analyze (bitmap bb_mask)
   int n_bbs;
   int *inverse_postorder;
 
-  inverse_postorder = XNEWVEC (int, last_basic_block);
+  inverse_postorder = XNEWVEC (int, cfun->cfg->get_last_basic_block ());
   n_bbs = pre_and_rev_post_order_compute (NULL, inverse_postorder, false);
 
   /* Gather some information about the blocks in this function.  */
-  rename_info = XCNEWVEC (struct bb_rename_info, n_basic_blocks);
+  rename_info = XCNEWVEC (struct bb_rename_info, cfun->cfg->get_n_basic_blocks ());
   i = 0;
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       struct bb_rename_info *ri = rename_info + i;
       ri->bb = bb;
@@ -696,7 +696,7 @@ regrename_analyze (bitmap bb_mask)
 
   for (i = 0; i < n_bbs; i++)
     {
-      basic_block bb1 = BASIC_BLOCK (inverse_postorder[i]);
+      basic_block bb1 = cfun->cfg->get_basic_block_by_idx (inverse_postorder[i]);
       struct bb_rename_info *this_info;
       bool success;
       edge e;
@@ -778,7 +778,7 @@ regrename_analyze (bitmap bb_mask)
      We perform the analysis for both incoming and outgoing edges, but we
      only need to merge once (in the second part, after verifying outgoing
      edges).  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       struct bb_rename_info *bb_ri = (struct bb_rename_info *) bb->aux;
       unsigned j;
@@ -843,7 +843,7 @@ regrename_analyze (bitmap bb_mask)
 	    }
 	}
     }
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       struct bb_rename_info *bb_ri = (struct bb_rename_info *) bb->aux;
       unsigned j;
@@ -920,7 +920,7 @@ regrename_analyze (bitmap bb_mask)
 
   free (rename_info);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     bb->aux = NULL;
 }
 
diff --git a/gcc/regs.h b/gcc/regs.h
index 090d6b6..38e4c91 100644
--- a/gcc/regs.h
+++ b/gcc/regs.h
@@ -137,7 +137,7 @@ extern size_t reg_info_p_size;
    frequency.  */
 #define REG_FREQ_FROM_BB(bb) (optimize_size				      \
 			      || (flag_branch_probabilities		      \
-				  && !ENTRY_BLOCK_PTR->count)		      \
+				  && !cfun->cfg->get_entry_block ()->count)		      \
 			      ? REG_FREQ_MAX				      \
 			      : ((bb)->frequency * REG_FREQ_MAX / BB_FREQ_MAX)\
 			      ? ((bb)->frequency * REG_FREQ_MAX / BB_FREQ_MAX)\
diff --git a/gcc/regstat.c b/gcc/regstat.c
index 5b1f3c42..9a22d75 100644
--- a/gcc/regstat.c
+++ b/gcc/regstat.c
@@ -120,7 +120,7 @@ regstat_bb_compute_ri (unsigned int bb_index,
 		       bitmap local_live, bitmap local_processed,
 		       int *local_live_last_luid)
 {
-  basic_block bb = BASIC_BLOCK (bb_index);
+  basic_block bb = cfun->cfg->get_basic_block_by_idx (bb_index);
   rtx insn;
   df_ref *def_rec;
   df_ref *use_rec;
@@ -375,7 +375,7 @@ regstat_compute_ri (void)
   reg_info_p = XCNEWVEC (struct reg_info_t, max_regno);
   local_live_last_luid = XNEWVEC (int, max_regno);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       regstat_bb_compute_ri (bb->index, live, artificial_uses,
 			     local_live, local_processed,
@@ -440,7 +440,7 @@ regstat_get_setjmp_crosses (void)
 static void
 regstat_bb_compute_calls_crossed (unsigned int bb_index, bitmap live)
 {
-  basic_block bb = BASIC_BLOCK (bb_index);
+  basic_block bb = cfun->cfg->get_basic_block_by_idx (bb_index);
   rtx insn;
   df_ref *def_rec;
   df_ref *use_rec;
@@ -522,7 +522,7 @@ regstat_compute_calls_crossed (void)
   reg_info_p_size = max_regno;
   reg_info_p = XCNEWVEC (struct reg_info_t, max_regno);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       regstat_bb_compute_calls_crossed (bb->index, live);
     }
diff --git a/gcc/reload.c b/gcc/reload.c
index 8733ff3..2539564 100644
--- a/gcc/reload.c
+++ b/gcc/reload.c
@@ -1615,7 +1615,7 @@ push_reload (rtx in, rtx out, rtx *inloc, rtx *outloc,
 	    && reg_mentioned_p (XEXP (note, 0), in)
 	    /* Check that a former pseudo is valid; see find_dummy_reload.  */
 	    && (ORIGINAL_REGNO (XEXP (note, 0)) < FIRST_PSEUDO_REGISTER
-		|| (! bitmap_bit_p (DF_LR_OUT (ENTRY_BLOCK_PTR),
+		|| (! bitmap_bit_p (DF_LR_OUT (cfun->cfg->get_entry_block ()),
 				    ORIGINAL_REGNO (XEXP (note, 0)))
 		    && hard_regno_nregs[regno][GET_MODE (XEXP (note, 0))] == 1))
 	    && ! refers_to_regno_for_reload_p (regno,
@@ -1939,7 +1939,7 @@ combine_reloads (void)
 	&& !fixed_regs[regno]
 	/* Check that a former pseudo is valid; see find_dummy_reload.  */
 	&& (ORIGINAL_REGNO (XEXP (note, 0)) < FIRST_PSEUDO_REGISTER
-	    || (!bitmap_bit_p (DF_LR_OUT (ENTRY_BLOCK_PTR),
+	    || (!bitmap_bit_p (DF_LR_OUT (cfun->cfg->get_entry_block ()),
 			       ORIGINAL_REGNO (XEXP (note, 0)))
 		&& hard_regno_nregs[regno][GET_MODE (XEXP (note, 0))] == 1)))
       {
@@ -2098,7 +2098,7 @@ find_dummy_reload (rtx real_in, rtx real_out, rtx *inloc, rtx *outloc,
 	     can ignore the conflict).  We must never introduce writes
 	     to such hardregs, as they would clobber the other live
 	     pseudo.  See PR 20973.  */
-          || (!bitmap_bit_p (DF_LR_OUT (ENTRY_BLOCK_PTR),
+          || (!bitmap_bit_p (DF_LR_OUT (cfun->cfg->get_entry_block ()),
 			     ORIGINAL_REGNO (in))
 	      /* Similarly, only do this if we can be sure that the death
 		 note is still valid.  global can assign some hardreg to
diff --git a/gcc/reload1.c b/gcc/reload1.c
index b8c3bfa..835ac38 100644
--- a/gcc/reload1.c
+++ b/gcc/reload1.c
@@ -610,14 +610,14 @@ has_nonexceptional_receiver (void)
     return true;
 
   /* First determine which blocks can reach exit via normal paths.  */
-  tos = worklist = XNEWVEC (basic_block, n_basic_blocks + 1);
+  tos = worklist = XNEWVEC (basic_block, cfun->cfg->get_n_basic_blocks () + 1);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     bb->flags &= ~BB_REACHABLE;
 
   /* Place the exit block on our worklist.  */
-  EXIT_BLOCK_PTR->flags |= BB_REACHABLE;
-  *tos++ = EXIT_BLOCK_PTR;
+  cfun->cfg->get_exit_block ()->flags |= BB_REACHABLE;
+  *tos++ = cfun->cfg->get_exit_block ();
 
   /* Iterate: find everything reachable from what we've already seen.  */
   while (tos != worklist)
@@ -640,7 +640,7 @@ has_nonexceptional_receiver (void)
 
   /* Now see if there's a reachable block with an exceptional incoming
      edge.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     if (bb->flags & BB_REACHABLE && bb_has_abnormal_pred (bb))
       return true;
 
@@ -1065,7 +1065,7 @@ reload (rtx first, int global)
      pseudo.  */
 
   if (! frame_pointer_needed)
-    FOR_EACH_BB (bb)
+    FOR_EACH_BB_CFG (bb, cfun->cfg)
       bitmap_clear_bit (df_get_live_in (bb), HARD_FRAME_POINTER_REGNUM);
 
   /* Come here (with failure set nonzero) if we can't get enough spill
@@ -1300,7 +1300,7 @@ reload (rtx first, int global)
   if (cfun->can_throw_non_call_exceptions)
     {
       sbitmap blocks;
-      blocks = sbitmap_alloc (last_basic_block);
+      blocks = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
       bitmap_ones (blocks);
       find_many_sub_basic_blocks (blocks);
       sbitmap_free (blocks);
@@ -1609,7 +1609,7 @@ calculate_elim_costs_all_insns (void)
   set_initial_elim_offsets ();
   set_initial_label_offsets ();
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       rtx insn;
       elim_bb = bb;
diff --git a/gcc/reorg.c b/gcc/reorg.c
index e601818..d48a01c 100644
--- a/gcc/reorg.c
+++ b/gcc/reorg.c
@@ -3632,7 +3632,7 @@ dbr_schedule (rtx first)
 
   /* If the current function has no insns other than the prologue and
      epilogue, then do not try to fill any delay slots.  */
-  if (n_basic_blocks == NUM_FIXED_BLOCKS)
+  if (cfun->cfg->get_n_basic_blocks () == NUM_FIXED_BLOCKS)
     return;
 
   /* Find the highest INSN_UID and allocate and initialize our map from
diff --git a/gcc/resource.c b/gcc/resource.c
index a0fd2ec..8ff2f09 100644
--- a/gcc/resource.c
+++ b/gcc/resource.c
@@ -147,7 +147,7 @@ find_basic_block (rtx insn, int search_limit)
 
   /* The start of the function.  */
   else if (insn == 0)
-    return ENTRY_BLOCK_PTR->next_bb->index;
+    return cfun->cfg->get_entry_block ()->next_bb->index;
 
   /* See if any of the upcoming CODE_LABELs start a basic block.  If we reach
      anything other than a CODE_LABEL or note, we can't find this code.  */
@@ -908,7 +908,7 @@ mark_target_live_regs (rtx insns, rtx target, struct resources *res)
 	 information, we can get it from there unless the insn at the
 	 start of the basic block has been deleted.  */
       if (tinfo && tinfo->block != -1
-	  && ! INSN_DELETED_P (BB_HEAD (BASIC_BLOCK (tinfo->block))))
+	  && ! INSN_DELETED_P (BB_HEAD (cfun->cfg->get_basic_block_by_idx (tinfo->block))))
 	b = tinfo->block;
     }
 
@@ -948,7 +948,7 @@ mark_target_live_regs (rtx insns, rtx target, struct resources *res)
      to use the LR problem.  Otherwise, we must assume everything is live.  */
   if (b != -1)
     {
-      regset regs_live = DF_LR_IN (BASIC_BLOCK (b));
+      regset regs_live = DF_LR_IN (cfun->cfg->get_basic_block_by_idx (b));
       rtx start_insn, stop_insn;
 
       /* Compute hard regs live at start of block.  */
@@ -956,8 +956,8 @@ mark_target_live_regs (rtx insns, rtx target, struct resources *res)
 
       /* Get starting and ending insn, handling the case where each might
 	 be a SEQUENCE.  */
-      start_insn = (b == ENTRY_BLOCK_PTR->next_bb->index ?
-		    insns : BB_HEAD (BASIC_BLOCK (b)));
+      start_insn = (b == cfun->cfg->get_entry_block ()->next_bb->index ?
+		    insns : BB_HEAD (cfun->cfg->get_basic_block_by_idx (b)));
       stop_insn = target;
 
       if (NONJUMP_INSN_P (start_insn)
@@ -1198,10 +1198,10 @@ init_resource_info (rtx epilogue_insn)
 
   /* Allocate and initialize the tables used by mark_target_live_regs.  */
   target_hash_table = XCNEWVEC (struct target_info *, TARGET_HASH_PRIME);
-  bb_ticks = XCNEWVEC (int, last_basic_block);
+  bb_ticks = XCNEWVEC (int, cfun->cfg->get_last_basic_block ());
 
   /* Set the BLOCK_FOR_INSN of each label that starts a basic block.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     if (LABEL_P (BB_HEAD (bb)))
       BLOCK_FOR_INSN (BB_HEAD (bb)) = bb;
 }
@@ -1240,7 +1240,7 @@ free_resource_info (void)
       bb_ticks = NULL;
     }
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     if (LABEL_P (BB_HEAD (bb)))
       BLOCK_FOR_INSN (BB_HEAD (bb)) = NULL;
 }
diff --git a/gcc/sched-deps.c b/gcc/sched-deps.c
index fde684f..93c82df 100644
--- a/gcc/sched-deps.c
+++ b/gcc/sched-deps.c
@@ -3957,7 +3957,7 @@ sched_deps_init (bool global_p)
 {
   /* Average number of insns in the basic block.
      '+ 1' is used to make it nonzero.  */
-  int insns_in_block = sched_max_luid / n_basic_blocks + 1;
+  int insns_in_block = sched_max_luid / cfun->cfg->get_n_basic_blocks () + 1;
 
   init_deps_data_vector ();
 
diff --git a/gcc/sched-ebb.c b/gcc/sched-ebb.c
index b70e071..1ea2f1f 100644
--- a/gcc/sched-ebb.c
+++ b/gcc/sched-ebb.c
@@ -625,7 +625,7 @@ schedule_ebbs (void)
 
   /* Taking care of this degenerate case makes the rest of
      this code simpler.  */
-  if (n_basic_blocks == NUM_FIXED_BLOCKS)
+  if (cfun->cfg->get_n_basic_blocks () == NUM_FIXED_BLOCKS)
     return;
 
   if (profile_info && flag_branch_probabilities)
@@ -637,7 +637,7 @@ schedule_ebbs (void)
   schedule_ebbs_init ();
 
   /* Schedule every region in the subroutine.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       rtx head = BB_HEAD (bb);
 
@@ -648,7 +648,7 @@ schedule_ebbs (void)
 	{
 	  edge e;
 	  tail = BB_END (bb);
-	  if (bb->next_bb == EXIT_BLOCK_PTR
+	  if (bb->next_bb == cfun->cfg->get_exit_block ()
 	      || LABEL_P (BB_HEAD (bb->next_bb)))
 	    break;
 	  e = find_fallthru_edge (bb->succs);
@@ -683,7 +683,7 @@ ebb_add_block (basic_block bb, basic_block after)
   /* Recovery blocks are always bounded by BARRIERS,
      therefore, they always form single block EBB,
      therefore, we can use rec->index to identify such EBBs.  */
-  if (after == EXIT_BLOCK_PTR)
+  if (after == cfun->cfg->get_exit_block ())
     bitmap_set_bit (&dont_calc_deps, bb->index);
   else if (after == last_bb)
     last_bb = bb;
@@ -737,7 +737,7 @@ ebb_fix_recovery_cfg (int bbi ATTRIBUTE_UNUSED, int jump_bbi,
   gcc_assert (last_bb->index != bbi);
 
   if (jump_bb_nexti == last_bb->index)
-    last_bb = BASIC_BLOCK (jump_bbi);
+    last_bb = cfun->cfg->get_basic_block_by_idx (jump_bbi);
 }
 
 #endif /* INSN_SCHEDULING */
diff --git a/gcc/sched-int.h b/gcc/sched-int.h
index 9ab3374..c64d5d5 100644
--- a/gcc/sched-int.h
+++ b/gcc/sched-int.h
@@ -943,14 +943,14 @@ extern vec<haifa_deps_insn_data_def> h_d_i_d;
 /* INSN is a speculation check that will simply reexecute the speculatively
    scheduled instruction if the speculation fails.  */
 #define IS_SPECULATION_SIMPLE_CHECK_P(INSN) \
-  (RECOVERY_BLOCK (INSN) == EXIT_BLOCK_PTR)
+  (RECOVERY_BLOCK (INSN) == cfun->cfg->get_exit_block ())
 
 /* INSN is a speculation check that will branch to RECOVERY_BLOCK if the
    speculation fails.  Insns in that block will reexecute the speculatively
    scheduled code and then will return immediately after INSN thus preserving
    semantics of the program.  */
 #define IS_SPECULATION_BRANCHY_CHECK_P(INSN) \
-  (RECOVERY_BLOCK (INSN) != NULL && RECOVERY_BLOCK (INSN) != EXIT_BLOCK_PTR)
+  (RECOVERY_BLOCK (INSN) != NULL && RECOVERY_BLOCK (INSN) != cfun->cfg->get_exit_block ())
 
 /* Dep status (aka ds_t) of the link encapsulates information, that is needed
    for speculative scheduling.  Namely, it is 4 integers in the range
@@ -1379,8 +1379,8 @@ extern int *containing_rgn;
 /* The mapping from ebb to block.  */
 extern int *ebb_head;
 #define BB_TO_BLOCK(ebb) (rgn_bb_table[ebb_head[ebb]])
-#define EBB_FIRST_BB(ebb) BASIC_BLOCK (BB_TO_BLOCK (ebb))
-#define EBB_LAST_BB(ebb) BASIC_BLOCK (rgn_bb_table[ebb_head[ebb + 1] - 1])
+#define EBB_FIRST_BB(ebb) cfun->cfg->get_basic_block_by_idx (BB_TO_BLOCK (ebb))
+#define EBB_LAST_BB(ebb) cfun->cfg->get_basic_block_by_idx (rgn_bb_table[ebb_head[ebb + 1] - 1])
 #define INSN_BB(INSN) (BLOCK_TO_BB (BLOCK_NUM (INSN)))
 
 extern int current_nr_blocks;
diff --git a/gcc/sched-rgn.c b/gcc/sched-rgn.c
index 2c971e2..8b8520f 100644
--- a/gcc/sched-rgn.c
+++ b/gcc/sched-rgn.c
@@ -272,7 +272,7 @@ is_cfg_nonregular (void)
 
   /* If we have insns which refer to labels as non-jumped-to operands,
      then we consider the cfg not well structured.  */
-  FOR_EACH_BB (b)
+  FOR_EACH_BB_CFG (b, cfun->cfg)
     FOR_BB_INSNS (b, insn)
       {
 	rtx note, next, set, dest;
@@ -317,7 +317,7 @@ is_cfg_nonregular (void)
      Unreachable loops with a single block are detected here.  This
      test is redundant with the one in find_rgns, but it's much
      cheaper to go ahead and catch the trivial case here.  */
-  FOR_EACH_BB (b)
+  FOR_EACH_BB_CFG (b, cfun->cfg)
     {
       if (EDGE_COUNT (b->preds) == 0
 	  || (single_pred_p (b)
@@ -401,7 +401,7 @@ debug_region (int rgn)
 
   for (bb = 0; bb < rgn_table[rgn].rgn_nr_blocks; bb++)
     {
-      dump_bb (stderr, BASIC_BLOCK (rgn_bb_table[current_blocks + bb]),
+      dump_bb (stderr, cfun->cfg->get_basic_block_by_idx (rgn_bb_table[current_blocks + bb]),
 	       0, TDF_SLIM | TDF_BLOCKS);
       fprintf (stderr, "\n");
     }
@@ -440,7 +440,7 @@ dump_region_dot (FILE *f, int rgn)
       edge e;
       edge_iterator ei;
       int src_bb_num = rgn_bb_table[current_blocks + i];
-      basic_block bb = BASIC_BLOCK (src_bb_num);
+      basic_block bb = cfun->cfg->get_basic_block_by_idx (src_bb_num);
 
       FOR_EACH_EDGE (e, ei, bb->succs)
         if (bb_in_region_p (e->dest->index, rgn))
@@ -478,7 +478,7 @@ find_single_block_region (bool ebbs_p)
       probability_cutoff = PARAM_VALUE (TRACER_MIN_BRANCH_PROBABILITY);
     probability_cutoff = REG_BR_PROB_BASE / 100 * probability_cutoff;
 
-    FOR_EACH_BB (ebb_start)
+    FOR_EACH_BB_CFG (ebb_start, cfun->cfg)
       {
         RGN_NR_BLOCKS (nr_regions) = 0;
         RGN_BLOCKS (nr_regions) = i;
@@ -495,7 +495,7 @@ find_single_block_region (bool ebbs_p)
             BLOCK_TO_BB (bb->index) = i - RGN_BLOCKS (nr_regions);
             i++;
 
-            if (bb->next_bb == EXIT_BLOCK_PTR
+            if (bb->next_bb == cfun->cfg->get_exit_block ()
                 || LABEL_P (BB_HEAD (bb->next_bb)))
               break;
 
@@ -511,7 +511,7 @@ find_single_block_region (bool ebbs_p)
       }
   }
   else
-    FOR_EACH_BB (bb)
+    FOR_EACH_BB_CFG (bb, cfun->cfg)
       {
         rgn_bb_table[nr_regions] = bb->index;
         RGN_NR_BLOCKS (nr_regions) = 1;
@@ -554,7 +554,7 @@ too_large (int block, int *num_bbs, int *num_insns)
 {
   (*num_bbs)++;
   (*num_insns) += (common_sched_info->estimate_number_of_insns
-                   (BASIC_BLOCK (block)));
+                   (cfun->cfg->get_basic_block_by_idx (block)));
 
   return ((*num_bbs > PARAM_VALUE (PARAM_MAX_SCHED_REGION_BLOCKS))
 	  || (*num_insns > PARAM_VALUE (PARAM_MAX_SCHED_REGION_INSNS)));
@@ -641,23 +641,23 @@ haifa_find_rgns (void)
      STACK, SP and DFS_NR are only used during the first traversal.  */
 
   /* Allocate and initialize variables for the first traversal.  */
-  max_hdr = XNEWVEC (int, last_basic_block);
-  dfs_nr = XCNEWVEC (int, last_basic_block);
-  stack = XNEWVEC (edge_iterator, n_edges);
+  max_hdr = XNEWVEC (int, cfun->cfg->get_last_basic_block ());
+  dfs_nr = XCNEWVEC (int, cfun->cfg->get_last_basic_block ());
+  stack = XNEWVEC (edge_iterator, cfun->cfg->get_n_edges ());
 
-  inner = sbitmap_alloc (last_basic_block);
+  inner = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
   bitmap_ones (inner);
 
-  header = sbitmap_alloc (last_basic_block);
+  header = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
   bitmap_clear (header);
 
-  in_queue = sbitmap_alloc (last_basic_block);
+  in_queue = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
   bitmap_clear (in_queue);
 
-  in_stack = sbitmap_alloc (last_basic_block);
+  in_stack = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
   bitmap_clear (in_stack);
 
-  for (i = 0; i < last_basic_block; i++)
+  for (i = 0; i < cfun->cfg->get_last_basic_block (); i++)
     max_hdr[i] = -1;
 
   #define EDGE_PASSED(E) (ei_end_p ((E)) || ei_edge ((E))->aux)
@@ -665,7 +665,7 @@ haifa_find_rgns (void)
 
   /* DFS traversal to find inner loops in the cfg.  */
 
-  current_edge = ei_start (single_succ (ENTRY_BLOCK_PTR)->succs);
+  current_edge = ei_start (single_succ (cfun->cfg->get_entry_block ())->succs);
   sp = -1;
 
   while (1)
@@ -744,7 +744,7 @@ haifa_find_rgns (void)
     }
 
   /* Reset ->aux field used by EDGE_PASSED.  */
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       edge_iterator ei;
       edge e;
@@ -761,7 +761,7 @@ haifa_find_rgns (void)
      the entry node by placing a nonzero value in dfs_nr.  Thus if
      dfs_nr is zero for any block, then it must be unreachable.  */
   unreachable = 0;
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     if (dfs_nr[bb->index] == 0)
       {
 	unreachable = 1;
@@ -772,7 +772,7 @@ haifa_find_rgns (void)
      to hold degree counts.  */
   degree = dfs_nr;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     degree[bb->index] = EDGE_COUNT (bb->preds);
 
   /* Do not perform region scheduling if there are any unreachable
@@ -793,19 +793,19 @@ haifa_find_rgns (void)
       /* Second traversal:find reducible inner loops and topologically sort
 	 block of each region.  */
 
-      queue = XNEWVEC (int, n_basic_blocks);
+      queue = XNEWVEC (int, cfun->cfg->get_n_basic_blocks ());
 
       extend_regions_p = PARAM_VALUE (PARAM_MAX_SCHED_EXTEND_REGIONS_ITERS) > 0;
       if (extend_regions_p)
         {
-          degree1 = XNEWVEC (int, last_basic_block);
-          extended_rgn_header = sbitmap_alloc (last_basic_block);
+          degree1 = XNEWVEC (int, cfun->cfg->get_last_basic_block ());
+          extended_rgn_header = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
           bitmap_clear (extended_rgn_header);
 	}
 
       /* Find blocks which are inner loop headers.  We still have non-reducible
 	 loops to consider at this point.  */
-      FOR_EACH_BB (bb)
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
 	{
 	  if (bitmap_bit_p (header, bb->index) && bitmap_bit_p (inner, bb->index))
 	    {
@@ -824,7 +824,7 @@ haifa_find_rgns (void)
 		 If there exists a block that is not dominated by the loop
 		 header, then the block is reachable from outside the loop
 		 and thus the loop is not a natural loop.  */
-	      FOR_EACH_BB (jbb)
+	      FOR_EACH_BB_CFG (jbb, cfun->cfg)
 		{
 		  /* First identify blocks in the loop, except for the loop
 		     entry block.  */
@@ -840,7 +840,7 @@ haifa_find_rgns (void)
 	      /* If we exited the loop early, then I is the header of
 		 a non-reducible loop and we should quit processing it
 		 now.  */
-	      if (jbb != EXIT_BLOCK_PTR)
+	      if (jbb != cfun->cfg->get_exit_block ())
 		continue;
 
 	      /* I is a header of an inner loop, or block 0 in a subroutine
@@ -853,12 +853,12 @@ haifa_find_rgns (void)
                 /* We save degree in case when we meet a too_large region
 		   and cancel it.  We need a correct degree later when
                    calling extend_rgns.  */
-                memcpy (degree1, degree, last_basic_block * sizeof (int));
+                memcpy (degree1, degree, cfun->cfg->get_last_basic_block () * sizeof (int));
 
 	      /* Decrease degree of all I's successors for topological
 		 ordering.  */
 	      FOR_EACH_EDGE (e, ei, bb->succs)
-		if (e->dest != EXIT_BLOCK_PTR)
+		if (e->dest != cfun->cfg->get_exit_block ())
 		  --degree[e->dest->index];
 
 	      /* Estimate # insns, and count # blocks in the region.  */
@@ -871,11 +871,11 @@ haifa_find_rgns (void)
 		 Place those blocks into the queue.  */
 	      if (no_loops)
 		{
-		  FOR_EACH_BB (jbb)
+		  FOR_EACH_BB_CFG (jbb, cfun->cfg)
 		    /* Leaf nodes have only a single successor which must
 		       be EXIT_BLOCK.  */
 		    if (single_succ_p (jbb)
-			&& single_succ (jbb) == EXIT_BLOCK_PTR)
+			&& single_succ (jbb) == cfun->cfg->get_exit_block ())
 		      {
 			queue[++tail] = jbb->index;
 			bitmap_set_bit (in_queue, jbb->index);
@@ -893,7 +893,7 @@ haifa_find_rgns (void)
 
 		  FOR_EACH_EDGE (e, ei, bb->preds)
 		    {
-		      if (e->src == ENTRY_BLOCK_PTR)
+		      if (e->src == cfun->cfg->get_entry_block ())
 			continue;
 
 		      node = e->src->index;
@@ -948,13 +948,13 @@ haifa_find_rgns (void)
 		  edge e;
 		  child = queue[++head];
 
-		  FOR_EACH_EDGE (e, ei, BASIC_BLOCK (child)->preds)
+		  FOR_EACH_EDGE (e, ei, cfun->cfg->get_basic_block_by_idx (child)->preds)
 		    {
 		      node = e->src->index;
 
 		      /* See discussion above about nodes not marked as in
 			 this loop during the initial DFS traversal.  */
-		      if (e->src == ENTRY_BLOCK_PTR
+		      if (e->src == cfun->cfg->get_entry_block ()
 			  || max_hdr[node] != loop_head)
 			{
 			  tail = -1;
@@ -1005,8 +1005,8 @@ haifa_find_rgns (void)
 			  CONTAINING_RGN (child) = nr_regions;
 			  queue[head] = queue[tail--];
 
-			  FOR_EACH_EDGE (e, ei, BASIC_BLOCK (child)->succs)
-			    if (e->dest != EXIT_BLOCK_PTR)
+			  FOR_EACH_EDGE (e, ei, cfun->cfg->get_basic_block_by_idx (child)->succs)
+			    if (e->dest != cfun->cfg->get_exit_block ())
 			      --degree[e->dest->index];
 			}
 		      else
@@ -1026,7 +1026,7 @@ haifa_find_rgns (void)
 		     This may provide several smaller regions instead
 		     of one too_large region.  */
                   FOR_EACH_EDGE (e, ei, bb->succs)
-                    if (e->dest != EXIT_BLOCK_PTR)
+                    if (e->dest != cfun->cfg->get_exit_block ())
                       bitmap_set_bit (extended_rgn_header, e->dest->index);
                 }
 	    }
@@ -1046,7 +1046,7 @@ haifa_find_rgns (void)
 
   /* Any block that did not end up in a region is placed into a region
      by itself.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     if (degree[bb->index] >= 0)
       {
 	rgn_bb_table[idx] = bb->index;
@@ -1153,13 +1153,13 @@ void
 extend_rgns (int *degree, int *idxp, sbitmap header, int *loop_hdr)
 {
   int *order, i, rescan = 0, idx = *idxp, iter = 0, max_iter, *max_hdr;
-  int nblocks = n_basic_blocks - NUM_FIXED_BLOCKS;
+  int nblocks = cfun->cfg->get_n_basic_blocks () - NUM_FIXED_BLOCKS;
 
   max_iter = PARAM_VALUE (PARAM_MAX_SCHED_EXTEND_REGIONS_ITERS);
 
-  max_hdr = XNEWVEC (int, last_basic_block);
+  max_hdr = XNEWVEC (int, cfun->cfg->get_last_basic_block ());
 
-  order = XNEWVEC (int, last_basic_block);
+  order = XNEWVEC (int, cfun->cfg->get_last_basic_block ());
   post_order_compute (order, false, false);
 
   for (i = nblocks - 1; i >= 0; i--)
@@ -1200,7 +1200,7 @@ extend_rgns (int *degree, int *idxp, sbitmap header, int *loop_hdr)
 	    {
 	      int hdr = -1;
 
-	      FOR_EACH_EDGE (e, ei, BASIC_BLOCK (bbn)->preds)
+	      FOR_EACH_EDGE (e, ei, cfun->cfg->get_basic_block_by_idx (bbn)->preds)
 		{
 		  int predn = e->src->index;
 
@@ -1304,8 +1304,8 @@ extend_rgns (int *degree, int *idxp, sbitmap header, int *loop_hdr)
 	      CONTAINING_RGN (bbn) = nr_regions;
 	      BLOCK_TO_BB (bbn) = 0;
 
-	      FOR_EACH_EDGE (e, ei, BASIC_BLOCK (bbn)->succs)
-		if (e->dest != EXIT_BLOCK_PTR)
+	      FOR_EACH_EDGE (e, ei, cfun->cfg->get_basic_block_by_idx (bbn)->succs)
+		if (e->dest != cfun->cfg->get_exit_block ())
 		  degree[e->dest->index]--;
 
 	      if (!large)
@@ -1361,8 +1361,8 @@ extend_rgns (int *degree, int *idxp, sbitmap header, int *loop_hdr)
 
 		      idx++;
 
-		      FOR_EACH_EDGE (e, ei, BASIC_BLOCK (succn)->succs)
-			if (e->dest != EXIT_BLOCK_PTR)
+		      FOR_EACH_EDGE (e, ei, cfun->cfg->get_basic_block_by_idx (succn)->succs)
+			if (e->dest != cfun->cfg->get_exit_block ())
 			  degree[e->dest->index]--;
 		    }
 		}
@@ -1420,13 +1420,13 @@ compute_dom_prob_ps (int bb)
   /* Initialize dom[bb] to '111..1'.  */
   bitmap_ones (dom[bb]);
 
-  FOR_EACH_EDGE (in_edge, in_ei, BASIC_BLOCK (BB_TO_BLOCK (bb))->preds)
+  FOR_EACH_EDGE (in_edge, in_ei, cfun->cfg->get_basic_block_by_idx (BB_TO_BLOCK (bb))->preds)
     {
       int pred_bb;
       edge out_edge;
       edge_iterator out_ei;
 
-      if (in_edge->src == ENTRY_BLOCK_PTR)
+      if (in_edge->src == cfun->cfg->get_entry_block ())
 	continue;
 
       pred_bb = BLOCK_TO_BB (in_edge->src->index);
@@ -1508,7 +1508,7 @@ compute_trg_info (int trg)
   sp->is_speculative = 0;
   sp->src_prob = REG_BR_PROB_BASE;
 
-  visited = sbitmap_alloc (last_basic_block);
+  visited = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
 
   for (i = trg + 1; i < current_nr_blocks; i++)
     {
@@ -1838,7 +1838,7 @@ update_live (rtx insn, int src)
   (bb_from == bb_to							\
    || IS_RGN_ENTRY (bb_from)						\
    || (bitmap_bit_p (ancestor_edges[bb_to],					\
-	 EDGE_TO_BIT (single_pred_edge (BASIC_BLOCK (BB_TO_BLOCK (bb_from)))))))
+	 EDGE_TO_BIT (single_pred_edge (cfun->cfg->get_basic_block_by_idx (BB_TO_BLOCK (bb_from)))))))
 
 /* Turns on the fed_by_spec_load flag for insns fed by load_insn.  */
 
@@ -2652,7 +2652,7 @@ deps_join (struct deps_desc *succ_deps, struct deps_desc *pred_deps)
 static void
 propagate_deps (int bb, struct deps_desc *pred_deps)
 {
-  basic_block block = BASIC_BLOCK (BB_TO_BLOCK (bb));
+  basic_block block = cfun->cfg->get_basic_block_by_idx (BB_TO_BLOCK (bb));
   edge_iterator ei;
   edge e;
 
@@ -2660,7 +2660,7 @@ propagate_deps (int bb, struct deps_desc *pred_deps)
   FOR_EACH_EDGE (e, ei, block->succs)
     {
       /* Only bbs "below" bb, in the same region, are interesting.  */
-      if (e->dest == EXIT_BLOCK_PTR
+      if (e->dest == cfun->cfg->get_exit_block ()
 	  || CONTAINING_RGN (block->index) != CONTAINING_RGN (e->dest->index)
 	  || BLOCK_TO_BB (e->dest->index) <= bb)
 	continue;
@@ -2861,7 +2861,7 @@ sched_is_disabled_for_current_region_p (void)
   int bb;
 
   for (bb = 0; bb < current_nr_blocks; bb++)
-    if (!(BASIC_BLOCK (BB_TO_BLOCK (bb))->flags & BB_DISABLE_SCHEDULE))
+    if (!(cfun->cfg->get_basic_block_by_idx (BB_TO_BLOCK (bb))->flags & BB_DISABLE_SCHEDULE))
       return false;
 
   return true;
@@ -2925,11 +2925,11 @@ static void
 realloc_bb_state_array (int saved_last_basic_block)
 {
   char *old_bb_state_array = bb_state_array;
-  size_t lbb = (size_t) last_basic_block;
+  size_t lbb = (size_t) cfun->cfg->get_last_basic_block ();
   size_t slbb = (size_t) saved_last_basic_block;
 
   /* Nothing to do if nothing changed since the last time this was called.  */
-  if (saved_last_basic_block == last_basic_block)
+  if (saved_last_basic_block == cfun->cfg->get_last_basic_block ())
     return;
 
   /* The selective scheduler doesn't use the state arrays.  */
@@ -3049,7 +3049,7 @@ schedule_region (int rgn)
       if (dbg_cnt (sched_block))
         {
 	  edge f;
-	  int saved_last_basic_block = last_basic_block;
+	  int saved_last_basic_block = cfun->cfg->get_last_basic_block ();
 
 	  schedule_block (&curr_bb, bb_state[first_bb->index]);
 	  gcc_assert (EBB_FIRST_BB (bb) == first_bb);
@@ -3112,7 +3112,7 @@ sched_rgn_init (bool single_blocks_p)
 
   /* Compute regions for scheduling.  */
   if (single_blocks_p
-      || n_basic_blocks == NUM_FIXED_BLOCKS + 1
+      || cfun->cfg->get_n_basic_blocks () == NUM_FIXED_BLOCKS + 1
       || !flag_schedule_interblock
       || is_cfg_nonregular ())
     {
@@ -3136,7 +3136,7 @@ sched_rgn_init (bool single_blocks_p)
 	free_dominance_info (CDI_DOMINATORS);
     }
 
-  gcc_assert (0 < nr_regions && nr_regions <= n_basic_blocks);
+  gcc_assert (0 < nr_regions && nr_regions <= cfun->cfg->get_n_basic_blocks ());
 
   RGN_BLOCKS (nr_regions) = (RGN_BLOCKS (nr_regions - 1) +
 			     RGN_NR_BLOCKS (nr_regions - 1));
@@ -3268,7 +3268,7 @@ sched_rgn_local_init (int rgn)
 
       /* Use ->aux to implement EDGE_TO_BIT mapping.  */
       rgn_nr_edges = 0;
-      FOR_EACH_BB (block)
+      FOR_EACH_BB_CFG (block, cfun->cfg)
 	{
 	  if (CONTAINING_RGN (block->index) != rgn)
 	    continue;
@@ -3278,7 +3278,7 @@ sched_rgn_local_init (int rgn)
 
       rgn_edges = XNEWVEC (edge, rgn_nr_edges);
       rgn_nr_edges = 0;
-      FOR_EACH_BB (block)
+      FOR_EACH_BB_CFG (block, cfun->cfg)
 	{
 	  if (CONTAINING_RGN (block->index) != rgn)
 	    continue;
@@ -3299,7 +3299,7 @@ sched_rgn_local_init (int rgn)
       /* Cleanup ->aux used for EDGE_TO_BIT mapping.  */
       /* We don't need them anymore.  But we want to avoid duplication of
 	 aux fields in the newly created edges.  */
-      FOR_EACH_BB (block)
+      FOR_EACH_BB_CFG (block, cfun->cfg)
 	{
 	  if (CONTAINING_RGN (block->index) != rgn)
 	    continue;
@@ -3372,7 +3372,7 @@ schedule_insns (void)
 
   /* Taking care of this degenerate case makes the rest of
      this code simpler.  */
-  if (n_basic_blocks == NUM_FIXED_BLOCKS)
+  if (cfun->cfg->get_n_basic_blocks () == NUM_FIXED_BLOCKS)
     return;
 
   rgn_setup_common_sched_info ();
@@ -3418,10 +3418,10 @@ rgn_add_remove_insn (rtx insn, int remove_p)
 void
 extend_regions (void)
 {
-  rgn_table = XRESIZEVEC (region, rgn_table, n_basic_blocks);
-  rgn_bb_table = XRESIZEVEC (int, rgn_bb_table, n_basic_blocks);
-  block_to_bb = XRESIZEVEC (int, block_to_bb, last_basic_block);
-  containing_rgn = XRESIZEVEC (int, containing_rgn, last_basic_block);
+  rgn_table = XRESIZEVEC (region, rgn_table, cfun->cfg->get_n_basic_blocks ());
+  rgn_bb_table = XRESIZEVEC (int, rgn_bb_table, cfun->cfg->get_n_basic_blocks ());
+  block_to_bb = XRESIZEVEC (int, block_to_bb, cfun->cfg->get_last_basic_block ());
+  containing_rgn = XRESIZEVEC (int, containing_rgn, cfun->cfg->get_last_basic_block ());
 }
 
 void
@@ -3451,10 +3451,10 @@ rgn_add_block (basic_block bb, basic_block after)
   extend_regions ();
   bitmap_set_bit (&not_in_df, bb->index);
 
-  if (after == 0 || after == EXIT_BLOCK_PTR)
+  if (after == 0 || after == cfun->cfg->get_exit_block ())
     {
       rgn_make_new_region_out_of_new_block (bb);
-      RGN_DONT_CALC_DEPS (nr_regions - 1) = (after == EXIT_BLOCK_PTR);
+      RGN_DONT_CALC_DEPS (nr_regions - 1) = (after == cfun->cfg->get_exit_block ());
     }
   else
     {
diff --git a/gcc/sched-vis.c b/gcc/sched-vis.c
index 763230c..07b3e23 100644
--- a/gcc/sched-vis.c
+++ b/gcc/sched-vis.c
@@ -889,7 +889,7 @@ extern void debug_bb_n_slim (int);
 DEBUG_FUNCTION void
 debug_bb_n_slim (int n)
 {
-  basic_block bb = BASIC_BLOCK (n);
+  basic_block bb = cfun->cfg->get_basic_block_by_idx (n);
   debug_bb_slim (bb);
 }
 
diff --git a/gcc/sel-sched-dump.c b/gcc/sel-sched-dump.c
index 347b5eb..1d9079b 100644
--- a/gcc/sel-sched-dump.c
+++ b/gcc/sel-sched-dump.c
@@ -750,7 +750,7 @@ sel_dump_cfg_2 (FILE *f, int flags)
   if (flags & SEL_DUMP_CFG_FUNCTION_NAME)
     fprintf (f, "function [label = \"%s\"];\n", current_function_name ());
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       insn_t insn = BB_HEAD (bb);
       insn_t next_tail = NEXT_INSN (BB_END (bb));
diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c
index 47e7695..efae748 100644
--- a/gcc/sel-sched-ir.c
+++ b/gcc/sel-sched-ir.c
@@ -3075,7 +3075,7 @@ sel_finish_global_and_expr (void)
     bbs.create (current_nr_blocks);
 
     for (i = 0; i < current_nr_blocks; i++)
-      bbs.quick_push (BASIC_BLOCK (BB_TO_BLOCK (i)));
+      bbs.quick_push (cfun->cfg->get_basic_block_by_idx (BB_TO_BLOCK (i)));
 
     /* Clear AV_SETs and INSN_EXPRs.  */
     {
@@ -3627,7 +3627,7 @@ verify_backedges (void)
       edge_iterator ei;
 
       for (i = 0; i < current_nr_blocks; i++)
-        FOR_EACH_EDGE (e, ei, BASIC_BLOCK (BB_TO_BLOCK (i))->succs)
+        FOR_EACH_EDGE (e, ei, cfun->cfg->get_basic_block_by_idx (BB_TO_BLOCK (i))->succs)
           if (in_current_region_p (e->dest)
               && BLOCK_TO_BB (e->dest->index) < i)
             n++;
@@ -3649,7 +3649,7 @@ sel_recompute_toporder (void)
   int i, n, rgn;
   int *postorder, n_blocks;
 
-  postorder = XALLOCAVEC (int, n_basic_blocks);
+  postorder = XALLOCAVEC (int, cfun->cfg->get_n_basic_blocks ());
   n_blocks = post_order_compute (postorder, false, false);
 
   rgn = CONTAINING_RGN (BB_TO_BLOCK (0));
@@ -3682,7 +3682,7 @@ maybe_tidy_empty_bb (basic_block bb)
      successors.  Otherwise remove it.  */
   if (!sel_bb_empty_p (bb)
       || (single_succ_p (bb)
-          && single_succ (bb) == EXIT_BLOCK_PTR
+          && single_succ (bb) == cfun->cfg->get_exit_block ()
           && (!single_pred_p (bb)
               || !(single_pred_edge (bb)->flags & EDGE_FALLTHRU)))
       || EDGE_COUNT (bb->preds) == 0
@@ -3853,7 +3853,7 @@ tidy_control_flow (basic_block xbb, bool full_tidying)
       && EDGE_COUNT (xbb->succs) == 1
       && (EDGE_SUCC (xbb, 0)->flags & EDGE_FALLTHRU)
       /* When successor is an EXIT block, it may not be the next block.  */
-      && single_succ (xbb) != EXIT_BLOCK_PTR
+      && single_succ (xbb) != cfun->cfg->get_exit_block ()
       /* And unconditional jump in previous basic block leads to
          next basic block of XBB and this jump can be safely removed.  */
       && in_current_region_p (xbb->prev_bb)
@@ -3897,7 +3897,7 @@ purge_empty_blocks (void)
   /* Do not attempt to delete the first basic block in the region.  */
   for (i = 1; i < current_nr_blocks; )
     {
-      basic_block b = BASIC_BLOCK (BB_TO_BLOCK (i));
+      basic_block b = cfun->cfg->get_basic_block_by_idx (BB_TO_BLOCK (i));
 
       if (maybe_tidy_empty_bb (b))
 	continue;
@@ -4095,14 +4095,14 @@ get_seqno_by_preds (rtx insn)
 void
 sel_extend_global_bb_info (void)
 {
-  sel_global_bb_info.safe_grow_cleared (last_basic_block);
+  sel_global_bb_info.safe_grow_cleared (cfun->cfg->get_last_basic_block ());
 }
 
 /* Extend region-scope data structures for basic blocks.  */
 static void
 extend_region_bb_info (void)
 {
-  sel_region_bb_info.safe_grow_cleared (last_basic_block);
+  sel_region_bb_info.safe_grow_cleared (cfun->cfg->get_last_basic_block ());
 }
 
 /* Extend all data structures to fit for all basic blocks.  */
@@ -4321,11 +4321,11 @@ init_lv_sets (void)
   basic_block bb;
 
   /* Initialize of LV sets.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     init_lv_set (bb);
 
   /* Don't forget EXIT_BLOCK.  */
-  init_lv_set (EXIT_BLOCK_PTR);
+  init_lv_set (cfun->cfg->get_exit_block ());
 }
 
 /* Release lv set of HEAD.  */
@@ -4346,10 +4346,10 @@ free_lv_sets (void)
   basic_block bb;
 
   /* Don't forget EXIT_BLOCK.  */
-  free_lv_set (EXIT_BLOCK_PTR);
+  free_lv_set (cfun->cfg->get_exit_block ());
 
   /* Free LV sets.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     if (BB_LV_SET (bb))
       free_lv_set (bb);
 }
@@ -4524,7 +4524,7 @@ sel_bb_head (basic_block bb)
 {
   insn_t head;
 
-  if (bb == EXIT_BLOCK_PTR)
+  if (bb == cfun->cfg->get_exit_block ())
     {
       gcc_assert (exit_insn != NULL_RTX);
       head = exit_insn;
@@ -4557,7 +4557,7 @@ sel_bb_end (basic_block bb)
   if (sel_bb_empty_p (bb))
     return NULL_RTX;
 
-  gcc_assert (bb != EXIT_BLOCK_PTR);
+  gcc_assert (bb != cfun->cfg->get_exit_block ());
 
   return BB_END (bb);
 }
@@ -4852,7 +4852,7 @@ bb_ends_ebb_p (basic_block bb)
   basic_block next_bb = bb_next_bb (bb);
   edge e;
 
-  if (next_bb == EXIT_BLOCK_PTR
+  if (next_bb == cfun->cfg->get_exit_block ()
       || bitmap_bit_p (forced_ebb_heads, next_bb->index)
       || (LABEL_P (BB_HEAD (next_bb))
 	  /* NB: LABEL_NUSES () is not maintained outside of jump.c.
@@ -4905,17 +4905,17 @@ recompute_rev_top_order (void)
   int *postorder;
   int n_blocks, i;
 
-  if (!rev_top_order_index || rev_top_order_index_len < last_basic_block)
+  if (!rev_top_order_index || rev_top_order_index_len < cfun->cfg->get_last_basic_block ())
     {
-      rev_top_order_index_len = last_basic_block;
+      rev_top_order_index_len = cfun->cfg->get_last_basic_block ();
       rev_top_order_index = XRESIZEVEC (int, rev_top_order_index,
                                         rev_top_order_index_len);
     }
 
-  postorder = XNEWVEC (int, n_basic_blocks);
+  postorder = XNEWVEC (int, cfun->cfg->get_n_basic_blocks ());
 
   n_blocks = post_order_compute (postorder, true, false);
-  gcc_assert (n_basic_blocks == n_blocks);
+  gcc_assert (cfun->cfg->get_n_basic_blocks () == n_blocks);
 
   /* Build reverse function: for each basic block with BB->INDEX == K
      rev_top_order_index[K] is it's reverse topological sort number.  */
@@ -5538,7 +5538,7 @@ sel_create_recovery_block (insn_t orig_insn)
 
   recovery_block = sched_create_recovery_block (&before_recovery);
   if (before_recovery)
-    copy_lv_set_from (before_recovery, EXIT_BLOCK_PTR);
+    copy_lv_set_from (before_recovery, cfun->cfg->get_exit_block ());
 
   gcc_assert (sel_bb_empty_p (recovery_block));
   sched_create_recovery_edges (first_bb, recovery_block, second_bb);
@@ -5821,7 +5821,7 @@ setup_nop_and_exit_insns (void)
   emit_insn (nop_pattern);
   exit_insn = get_insns ();
   end_sequence ();
-  set_block_for_insn (exit_insn, EXIT_BLOCK_PTR);
+  set_block_for_insn (exit_insn, cfun->cfg->get_exit_block ());
 }
 
 /* Free special insns used in the scheduler.  */
@@ -6079,7 +6079,7 @@ sel_init_pipelining (void)
 		       | LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS);
   current_loop_nest = NULL;
 
-  bbs_in_loop_rgns = sbitmap_alloc (last_basic_block);
+  bbs_in_loop_rgns = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
   bitmap_clear (bbs_in_loop_rgns);
 
   recompute_rev_top_order ();
@@ -6145,16 +6145,16 @@ make_regions_from_the_rest (void)
   /* LOOP_HDR[I] == -1 if I-th bb doesn't belong to any loop,
      LOOP_HDR[I] == LOOP_HDR[J] iff basic blocks I and J reside within the same
      loop.  */
-  loop_hdr = XNEWVEC (int, last_basic_block);
-  degree = XCNEWVEC (int, last_basic_block);
+  loop_hdr = XNEWVEC (int, cfun->cfg->get_last_basic_block ());
+  degree = XCNEWVEC (int, cfun->cfg->get_last_basic_block ());
 
 
   /* For each basic block that belongs to some loop assign the number
      of innermost loop it belongs to.  */
-  for (i = 0; i < last_basic_block; i++)
+  for (i = 0; i < cfun->cfg->get_last_basic_block (); i++)
     loop_hdr[i] = -1;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       if (bb->loop_father && !bb->loop_father->num == 0
 	  && !(bb->flags & BB_IRREDUCIBLE_LOOP))
@@ -6164,7 +6164,7 @@ make_regions_from_the_rest (void)
   /* For each basic block degree is calculated as the number of incoming
      edges, that are going out of bbs that are not yet scheduled.
      The basic blocks that are scheduled have degree value of zero.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       degree[bb->index] = 0;
 
@@ -6182,7 +6182,7 @@ make_regions_from_the_rest (void)
 
   /* Any block that did not end up in a region is placed into a region
      by itself.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     if (degree[bb->index] >= 0)
       {
 	rgn_bb_table[cur_rgn_blocks] = bb->index;
@@ -6348,7 +6348,7 @@ sel_remove_loop_preheader (void)
   /* Add blocks that aren't within the current loop to PREHEADER_BLOCKS.  */
   for (i = 0; i < RGN_NR_BLOCKS (cur_rgn); i++)
     {
-      bb = BASIC_BLOCK (BB_TO_BLOCK (i));
+      bb = cfun->cfg->get_basic_block_by_idx (BB_TO_BLOCK (i));
 
       /* If the basic block belongs to region, but doesn't belong to
 	 corresponding loop, then it should be a preheader.  */
@@ -6398,7 +6398,7 @@ sel_remove_loop_preheader (void)
                  If it is so - delete this jump and clear data sets of its
                  basic block if it becomes empty.  */
 	      if (next_bb->prev_bb == prev_bb
-                  && prev_bb != ENTRY_BLOCK_PTR
+                  && prev_bb != cfun->cfg->get_entry_block ()
                   && bb_has_removable_jump_to_p (prev_bb, next_bb))
                 {
                   redirect_edge_and_branch (EDGE_SUCC (prev_bb, 0), next_bb);
diff --git a/gcc/sel-sched-ir.h b/gcc/sel-sched-ir.h
index 486159d..cfcdbf4 100644
--- a/gcc/sel-sched-ir.h
+++ b/gcc/sel-sched-ir.h
@@ -1024,7 +1024,7 @@ inner_loop_header_p (basic_block bb)
   if (!current_loop_nest)
     return false;
 
-  if (bb == EXIT_BLOCK_PTR)
+  if (bb == cfun->cfg->get_exit_block ())
     return false;
 
   inner_loop = bb->loop_father;
@@ -1050,7 +1050,7 @@ get_loop_exit_edges_unique_dests (const struct loop *loop)
   vec<edge> edges = vNULL;
   struct loop_exit *exit;
 
-  gcc_assert (loop->latch != EXIT_BLOCK_PTR
+  gcc_assert (loop->latch != cfun->cfg->get_exit_block ()
               && current_loops->state & LOOPS_HAVE_RECORDED_EXITS);
 
   for (exit = loop->exits->next; exit->e; exit = exit->next)
@@ -1083,7 +1083,7 @@ sel_bb_empty_or_nop_p (basic_block bb)
   if (!INSN_NOP_P (first))
     return false;
 
-  if (bb == EXIT_BLOCK_PTR)
+  if (bb == cfun->cfg->get_exit_block ())
     return false;
 
   last = sel_bb_end (bb);
@@ -1204,7 +1204,7 @@ _succ_iter_start (insn_t *succp, insn_t insn, int flags)
   i.current_exit = -1;
   i.loop_exits.create (0);
 
-  if (bb != EXIT_BLOCK_PTR && BB_END (bb) != insn)
+  if (bb != cfun->cfg->get_exit_block () && BB_END (bb) != insn)
     {
       i.bb_end = false;
 
@@ -1308,7 +1308,7 @@ _succ_iter_cond (succ_iterator *ip, rtx *succp, rtx insn,
 	{
 	  basic_block bb = ip->e2->dest;
 
-	  if (bb == EXIT_BLOCK_PTR || bb == after_recovery)
+	  if (bb == cfun->cfg->get_exit_block () || bb == after_recovery)
 	    *succp = exit_insn;
 	  else
 	    {
diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c
index fb9386f..8eac751 100644
--- a/gcc/sel-sched.c
+++ b/gcc/sel-sched.c
@@ -4551,7 +4551,7 @@ find_block_for_bookkeeping (edge e1, edge e2, bool lax)
   edge e;
 
   /* Loop over edges from E1 to E2, inclusive.  */
-  for (e = e1; !lax || e->dest != EXIT_BLOCK_PTR; e = EDGE_SUCC (e->dest, 0))
+  for (e = e1; !lax || e->dest != cfun->cfg->get_exit_block (); e = EDGE_SUCC (e->dest, 0))
     {
       if (EDGE_COUNT (e->dest->preds) == 2)
 	{
@@ -4642,7 +4642,7 @@ create_block_for_bookkeeping (edge e1, edge e2)
       if (DEBUG_INSN_P (insn)
 	  && single_succ_p (new_bb)
 	  && (succ = single_succ (new_bb))
-	  && succ != EXIT_BLOCK_PTR
+	  && succ != cfun->cfg->get_exit_block ()
 	  && DEBUG_INSN_P ((last = sel_bb_end (new_bb))))
 	{
 	  while (insn != last && (DEBUG_INSN_P (insn) || NOTE_P (insn)))
@@ -4662,8 +4662,8 @@ create_block_for_bookkeeping (edge e1, edge e2)
 	      new_bb->index = succ->index;
 	      succ->index = i;
 
-	      SET_BASIC_BLOCK (new_bb->index, new_bb);
-	      SET_BASIC_BLOCK (succ->index, succ);
+	      cfun->cfg->set_basic_block_by_idx (new_bb->index, new_bb);
+	      cfun->cfg->set_basic_block_by_idx (succ->index, succ);
 
 	      memcpy (&gbi, SEL_GLOBAL_BB_INFO (new_bb), sizeof (gbi));
 	      memcpy (SEL_GLOBAL_BB_INFO (new_bb), SEL_GLOBAL_BB_INFO (succ),
@@ -4902,7 +4902,7 @@ remove_insns_that_need_bookkeeping (fence_t fence, av_set_t *av_ptr)
 	  && (EXPR_SPEC (expr)
 	      || !EXPR_ORIG_BB_INDEX (expr)
 	      || !dominated_by_p (CDI_DOMINATORS,
-				  BASIC_BLOCK (EXPR_ORIG_BB_INDEX (expr)),
+				  cfun->cfg->get_basic_block_by_idx (EXPR_ORIG_BB_INDEX (expr)),
 				  BLOCK_FOR_INSN (FENCE_INSN (fence)))))
 	{
           if (sched_verbose >= 4)
@@ -6872,7 +6872,7 @@ current_region_empty_p (void)
 {
   int i;
   for (i = 0; i < current_nr_blocks; i++)
-    if (! sel_bb_empty_p (BASIC_BLOCK (BB_TO_BLOCK (i))))
+    if (! sel_bb_empty_p (cfun->cfg->get_basic_block_by_idx (BB_TO_BLOCK (i))))
       return false;
 
   return true;
@@ -6931,7 +6931,7 @@ sel_region_init (int rgn)
   bbs.create (current_nr_blocks);
 
   for (i = 0; i < current_nr_blocks; i++)
-    bbs.quick_push (BASIC_BLOCK (BB_TO_BLOCK (i)));
+    bbs.quick_push (cfun->cfg->get_basic_block_by_idx (BB_TO_BLOCK (i)));
 
   sel_init_bbs (bbs);
 
@@ -6966,13 +6966,13 @@ sel_region_init (int rgn)
      compute_live for the first insn of the loop.  */
   if (current_loop_nest)
     {
-      int header = (sel_is_loop_preheader_p (BASIC_BLOCK (BB_TO_BLOCK (0)))
+      int header = (sel_is_loop_preheader_p (cfun->cfg->get_basic_block_by_idx (BB_TO_BLOCK (0)))
                     ? 1
                     : 0);
 
       if (current_nr_blocks == header + 1)
         update_liveness_on_insn
-          (sel_bb_head (BASIC_BLOCK (BB_TO_BLOCK (header))));
+          (sel_bb_head (cfun->cfg->get_basic_block_by_idx (BB_TO_BLOCK (header))));
     }
 
   /* Set hooks so that no newly generated insn will go out unnoticed.  */
@@ -7010,7 +7010,7 @@ simplify_changed_insns (void)
 
   for (i = 0; i < current_nr_blocks; i++)
     {
-      basic_block bb = BASIC_BLOCK (BB_TO_BLOCK (i));
+      basic_block bb = cfun->cfg->get_basic_block_by_idx (BB_TO_BLOCK (i));
       rtx insn;
 
       FOR_BB_INSNS (bb, insn)
@@ -7751,7 +7751,7 @@ run_selective_scheduling (void)
 {
   int rgn;
 
-  if (n_basic_blocks == NUM_FIXED_BLOCKS)
+  if (cfun->cfg->get_n_basic_blocks () == NUM_FIXED_BLOCKS)
     return;
 
   sel_global_init ();
diff --git a/gcc/sese.c b/gcc/sese.c
index 10ccee2..70fd525 100644
--- a/gcc/sese.c
+++ b/gcc/sese.c
@@ -136,7 +136,7 @@ build_sese_loop_nests (sese region)
   basic_block bb;
   struct loop *loop0, *loop1;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     if (bb_in_sese_p (bb, region))
       {
 	struct loop *loop = bb->loop_father;
@@ -283,10 +283,10 @@ sese_build_liveouts (sese region, bitmap liveouts)
 {
   basic_block bb;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     sese_build_liveouts_bb (region, liveouts, bb);
   if (MAY_HAVE_DEBUG_STMTS)
-    FOR_EACH_BB (bb)
+    FOR_EACH_BB_CFG (bb, cfun->cfg)
       sese_reset_debug_liveouts_bb (region, liveouts, bb);
 }
 
diff --git a/gcc/stack-ptr-mod.c b/gcc/stack-ptr-mod.c
index 739bcfc..080763d 100644
--- a/gcc/stack-ptr-mod.c
+++ b/gcc/stack-ptr-mod.c
@@ -58,7 +58,7 @@ notice_stack_pointer_modification (void)
      been used.  */
   crtl->sp_is_unchanging = !cfun->calls_alloca;
   if (crtl->sp_is_unchanging)
-    FOR_EACH_BB (bb)
+    FOR_EACH_BB_CFG (bb, cfun->cfg)
       FOR_BB_INSNS (bb, insn)
         {
 	  if (INSN_P (insn))
diff --git a/gcc/store-motion.c b/gcc/store-motion.c
index df75670..b667811 100644
--- a/gcc/store-motion.c
+++ b/gcc/store-motion.c
@@ -656,7 +656,7 @@ compute_store_table (void)
   already_set = XNEWVEC (int, max_gcse_regno);
 
   /* Find all the stores we care about.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       /* First compute the registers set in this block.  */
       FOR_BB_INSNS (bb, insn)
@@ -805,7 +805,7 @@ insert_store (struct st_expr * expr, edge e)
 
   /* If tmp is NULL, we found an insertion on every edge, blank the
      insertion vector for these edges, and insert at the start of the BB.  */
-  if (!tmp && bb != EXIT_BLOCK_PTR)
+  if (!tmp && bb != cfun->cfg->get_exit_block ())
     {
       FOR_EACH_EDGE (tmp, ei, e->dest->preds)
 	{
@@ -844,11 +844,11 @@ remove_reachable_equiv_notes (basic_block bb, struct st_expr *smexpr)
   edge_iterator *stack, ei;
   int sp;
   edge act;
-  sbitmap visited = sbitmap_alloc (last_basic_block);
+  sbitmap visited = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
   rtx last, insn, note;
   rtx mem = smexpr->pattern;
 
-  stack = XNEWVEC (edge_iterator, n_basic_blocks);
+  stack = XNEWVEC (edge_iterator, cfun->cfg->get_n_basic_blocks ());
   sp = 0;
   ei = ei_start (bb->succs);
 
@@ -869,7 +869,7 @@ remove_reachable_equiv_notes (basic_block bb, struct st_expr *smexpr)
 	}
       bb = act->dest;
 
-      if (bb == EXIT_BLOCK_PTR
+      if (bb == cfun->cfg->get_exit_block ()
 	  || bitmap_bit_p (visited, bb->index))
 	{
 	  if (!ei_end_p (ei))
@@ -1016,11 +1016,11 @@ build_store_vectors (void)
 
   /* Build the gen_vector. This is any store in the table which is not killed
      by aliasing later in its block.  */
-  st_avloc = sbitmap_vector_alloc (last_basic_block, num_stores);
-  bitmap_vector_clear (st_avloc, last_basic_block);
+  st_avloc = sbitmap_vector_alloc (cfun->cfg->get_last_basic_block (), num_stores);
+  bitmap_vector_clear (st_avloc, cfun->cfg->get_last_basic_block ());
 
-  st_antloc = sbitmap_vector_alloc (last_basic_block, num_stores);
-  bitmap_vector_clear (st_antloc, last_basic_block);
+  st_antloc = sbitmap_vector_alloc (cfun->cfg->get_last_basic_block (), num_stores);
+  bitmap_vector_clear (st_antloc, cfun->cfg->get_last_basic_block ());
 
   for (ptr = first_st_expr (); ptr != NULL; ptr = next_st_expr (ptr))
     {
@@ -1052,14 +1052,14 @@ build_store_vectors (void)
 	}
     }
 
-  st_kill = sbitmap_vector_alloc (last_basic_block, num_stores);
-  bitmap_vector_clear (st_kill, last_basic_block);
+  st_kill = sbitmap_vector_alloc (cfun->cfg->get_last_basic_block (), num_stores);
+  bitmap_vector_clear (st_kill, cfun->cfg->get_last_basic_block ());
 
-  st_transp = sbitmap_vector_alloc (last_basic_block, num_stores);
-  bitmap_vector_clear (st_transp, last_basic_block);
+  st_transp = sbitmap_vector_alloc (cfun->cfg->get_last_basic_block (), num_stores);
+  bitmap_vector_clear (st_transp, cfun->cfg->get_last_basic_block ());
   regs_set_in_block = XNEWVEC (int, max_gcse_regno);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       memset (regs_set_in_block, 0, sizeof (int) * max_gcse_regno);
 
@@ -1095,10 +1095,10 @@ build_store_vectors (void)
 
   if (dump_file)
     {
-      dump_bitmap_vector (dump_file, "st_antloc", "", st_antloc, last_basic_block);
-      dump_bitmap_vector (dump_file, "st_kill", "", st_kill, last_basic_block);
-      dump_bitmap_vector (dump_file, "st_transp", "", st_transp, last_basic_block);
-      dump_bitmap_vector (dump_file, "st_avloc", "", st_avloc, last_basic_block);
+      dump_bitmap_vector (dump_file, "st_antloc", "", st_antloc, cfun->cfg->get_last_basic_block ());
+      dump_bitmap_vector (dump_file, "st_kill", "", st_kill, cfun->cfg->get_last_basic_block ());
+      dump_bitmap_vector (dump_file, "st_transp", "", st_transp, cfun->cfg->get_last_basic_block ());
+      dump_bitmap_vector (dump_file, "st_avloc", "", st_avloc, cfun->cfg->get_last_basic_block ());
     }
 }
 
@@ -1182,7 +1182,7 @@ one_store_motion_pass (void)
 
       /* Now we want to insert the new stores which are going to be needed.  */
 
-      FOR_EACH_BB (bb)
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
 	if (bitmap_bit_p (st_delete_map[bb->index], ptr->index))
 	  {
 	    delete_store (ptr, bb);
@@ -1208,7 +1208,7 @@ one_store_motion_pass (void)
   if (dump_file)
     {
       fprintf (dump_file, "STORE_MOTION of %s, %d basic blocks, ",
-	       current_function_name (), n_basic_blocks);
+	       current_function_name (), cfun->cfg->get_n_basic_blocks ());
       fprintf (dump_file, "%d insns deleted, %d insns created\n",
 	       n_stores_deleted, n_stores_created);
     }
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a0278d5..0cf5700 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,15 @@
+2013-05-25  David Malcolm  <dmalcolm@redhat.com>
+
+	Patch autogenerated by refactor_cfun.py from
+	https://github.com/davidmalcolm/gcc-refactoring-scripts
+	revision a205d8d1341c462a14673fc0fcd22b039baf7865
+
+	* testsuite/gcc.dg/plugin/selfassign.c (get_real_ref_rhs): Remove
+	usage of FOR_EACH_BB macro.
+
+	* testsuite/g++.dg/plugin/selfassign.c (get_real_ref_rhs): Remove
+	usage of FOR_EACH_BB macro.
+
 2013-05-24  Paolo Carlini  <paolo.carlini@oracle.com>
 
 	PR c++/19618
diff --git a/gcc/testsuite/g++.dg/plugin/selfassign.c b/gcc/testsuite/g++.dg/plugin/selfassign.c
index 37a0a97..4aec9fe 100644
--- a/gcc/testsuite/g++.dg/plugin/selfassign.c
+++ b/gcc/testsuite/g++.dg/plugin/selfassign.c
@@ -246,7 +246,7 @@ execute_warn_self_assign (void)
   gimple_stmt_iterator gsi;
   basic_block bb;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
         warn_self_assign (gsi_stmt (gsi));
diff --git a/gcc/testsuite/gcc.dg/plugin/selfassign.c b/gcc/testsuite/gcc.dg/plugin/selfassign.c
index 37a0a97..4aec9fe 100644
--- a/gcc/testsuite/gcc.dg/plugin/selfassign.c
+++ b/gcc/testsuite/gcc.dg/plugin/selfassign.c
@@ -246,7 +246,7 @@ execute_warn_self_assign (void)
   gimple_stmt_iterator gsi;
   basic_block bb;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
         warn_self_assign (gsi_stmt (gsi));
diff --git a/gcc/tracer.c b/gcc/tracer.c
index 975cadb..4059686 100644
--- a/gcc/tracer.c
+++ b/gcc/tracer.c
@@ -223,9 +223,9 @@ find_trace (basic_block bb, basic_block *trace)
 static bool
 tail_duplicate (void)
 {
-  fibnode_t *blocks = XCNEWVEC (fibnode_t, last_basic_block);
-  basic_block *trace = XNEWVEC (basic_block, n_basic_blocks);
-  int *counts = XNEWVEC (int, last_basic_block);
+  fibnode_t *blocks = XCNEWVEC (fibnode_t, cfun->cfg->get_last_basic_block ());
+  basic_block *trace = XNEWVEC (basic_block, cfun->cfg->get_n_basic_blocks ());
+  int *counts = XNEWVEC (int, cfun->cfg->get_last_basic_block ());
   int ninsns = 0, nduplicated = 0;
   gcov_type weighted_insns = 0, traced_insns = 0;
   fibheap_t heap = fibheap_new ();
@@ -236,7 +236,7 @@ tail_duplicate (void)
 
   /* Create an oversized sbitmap to reduce the chance that we need to
      resize it.  */
-  bb_seen = sbitmap_alloc (last_basic_block * 2);
+  bb_seen = sbitmap_alloc (cfun->cfg->get_last_basic_block () * 2);
   bitmap_clear (bb_seen);
   initialize_original_copy_tables ();
 
@@ -249,7 +249,7 @@ tail_duplicate (void)
   branch_ratio_cutoff =
     (REG_BR_PROB_BASE / 100 * PARAM_VALUE (TRACER_MIN_BRANCH_RATIO));
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       int n = count_insns (bb);
       if (!ignore_bb_p (bb))
@@ -368,7 +368,7 @@ tracer (void)
 {
   bool changed;
 
-  if (n_basic_blocks <= NUM_FIXED_BLOCKS + 1)
+  if (cfun->cfg->get_n_basic_blocks () <= NUM_FIXED_BLOCKS + 1)
     return 0;
 
   mark_dfs_back_edges ();
diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c
index c66278c..fd87ab9 100644
--- a/gcc/trans-mem.c
+++ b/gcc/trans-mem.c
@@ -1878,12 +1878,12 @@ tm_region_init (struct tm_region *region)
   vec<tm_region_p> bb_regions = vNULL;
 
   all_tm_regions = region;
-  bb = single_succ (ENTRY_BLOCK_PTR);
+  bb = single_succ (cfun->cfg->get_entry_block ());
 
   /* We could store this information in bb->aux, but we may get called
      through get_all_tm_blocks() from another pass that may be already
      using bb->aux.  */
-  bb_regions.safe_grow_cleared (last_basic_block);
+  bb_regions.safe_grow_cleared (cfun->cfg->get_last_basic_block ());
 
   queue.safe_push (bb);
   bb_regions[bb->index] = region;
@@ -1944,7 +1944,7 @@ gate_tm_init (void)
       struct tm_region *region = (struct tm_region *)
 	obstack_alloc (&tm_obstack.obstack, sizeof (struct tm_region));
       memset (region, 0, sizeof (*region));
-      region->entry_block = single_succ (ENTRY_BLOCK_PTR);
+      region->entry_block = single_succ (cfun->cfg->get_entry_block ());
       /* For a clone, the entire function is the region.  But even if
 	 we don't need to record any exit blocks, we may need to
 	 record irrevocable blocks.  */
@@ -2540,7 +2540,7 @@ static vec<tm_region_p>
 get_bb_regions_instrumented (bool traverse_clones,
 			     bool include_uninstrumented_p)
 {
-  unsigned n = last_basic_block;
+  unsigned n = cfun->cfg->get_last_basic_block ();
   struct bb2reg_stuff stuff;
   vec<tm_region_p> ret;
 
@@ -2568,7 +2568,7 @@ compute_transaction_bits (void)
      certainly don't need it to calculate CDI_DOMINATOR info.  */
   gate_tm_init ();
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     bb->flags &= ~BB_IN_TRANSACTION;
 
   for (region = all_tm_regions; region; region = region->next)
@@ -2905,7 +2905,7 @@ execute_tm_mark (void)
 		  && sub & GTMA_MAY_ENTER_IRREVOCABLE)
 		continue;
 	    }
-	  expand_block_tm (r, BASIC_BLOCK (i));
+	  expand_block_tm (r, cfun->cfg->get_basic_block_by_idx (i));
 	}
     }
 
@@ -3080,7 +3080,7 @@ execute_tm_edges (void)
 
   FOR_EACH_VEC_ELT (bb_regions, i, r)
     if (r != NULL)
-      expand_block_edges (r, BASIC_BLOCK (i));
+      expand_block_edges (r, cfun->cfg->get_basic_block_by_idx (i));
 
   bb_regions.release ();
 
@@ -3512,7 +3512,7 @@ tm_memopt_compute_available (struct tm_region *region,
 	/* If the out state of this block changed, then we need to add
 	   its successors to the worklist if they are not already in.  */
 	FOR_EACH_EDGE (e, ei, bb->succs)
-	  if (!AVAIL_IN_WORKLIST_P (e->dest) && e->dest != EXIT_BLOCK_PTR)
+	  if (!AVAIL_IN_WORKLIST_P (e->dest) && e->dest != cfun->cfg->get_exit_block ())
 	    {
 	      *qin++ = e->dest;
 	      AVAIL_IN_WORKLIST_P (e->dest) = true;
@@ -3579,7 +3579,7 @@ tm_memopt_compute_antic (struct tm_region *region,
       unsigned int i;
       bitmap_iterator bi;
       EXECUTE_IF_SET_IN_BITMAP (region->exit_blocks, 0, i, bi)
-	BB_VISITED_P (BASIC_BLOCK (i)) = true;
+	BB_VISITED_P (cfun->cfg->get_basic_block_by_idx (i)) = true;
     }
 
   qin = worklist;
@@ -4400,12 +4400,12 @@ ipa_tm_scan_irr_function (struct cgraph_node *node, bool for_clone)
   if (for_clone)
     {
       old_irr = d->irrevocable_blocks_clone;
-      queue.quick_push (single_succ (ENTRY_BLOCK_PTR));
+      queue.quick_push (single_succ (cfun->cfg->get_entry_block ()));
       if (ipa_tm_scan_irr_blocks (&queue, new_irr, old_irr, NULL))
 	{
-	  ipa_tm_propagate_irr (single_succ (ENTRY_BLOCK_PTR), new_irr,
+	  ipa_tm_propagate_irr (single_succ (cfun->cfg->get_entry_block ()), new_irr,
 				old_irr, NULL);
-	  ret = bitmap_bit_p (new_irr, single_succ (ENTRY_BLOCK_PTR)->index);
+	  ret = bitmap_bit_p (new_irr, single_succ (cfun->cfg->get_entry_block ())->index);
 	}
     }
   else
@@ -4432,7 +4432,7 @@ ipa_tm_scan_irr_function (struct cgraph_node *node, bool for_clone)
       unsigned i;
 
       EXECUTE_IF_SET_IN_BITMAP (new_irr, 0, i, bmi)
-	ipa_tm_decrement_clone_counts (BASIC_BLOCK (i), for_clone);
+	ipa_tm_decrement_clone_counts (cfun->cfg->get_basic_block_by_idx (i), for_clone);
 
       if (old_irr)
 	{
@@ -5145,7 +5145,7 @@ ipa_tm_transform_clone (struct cgraph_node *node)
   calculate_dominance_info (CDI_DOMINATORS);
 
   need_ssa_rename =
-    ipa_tm_transform_calls (d->clone, NULL, single_succ (ENTRY_BLOCK_PTR),
+    ipa_tm_transform_calls (d->clone, NULL, single_succ (cfun->cfg->get_entry_block ()),
 			    d->irrevocable_blocks_clone);
 
   if (need_ssa_rename)
diff --git a/gcc/tree-call-cdce.c b/gcc/tree-call-cdce.c
index 9b6186e..b015f8c 100644
--- a/gcc/tree-call-cdce.c
+++ b/gcc/tree-call-cdce.c
@@ -861,7 +861,7 @@ tree_call_cdce (void)
   gimple_stmt_iterator i;
   bool something_changed = false;
   vec<gimple> cond_dead_built_in_calls = vNULL;
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       /* Collect dead call candidates.  */
       for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i))
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index f38a32a..1b8b5c9 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -213,12 +213,12 @@ build_gimple_cfg (gimple_seq seq)
     factor_computed_gotos ();
 
   /* Make sure there is always at least one block, even if it's empty.  */
-  if (n_basic_blocks == NUM_FIXED_BLOCKS)
-    create_empty_bb (ENTRY_BLOCK_PTR);
+  if (cfun->cfg->get_n_basic_blocks () == NUM_FIXED_BLOCKS)
+    create_empty_bb (cfun->cfg->get_entry_block ());
 
   /* Adjust the size of the array.  */
-  if (basic_block_info->length () < (size_t) n_basic_blocks)
-    vec_safe_grow_cleared (basic_block_info, n_basic_blocks);
+  if (cfun->cfg->get_basic_block_info ()->length () < (size_t) cfun->cfg->get_n_basic_blocks ())
+    vec_safe_grow_cleared (cfun->cfg->get_basic_block_info (), cfun->cfg->get_n_basic_blocks ());
 
   /* To speed up statement iterator walks, we first purge dead labels.  */
   cleanup_dead_labels ();
@@ -302,7 +302,7 @@ factor_computed_gotos (void)
      Examine the last statement in each basic block to see if the block
      ends with a computed goto.  */
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator gsi = gsi_last_bb (bb);
       gimple last;
@@ -369,7 +369,7 @@ make_blocks (gimple_seq seq)
   gimple stmt = NULL;
   bool start_new_block = true;
   bool first_stmt_of_seq = true;
-  basic_block bb = ENTRY_BLOCK_PTR;
+  basic_block bb = cfun->cfg->get_entry_block ();
 
   while (!gsi_end_p (i))
     {
@@ -443,7 +443,7 @@ create_bb (void *h, void *e, basic_block after)
      not have to clear the newly allocated basic block here.  */
   bb = alloc_block ();
 
-  bb->index = last_basic_block;
+  bb->index = cfun->cfg->get_last_basic_block ();
   bb->flags = BB_NEW;
   set_bb_seq (bb, h ? (gimple_seq) h : NULL);
 
@@ -451,17 +451,17 @@ create_bb (void *h, void *e, basic_block after)
   link_block (bb, after);
 
   /* Grow the basic block array if needed.  */
-  if ((size_t) last_basic_block == basic_block_info->length ())
+  if ((size_t) cfun->cfg->get_last_basic_block () == cfun->cfg->get_basic_block_info ()->length ())
     {
-      size_t new_size = last_basic_block + (last_basic_block + 3) / 4;
-      vec_safe_grow_cleared (basic_block_info, new_size);
+      size_t new_size = cfun->cfg->get_last_basic_block () + (cfun->cfg->get_last_basic_block () + 3) / 4;
+      vec_safe_grow_cleared (cfun->cfg->get_basic_block_info (), new_size);
     }
 
   /* Add the newly created block to the array.  */
-  SET_BASIC_BLOCK (last_basic_block, bb);
+  cfun->cfg->set_basic_block_by_idx (cfun->cfg->get_last_basic_block (), bb);
 
-  n_basic_blocks++;
-  last_basic_block++;
+  cfun->cfg->get_n_basic_blocks ()++;
+  cfun->cfg->get_last_basic_block ()++;
 
   return bb;
 }
@@ -478,7 +478,7 @@ fold_cond_expr_cond (void)
 {
   basic_block bb;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple stmt = last_stmt (bb);
 
@@ -520,10 +520,10 @@ make_edges (void)
 
   /* Create an edge from entry to the first block with executable
      statements in it.  */
-  make_edge (ENTRY_BLOCK_PTR, BASIC_BLOCK (NUM_FIXED_BLOCKS), EDGE_FALLTHRU);
+  make_edge (cfun->cfg->get_entry_block (), cfun->cfg->get_basic_block_by_idx (NUM_FIXED_BLOCKS), EDGE_FALLTHRU);
 
   /* Traverse the basic block array placing edges.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple last = last_stmt (bb);
       bool fallthru;
@@ -538,7 +538,7 @@ make_edges (void)
 	      fallthru = false;
 	      break;
 	    case GIMPLE_RETURN:
-	      make_edge (bb, EXIT_BLOCK_PTR, 0);
+	      make_edge (bb, cfun->cfg->get_exit_block (), 0);
 	      fallthru = false;
 	      break;
 	    case GIMPLE_COND:
@@ -570,7 +570,7 @@ make_edges (void)
 
 	      /* BUILTIN_RETURN is really a return statement.  */
 	      if (gimple_call_builtin_p (last, BUILT_IN_RETURN))
-		make_edge (bb, EXIT_BLOCK_PTR, 0), fallthru = false;
+		make_edge (bb, cfun->cfg->get_exit_block (), 0), fallthru = false;
 	      /* Some calls are known not to return.  */
 	      else
 	        fallthru = !(gimple_call_flags (last) & ECF_NORETURN);
@@ -757,7 +757,7 @@ assign_discriminators (void)
 {
   basic_block bb;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       edge e;
       edge_iterator ei;
@@ -870,7 +870,7 @@ end_recording_case_labels (void)
   edge_to_cases = NULL;
   EXECUTE_IF_SET_IN_BITMAP (touched_switch_bbs, 0, i, bi)
     {
-      basic_block bb = BASIC_BLOCK (i);
+      basic_block bb = cfun->cfg->get_basic_block_by_idx (i);
       if (bb)
 	{
 	  gimple stmt = last_stmt (bb);
@@ -954,7 +954,7 @@ label_to_block_fn (struct function *ifun, tree dest)
      and undefined variable warnings quite right.  */
   if (seen_error () && uid < 0)
     {
-      gimple_stmt_iterator gsi = gsi_start_bb (BASIC_BLOCK (NUM_FIXED_BLOCKS));
+      gimple_stmt_iterator gsi = gsi_start_bb (cfun->cfg->get_basic_block_by_idx (NUM_FIXED_BLOCKS));
       gimple stmt;
 
       stmt = gimple_build_label (dest);
@@ -975,7 +975,7 @@ make_abnormal_goto_edges (basic_block bb, bool for_call)
   basic_block target_bb;
   gimple_stmt_iterator gsi;
 
-  FOR_EACH_BB (target_bb)
+  FOR_EACH_BB_CFG (target_bb, cfun->cfg)
     {
       for (gsi = gsi_start_bb (target_bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	{
@@ -1148,11 +1148,11 @@ void
 cleanup_dead_labels (void)
 {
   basic_block bb;
-  label_for_bb = XCNEWVEC (struct label_record, last_basic_block);
+  label_for_bb = XCNEWVEC (struct label_record, cfun->cfg->get_last_basic_block ());
 
   /* Find a suitable label for each block.  We use the first user-defined
      label if there is one, or otherwise just the first label we see.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator i;
 
@@ -1188,7 +1188,7 @@ cleanup_dead_labels (void)
 
   /* Now redirect all jumps/branches to the selected label.
      First do so for each block ending in a control statement.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple stmt = last_stmt (bb);
       tree label, new_label;
@@ -1280,7 +1280,7 @@ cleanup_dead_labels (void)
   /* Finally, purge dead labels.  All user-defined labels and labels that
      can be the target of non-local gotos and labels which have their
      address taken are preserved.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator i;
       tree label_for_this_bb = label_for_bb[bb->index].label;
@@ -1404,7 +1404,7 @@ group_case_labels (void)
 {
   basic_block bb;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple stmt = last_stmt (bb);
       if (stmt && gimple_code (stmt) == GIMPLE_SWITCH)
@@ -1432,7 +1432,7 @@ gimple_can_merge_blocks_p (basic_block a, basic_block b)
   if (!single_pred_p (b))
     return false;
 
-  if (b == EXIT_BLOCK_PTR)
+  if (b == cfun->cfg->get_exit_block ())
     return false;
 
   /* If A ends by a statement causing exceptions or something similar, we
@@ -2050,8 +2050,8 @@ gimple_debug_bb (basic_block bb)
 basic_block
 gimple_debug_bb_n (int n)
 {
-  gimple_debug_bb (BASIC_BLOCK (n));
-  return BASIC_BLOCK (n);
+  gimple_debug_bb (cfun->cfg->get_basic_block_by_idx (n));
+  return cfun->cfg->get_basic_block_by_idx (n);
 }
 
 
@@ -2079,7 +2079,7 @@ gimple_dump_cfg (FILE *file, int flags)
     {
       dump_function_header (file, current_function_decl, flags);
       fprintf (file, ";; \n%d basic blocks, %d edges, last basic block %d.\n\n",
-	       n_basic_blocks, n_edges, last_basic_block);
+	       cfun->cfg->get_n_basic_blocks (), cfun->cfg->get_n_edges (), cfun->cfg->get_last_basic_block ());
 
       brief_dump_cfg (file, flags | TDF_COMMENT);
       fprintf (file, "\n");
@@ -2114,13 +2114,13 @@ dump_cfg_stats (FILE *file)
   fprintf (file, fmt_str, "", "  instances  ", "used ");
   fprintf (file, "---------------------------------------------------------\n");
 
-  size = n_basic_blocks * sizeof (struct basic_block_def);
+  size = cfun->cfg->get_n_basic_blocks () * sizeof (struct basic_block_def);
   total += size;
-  fprintf (file, fmt_str_1, "Basic blocks", n_basic_blocks,
+  fprintf (file, fmt_str_1, "Basic blocks", cfun->cfg->get_n_basic_blocks (),
 	   SCALE (size), LABEL (size));
 
   num_edges = 0;
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     num_edges += EDGE_COUNT (bb->succs);
   size = num_edges * sizeof (struct edge_def);
   total += size;
@@ -2342,7 +2342,7 @@ stmt_ends_bb_p (gimple t)
 void
 delete_tree_cfg_annotations (void)
 {
-  vec_free (label_to_block_map);
+  vec_free (cfun->cfg->get_label_to_block_map ());
 }
 
 
@@ -4222,9 +4222,9 @@ verify_gimple_label (gimple stmt)
 
   uid = LABEL_DECL_UID (decl);
   if (cfun->cfg
-      && (uid == -1 || (*label_to_block_map)[uid] != gimple_bb (stmt)))
+      && (uid == -1 || (*cfun->cfg->get_label_to_block_map ())[uid] != gimple_bb (stmt)))
     {
-      error ("incorrect entry in label_to_block_map");
+      error ("incorrect entry in cfun->cfg->get_label_to_block_map ()");
       err |= true;
     }
 
@@ -4810,26 +4810,26 @@ gimple_verify_flow_info (void)
   edge e;
   edge_iterator ei;
 
-  if (ENTRY_BLOCK_PTR->il.gimple.seq || ENTRY_BLOCK_PTR->il.gimple.phi_nodes)
+  if (cfun->cfg->get_entry_block ()->il.gimple.seq || cfun->cfg->get_entry_block ()->il.gimple.phi_nodes)
     {
       error ("ENTRY_BLOCK has IL associated with it");
       err = 1;
     }
 
-  if (EXIT_BLOCK_PTR->il.gimple.seq || EXIT_BLOCK_PTR->il.gimple.phi_nodes)
+  if (cfun->cfg->get_exit_block ()->il.gimple.seq || cfun->cfg->get_exit_block ()->il.gimple.phi_nodes)
     {
       error ("EXIT_BLOCK has IL associated with it");
       err = 1;
     }
 
-  FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
+  FOR_EACH_EDGE (e, ei, cfun->cfg->get_exit_block ()->preds)
     if (e->flags & EDGE_FALLTHRU)
       {
 	error ("fallthru to exit from bb %d", e->src->index);
 	err = 1;
       }
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       bool found_ctrl_stmt = false;
 
@@ -5002,7 +5002,7 @@ gimple_verify_flow_info (void)
 	      error ("wrong outgoing edge flags at end of bb %d", bb->index);
 	      err = 1;
 	    }
-	  if (single_succ (bb) != EXIT_BLOCK_PTR)
+	  if (single_succ (bb) != cfun->cfg->get_exit_block ())
 	    {
 	      error ("return edge does not point to exit in bb %d",
 		     bb->index);
@@ -5242,7 +5242,7 @@ gimple_redirect_edge_and_branch (edge e, basic_block dest)
   if (e->flags & EDGE_EH)
     return redirect_eh_edge (e, dest);
 
-  if (e->src != ENTRY_BLOCK_PTR)
+  if (e->src != cfun->cfg->get_entry_block ())
     {
       ret = gimple_try_redirect_by_replacing_jump (e, dest);
       if (ret)
@@ -5525,7 +5525,7 @@ gimple_duplicate_bb (basic_block bb)
   gimple_seq phis = phi_nodes (bb);
   gimple phi, stmt, copy;
 
-  new_bb = create_empty_bb (EXIT_BLOCK_PTR->prev_bb);
+  new_bb = create_empty_bb (cfun->cfg->get_exit_block ()->prev_bb);
 
   /* Copy the PHI nodes.  We ignore PHI node arguments here because
      the incoming edges have not been setup yet.  */
@@ -6827,9 +6827,9 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb,
      FIXME, this is silly.  The CFG ought to become a parameter to
      these helpers.  */
   push_cfun (dest_cfun);
-  make_edge (ENTRY_BLOCK_PTR, entry_bb, EDGE_FALLTHRU);
+  make_edge (cfun->cfg->get_entry_block (), entry_bb, EDGE_FALLTHRU);
   if (exit_bb)
-    make_edge (exit_bb,  EXIT_BLOCK_PTR, 0);
+    make_edge (exit_bb,  cfun->cfg->get_exit_block (), 0);
   pop_cfun ();
 
   /* Back in the original function, the SESE region has disappeared,
@@ -7141,7 +7141,7 @@ print_loop (FILE *file, struct loop *loop, int indent, int verbosity)
   if (verbosity >= 1)
     {
       fprintf (file, "%s{\n", s_indent);
-      FOR_EACH_BB (bb)
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
 	if (bb->loop_father == loop)
 	  print_loops_bb (file, bb, indent, verbosity);
 
@@ -7173,7 +7173,7 @@ print_loops (FILE *file, int verbosity)
 {
   basic_block bb;
 
-  bb = ENTRY_BLOCK_PTR;
+  bb = cfun->cfg->get_entry_block ();
   if (bb && bb->loop_father)
     print_loop_and_siblings (file, bb->loop_father, 0, verbosity);
 }
@@ -7333,16 +7333,16 @@ gimple_flow_call_edges_add (sbitmap blocks)
 {
   int i;
   int blocks_split = 0;
-  int last_bb = last_basic_block;
+  int last_bb = cfun->cfg->get_last_basic_block ();
   bool check_last_block = false;
 
-  if (n_basic_blocks == NUM_FIXED_BLOCKS)
+  if (cfun->cfg->get_n_basic_blocks () == NUM_FIXED_BLOCKS)
     return 0;
 
   if (! blocks)
     check_last_block = true;
   else
-    check_last_block = bitmap_bit_p (blocks, EXIT_BLOCK_PTR->prev_bb->index);
+    check_last_block = bitmap_bit_p (blocks, cfun->cfg->get_exit_block ()->prev_bb->index);
 
   /* In the last basic block, before epilogue generation, there will be
      a fallthru edge to EXIT.  Special care is required if the last insn
@@ -7358,7 +7358,7 @@ gimple_flow_call_edges_add (sbitmap blocks)
      Handle this by adding a dummy instruction in a new last basic block.  */
   if (check_last_block)
     {
-      basic_block bb = EXIT_BLOCK_PTR->prev_bb;
+      basic_block bb = cfun->cfg->get_exit_block ()->prev_bb;
       gimple_stmt_iterator gsi = gsi_last_nondebug_bb (bb);
       gimple t = NULL;
 
@@ -7369,7 +7369,7 @@ gimple_flow_call_edges_add (sbitmap blocks)
 	{
 	  edge e;
 
-	  e = find_edge (bb, EXIT_BLOCK_PTR);
+	  e = find_edge (bb, cfun->cfg->get_exit_block ());
 	  if (e)
 	    {
 	      gsi_insert_on_edge (e, gimple_build_nop ());
@@ -7383,7 +7383,7 @@ gimple_flow_call_edges_add (sbitmap blocks)
      return or not...  */
   for (i = 0; i < last_bb; i++)
     {
-      basic_block bb = BASIC_BLOCK (i);
+      basic_block bb = cfun->cfg->get_basic_block_by_idx (i);
       gimple_stmt_iterator gsi;
       gimple stmt, last_stmt;
 
@@ -7412,7 +7412,7 @@ gimple_flow_call_edges_add (sbitmap blocks)
 #ifdef ENABLE_CHECKING
 		  if (stmt == last_stmt)
 		    {
-		      e = find_edge (bb, EXIT_BLOCK_PTR);
+		      e = find_edge (bb, cfun->cfg->get_exit_block ());
 		      gcc_assert (e == NULL);
 		    }
 #endif
@@ -7425,7 +7425,7 @@ gimple_flow_call_edges_add (sbitmap blocks)
 		      if (e)
 			blocks_split++;
 		    }
-		  make_edge (bb, EXIT_BLOCK_PTR, EDGE_FAKE);
+		  make_edge (bb, cfun->cfg->get_exit_block (), EDGE_FAKE);
 		}
 	      gsi_prev (&gsi);
 	    }
@@ -7463,7 +7463,7 @@ remove_edge_and_dominated_blocks (edge e)
     }
 
   /* No updating is needed for edges to exit.  */
-  if (e->dest == EXIT_BLOCK_PTR)
+  if (e->dest == cfun->cfg->get_exit_block ())
     {
       if (cfgcleanup_altered_bbs)
 	bitmap_set_bit (cfgcleanup_altered_bbs, e->src->index);
@@ -7503,7 +7503,7 @@ remove_edge_and_dominated_blocks (edge e)
 	{
 	  FOR_EACH_EDGE (f, ei, bb->succs)
 	    {
-	      if (f->dest != EXIT_BLOCK_PTR)
+	      if (f->dest != cfun->cfg->get_exit_block ())
 		bitmap_set_bit (df, f->dest->index);
 	    }
 	}
@@ -7512,7 +7512,7 @@ remove_edge_and_dominated_blocks (edge e)
 
       EXECUTE_IF_SET_IN_BITMAP (df, 0, i, bi)
 	{
-	  bb = BASIC_BLOCK (i);
+	  bb = cfun->cfg->get_basic_block_by_idx (i);
 	  bitmap_set_bit (df_idom,
 			  get_immediate_dominator (CDI_DOMINATORS, bb)->index);
 	}
@@ -7550,7 +7550,7 @@ remove_edge_and_dominated_blocks (edge e)
      the dominance frontier of E.  Therefore, Y belongs to DF_IDOM.  */
   EXECUTE_IF_SET_IN_BITMAP (df_idom, 0, i, bi)
     {
-      bb = BASIC_BLOCK (i);
+      bb = cfun->cfg->get_basic_block_by_idx (i);
       for (dbb = first_dom_son (CDI_DOMINATORS, bb);
 	   dbb;
 	   dbb = next_dom_son (CDI_DOMINATORS, dbb))
@@ -7603,7 +7603,7 @@ gimple_purge_all_dead_eh_edges (const_bitmap blocks)
 
   EXECUTE_IF_SET_IN_BITMAP (blocks, 0, i, bi)
     {
-      basic_block bb = BASIC_BLOCK (i);
+      basic_block bb = cfun->cfg->get_basic_block_by_idx (i);
 
       /* Earlier gimple_purge_dead_eh_edges could have removed
 	 this basic block already.  */
@@ -7660,7 +7660,7 @@ gimple_purge_all_dead_abnormal_call_edges (const_bitmap blocks)
 
   EXECUTE_IF_SET_IN_BITMAP (blocks, 0, i, bi)
     {
-      basic_block bb = BASIC_BLOCK (i);
+      basic_block bb = cfun->cfg->get_basic_block_by_idx (i);
 
       /* Earlier gimple_purge_dead_abnormal_call_edges could have removed
 	 this basic block already.  */
@@ -7777,11 +7777,11 @@ gimple_account_profile_record (basic_block bb, int after_pass,
     {
       record->size[after_pass]
 	+= estimate_num_insns (gsi_stmt (i), &eni_size_weights);
-      if (profile_status == PROFILE_READ)
+      if (cfun->cfg->get_profile_status () == PROFILE_READ)
 	record->time[after_pass]
 	  += estimate_num_insns (gsi_stmt (i),
 				 &eni_time_weights) * bb->count;
-      else if (profile_status == PROFILE_GUESSED)
+      else if (cfun->cfg->get_profile_status () == PROFILE_GUESSED)
 	record->time[after_pass]
 	  += estimate_num_insns (gsi_stmt (i),
 				 &eni_time_weights) * bb->frequency;
@@ -7839,7 +7839,7 @@ split_critical_edges (void)
      expensive.  So we want to enable recording of edge to CASE_LABEL_EXPR
      mappings around the calls to split_edge.  */
   start_recording_case_labels ();
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       FOR_EACH_EDGE (e, ei, bb->succs)
         {
@@ -7854,8 +7854,8 @@ split_critical_edges (void)
 	     gimple_find_edge_insert_loc.  */
 	  else if ((!single_pred_p (e->dest)
 	            || !gimple_seq_empty_p (phi_nodes (e->dest))
-	            || e->dest == EXIT_BLOCK_PTR)
-		   && e->src != ENTRY_BLOCK_PTR
+	            || e->dest == cfun->cfg->get_exit_block ())
+		   && e->src != cfun->cfg->get_entry_block ()
 	           && !(e->flags & EDGE_ABNORMAL))
 	    {
 	      gimple_stmt_iterator gsi;
@@ -7961,10 +7961,10 @@ execute_warn_function_return (void)
 
   /* If we have a path to EXIT, then we do return.  */
   if (TREE_THIS_VOLATILE (cfun->decl)
-      && EDGE_COUNT (EXIT_BLOCK_PTR->preds) > 0)
+      && EDGE_COUNT (cfun->cfg->get_exit_block ()->preds) > 0)
     {
       location = UNKNOWN_LOCATION;
-      FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
+      FOR_EACH_EDGE (e, ei, cfun->cfg->get_exit_block ()->preds)
 	{
 	  last = last_stmt (e->src);
 	  if ((gimple_code (last) == GIMPLE_RETURN
@@ -7981,10 +7981,10 @@ execute_warn_function_return (void)
      without returning a value.  */
   else if (warn_return_type
 	   && !TREE_NO_WARNING (cfun->decl)
-	   && EDGE_COUNT (EXIT_BLOCK_PTR->preds) > 0
+	   && EDGE_COUNT (cfun->cfg->get_exit_block ()->preds) > 0
 	   && !VOID_TYPE_P (TREE_TYPE (TREE_TYPE (cfun->decl))))
     {
-      FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
+      FOR_EACH_EDGE (e, ei, cfun->cfg->get_exit_block ()->preds)
 	{
 	  gimple last = last_stmt (e->src);
 	  if (gimple_code (last) == GIMPLE_RETURN
@@ -8054,7 +8054,7 @@ static unsigned int
 execute_warn_function_noreturn (void)
 {
   if (!TREE_THIS_VOLATILE (current_function_decl)
-      && EDGE_COUNT (EXIT_BLOCK_PTR->preds) == 0)
+      && EDGE_COUNT (cfun->cfg->get_exit_block ()->preds) == 0)
     warn_function_noreturn (current_function_decl);
   return 0;
 }
diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c
index 9b314f7..71679ea 100644
--- a/gcc/tree-cfgcleanup.c
+++ b/gcc/tree-cfgcleanup.c
@@ -239,14 +239,14 @@ tree_forwarder_block_p (basic_block bb, bool phi_wanted)
 	 Otherwise, BB must have PHI nodes.  */
       || gimple_seq_empty_p (phi_nodes (bb)) == phi_wanted
       /* BB may not be a predecessor of EXIT_BLOCK_PTR.  */
-      || single_succ (bb) == EXIT_BLOCK_PTR
+      || single_succ (bb) == cfun->cfg->get_exit_block ()
       /* Nor should this be an infinite loop.  */
       || single_succ (bb) == bb
       /* BB may not have an abnormal outgoing edge.  */
       || (single_succ_edge (bb)->flags & EDGE_ABNORMAL))
     return false;
 
-  gcc_checking_assert (bb != ENTRY_BLOCK_PTR);
+  gcc_checking_assert (bb != cfun->cfg->get_entry_block ());
 
   locus = single_succ_edge (bb)->goto_locus;
 
@@ -256,7 +256,7 @@ tree_forwarder_block_p (basic_block bb, bool phi_wanted)
     edge e;
 
     FOR_EACH_EDGE (e, ei, bb->preds)
-      if (e->src == ENTRY_BLOCK_PTR || (e->flags & EDGE_EH))
+      if (e->src == cfun->cfg->get_entry_block () || (e->flags & EDGE_EH))
 	return false;
       /* If goto_locus of any of the edges differs, prevent removing
 	 the forwarder block for -O0.  */
@@ -535,7 +535,7 @@ fixup_noreturn_call (gimple stmt)
 		  SET_USE (use_p, error_mark_node);
 	    }
 	  EXECUTE_IF_SET_IN_BITMAP (blocks, 0, bb_index, bi)
-	    delete_basic_block (BASIC_BLOCK (bb_index));
+	    delete_basic_block (cfun->cfg->get_basic_block_by_idx (bb_index));
 	  BITMAP_FREE (blocks);
 	  release_ssa_name (op);
 	}
@@ -569,8 +569,8 @@ split_bbs_on_noreturn_calls (void)
 	   BB is present in the cfg.  */
 	if (bb == NULL
 	    || bb->index < NUM_FIXED_BLOCKS
-	    || bb->index >= last_basic_block
-	    || BASIC_BLOCK (bb->index) != bb
+	    || bb->index >= cfun->cfg->get_last_basic_block ()
+	    || cfun->cfg->get_basic_block_by_idx (bb->index) != bb
 	    || !gimple_call_noreturn_p (stmt))
 	  continue;
 
@@ -626,10 +626,10 @@ cleanup_tree_cfg_1 (void)
 
   /* Start by iterating over all basic blocks.  We cannot use FOR_EACH_BB,
      since the basic blocks may get removed.  */
-  n = last_basic_block;
+  n = cfun->cfg->get_last_basic_block ();
   for (i = NUM_FIXED_BLOCKS; i < n; i++)
     {
-      bb = BASIC_BLOCK (i);
+      bb = cfun->cfg->get_basic_block_by_idx (i);
       if (bb)
 	retval |= cleanup_tree_cfg_bb (bb);
     }
@@ -642,7 +642,7 @@ cleanup_tree_cfg_1 (void)
       if (i < NUM_FIXED_BLOCKS)
 	continue;
 
-      bb = BASIC_BLOCK (i);
+      bb = cfun->cfg->get_basic_block_by_idx (i);
       if (!bb)
 	continue;
 
@@ -895,14 +895,14 @@ remove_forwarder_block_with_phi (basic_block bb)
 static unsigned int
 merge_phi_nodes (void)
 {
-  basic_block *worklist = XNEWVEC (basic_block, n_basic_blocks);
+  basic_block *worklist = XNEWVEC (basic_block, cfun->cfg->get_n_basic_blocks ());
   basic_block *current = worklist;
   basic_block bb;
 
   calculate_dominance_info (CDI_DOMINATORS);
 
   /* Find all PHI nodes that we may be able to merge.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       basic_block dest;
 
diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c
index d43172b..4fba705 100644
--- a/gcc/tree-complex.c
+++ b/gcc/tree-complex.c
@@ -189,7 +189,7 @@ init_dont_simulate_again (void)
   gimple phi;
   bool saw_a_complex_op = false;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	{
@@ -678,7 +678,7 @@ update_complex_assignment (gimple_stmt_iterator *gsi, tree r, tree i)
 static void
 update_parameter_components (void)
 {
-  edge entry_edge = single_succ_edge (ENTRY_BLOCK_PTR);
+  edge entry_edge = single_succ_edge (cfun->cfg->get_entry_block ());
   tree parm;
 
   for (parm = DECL_ARGUMENTS (cfun->decl); parm ; parm = DECL_CHAIN (parm))
@@ -1618,8 +1618,8 @@ tree_lower_complex (void)
   update_parameter_components ();
 
   /* ??? Ideally we'd traverse the blocks in breadth-first order.  */
-  old_last_basic_block = last_basic_block;
-  FOR_EACH_BB (bb)
+  old_last_basic_block = cfun->cfg->get_last_basic_block ();
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       if (bb->index >= old_last_basic_block)
 	continue;
diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c
index 57aae95..8d436de 100644
--- a/gcc/tree-dfa.c
+++ b/gcc/tree-dfa.c
@@ -71,7 +71,7 @@ renumber_gimple_stmt_uids (void)
   basic_block bb;
 
   set_gimple_stmt_max_uid (cfun, 0);
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator bsi;
       for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); gsi_next (&bsi))
@@ -270,7 +270,7 @@ collect_dfa_stats (struct dfa_stats_d *dfa_stats_p ATTRIBUTE_UNUSED)
   memset ((void *)dfa_stats_p, 0, sizeof (struct dfa_stats_d));
 
   /* Walk all the statements in the function counting references.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator si;
 
@@ -745,7 +745,7 @@ dump_enumerated_decls (FILE *file, int flags)
 
   memset (&wi, '\0', sizeof (wi));
   wi.info = (void *) &decl_list;
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator gsi;
 
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index fc350bd..f9fa731 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -3199,7 +3199,7 @@ execute_lower_resx (void)
 
   mnt_map = pointer_map_create ();
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple last = last_stmt (bb);
       if (last && is_gimple_resx (last))
@@ -3589,7 +3589,7 @@ execute_lower_eh_dispatch (void)
 
   assign_filter_values ();
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple last = last_stmt (bb);
       if (last == NULL)
@@ -3671,7 +3671,7 @@ mark_reachable_handlers (sbitmap *r_reachablep, sbitmap *lp_reachablep)
   else
     lp_reachable = NULL;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator gsi;
 
diff --git a/gcc/tree-emutls.c b/gcc/tree-emutls.c
index fc75b31..b628483 100644
--- a/gcc/tree-emutls.c
+++ b/gcc/tree-emutls.c
@@ -625,7 +625,7 @@ lower_emutls_function_body (struct cgraph_node *node)
      create a node for it.  */
   d.builtin_node = cgraph_get_create_node (d.builtin_decl);
 
-  FOR_EACH_BB (d.bb)
+  FOR_EACH_BB_CFG (d.bb, cfun->cfg)
     {
       gimple_stmt_iterator gsi;
       unsigned int i, nedge;
diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c
index 0ebb8c3..0e059f2 100644
--- a/gcc/tree-if-conv.c
+++ b/gcc/tree-if-conv.c
@@ -907,7 +907,7 @@ get_loop_body_in_if_conv_order (const struct loop *loop)
   unsigned int visited_count = 0;
 
   gcc_assert (loop->num_nodes);
-  gcc_assert (loop->latch != EXIT_BLOCK_PTR);
+  gcc_assert (loop->latch != cfun->cfg->get_exit_block ());
 
   blocks = XCNEWVEC (basic_block, loop->num_nodes);
   visited = BITMAP_ALLOC (NULL);
@@ -1835,7 +1835,7 @@ main_tree_if_conversion (void)
 #ifdef ENABLE_CHECKING
   {
     basic_block bb;
-    FOR_EACH_BB (bb)
+    FOR_EACH_BB_CFG (bb, cfun->cfg)
       gcc_assert (!bb->aux);
   }
 #endif
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 57af7de..d74146e 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -187,7 +187,7 @@ remap_ssa_name (tree name, copy_body_data *id)
       if (SSA_NAME_IS_DEFAULT_DEF (name)
 	  && TREE_CODE (SSA_NAME_VAR (name)) == PARM_DECL
 	  && id->entry_bb == NULL
-	  && single_succ_p (ENTRY_BLOCK_PTR))
+	  && single_succ_p (cfun->cfg->get_entry_block ()))
 	{
 	  tree vexpr = make_node (DEBUG_EXPR_DECL);
 	  gimple def_temp;
@@ -206,7 +206,7 @@ remap_ssa_name (tree name, copy_body_data *id)
 	  DECL_ARTIFICIAL (vexpr) = 1;
 	  TREE_TYPE (vexpr) = TREE_TYPE (name);
 	  DECL_MODE (vexpr) = DECL_MODE (SSA_NAME_VAR (name));
-	  gsi = gsi_after_labels (single_succ (ENTRY_BLOCK_PTR));
+	  gsi = gsi_after_labels (single_succ (cfun->cfg->get_entry_block ()));
 	  gsi_insert_before (&gsi, def_temp, GSI_SAME_STMT);
 	  return vexpr;
 	}
@@ -288,7 +288,7 @@ remap_ssa_name (tree name, copy_body_data *id)
 	      && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name)
 	      && (!SSA_NAME_VAR (name)
 		  || TREE_CODE (SSA_NAME_VAR (name)) != PARM_DECL)
-	      && (id->entry_bb != EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->dest
+	      && (id->entry_bb != EDGE_SUCC (cfun->cfg->get_entry_block (), 0)->dest
 		  || EDGE_COUNT (id->entry_bb->preds) != 1))
 	    {
 	      gimple_stmt_iterator gsi = gsi_last_bb (id->entry_bb);
@@ -1880,7 +1880,7 @@ copy_edges_for_bb (basic_block bb, gcov_type count_scale, basic_block ret_bb,
 
 	/* Return edges do get a FALLTHRU flag when the get inlined.  */
 	if (old_edge->dest->index == EXIT_BLOCK && !old_edge->flags
-	    && old_edge->dest->aux != EXIT_BLOCK_PTR)
+	    && old_edge->dest->aux != cfun->cfg->get_exit_block ())
 	  flags |= EDGE_FALLTHRU;
 	new_edge = make_edge (new_bb, (basic_block) old_edge->dest->aux, flags);
 	new_edge->count = apply_scale (old_edge->count, count_scale);
@@ -2096,15 +2096,15 @@ initialize_cfun (tree new_fndecl, tree callee_fndecl, gcov_type count)
   init_empty_tree_cfg ();
 
   profile_status_for_function (cfun) = profile_status_for_function (src_cfun);
-  ENTRY_BLOCK_PTR->count =
+  cfun->cfg->get_entry_block ()->count =
     (ENTRY_BLOCK_PTR_FOR_FUNCTION (src_cfun)->count * count_scale /
      REG_BR_PROB_BASE);
-  ENTRY_BLOCK_PTR->frequency
+  cfun->cfg->get_entry_block ()->frequency
     = ENTRY_BLOCK_PTR_FOR_FUNCTION (src_cfun)->frequency;
-  EXIT_BLOCK_PTR->count =
+  cfun->cfg->get_exit_block ()->count =
     (EXIT_BLOCK_PTR_FOR_FUNCTION (src_cfun)->count * count_scale /
      REG_BR_PROB_BASE);
-  EXIT_BLOCK_PTR->frequency =
+  cfun->cfg->get_exit_block ()->frequency =
     EXIT_BLOCK_PTR_FOR_FUNCTION (src_cfun)->frequency;
   if (src_cfun->eh)
     init_eh_for_function ();
@@ -2275,8 +2275,8 @@ copy_cfg_body (copy_body_data * id, gcov_type count, int frequency_scale,
       incoming_count = apply_scale (incoming_count, count_scale);
       incoming_frequency
 	= apply_scale ((gcov_type)incoming_frequency, frequency_scale);
-      ENTRY_BLOCK_PTR->count = incoming_count;
-      ENTRY_BLOCK_PTR->frequency = incoming_frequency;
+      cfun->cfg->get_entry_block ()->count = incoming_count;
+      cfun->cfg->get_entry_block ()->frequency = incoming_frequency;
     }
 
   /* Must have a CFG here at this point.  */
@@ -2305,7 +2305,7 @@ copy_cfg_body (copy_body_data * id, gcov_type count, int frequency_scale,
 	new_bb->loop_father = entry_block_map->loop_father;
       }
 
-  last = last_basic_block;
+  last = cfun->cfg->get_last_basic_block ();
 
   /* Now that we've duplicated the blocks, duplicate their edges.  */
   bool can_make_abormal_goto
@@ -2357,11 +2357,11 @@ copy_cfg_body (copy_body_data * id, gcov_type count, int frequency_scale,
 
   /* Zero out AUX fields of newly created block during EH edge
      insertion. */
-  for (; last < last_basic_block; last++)
+  for (; last < cfun->cfg->get_last_basic_block (); last++)
     {
       if (need_debug_cleanup)
-	maybe_move_debug_stmts_to_successors (id, BASIC_BLOCK (last));
-      BASIC_BLOCK (last)->aux = NULL;
+	maybe_move_debug_stmts_to_successors (id, cfun->cfg->get_basic_block_by_idx (last));
+      cfun->cfg->get_basic_block_by_idx (last)->aux = NULL;
     }
   entry_block_map->aux = NULL;
   exit_block_map->aux = NULL;
@@ -4233,12 +4233,12 @@ gimple_expand_calls_inline (basic_block bb, copy_body_data *id)
 static void
 fold_marked_statements (int first, struct pointer_set_t *statements)
 {
-  for (; first < n_basic_blocks; first++)
-    if (BASIC_BLOCK (first))
+  for (; first < cfun->cfg->get_n_basic_blocks (); first++)
+    if (cfun->cfg->get_basic_block_by_idx (first))
       {
         gimple_stmt_iterator gsi;
 
-	for (gsi = gsi_start_bb (BASIC_BLOCK (first));
+	for (gsi = gsi_start_bb (cfun->cfg->get_basic_block_by_idx (first));
 	     !gsi_end_p (gsi);
 	     gsi_next (&gsi))
 	  if (pointer_set_contains (statements, gsi_stmt (gsi)))
@@ -4264,7 +4264,7 @@ fold_marked_statements (int first, struct pointer_set_t *statements)
 			  break;
 			}
 		      if (gsi_end_p (i2))
-			i2 = gsi_start_bb (BASIC_BLOCK (first));
+			i2 = gsi_start_bb (cfun->cfg->get_basic_block_by_idx (first));
 		      else
 			gsi_next (&i2);
 		      while (1)
@@ -4288,7 +4288,7 @@ fold_marked_statements (int first, struct pointer_set_t *statements)
 				 is mood anyway.  */
 			      if (maybe_clean_or_replace_eh_stmt (old_stmt,
 								  new_stmt))
-				gimple_purge_dead_eh_edges (BASIC_BLOCK (first));
+				gimple_purge_dead_eh_edges (cfun->cfg->get_basic_block_by_idx (first));
 			      break;
 			    }
 			  gsi_next (&i2);
@@ -4308,7 +4308,7 @@ fold_marked_statements (int first, struct pointer_set_t *statements)
 						       new_stmt);
 
 		  if (maybe_clean_or_replace_eh_stmt (old_stmt, new_stmt))
-		    gimple_purge_dead_eh_edges (BASIC_BLOCK (first));
+		    gimple_purge_dead_eh_edges (cfun->cfg->get_basic_block_by_idx (first));
 		}
 	    }
       }
@@ -4336,7 +4336,7 @@ optimize_inline_calls (tree fn)
 {
   copy_body_data id;
   basic_block bb;
-  int last = n_basic_blocks;
+  int last = cfun->cfg->get_n_basic_blocks ();
   struct gimplify_ctx gctx;
   bool inlined_p = false;
 
@@ -4372,7 +4372,7 @@ optimize_inline_calls (tree fn)
      will split id->current_basic_block, and the new blocks will
      follow it; we'll trudge through them, processing their CALL_EXPRs
      along the way.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     inlined_p |= gimple_expand_calls_inline (bb, &id);
 
   pop_gimplify_context (NULL);
@@ -4415,7 +4415,7 @@ optimize_inline_calls (tree fn)
 	  | TODO_cleanup_cfg
 	  | (gimple_in_ssa_p (cfun) ? TODO_remove_unused_locals : 0)
 	  | (gimple_in_ssa_p (cfun) ? TODO_update_address_taken : 0)
-	  | (profile_status != PROFILE_ABSENT ? TODO_rebuild_frequencies : 0));
+	  | (cfun->cfg->get_profile_status () != PROFILE_ABSENT ? TODO_rebuild_frequencies : 0));
 }
 
 /* Passed to walk_tree.  Copies the node pointed to, if appropriate.  */
@@ -4924,7 +4924,7 @@ delete_unreachable_blocks_update_callgraph (copy_body_data *id)
 
   /* Delete all unreachable basic blocks.  */
 
-  for (b = ENTRY_BLOCK_PTR->next_bb; b != EXIT_BLOCK_PTR; b = next_bb)
+  for (b = cfun->cfg->get_entry_block ()->next_bb; b != cfun->cfg->get_exit_block (); b = next_bb)
     {
       next_bb = b->next_bb;
 
@@ -5204,7 +5204,7 @@ tree_function_versioning (tree old_decl, tree new_decl,
 
   /* Copy the Function's body.  */
   copy_body (&id, old_entry_block->count, REG_BR_PROB_BASE,
-	     ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, blocks_to_copy, new_entry);
+	     cfun->cfg->get_entry_block (), cfun->cfg->get_exit_block (), blocks_to_copy, new_entry);
 
   /* Renumber the lexical scoping (non-code) blocks consecutively.  */
   number_blocks (new_decl);
@@ -5212,7 +5212,7 @@ tree_function_versioning (tree old_decl, tree new_decl,
   /* We want to create the BB unconditionally, so that the addition of
      debug stmts doesn't affect BB count, which may in the end cause
      codegen differences.  */
-  bb = split_edge (single_succ_edge (ENTRY_BLOCK_PTR));
+  bb = split_edge (single_succ_edge (cfun->cfg->get_entry_block ()));
   while (init_stmts.length ())
     insert_init_stmt (&id, bb, init_stmts.pop ());
   update_clone_info (&id);
@@ -5249,7 +5249,7 @@ tree_function_versioning (tree old_decl, tree new_decl,
       struct cgraph_edge *e;
       rebuild_frequencies ();
 
-      new_version_node->count = ENTRY_BLOCK_PTR->count;
+      new_version_node->count = cfun->cfg->get_entry_block ()->count;
       for (e = new_version_node->callees; e; e = e->next_callee)
 	{
 	  basic_block bb = gimple_bb (e->call_stmt);
diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c
index f028b25..43e15fc 100644
--- a/gcc/tree-into-ssa.c
+++ b/gcc/tree-into-ssa.c
@@ -540,7 +540,7 @@ set_livein_block (tree var, basic_block bb)
 
       if (def_block_index == -1
 	  || ! dominated_by_p (CDI_DOMINATORS, bb,
-	                       BASIC_BLOCK (def_block_index)))
+	                       cfun->cfg->get_basic_block_by_idx (def_block_index)))
 	info->need_phi_state = NEED_PHI_STATE_MAYBE;
     }
   else
@@ -804,7 +804,7 @@ prune_unused_phi_nodes (bitmap phis, bitmap kills, bitmap uses)
   adef = 1;
   EXECUTE_IF_SET_IN_BITMAP (to_remove, 0, i, bi)
     {
-      def_bb = BASIC_BLOCK (i);
+      def_bb = cfun->cfg->get_basic_block_by_idx (i);
       defs[adef].bb_index = i;
       defs[adef].dfs_num = bb_dom_dfs_in (CDI_DOMINATORS, def_bb);
       defs[adef + 1].bb_index = i;
@@ -878,7 +878,7 @@ prune_unused_phi_nodes (bitmap phis, bitmap kills, bitmap uses)
 	p = b;
       else
 	{
-	  use_bb = get_immediate_dominator (CDI_DOMINATORS, BASIC_BLOCK (b));
+	  use_bb = get_immediate_dominator (CDI_DOMINATORS, cfun->cfg->get_basic_block_by_idx (b));
 	  p = find_dfsnum_interval (defs, n_defs,
 				    bb_dom_dfs_in (CDI_DOMINATORS, use_bb));
 	  if (!bitmap_bit_p (phis, p))
@@ -890,7 +890,7 @@ prune_unused_phi_nodes (bitmap phis, bitmap kills, bitmap uses)
 	continue;
 
       /* Add the new uses to the worklist.  */
-      def_bb = BASIC_BLOCK (p);
+      def_bb = cfun->cfg->get_basic_block_by_idx (p);
       FOR_EACH_EDGE (e, ei, def_bb->preds)
 	{
 	  u = e->src->index;
@@ -947,7 +947,7 @@ mark_phi_for_rewrite (basic_block bb, gimple phi)
 
   bitmap_set_bit (blocks_with_phis_to_rewrite, idx);
 
-  n = (unsigned) last_basic_block + 1;
+  n = (unsigned) cfun->cfg->get_last_basic_block () + 1;
   if (phis_to_rewrite.length () < n)
     phis_to_rewrite.safe_grow_cleared (n);
 
@@ -988,7 +988,7 @@ insert_phi_nodes_for (tree var, bitmap phi_insertion_points, bool update_p)
   /* And insert the PHI nodes.  */
   EXECUTE_IF_SET_IN_BITMAP (phi_insertion_points, 0, bb_index, bi)
     {
-      bb = BASIC_BLOCK (bb_index);
+      bb = cfun->cfg->get_basic_block_by_idx (bb_index);
       if (update_p)
 	mark_block_for_update (bb);
 
@@ -1207,10 +1207,10 @@ rewrite_debug_stmt_uses (gimple stmt)
       def = info->current_def;
       if (!def)
 	{
-	  if (TREE_CODE (var) == PARM_DECL && single_succ_p (ENTRY_BLOCK_PTR))
+	  if (TREE_CODE (var) == PARM_DECL && single_succ_p (cfun->cfg->get_entry_block ()))
 	    {
 	      gimple_stmt_iterator gsi
-		= gsi_after_labels (single_succ (ENTRY_BLOCK_PTR));
+		= gsi_after_labels (single_succ (cfun->cfg->get_entry_block ()));
 	      int lim;
 	      /* Search a few source bind stmts at the start of first bb to
 		 see if a DEBUG_EXPR_DECL can't be reused.  */
@@ -1239,7 +1239,7 @@ rewrite_debug_stmt_uses (gimple stmt)
 		  DECL_ARTIFICIAL (def) = 1;
 		  TREE_TYPE (def) = TREE_TYPE (var);
 		  DECL_MODE (def) = DECL_MODE (var);
-		  gsi = gsi_after_labels (single_succ (ENTRY_BLOCK_PTR));
+		  gsi = gsi_after_labels (single_succ (cfun->cfg->get_entry_block ()));
 		  gsi_insert_before (&gsi, def_temp, GSI_SAME_STMT);
 		}
 	      update = true;
@@ -1872,7 +1872,7 @@ maybe_register_def (def_operand_p def_p, gimple stmt,
 		     bind stmts, but there wouldn't be a PC to bind
 		     them to either, so avoid diverging the CFG.  */
 		  if (ef && single_pred_p (ef->dest)
-		      && ef->dest != EXIT_BLOCK_PTR)
+		      && ef->dest != cfun->cfg->get_exit_block ())
 		    {
 		      /* If there were PHI nodes in the node, we'd
 			 have to make sure the value we're binding
@@ -2284,7 +2284,7 @@ mark_def_site_blocks (void)
   init_walk_dominator_tree (&walk_data);
 
   /* Recursively walk the dominator tree.  */
-  walk_dominator_tree (&walk_data, ENTRY_BLOCK_PTR);
+  walk_dominator_tree (&walk_data, cfun->cfg->get_entry_block ());
 
   /* Finalize the dominator walker.  */
   fini_walk_dominator_tree (&walk_data);
@@ -2357,12 +2357,12 @@ rewrite_into_ssa (void)
   /* Initialize the set of interesting blocks.  The callback
      mark_def_sites will add to this set those blocks that the renamer
      should process.  */
-  interesting_blocks = sbitmap_alloc (last_basic_block);
+  interesting_blocks = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
   bitmap_clear (interesting_blocks);
 
   /* Initialize dominance frontier.  */
-  dfs = XNEWVEC (bitmap_head, last_basic_block);
-  FOR_EACH_BB (bb)
+  dfs = XNEWVEC (bitmap_head, cfun->cfg->get_last_basic_block ());
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     bitmap_initialize (&dfs[bb->index], &bitmap_default_obstack);
 
   /* 1- Compute dominance frontiers.  */
@@ -2376,10 +2376,10 @@ rewrite_into_ssa (void)
   insert_phi_nodes (dfs);
 
   /* 4- Rename all the blocks.  */
-  rewrite_blocks (ENTRY_BLOCK_PTR, REWRITE_ALL);
+  rewrite_blocks (cfun->cfg->get_entry_block (), REWRITE_ALL);
 
   /* Free allocated memory.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     bitmap_clear (&dfs[bb->index]);
   free (dfs);
 
@@ -2654,7 +2654,7 @@ prepare_def_site_for (tree name, bool insert_phi_p)
   bb = gimple_bb (stmt);
   if (bb)
     {
-      gcc_checking_assert (bb->index < last_basic_block);
+      gcc_checking_assert (bb->index < cfun->cfg->get_last_basic_block ());
       mark_block_for_update (bb);
       mark_def_interesting (name, stmt, bb, insert_phi_p);
     }
@@ -2999,10 +2999,10 @@ insert_updated_phi_nodes_for (tree var, bitmap_head *dfs, bitmap blocks,
 	     common dominator of all the definition blocks.  */
 	  entry = nearest_common_dominator_for_set (CDI_DOMINATORS,
 						    db->def_blocks);
-	  if (entry != ENTRY_BLOCK_PTR)
+	  if (entry != cfun->cfg->get_entry_block ())
 	    EXECUTE_IF_SET_IN_BITMAP (idf, 0, i, bi)
-	      if (BASIC_BLOCK (i) != entry
-		  && dominated_by_p (CDI_DOMINATORS, BASIC_BLOCK (i), entry))
+	      if (cfun->cfg->get_basic_block_by_idx (i) != entry
+		  && dominated_by_p (CDI_DOMINATORS, cfun->cfg->get_basic_block_by_idx (i), entry))
 		bitmap_set_bit (pruned_idf, i);
 	}
       else
@@ -3034,7 +3034,7 @@ insert_updated_phi_nodes_for (tree var, bitmap_head *dfs, bitmap blocks,
 	{
 	  edge e;
 	  edge_iterator ei;
-	  basic_block bb = BASIC_BLOCK (i);
+	  basic_block bb = cfun->cfg->get_basic_block_by_idx (i);
 
 	  FOR_EACH_EDGE (e, ei, bb->preds)
 	    if (e->src->index >= 0)
@@ -3163,7 +3163,7 @@ update_ssa (unsigned update_flags)
 
   blocks_with_phis_to_rewrite = BITMAP_ALLOC (NULL);
   if (!phis_to_rewrite.exists ())
-    phis_to_rewrite.create (last_basic_block + 1);
+    phis_to_rewrite.create (cfun->cfg->get_last_basic_block () + 1);
   blocks_to_update = BITMAP_ALLOC (NULL);
 
   /* Ensure that the dominance information is up-to-date.  */
@@ -3198,7 +3198,7 @@ update_ssa (unsigned update_flags)
 	 be possible to determine the nearest block that had a
 	 definition for each of the symbols that are marked for
 	 updating.  For now this seems more work than it's worth.  */
-      start_bb = ENTRY_BLOCK_PTR;
+      start_bb = cfun->cfg->get_entry_block ();
 
       /* Traverse the CFG looking for existing definitions and uses of
 	 symbols in SSA operands.  Mark interesting blocks and
@@ -3247,8 +3247,8 @@ update_ssa (unsigned update_flags)
 
       /* If the caller requested PHI nodes to be added, compute
 	 dominance frontiers.  */
-      dfs = XNEWVEC (bitmap_head, last_basic_block);
-      FOR_EACH_BB (bb)
+      dfs = XNEWVEC (bitmap_head, cfun->cfg->get_last_basic_block ());
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
 	bitmap_initialize (&dfs[bb->index], &bitmap_default_obstack);
       compute_dominance_frontiers (dfs);
 
@@ -3274,14 +3274,14 @@ update_ssa (unsigned update_flags)
 	insert_updated_phi_nodes_for (sym, dfs, blocks_to_update,
 	                              update_flags);
 
-      FOR_EACH_BB (bb)
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
 	bitmap_clear (&dfs[bb->index]);
       free (dfs);
 
       /* Insertion of PHI nodes may have added blocks to the region.
 	 We need to re-compute START_BB to include the newly added
 	 blocks.  */
-      if (start_bb != ENTRY_BLOCK_PTR)
+      if (start_bb != cfun->cfg->get_entry_block ())
 	start_bb = nearest_common_dominator_for_set (CDI_DOMINATORS,
 						     blocks_to_update);
     }
@@ -3295,7 +3295,7 @@ update_ssa (unsigned update_flags)
     get_var_info (sym)->info.current_def = NULL_TREE;
 
   /* Now start the renaming process at START_BB.  */
-  interesting_blocks = sbitmap_alloc (last_basic_block);
+  interesting_blocks = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
   bitmap_clear (interesting_blocks);
   EXECUTE_IF_SET_IN_BITMAP (blocks_to_update, 0, i, bi)
     bitmap_set_bit (interesting_blocks, i);
@@ -3318,9 +3318,9 @@ update_ssa (unsigned update_flags)
       c = 0;
       EXECUTE_IF_SET_IN_BITMAP (blocks_to_update, 0, i, bi)
 	c++;
-      fprintf (dump_file, "Number of blocks in CFG: %d\n", last_basic_block);
+      fprintf (dump_file, "Number of blocks in CFG: %d\n", cfun->cfg->get_last_basic_block ());
       fprintf (dump_file, "Number of blocks to update: %d (%3.0f%%)\n",
-	       c, PERCENT (c, last_basic_block));
+	       c, PERCENT (c, cfun->cfg->get_last_basic_block ()));
 
       if (dump_flags & TDF_DETAILS)
 	{
diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c
index 13b78cc..2dfc4f2 100644
--- a/gcc/tree-loop-distribution.c
+++ b/gcc/tree-loop-distribution.c
@@ -1497,7 +1497,7 @@ tree_loop_distribution (void)
   bool changed = false;
   basic_block bb;
 
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator gsi;
       for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
diff --git a/gcc/tree-mudflap.c b/gcc/tree-mudflap.c
index b250bfe..35a644e 100644
--- a/gcc/tree-mudflap.c
+++ b/gcc/tree-mudflap.c
@@ -487,7 +487,7 @@ mf_decl_cache_locals (void)
   gimple_set_location (g, DECL_SOURCE_LOCATION (current_function_decl));
   gimple_seq_add_stmt (&seq, g);
 
-  insert_edge_copies_seq (seq, ENTRY_BLOCK_PTR);
+  insert_edge_copies_seq (seq, cfun->cfg->get_entry_block ());
 
   gsi_commit_edge_inserts ();
 }
@@ -948,10 +948,10 @@ mf_xform_statements (void)
 {
   basic_block bb, next;
   gimple_stmt_iterator i;
-  int saved_last_basic_block = last_basic_block;
+  int saved_last_basic_block = cfun->cfg->get_last_basic_block ();
   enum gimple_rhs_class grhs_class;
 
-  bb = ENTRY_BLOCK_PTR ->next_bb;
+  bb = cfun->cfg->get_entry_block () ->next_bb;
   do
     {
       next = bb->next_bb;
diff --git a/gcc/tree-nrv.c b/gcc/tree-nrv.c
index 51bc7cd..4c2fd71 100644
--- a/gcc/tree-nrv.c
+++ b/gcc/tree-nrv.c
@@ -135,7 +135,7 @@ tree_nrv (void)
     return 0;
 
   /* Look through each block for assignments to the RESULT_DECL.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	{
@@ -229,7 +229,7 @@ tree_nrv (void)
      RESULT.  */
   data.var = found;
   data.result = result;
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); )
 	{
@@ -331,7 +331,7 @@ execute_return_slot_opt (void)
 {
   basic_block bb;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator gsi;
       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
diff --git a/gcc/tree-object-size.c b/gcc/tree-object-size.c
index 2b8311a..bbd41c5 100644
--- a/gcc/tree-object-size.c
+++ b/gcc/tree-object-size.c
@@ -1197,7 +1197,7 @@ static unsigned int
 compute_object_sizes (void)
 {
   basic_block bb;
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator i;
       for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i))
diff --git a/gcc/tree-optimize.c b/gcc/tree-optimize.c
index 0948d2e..1774720 100644
--- a/gcc/tree-optimize.c
+++ b/gcc/tree-optimize.c
@@ -128,16 +128,16 @@ execute_fixup_cfg (void)
 
   count_scale
       = GCOV_COMPUTE_SCALE (cgraph_get_node (current_function_decl)->count,
-                            ENTRY_BLOCK_PTR->count);
+                            cfun->cfg->get_entry_block ()->count);
 
-  ENTRY_BLOCK_PTR->count = cgraph_get_node (current_function_decl)->count;
-  EXIT_BLOCK_PTR->count = apply_scale (EXIT_BLOCK_PTR->count,
+  cfun->cfg->get_entry_block ()->count = cgraph_get_node (current_function_decl)->count;
+  cfun->cfg->get_exit_block ()->count = apply_scale (cfun->cfg->get_exit_block ()->count,
                                        count_scale);
 
-  FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR->succs)
+  FOR_EACH_EDGE (e, ei, cfun->cfg->get_entry_block ()->succs)
     e->count = apply_scale (e->count, count_scale);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       bb->count = apply_scale (bb->count, count_scale);
       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
diff --git a/gcc/tree-outof-ssa.c b/gcc/tree-outof-ssa.c
index ff3e058..43bba76 100644
--- a/gcc/tree-outof-ssa.c
+++ b/gcc/tree-outof-ssa.c
@@ -749,7 +749,7 @@ eliminate_useless_phis (void)
   gimple_stmt_iterator gsi;
   tree result;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); )
         {
@@ -807,7 +807,7 @@ rewrite_trees (var_map map ATTRIBUTE_UNUSED)
   /* Search for PHIs where the destination has no partition, but one
      or more arguments has a partition.  This should not happen and can
      create incorrect code.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator gsi;
       for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
@@ -849,7 +849,7 @@ expand_phi_nodes (struct ssaexpand *sa)
   elim_graph g = new_elim_graph (sa->map->num_partitions);
   g->map = sa->map;
 
-  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR->next_bb, EXIT_BLOCK_PTR, next_bb)
+  FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block ()->next_bb, cfun->cfg->get_exit_block (), next_bb)
     if (!gimple_seq_empty_p (phi_nodes (bb)))
       {
 	edge e;
@@ -1014,7 +1014,7 @@ insert_backedge_copies (void)
 
   mark_dfs_back_edges ();
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       /* Mark block as possibly needing calculation of UIDs.  */
       bb->aux = &bb->aux;
diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c
index 9985b40..77ce038 100644
--- a/gcc/tree-profile.c
+++ b/gcc/tree-profile.c
@@ -366,7 +366,7 @@ gimple_gen_ic_func_profiler (void)
 					  &current_function_decl,
 					  __gcov_indirect_call_callee);
    */
-  gsi = gsi_after_labels (single_succ (ENTRY_BLOCK_PTR));
+  gsi = gsi_after_labels (single_succ (cfun->cfg->get_entry_block ()));
 
   cur_func = force_gimple_operand_gsi (&gsi,
 				       build_addr (current_function_decl,
@@ -529,7 +529,7 @@ tree_profiling (void)
 
       push_cfun (DECL_STRUCT_FUNCTION (node->symbol.decl));
 
-      FOR_EACH_BB (bb)
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
 	{
 	  gimple_stmt_iterator gsi;
 	  for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c
index c7e9d4b..e9c6dd5 100644
--- a/gcc/tree-scalar-evolution.c
+++ b/gcc/tree-scalar-evolution.c
@@ -3270,7 +3270,7 @@ scev_const_prop (void)
   if (number_of_loops (cfun) <= 1)
     return 0;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       loop = bb->loop_father;
 
diff --git a/gcc/tree-scalar-evolution.h b/gcc/tree-scalar-evolution.h
index 55ba82c..cc824ac 100644
--- a/gcc/tree-scalar-evolution.h
+++ b/gcc/tree-scalar-evolution.h
@@ -46,7 +46,7 @@ static inline basic_block
 block_before_loop (loop_p loop)
 {
   edge preheader = loop_preheader_edge (loop);
-  return (preheader ? preheader->src : ENTRY_BLOCK_PTR);
+  return (preheader ? preheader->src : cfun->cfg->get_entry_block ());
 }
 
 /* Analyze all the parameters of the chrec that were left under a
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index 7e950ae..1ec40bb 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -1216,7 +1216,7 @@ scan_function (void)
   basic_block bb;
   bool ret = false;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator gsi;
       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
@@ -3270,7 +3270,7 @@ sra_modify_function_body (void)
   bool cfg_changed = false;
   basic_block bb;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator gsi = gsi_start_bb (bb);
       while (!gsi_end_p (gsi))
@@ -3375,7 +3375,7 @@ initialize_parameter_reductions (void)
 
   seq = gsi_seq (gsi);
   if (seq)
-    gsi_insert_seq_on_edge_immediate (single_succ_edge (ENTRY_BLOCK_PTR), seq);
+    gsi_insert_seq_on_edge_immediate (single_succ_edge (cfun->cfg->get_entry_block ()), seq);
 }
 
 /* The "main" function of intraprocedural SRA passes.  Runs the analysis and if
@@ -3720,8 +3720,8 @@ propagate_dereference_distances (void)
   basic_block bb;
 
   queue.create (last_basic_block_for_function (cfun));
-  queue.quick_push (ENTRY_BLOCK_PTR);
-  FOR_EACH_BB (bb)
+  queue.quick_push (cfun->cfg->get_entry_block ());
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       queue.quick_push (bb);
       bb->aux = bb;
@@ -3750,7 +3750,7 @@ propagate_dereference_distances (void)
 	  {
 	    int succ_idx = e->dest->index * func_param_count + i;
 
-	    if (e->src == EXIT_BLOCK_PTR)
+	    if (e->src == cfun->cfg->get_exit_block ())
 	      continue;
 
 	    if (first)
@@ -3791,10 +3791,10 @@ dump_dereferences_table (FILE *f, const char *str, HOST_WIDE_INT *table)
   basic_block bb;
 
   fprintf (dump_file, str);
-  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
+  FOR_BB_BETWEEN (bb, cfun->cfg->get_entry_block (), cfun->cfg->get_exit_block (), next_bb)
     {
       fprintf (f, "%4i  %i   ", bb->index, bitmap_bit_p (final_bbs, bb->index));
-      if (bb != EXIT_BLOCK_PTR)
+      if (bb != cfun->cfg->get_exit_block ())
 	{
 	  int i;
 	  for (i = 0; i < func_param_count; i++)
@@ -3846,7 +3846,7 @@ analyze_caller_dereference_legality (vec<access_p> representatives)
   for (i = 0; i < func_param_count; i++)
     {
       struct access *repr = representatives[i];
-      int idx = ENTRY_BLOCK_PTR->index * func_param_count + i;
+      int idx = cfun->cfg->get_entry_block ()->index * func_param_count + i;
 
       if (!repr || no_accesses_p (repr))
 	continue;
@@ -4575,7 +4575,7 @@ ipa_sra_modify_function_body (ipa_parm_adjustment_vec adjustments)
   bool cfg_changed = false;
   basic_block bb;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator gsi;
 
@@ -4660,9 +4660,9 @@ sra_ipa_reset_debug_stmts (ipa_parm_adjustment_vec adjustments)
   int i, len;
   gimple_stmt_iterator *gsip = NULL, gsi;
 
-  if (MAY_HAVE_DEBUG_STMTS && single_succ_p (ENTRY_BLOCK_PTR))
+  if (MAY_HAVE_DEBUG_STMTS && single_succ_p (cfun->cfg->get_entry_block ()))
     {
-      gsi = gsi_after_labels (single_succ (ENTRY_BLOCK_PTR));
+      gsi = gsi_after_labels (single_succ (cfun->cfg->get_entry_block ()));
       gsip = &gsi;
     }
   len = adjustments.length ();
@@ -4814,7 +4814,7 @@ convert_callers (struct cgraph_node *node, tree old_decl,
   if (!encountered_recursive_call)
     return;
 
-  FOR_EACH_BB (this_block)
+  FOR_EACH_BB_CFG (this_block, cfun->cfg)
     {
       gimple_stmt_iterator gsi;
 
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 1bc4c2f..734848b 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -719,7 +719,7 @@ ccp_initialize (void)
   const_val = XCNEWVEC (prop_value_t, n_const_val);
 
   /* Initialize simulation flags for PHI nodes and statements.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator i;
 
@@ -753,7 +753,7 @@ ccp_initialize (void)
   /* Now process PHI nodes.  We never clear the simulate_again flag on
      phi nodes, since we do not know which edges are executable yet,
      except for phi nodes for virtual operands when we do not do store ccp.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator i;
 
@@ -1723,7 +1723,7 @@ gsi_prev_dom_bb_nondebug (gimple_stmt_iterator *i)
   while (gsi_end_p (*i))
     {
       dom = get_immediate_dominator (CDI_DOMINATORS, i->bb);
-      if (dom == NULL || dom == ENTRY_BLOCK_PTR)
+      if (dom == NULL || dom == cfun->cfg->get_entry_block ())
 	return;
 
       *i = gsi_last_bb (dom);
@@ -2195,7 +2195,7 @@ optimize_stack_restore (gimple_stmt_iterator i)
     case 0:
       break;
     case 1:
-      if (single_succ_edge (bb)->dest != EXIT_BLOCK_PTR)
+      if (single_succ_edge (bb)->dest != cfun->cfg->get_exit_block ())
 	return NULL_TREE;
       break;
     default:
@@ -2383,7 +2383,7 @@ execute_fold_all_builtins (void)
   basic_block bb;
   unsigned int todoflags = 0;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator i;
       for (i = gsi_start_bb (bb); !gsi_end_p (i); )
diff --git a/gcc/tree-ssa-coalesce.c b/gcc/tree-ssa-coalesce.c
index 354b5f1..bb1ab2f 100644
--- a/gcc/tree-ssa-coalesce.c
+++ b/gcc/tree-ssa-coalesce.c
@@ -809,7 +809,7 @@ build_ssa_conflict_graph (tree_live_info_p liveinfo)
 
   live = new_live_track (map);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator gsi;
 
@@ -917,7 +917,7 @@ create_outofssa_var_map (coalesce_list_p cl, bitmap used_in_copy)
 
   map = init_var_map (num_ssa_names);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       tree arg;
 
@@ -1078,7 +1078,7 @@ create_outofssa_var_map (coalesce_list_p cl, bitmap used_in_copy)
 		  v2 = SSA_NAME_VERSION (var);
 		  bitmap_set_bit (used_in_copy, v1);
 		  bitmap_set_bit (used_in_copy, v2);
-		  cost = coalesce_cost_bb (EXIT_BLOCK_PTR);
+		  cost = coalesce_cost_bb (cfun->cfg->get_exit_block ());
 		  add_coalesce (cl, v1, v2, cost);
 		}
 	    }
@@ -1178,7 +1178,7 @@ coalesce_partitions (var_map map, ssa_conflicts_p graph, coalesce_list_p cl,
      in the coalesce list because they do not need to be sorted, and simply
      consume extra memory/compilation time in large programs.  */
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       FOR_EACH_EDGE (e, ei, bb->preds)
 	if (e->flags & EDGE_ABNORMAL)
diff --git a/gcc/tree-ssa-copy.c b/gcc/tree-ssa-copy.c
index f58f7b3..55eca492 100644
--- a/gcc/tree-ssa-copy.c
+++ b/gcc/tree-ssa-copy.c
@@ -669,7 +669,7 @@ init_copy_prop (void)
   n_copy_of = num_ssa_names;
   copy_of = XCNEWVEC (prop_value_t, n_copy_of);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator si;
       int depth = bb_loop_depth (bb);
diff --git a/gcc/tree-ssa-copyrename.c b/gcc/tree-ssa-copyrename.c
index 6f49b7e..54a5f96 100644
--- a/gcc/tree-ssa-copyrename.c
+++ b/gcc/tree-ssa-copyrename.c
@@ -317,7 +317,7 @@ rename_ssa_copies (void)
 
   map = init_var_map (num_ssa_names);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       /* Scan for real copies.  */
       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
@@ -333,7 +333,7 @@ rename_ssa_copies (void)
 	}
     }
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       /* Treat PHI nodes as copies between the result and each argument.  */
       for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c
index 05c58fe..918bb72 100644
--- a/gcc/tree-ssa-dce.c
+++ b/gcc/tree-ssa-dce.c
@@ -112,9 +112,9 @@ static bool cfg_altered;
 static inline void
 set_control_dependence_map_bit (basic_block bb, int edge_index)
 {
-  if (bb == ENTRY_BLOCK_PTR)
+  if (bb == cfun->cfg->get_entry_block ())
     return;
-  gcc_assert (bb != EXIT_BLOCK_PTR);
+  gcc_assert (bb != cfun->cfg->get_exit_block ());
   bitmap_set_bit (control_dependence_map[bb->index], edge_index);
 }
 
@@ -132,15 +132,15 @@ clear_control_dependence_bitmap (basic_block bb)
 static inline basic_block
 find_pdom (basic_block block)
 {
-  gcc_assert (block != ENTRY_BLOCK_PTR);
+  gcc_assert (block != cfun->cfg->get_entry_block ());
 
-  if (block == EXIT_BLOCK_PTR)
-    return EXIT_BLOCK_PTR;
+  if (block == cfun->cfg->get_exit_block ())
+    return cfun->cfg->get_exit_block ();
   else
     {
       basic_block bb = get_immediate_dominator (CDI_POST_DOMINATORS, block);
       if (! bb)
-	return EXIT_BLOCK_PTR;
+	return cfun->cfg->get_exit_block ();
       return bb;
     }
 }
@@ -155,15 +155,15 @@ find_control_dependence (struct edge_list *el, int edge_index)
   basic_block current_block;
   basic_block ending_block;
 
-  gcc_assert (INDEX_EDGE_PRED_BB (el, edge_index) != EXIT_BLOCK_PTR);
+  gcc_assert (INDEX_EDGE_PRED_BB (el, edge_index) != cfun->cfg->get_exit_block ());
 
-  if (INDEX_EDGE_PRED_BB (el, edge_index) == ENTRY_BLOCK_PTR)
-    ending_block = single_succ (ENTRY_BLOCK_PTR);
+  if (INDEX_EDGE_PRED_BB (el, edge_index) == cfun->cfg->get_entry_block ())
+    ending_block = single_succ (cfun->cfg->get_entry_block ());
   else
     ending_block = find_pdom (INDEX_EDGE_PRED_BB (el, edge_index));
 
   for (current_block = INDEX_EDGE_SUCC_BB (el, edge_index);
-       current_block != ending_block && current_block != EXIT_BLOCK_PTR;
+       current_block != ending_block && current_block != cfun->cfg->get_exit_block ();
        current_block = find_pdom (current_block))
     {
       edge e = INDEX_EDGE (el, edge_index);
@@ -407,9 +407,9 @@ mark_control_dependent_edges_necessary (basic_block bb, struct edge_list *el,
   unsigned edge_number;
   bool skipped = false;
 
-  gcc_assert (bb != EXIT_BLOCK_PTR);
+  gcc_assert (bb != cfun->cfg->get_exit_block ());
 
-  if (bb == ENTRY_BLOCK_PTR)
+  if (bb == cfun->cfg->get_entry_block ())
     return;
 
   EXECUTE_IF_CONTROL_DEPENDENT (bi, bb->index, edge_number)
@@ -447,7 +447,7 @@ find_obviously_necessary_stmts (struct edge_list *el)
   gimple phi, stmt;
   int flags;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       /* PHI nodes are never inherently necessary.  */
       for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
@@ -478,7 +478,7 @@ find_obviously_necessary_stmts (struct edge_list *el)
       struct loop *loop;
       scev_initialize ();
       if (mark_irreducible_loops ())
-	FOR_EACH_BB (bb)
+	FOR_EACH_BB_CFG (bb, cfun->cfg)
 	  {
 	    edge_iterator ei;
 	    FOR_EACH_EDGE (e, ei, bb->succs)
@@ -711,7 +711,7 @@ propagate_necessity (struct edge_list *el)
 	     containing STMT is control dependent, but only if we haven't
 	     already done so.  */
 	  basic_block bb = gimple_bb (stmt);
-	  if (bb != ENTRY_BLOCK_PTR
+	  if (bb != cfun->cfg->get_entry_block ()
 	      && !bitmap_bit_p (visited_control_parents, bb->index))
 	    mark_control_dependent_edges_necessary (bb, el, false);
 	}
@@ -817,7 +817,7 @@ propagate_necessity (struct edge_list *el)
 		      if (!bitmap_bit_p (last_stmt_necessary, arg_bb->index))
 			mark_last_stmt_necessary (arg_bb);
 		    }
-		  else if (arg_bb != ENTRY_BLOCK_PTR
+		  else if (arg_bb != cfun->cfg->get_entry_block ()
 		           && !bitmap_bit_p (visited_control_parents,
 					 arg_bb->index))
 		    mark_control_dependent_edges_necessary (arg_bb, el, true);
@@ -1193,7 +1193,7 @@ remove_dead_stmt (gimple_stmt_iterator *i, basic_block bb)
 	 fake edges in the dominator tree.  */
       if (e)
         ;
-      else if (! post_dom_bb || post_dom_bb == EXIT_BLOCK_PTR)
+      else if (! post_dom_bb || post_dom_bb == cfun->cfg->get_exit_block ())
 	e = EDGE_SUCC (bb, 0);
       else
         e = forward_edge_to_pdom (EDGE_SUCC (bb, 0), post_dom_bb);
@@ -1285,7 +1285,7 @@ eliminate_unnecessary_stmts (void)
 
      as desired.  */
   gcc_assert (dom_info_available_p (CDI_DOMINATORS));
-  h = get_all_dominated_blocks (CDI_DOMINATORS, single_succ (ENTRY_BLOCK_PTR));
+  h = get_all_dominated_blocks (CDI_DOMINATORS, single_succ (cfun->cfg->get_entry_block ()));
 
   while (h.length ())
     {
@@ -1382,7 +1382,7 @@ eliminate_unnecessary_stmts (void)
       find_unreachable_blocks ();
 
       /* Delete all unreachable basic blocks in reverse dominator order.  */
-      for (bb = EXIT_BLOCK_PTR->prev_bb; bb != ENTRY_BLOCK_PTR; bb = prev_bb)
+      for (bb = cfun->cfg->get_exit_block ()->prev_bb; bb != cfun->cfg->get_entry_block (); bb = prev_bb)
 	{
 	  prev_bb = bb->prev_bb;
 
@@ -1442,7 +1442,7 @@ eliminate_unnecessary_stmts (void)
 	    }
 	}
     }
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       /* Remove dead PHI nodes.  */
       something_changed |= remove_dead_phis (bb);
@@ -1483,13 +1483,13 @@ tree_dce_init (bool aggressive)
     {
       int i;
 
-      control_dependence_map = XNEWVEC (bitmap, last_basic_block);
-      for (i = 0; i < last_basic_block; ++i)
+      control_dependence_map = XNEWVEC (bitmap, cfun->cfg->get_last_basic_block ());
+      for (i = 0; i < cfun->cfg->get_last_basic_block (); ++i)
 	control_dependence_map[i] = BITMAP_ALLOC (NULL);
 
-      last_stmt_necessary = sbitmap_alloc (last_basic_block);
+      last_stmt_necessary = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
       bitmap_clear (last_stmt_necessary);
-      bb_contains_live_stmts = sbitmap_alloc (last_basic_block);
+      bb_contains_live_stmts = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
       bitmap_clear (bb_contains_live_stmts);
     }
 
@@ -1509,7 +1509,7 @@ tree_dce_done (bool aggressive)
     {
       int i;
 
-      for (i = 0; i < last_basic_block; ++i)
+      for (i = 0; i < cfun->cfg->get_last_basic_block (); ++i)
 	BITMAP_FREE (control_dependence_map[i]);
       free (control_dependence_map);
 
@@ -1564,7 +1564,7 @@ perform_tree_ssa_dce (bool aggressive)
       find_all_control_dependences (el);
       timevar_pop (TV_CONTROL_DEPENDENCES);
 
-      visited_control_parents = sbitmap_alloc (last_basic_block);
+      visited_control_parents = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
       bitmap_clear (visited_control_parents);
 
       mark_dfs_back_edges ();
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index 602289d..42eb712 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -757,7 +757,7 @@ free_all_edge_infos (void)
   edge_iterator ei;
   edge e;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       FOR_EACH_EDGE (e, ei, bb->preds)
         {
@@ -824,12 +824,12 @@ tree_ssa_dominator_optimize (void)
   mark_dfs_back_edges ();
 
   /* Recursively walk the dominator tree optimizing statements.  */
-  walk_dominator_tree (&walk_data, ENTRY_BLOCK_PTR);
+  walk_dominator_tree (&walk_data, cfun->cfg->get_entry_block ());
 
   {
     gimple_stmt_iterator gsi;
     basic_block bb;
-    FOR_EACH_BB (bb)
+    FOR_EACH_BB_CFG (bb, cfun->cfg)
       {
 	for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	  update_stmt_if_modified (gsi_stmt (gsi));
@@ -865,13 +865,13 @@ tree_ssa_dominator_optimize (void)
 	 iterator.  */
       EXECUTE_IF_SET_IN_BITMAP (need_eh_cleanup, 0, i, bi)
 	{
-	  basic_block bb = BASIC_BLOCK (i);
+	  basic_block bb = cfun->cfg->get_basic_block_by_idx (i);
 	  if (bb == NULL)
 	    continue;
 	  while (single_succ_p (bb)
 		 && (single_succ_edge (bb)->flags & EDGE_EH) == 0)
 	    bb = single_succ (bb);
-	  if (bb == EXIT_BLOCK_PTR)
+	  if (bb == cfun->cfg->get_exit_block ())
 	    continue;
 	  if ((unsigned) bb->index != i)
 	    bitmap_set_bit (need_eh_cleanup, bb->index);
@@ -1674,7 +1674,7 @@ record_edge_info (basic_block bb)
 	    {
 	      int i;
               int n_labels = gimple_switch_num_labels (stmt);
-	      tree *info = XCNEWVEC (tree, last_basic_block);
+	      tree *info = XCNEWVEC (tree, cfun->cfg->get_last_basic_block ());
 	      edge e;
 	      edge_iterator ei;
 
@@ -3030,7 +3030,7 @@ eliminate_degenerate_phis (void)
      phase in dominator order.  Presumably this is because walking
      in dominator order leaves fewer PHIs for later examination
      by the worklist phase.  */
-  eliminate_degenerate_phis_1 (ENTRY_BLOCK_PTR, interesting_names);
+  eliminate_degenerate_phis_1 (cfun->cfg->get_entry_block (), interesting_names);
 
   /* Second phase.  Eliminate second order degenerate PHIs as well
      as trivial copies or constant initializations identified by
diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c
index ad99ea9..a68aa12 100644
--- a/gcc/tree-ssa-dse.c
+++ b/gcc/tree-ssa-dse.c
@@ -333,7 +333,7 @@ tree_ssa_dse (void)
   init_walk_dominator_tree (&walk_data);
 
   /* Recursively walk the dominator tree.  */
-  walk_dominator_tree (&walk_data, EXIT_BLOCK_PTR);
+  walk_dominator_tree (&walk_data, cfun->cfg->get_exit_block ());
 
   /* Finalize the dominator walker.  */
   fini_walk_dominator_tree (&walk_data);
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
index 6043d31..3f45d7d 100644
--- a/gcc/tree-ssa-forwprop.c
+++ b/gcc/tree-ssa-forwprop.c
@@ -3220,7 +3220,7 @@ ssa_forward_propagate_and_combine (void)
 
   cfg_changed = false;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator gsi;
 
diff --git a/gcc/tree-ssa-ifcombine.c b/gcc/tree-ssa-ifcombine.c
index 9598eb8..afdb782 100644
--- a/gcc/tree-ssa-ifcombine.c
+++ b/gcc/tree-ssa-ifcombine.c
@@ -627,7 +627,7 @@ tree_ssa_ifcombine (void)
   bbs = blocks_in_phiopt_order ();
   calculate_dominance_info (CDI_DOMINATORS);
 
-  for (i = 0; i < n_basic_blocks - NUM_FIXED_BLOCKS; ++i)
+  for (i = 0; i < cfun->cfg->get_n_basic_blocks () - NUM_FIXED_BLOCKS; ++i)
     {
       basic_block bb = bbs[i];
       gimple stmt = last_stmt (bb);
diff --git a/gcc/tree-ssa-live.c b/gcc/tree-ssa-live.c
index 83a52a0..7c6d9e1 100644
--- a/gcc/tree-ssa-live.c
+++ b/gcc/tree-ssa-live.c
@@ -654,7 +654,7 @@ clear_unused_block_pointer (void)
   basic_block bb;
   gimple_stmt_iterator gsi;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
       {
 	unsigned i;
@@ -772,7 +772,7 @@ remove_unused_locals (void)
   usedvars = BITMAP_ALLOC (NULL);
 
   /* Walk the CFG marking all referenced symbols.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator gsi;
       size_t i;
@@ -837,7 +837,7 @@ remove_unused_locals (void)
      ignores them, and the second pass (if there were any) tries to remove
      them.  */
   if (have_local_clobbers)
-    FOR_EACH_BB (bb)
+    FOR_EACH_BB_CFG (bb, cfun->cfg)
       {
 	gimple_stmt_iterator gsi;
 
@@ -941,17 +941,17 @@ new_tree_live_info (var_map map)
 
   live = XNEW (struct tree_live_info_d);
   live->map = map;
-  live->num_blocks = last_basic_block;
+  live->num_blocks = cfun->cfg->get_last_basic_block ();
 
-  live->livein = XNEWVEC (bitmap_head, last_basic_block);
-  FOR_EACH_BB (bb)
+  live->livein = XNEWVEC (bitmap_head, cfun->cfg->get_last_basic_block ());
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     bitmap_initialize (&live->livein[bb->index], &liveness_bitmap_obstack);
 
-  live->liveout = XNEWVEC (bitmap_head, last_basic_block);
-  FOR_EACH_BB (bb)
+  live->liveout = XNEWVEC (bitmap_head, cfun->cfg->get_last_basic_block ());
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     bitmap_initialize (&live->liveout[bb->index], &liveness_bitmap_obstack);
 
-  live->work_stack = XNEWVEC (int, last_basic_block);
+  live->work_stack = XNEWVEC (int, cfun->cfg->get_last_basic_block ());
   live->stack_top = live->work_stack;
 
   live->global = BITMAP_ALLOC (&liveness_bitmap_obstack);
@@ -994,7 +994,7 @@ loe_visit_block (tree_live_info_p live, basic_block bb, sbitmap visited,
   FOR_EACH_EDGE (e, ei, bb->preds)
     {
       pred_bb = e->src;
-      if (pred_bb == ENTRY_BLOCK_PTR)
+      if (pred_bb == cfun->cfg->get_entry_block ())
 	continue;
       /* TMP is variables live-on-entry from BB that aren't defined in the
 	 predecessor block.  This should be the live on entry vars to pred.
@@ -1023,21 +1023,21 @@ live_worklist (tree_live_info_p live)
 {
   unsigned b;
   basic_block bb;
-  sbitmap visited = sbitmap_alloc (last_basic_block + 1);
+  sbitmap visited = sbitmap_alloc (cfun->cfg->get_last_basic_block () + 1);
   bitmap tmp = BITMAP_ALLOC (&liveness_bitmap_obstack);
 
   bitmap_clear (visited);
 
   /* Visit all the blocks in reverse order and propagate live on entry values
      into the predecessors blocks.  */
-  FOR_EACH_BB_REVERSE (bb)
+  FOR_EACH_BB_REVERSE_CFG (bb, cfun->cfg)
     loe_visit_block (live, bb, visited, tmp);
 
   /* Process any blocks which require further iteration.  */
   while (live->stack_top != live->work_stack)
     {
       b = *--(live->stack_top);
-      loe_visit_block (live, BASIC_BLOCK (b), visited, tmp);
+      loe_visit_block (live, cfun->cfg->get_basic_block_by_idx (b), visited, tmp);
     }
 
   BITMAP_FREE (tmp);
@@ -1072,7 +1072,7 @@ set_var_live_on_entry (tree ssa_name, tree_live_info_p live)
 	bitmap_set_bit (&live->liveout[def_bb->index], p);
     }
   else
-    def_bb = ENTRY_BLOCK_PTR;
+    def_bb = cfun->cfg->get_entry_block ();
 
   /* Visit each use of SSA_NAME and if it isn't in the same block as the def,
      add it to the list of live on entry blocks.  */
@@ -1088,7 +1088,7 @@ set_var_live_on_entry (tree ssa_name, tree_live_info_p live)
 	     defined in that block, or whether its live on entry.  */
 	  int index = PHI_ARG_INDEX_FROM_USE (use);
 	  edge e = gimple_phi_arg_edge (use_stmt, index);
-	  if (e->src != ENTRY_BLOCK_PTR)
+	  if (e->src != cfun->cfg->get_entry_block ())
 	    {
 	      if (e->src != def_bb)
 		add_block = e->src;
@@ -1129,11 +1129,11 @@ calculate_live_on_exit (tree_live_info_p liveinfo)
   edge_iterator ei;
 
   /* live on entry calculations used liveout vectors for defs, clear them.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     bitmap_clear (&liveinfo->liveout[bb->index]);
 
   /* Set all the live-on-exit bits for uses in PHIs.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator gsi;
       size_t i;
@@ -1154,14 +1154,14 @@ calculate_live_on_exit (tree_live_info_p liveinfo)
 	      if (p == NO_PARTITION)
 		continue;
 	      e = gimple_phi_arg_edge (phi, i);
-	      if (e->src != ENTRY_BLOCK_PTR)
+	      if (e->src != cfun->cfg->get_entry_block ())
 		bitmap_set_bit (&liveinfo->liveout[e->src->index], p);
 	    }
 	}
 
       /* Add each successors live on entry to this bock live on exit.  */
       FOR_EACH_EDGE (e, ei, bb->succs)
-        if (e->dest != EXIT_BLOCK_PTR)
+        if (e->dest != cfun->cfg->get_exit_block ())
 	  bitmap_ior_into (&liveinfo->liveout[bb->index],
 			   live_on_entry (liveinfo, e->dest));
     }
@@ -1274,7 +1274,7 @@ dump_live_info (FILE *f, tree_live_info_p live, int flag)
 
   if ((flag & LIVEDUMP_ENTRY) && live->livein)
     {
-      FOR_EACH_BB (bb)
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
 	{
 	  fprintf (f, "\nLive on entry to BB%d : ", bb->index);
 	  EXECUTE_IF_SET_IN_BITMAP (&live->livein[bb->index], 0, i, bi)
@@ -1288,7 +1288,7 @@ dump_live_info (FILE *f, tree_live_info_p live, int flag)
 
   if ((flag & LIVEDUMP_EXIT) && live->liveout)
     {
-      FOR_EACH_BB (bb)
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
 	{
 	  fprintf (f, "\nLive on exit from BB%d : ", bb->index);
 	  EXECUTE_IF_SET_IN_BITMAP (&live->liveout[bb->index], 0, i, bi)
@@ -1354,12 +1354,12 @@ verify_live_on_entry (tree_live_info_p live)
    /* Check for live on entry partitions and report those with a DEF in
       the program. This will typically mean an optimization has done
       something wrong.  */
-  bb = ENTRY_BLOCK_PTR;
+  bb = cfun->cfg->get_entry_block ();
   num = 0;
   FOR_EACH_EDGE (e, ei, bb->succs)
     {
       int entry_block = e->dest->index;
-      if (e->dest == EXIT_BLOCK_PTR)
+      if (e->dest == cfun->cfg->get_exit_block ())
         continue;
       for (i = 0; i < (unsigned)num_var_partitions (map); i++)
 	{
diff --git a/gcc/tree-ssa-live.h b/gcc/tree-ssa-live.h
index 8fd1e80..664be42 100644
--- a/gcc/tree-ssa-live.h
+++ b/gcc/tree-ssa-live.h
@@ -270,8 +270,8 @@ static inline bitmap
 live_on_entry (tree_live_info_p live, basic_block bb)
 {
   gcc_checking_assert (live->livein
-		       && bb != ENTRY_BLOCK_PTR
-		       && bb != EXIT_BLOCK_PTR);
+		       && bb != cfun->cfg->get_entry_block ()
+		       && bb != cfun->cfg->get_exit_block ());
 
   return &live->livein[bb->index];
 }
@@ -284,8 +284,8 @@ static inline bitmap
 live_on_exit (tree_live_info_p live, basic_block bb)
 {
   gcc_checking_assert (live->liveout
-		       && bb != ENTRY_BLOCK_PTR
-		       && bb != EXIT_BLOCK_PTR);
+		       && bb != cfun->cfg->get_entry_block ()
+		       && bb != cfun->cfg->get_exit_block ());
 
   return &live->liveout[bb->index];
 }
diff --git a/gcc/tree-ssa-loop-ch.c b/gcc/tree-ssa-loop-ch.c
index ff17c7e..8a8af23 100644
--- a/gcc/tree-ssa-loop-ch.c
+++ b/gcc/tree-ssa-loop-ch.c
@@ -142,9 +142,9 @@ copy_loop_headers (void)
       return 0;
     }
 
-  bbs = XNEWVEC (basic_block, n_basic_blocks);
-  copied_bbs = XNEWVEC (basic_block, n_basic_blocks);
-  bbs_size = n_basic_blocks;
+  bbs = XNEWVEC (basic_block, cfun->cfg->get_n_basic_blocks ());
+  copied_bbs = XNEWVEC (basic_block, cfun->cfg->get_n_basic_blocks ());
+  bbs_size = cfun->cfg->get_n_basic_blocks ();
 
   FOR_EACH_LOOP (li, loop, 0)
     {
diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c
index e5e502b..bf5311d 100644
--- a/gcc/tree-ssa-loop-im.c
+++ b/gcc/tree-ssa-loop-im.c
@@ -1192,7 +1192,7 @@ determine_invariantness (void)
   walk_data.before_dom_children = determine_invariantness_stmt;
 
   init_walk_dominator_tree (&walk_data);
-  walk_dominator_tree (&walk_data, ENTRY_BLOCK_PTR);
+  walk_dominator_tree (&walk_data, cfun->cfg->get_entry_block ());
   fini_walk_dominator_tree (&walk_data);
 }
 
@@ -1346,7 +1346,7 @@ move_computations (void)
   walk_data.before_dom_children = move_computations_stmt;
 
   init_walk_dominator_tree (&walk_data);
-  walk_dominator_tree (&walk_data, ENTRY_BLOCK_PTR);
+  walk_dominator_tree (&walk_data, cfun->cfg->get_entry_block ());
   fini_walk_dominator_tree (&walk_data);
 
   gsi_commit_edge_inserts ();
@@ -1599,8 +1599,8 @@ analyze_memory_references (void)
   /* Collect all basic-blocks in loops and sort them after their
      loops postorder.  */
   i = 0;
-  bbs = XNEWVEC (basic_block, n_basic_blocks - NUM_FIXED_BLOCKS);
-  FOR_EACH_BB (bb)
+  bbs = XNEWVEC (basic_block, cfun->cfg->get_n_basic_blocks () - NUM_FIXED_BLOCKS);
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     if (bb->loop_father != current_loops->tree_root)
       bbs[i++] = bb;
   n = i;
@@ -2517,12 +2517,12 @@ fill_always_executed_in_1 (struct loop *loop, sbitmap contains_call)
 static void
 fill_always_executed_in (void)
 {
-  sbitmap contains_call = sbitmap_alloc (last_basic_block);
+  sbitmap contains_call = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
   basic_block bb;
   struct loop *loop;
 
   bitmap_clear (contains_call);
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator gsi;
       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
@@ -2594,7 +2594,7 @@ tree_ssa_lim_finalize (void)
 
   free_aux_for_edges ();
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     SET_ALWAYS_EXECUTED_IN (bb, NULL);
 
   bitmap_obstack_release (&lim_bitmap_obstack);
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 7cfe80d..2330c03 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -1996,7 +1996,7 @@ find_interesting_uses (struct ivopts_data *data)
       bb = body[i];
 
       FOR_EACH_EDGE (e, ei, bb->succs)
-	if (e->dest != EXIT_BLOCK_PTR
+	if (e->dest != cfun->cfg->get_exit_block ()
 	    && !flow_bb_inside_loop_p (data->current_loop, e->dest))
 	  find_interesting_uses_outside (data, e);
 
diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c
index edc5b7b..55c6091 100644
--- a/gcc/tree-ssa-loop-manip.c
+++ b/gcc/tree-ssa-loop-manip.c
@@ -180,11 +180,11 @@ compute_live_loop_exits (bitmap live_exits, bitmap use_blocks,
   /* Normally the work list size is bounded by the number of basic
      blocks in the largest loop.  We don't know this number, but we
      can be fairly sure that it will be relatively small.  */
-  worklist.create (MAX (8, n_basic_blocks / 128));
+  worklist.create (MAX (8, cfun->cfg->get_n_basic_blocks () / 128));
 
   EXECUTE_IF_SET_IN_BITMAP (use_blocks, 0, i, bi)
     {
-      basic_block use_bb = BASIC_BLOCK (i);
+      basic_block use_bb = cfun->cfg->get_basic_block_by_idx (i);
       struct loop *use_loop = use_bb->loop_father;
       gcc_checking_assert (def_loop != use_loop
 			   && ! flow_loop_nested_p (def_loop, use_loop));
@@ -216,7 +216,7 @@ compute_live_loop_exits (bitmap live_exits, bitmap use_blocks,
 	  bool pred_visited;
 
 	  /* We should have met DEF_BB along the way.  */
-	  gcc_assert (pred != ENTRY_BLOCK_PTR);
+	  gcc_assert (pred != cfun->cfg->get_entry_block ());
 
 	  if (pred_loop_depth >= def_loop_depth)
 	    {
@@ -308,7 +308,7 @@ add_exit_phis_var (tree var, bitmap use_blocks, bitmap *loop_exits)
 
   EXECUTE_IF_SET_IN_BITMAP (live_exits, 0, index, bi)
     {
-      add_exit_phi (BASIC_BLOCK (index), var);
+      add_exit_phi (cfun->cfg->get_basic_block_by_idx (index), var);
     }
 
   BITMAP_FREE (live_exits);
@@ -445,9 +445,9 @@ find_uses_to_rename (bitmap changed_bbs, bitmap *use_blocks, bitmap need_phis)
 
   if (changed_bbs)
     EXECUTE_IF_SET_IN_BITMAP (changed_bbs, 0, index, bi)
-      find_uses_to_rename_bb (BASIC_BLOCK (index), use_blocks, need_phis);
+      find_uses_to_rename_bb (cfun->cfg->get_basic_block_by_idx (index), use_blocks, need_phis);
   else
-    FOR_EACH_BB (bb)
+    FOR_EACH_BB_CFG (bb, cfun->cfg)
       find_uses_to_rename_bb (bb, use_blocks, need_phis);
 }
 
@@ -586,7 +586,7 @@ verify_loop_closed_ssa (bool verify_ssa_p)
 
   timevar_push (TV_VERIFY_LOOP_CLOSED);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); gsi_next (&bsi))
 	{
@@ -712,14 +712,14 @@ copy_phi_node_args (unsigned first_new_block)
 {
   unsigned i;
 
-  for (i = first_new_block; i < (unsigned) last_basic_block; i++)
-    BASIC_BLOCK (i)->flags |= BB_DUPLICATED;
+  for (i = first_new_block; i < (unsigned) cfun->cfg->get_last_basic_block (); i++)
+    cfun->cfg->get_basic_block_by_idx (i)->flags |= BB_DUPLICATED;
 
-  for (i = first_new_block; i < (unsigned) last_basic_block; i++)
-    add_phi_args_after_copy_bb (BASIC_BLOCK (i));
+  for (i = first_new_block; i < (unsigned) cfun->cfg->get_last_basic_block (); i++)
+    add_phi_args_after_copy_bb (cfun->cfg->get_basic_block_by_idx (i));
 
-  for (i = first_new_block; i < (unsigned) last_basic_block; i++)
-    BASIC_BLOCK (i)->flags &= ~BB_DUPLICATED;
+  for (i = first_new_block; i < (unsigned) cfun->cfg->get_last_basic_block (); i++)
+    cfun->cfg->get_basic_block_by_idx (i)->flags &= ~BB_DUPLICATED;
 }
 
 
@@ -756,7 +756,7 @@ gimple_duplicate_loop_to_header_edge (struct loop *loop, edge e,
     verify_loop_closed_ssa (true);
 #endif
 
-  first_new_block = last_basic_block;
+  first_new_block = cfun->cfg->get_last_basic_block ();
   if (!duplicate_loop_to_header_edge (loop, e, ndupl, wont_exit,
 				      orig, to_remove, flags))
     return false;
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c
index 090e114..5175dc6 100644
--- a/gcc/tree-ssa-loop-niter.c
+++ b/gcc/tree-ssa-loop-niter.c
@@ -415,7 +415,7 @@ bound_difference (struct loop *loop, tree x, tree y, bounds *bnds)
   /* Now walk the dominators of the loop header and use the entry
      guards to refine the estimates.  */
   for (bb = loop->header;
-       bb != ENTRY_BLOCK_PTR && cnt < MAX_DOMINATORS_TO_WALK;
+       bb != cfun->cfg->get_entry_block () && cnt < MAX_DOMINATORS_TO_WALK;
        bb = get_immediate_dominator (CDI_DOMINATORS, bb))
     {
       if (!single_pred_p (bb))
@@ -1685,7 +1685,7 @@ simplify_using_initial_conditions (struct loop *loop, tree expr)
      the number of BBs times the number of loops in degenerate
      cases.  */
   for (bb = loop->header;
-       bb != ENTRY_BLOCK_PTR && cnt < MAX_DOMINATORS_TO_WALK;
+       bb != cfun->cfg->get_entry_block () && cnt < MAX_DOMINATORS_TO_WALK;
        bb = get_immediate_dominator (CDI_DOMINATORS, bb))
     {
       if (!single_pred_p (bb))
diff --git a/gcc/tree-ssa-loop-prefetch.c b/gcc/tree-ssa-loop-prefetch.c
index 4d31304..55646b7 100644
--- a/gcc/tree-ssa-loop-prefetch.c
+++ b/gcc/tree-ssa-loop-prefetch.c
@@ -1272,7 +1272,7 @@ may_use_storent_in_loop_p (struct loop *loop)
 
       FOR_EACH_VEC_ELT (exits, i, exit)
 	if ((exit->flags & EDGE_ABNORMAL)
-	    && exit->dest == EXIT_BLOCK_PTR)
+	    && exit->dest == cfun->cfg->get_exit_block ())
 	  ret = false;
 
       exits.release ();
diff --git a/gcc/tree-ssa-loop-unswitch.c b/gcc/tree-ssa-loop-unswitch.c
index 5c32b56..0f1b038 100644
--- a/gcc/tree-ssa-loop-unswitch.c
+++ b/gcc/tree-ssa-loop-unswitch.c
@@ -187,7 +187,7 @@ simplify_using_entry_checks (struct loop *loop, tree cond)
 	return cond;
 
       e = single_pred_edge (e->src);
-      if (e->src == ENTRY_BLOCK_PTR)
+      if (e->src == cfun->cfg->get_entry_block ())
 	return cond;
     }
 }
diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c
index a94172d..f4e1757 100644
--- a/gcc/tree-ssa-math-opts.c
+++ b/gcc/tree-ssa-math-opts.c
@@ -276,7 +276,7 @@ register_division_in (basic_block bb)
   if (!occ)
     {
       occ = occ_new (bb, NULL);
-      insert_bb (occ, ENTRY_BLOCK_PTR, &occ_head);
+      insert_bb (occ, cfun->cfg->get_entry_block (), &occ_head);
     }
 
   occ->bb_has_division = true;
@@ -503,14 +503,14 @@ execute_cse_reciprocals (void)
 
   occ_pool = create_alloc_pool ("dominators for recip",
 				sizeof (struct occurrence),
-				n_basic_blocks / 3 + 1);
+				cfun->cfg->get_n_basic_blocks () / 3 + 1);
 
   memset (&reciprocal_stats, 0, sizeof (reciprocal_stats));
   calculate_dominance_info (CDI_DOMINATORS);
   calculate_dominance_info (CDI_POST_DOMINATORS);
 
 #ifdef ENABLE_CHECKING
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     gcc_assert (!bb->aux);
 #endif
 
@@ -523,7 +523,7 @@ execute_cse_reciprocals (void)
 	  execute_cse_reciprocals_1 (NULL, name);
       }
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator gsi;
       gimple phi;
@@ -1384,7 +1384,7 @@ execute_cse_sincos (void)
   calculate_dominance_info (CDI_DOMINATORS);
   memset (&sincos_stats, 0, sizeof (sincos_stats));
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator gsi;
       bool cleanup_eh = false;
@@ -1856,7 +1856,7 @@ execute_optimize_bswap (void)
 
   memset (&bswap_stats, 0, sizeof (bswap_stats));
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator gsi;
 
@@ -2679,7 +2679,7 @@ execute_optimize_widening_mul (void)
 
   memset (&widen_mul_stats, 0, sizeof (widen_mul_stats));
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator gsi;
 
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index 5e99678..0bdb1dc 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -309,7 +309,7 @@ tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads)
      outer ones, and also that we do not try to visit a removed
      block.  */
   bb_order = blocks_in_phiopt_order ();
-  n = n_basic_blocks - NUM_FIXED_BLOCKS;
+  n = cfun->cfg->get_n_basic_blocks () - NUM_FIXED_BLOCKS;
 
   for (i = 0; i < n; i++)
     {
@@ -484,18 +484,18 @@ basic_block *
 blocks_in_phiopt_order (void)
 {
   basic_block x, y;
-  basic_block *order = XNEWVEC (basic_block, n_basic_blocks);
-  unsigned n = n_basic_blocks - NUM_FIXED_BLOCKS;
+  basic_block *order = XNEWVEC (basic_block, cfun->cfg->get_n_basic_blocks ());
+  unsigned n = cfun->cfg->get_n_basic_blocks () - NUM_FIXED_BLOCKS;
   unsigned np, i;
-  sbitmap visited = sbitmap_alloc (last_basic_block);
+  sbitmap visited = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
 
 #define MARK_VISITED(BB) (bitmap_set_bit (visited, (BB)->index))
 #define VISITED_P(BB) (bitmap_bit_p (visited, (BB)->index))
 
   bitmap_clear (visited);
 
-  MARK_VISITED (ENTRY_BLOCK_PTR);
-  FOR_EACH_BB (x)
+  MARK_VISITED (cfun->cfg->get_entry_block ());
+  FOR_EACH_BB_CFG (x, cfun->cfg)
     {
       if (VISITED_P (x))
 	continue;
@@ -1447,7 +1447,7 @@ get_non_trapping (void)
   walk_data.block_local_data_size = 0;
 
   init_walk_dominator_tree (&walk_data);
-  walk_dominator_tree (&walk_data, ENTRY_BLOCK_PTR);
+  walk_dominator_tree (&walk_data, cfun->cfg->get_entry_block ());
   fini_walk_dominator_tree (&walk_data);
   seen_ssa_names.dispose ();
 
diff --git a/gcc/tree-ssa-phiprop.c b/gcc/tree-ssa-phiprop.c
index 96d7ba6..ffe8cc3 100644
--- a/gcc/tree-ssa-phiprop.c
+++ b/gcc/tree-ssa-phiprop.c
@@ -374,7 +374,7 @@ tree_ssa_phiprop (void)
 
   /* Walk the dominator tree in preorder.  */
   bbs = get_all_dominated_blocks (CDI_DOMINATORS,
-				  single_succ (ENTRY_BLOCK_PTR));
+				  single_succ (cfun->cfg->get_entry_block ()));
   FOR_EACH_VEC_ELT (bbs, i, bb)
     for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
       did_something |= propagate_with_phi (bb, gsi_stmt (gsi), phivn, n);
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index 345ebcc..b6312fa 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -2441,10 +2441,10 @@ compute_antic (void)
 
   /* If any predecessor edges are abnormal, we punt, so antic_in is empty.
      We pre-build the map of blocks with incoming abnormal edges here.  */
-  has_abnormal_preds = sbitmap_alloc (last_basic_block);
+  has_abnormal_preds = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
   bitmap_clear (has_abnormal_preds);
 
-  FOR_ALL_BB (block)
+  FOR_ALL_BB_CFG (block, cfun->cfg)
     {
       edge_iterator ei;
       edge e;
@@ -2468,9 +2468,9 @@ compute_antic (void)
     }
 
   /* At the exit block we anticipate nothing.  */
-  BB_VISITED (EXIT_BLOCK_PTR) = 1;
+  BB_VISITED (cfun->cfg->get_exit_block ()) = 1;
 
-  changed_blocks = sbitmap_alloc (last_basic_block + 1);
+  changed_blocks = sbitmap_alloc (cfun->cfg->get_last_basic_block () + 1);
   bitmap_ones (changed_blocks);
   while (changed)
     {
@@ -2486,7 +2486,7 @@ compute_antic (void)
 	{
 	  if (bitmap_bit_p (changed_blocks, postorder[i]))
 	    {
-	      basic_block block = BASIC_BLOCK (postorder[i]);
+	      basic_block block = cfun->cfg->get_basic_block_by_idx (postorder[i]);
 	      changed |= compute_antic_aux (block,
 					    bitmap_bit_p (has_abnormal_preds,
 						      block->index));
@@ -2515,7 +2515,7 @@ compute_antic (void)
 	    {
 	      if (bitmap_bit_p (changed_blocks, postorder[i]))
 		{
-		  basic_block block = BASIC_BLOCK (postorder[i]);
+		  basic_block block = cfun->cfg->get_basic_block_by_idx (postorder[i]);
 		  changed
 		    |= compute_partial_antic_aux (block,
 						  bitmap_bit_p (has_abnormal_preds,
@@ -3656,7 +3656,7 @@ insert (void)
   basic_block bb;
   int num_iterations = 0;
 
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     NEW_SETS (bb) = bitmap_set_new ();
 
   while (new_stuff)
@@ -3664,7 +3664,7 @@ insert (void)
       num_iterations++;
       if (dump_file && dump_flags & TDF_DETAILS)
 	fprintf (dump_file, "Starting insert iteration %d\n", num_iterations);
-      new_stuff = insert_aux (ENTRY_BLOCK_PTR);
+      new_stuff = insert_aux (cfun->cfg->get_entry_block ());
     }
   statistics_histogram_event (cfun, "insert iterations", num_iterations);
 }
@@ -3703,24 +3703,24 @@ compute_avail (void)
 
       e = get_or_alloc_expr_for_name (name);
       add_to_value (get_expr_value_id (e), e);
-      bitmap_insert_into_set (TMP_GEN (ENTRY_BLOCK_PTR), e);
-      bitmap_value_insert_into_set (AVAIL_OUT (ENTRY_BLOCK_PTR), e);
+      bitmap_insert_into_set (TMP_GEN (cfun->cfg->get_entry_block ()), e);
+      bitmap_value_insert_into_set (AVAIL_OUT (cfun->cfg->get_entry_block ()), e);
     }
 
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
-      print_bitmap_set (dump_file, TMP_GEN (ENTRY_BLOCK_PTR),
+      print_bitmap_set (dump_file, TMP_GEN (cfun->cfg->get_entry_block ()),
 			"tmp_gen", ENTRY_BLOCK);
-      print_bitmap_set (dump_file, AVAIL_OUT (ENTRY_BLOCK_PTR),
+      print_bitmap_set (dump_file, AVAIL_OUT (cfun->cfg->get_entry_block ()),
 			"avail_out", ENTRY_BLOCK);
     }
 
   /* Allocate the worklist.  */
-  worklist = XNEWVEC (basic_block, n_basic_blocks);
+  worklist = XNEWVEC (basic_block, cfun->cfg->get_n_basic_blocks ());
 
   /* Seed the algorithm by putting the dominator children of the entry
      block on the worklist.  */
-  for (son = first_dom_son (CDI_DOMINATORS, ENTRY_BLOCK_PTR);
+  for (son = first_dom_son (CDI_DOMINATORS, cfun->cfg->get_entry_block ());
        son;
        son = next_dom_son (CDI_DOMINATORS, son))
     worklist[sp++] = son;
@@ -4427,7 +4427,7 @@ eliminate (void)
   walk_data.global_data = NULL;
   walk_data.block_local_data_size = 0;
   init_walk_dominator_tree (&walk_data);
-  walk_dominator_tree (&walk_data, ENTRY_BLOCK_PTR);
+  walk_dominator_tree (&walk_data, cfun->cfg->get_entry_block ());
   fini_walk_dominator_tree (&walk_data);
 
   el_avail.release ();
@@ -4648,7 +4648,7 @@ init_pre (void)
   connect_infinite_loops_to_exit ();
   memset (&pre_stats, 0, sizeof (pre_stats));
 
-  postorder = XNEWVEC (int, n_basic_blocks);
+  postorder = XNEWVEC (int, cfun->cfg->get_n_basic_blocks ());
   postorder_num = inverted_post_order_compute (postorder);
 
   alloc_aux_for_blocks (sizeof (struct bb_bitmap_sets));
@@ -4663,7 +4663,7 @@ init_pre (void)
 				       sizeof (struct bitmap_set), 30);
   pre_expr_pool = create_alloc_pool ("pre_expr nodes",
 				     sizeof (struct pre_expr_d), 30);
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       EXP_GEN (bb) = bitmap_set_new ();
       PHI_GEN (bb) = bitmap_set_new ();
@@ -4724,7 +4724,7 @@ do_pre (void)
      fixed, don't run it when he have an incredibly large number of
      bb's.  If we aren't going to run insert, there is no point in
      computing ANTIC, either, even though it's plenty fast.  */
-  if (n_basic_blocks < 4000)
+  if (cfun->cfg->get_n_basic_blocks () < 4000)
     {
       compute_antic ();
       insert ();
diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c
index afd7233..8221f48 100644
--- a/gcc/tree-ssa-propagate.c
+++ b/gcc/tree-ssa-propagate.c
@@ -175,7 +175,7 @@ cfg_blocks_add (basic_block bb)
 {
   bool head = false;
 
-  gcc_assert (bb != ENTRY_BLOCK_PTR && bb != EXIT_BLOCK_PTR);
+  gcc_assert (bb != cfun->cfg->get_entry_block () && bb != cfun->cfg->get_exit_block ());
   gcc_assert (!bitmap_bit_p (bb_in_list, bb->index));
 
   if (cfg_blocks_empty_p ())
@@ -270,7 +270,7 @@ static void
 add_control_edge (edge e)
 {
   basic_block bb = e->dest;
-  if (bb == EXIT_BLOCK_PTR)
+  if (bb == cfun->cfg->get_exit_block ())
     return;
 
   /* If the edge had already been executed, skip it.  */
@@ -399,7 +399,7 @@ simulate_block (basic_block block)
   gimple_stmt_iterator gsi;
 
   /* There is nothing to do for the exit block.  */
-  if (block == EXIT_BLOCK_PTR)
+  if (block == cfun->cfg->get_exit_block ())
     return;
 
   if (dump_file && (dump_flags & TDF_DETAILS))
@@ -480,10 +480,10 @@ ssa_prop_init (void)
   vec_alloc (interesting_ssa_edges, 20);
   vec_alloc (varying_ssa_edges, 20);
 
-  executable_blocks = sbitmap_alloc (last_basic_block);
+  executable_blocks = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
   bitmap_clear (executable_blocks);
 
-  bb_in_list = sbitmap_alloc (last_basic_block);
+  bb_in_list = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
   bitmap_clear (bb_in_list);
 
   if (dump_file && (dump_flags & TDF_DETAILS))
@@ -494,7 +494,7 @@ ssa_prop_init (void)
 
   /* Initially assume that every edge in the CFG is not executable.
      (including the edges coming out of ENTRY_BLOCK_PTR).  */
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator si;
 
@@ -510,7 +510,7 @@ ssa_prop_init (void)
 
   /* Seed the algorithm by adding the successors of the entry block to the
      edge worklist.  */
-  FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR->succs)
+  FOR_EACH_EDGE (e, ei, cfun->cfg->get_entry_block ()->succs)
     add_control_edge (e);
 }
 
@@ -1083,7 +1083,7 @@ substitute_and_fold (ssa_prop_get_value_fn get_value_fn,
       }
 
   /* Propagate into all uses and fold.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator i;
 
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c
index 8e13763..4456948 100644
--- a/gcc/tree-ssa-reassoc.c
+++ b/gcc/tree-ssa-reassoc.c
@@ -1167,7 +1167,7 @@ build_and_add_sum (tree type, tree op1, tree op2, enum tree_code opcode)
     {
       gimple first_stmt;
       unsigned uid;
-      gsi = gsi_after_labels (single_succ (ENTRY_BLOCK_PTR));
+      gsi = gsi_after_labels (single_succ (cfun->cfg->get_entry_block ()));
       first_stmt = gsi_stmt (gsi);
       uid = first_stmt ? gimple_uid (first_stmt) : 1;
       gimple_set_uid (sum, uid);
@@ -1952,7 +1952,7 @@ update_range_test (struct range_entry *range, struct range_entry *otherrange,
 {
   operand_entry_t oe = (*ops)[range->idx];
   tree op = oe->op;
-  gimple stmt = op ? SSA_NAME_DEF_STMT (op) : last_stmt (BASIC_BLOCK (oe->id));
+  gimple stmt = op ? SSA_NAME_DEF_STMT (op) : last_stmt (cfun->cfg->get_basic_block_by_idx (oe->id));
   location_t loc = gimple_location (stmt);
   tree optype = op ? TREE_TYPE (op) : boolean_type_node;
   tree tem = build_range_check (loc, optype, exp, in_p, low, high);
@@ -2106,7 +2106,7 @@ update_range_test (struct range_entry *range, struct range_entry *otherrange,
 	    {
 	      /* If range test was a GIMPLE_COND, simply change it
 		 into an always false or always true condition.  */
-	      stmt = last_stmt (BASIC_BLOCK (oe->id));
+	      stmt = last_stmt (cfun->cfg->get_basic_block_by_idx (oe->id));
 	      if (oe->rank == BIT_IOR_EXPR)
 		gimple_cond_make_false (stmt);
 	      else
@@ -2147,7 +2147,7 @@ optimize_range_tests (enum tree_code opcode,
       oe = (*ops)[i];
       ranges[i].idx = i;
       init_range_entry (ranges + i, oe->op,
-			oe->op ? NULL : last_stmt (BASIC_BLOCK (oe->id)));
+			oe->op ? NULL : last_stmt (cfun->cfg->get_basic_block_by_idx (oe->id)));
       /* For | invert it now, we will invert it again before emitting
 	 the optimized expression.  */
       if (opcode == BIT_IOR_EXPR
@@ -4324,9 +4324,9 @@ debug_ops_vector (vec<operand_entry_t> ops)
 static void
 do_reassoc (void)
 {
-  break_up_subtract_bb (ENTRY_BLOCK_PTR);
+  break_up_subtract_bb (cfun->cfg->get_entry_block ());
   renumber_gimple_stmt_uids ();
-  reassociate_bb (EXIT_BLOCK_PTR);
+  reassociate_bb (cfun->cfg->get_exit_block ());
 }
 
 /* Initialize the reassociation pass.  */
@@ -4336,7 +4336,7 @@ init_reassoc (void)
 {
   int i;
   long rank = 2;
-  int *bbs = XNEWVEC (int, n_basic_blocks - NUM_FIXED_BLOCKS);
+  int *bbs = XNEWVEC (int, cfun->cfg->get_n_basic_blocks () - NUM_FIXED_BLOCKS);
 
   /* Find the loops, so that we can prevent moving calculations in
      them.  */
@@ -4351,7 +4351,7 @@ init_reassoc (void)
   /* Reverse RPO (Reverse Post Order) will give us something where
      deeper loops come later.  */
   pre_and_rev_post_order_compute (NULL, bbs, false);
-  bb_rank = XCNEWVEC (long, last_basic_block);
+  bb_rank = XCNEWVEC (long, cfun->cfg->get_last_basic_block ());
   operand_rank = pointer_map_create ();
 
   /* Give each default definition a distinct rank.  This includes
@@ -4366,7 +4366,7 @@ init_reassoc (void)
     }
 
   /* Set up rank for each BB  */
-  for (i = 0; i < n_basic_blocks - NUM_FIXED_BLOCKS; i++)
+  for (i = 0; i < cfun->cfg->get_n_basic_blocks () - NUM_FIXED_BLOCKS; i++)
     bb_rank[bbs[i]] = ++rank  << 16;
 
   free (bbs);
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 0e7a74c..c6189ca 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -3957,14 +3957,14 @@ init_scc_vn (void)
 
   shared_lookup_phiargs.create (0);
   shared_lookup_references.create (0);
-  rpo_numbers = XNEWVEC (int, last_basic_block);
-  rpo_numbers_temp = XNEWVEC (int, n_basic_blocks - NUM_FIXED_BLOCKS);
+  rpo_numbers = XNEWVEC (int, cfun->cfg->get_last_basic_block ());
+  rpo_numbers_temp = XNEWVEC (int, cfun->cfg->get_n_basic_blocks () - NUM_FIXED_BLOCKS);
   pre_and_rev_post_order_compute (NULL, rpo_numbers_temp, false);
 
   /* RPO numbers is an array of rpo ordering, rpo[i] = bb means that
      the i'th block in RPO order is bb.  We want to map bb's to RPO
      numbers, so we need to rearrange this array.  */
-  for (j = 0; j < n_basic_blocks - NUM_FIXED_BLOCKS; j++)
+  for (j = 0; j < cfun->cfg->get_n_basic_blocks () - NUM_FIXED_BLOCKS; j++)
     rpo_numbers[rpo_numbers_temp[j]] = j;
 
   XDELETE (rpo_numbers_temp);
diff --git a/gcc/tree-ssa-sink.c b/gcc/tree-ssa-sink.c
index 87a0a59..00d5288 100644
--- a/gcc/tree-ssa-sink.c
+++ b/gcc/tree-ssa-sink.c
@@ -166,7 +166,7 @@ nearest_common_dominator_of_uses (gimple stmt, bool *debug_stmts)
 	    }
 
 	  /* Short circuit. Nothing dominates the entry block.  */
-	  if (useblock == ENTRY_BLOCK_PTR)
+	  if (useblock == cfun->cfg->get_entry_block ())
 	    {
 	      BITMAP_FREE (blocks);
 	      return NULL;
@@ -174,10 +174,10 @@ nearest_common_dominator_of_uses (gimple stmt, bool *debug_stmts)
 	  bitmap_set_bit (blocks, useblock->index);
 	}
     }
-  commondom = BASIC_BLOCK (bitmap_first_set_bit (blocks));
+  commondom = cfun->cfg->get_basic_block_by_idx (bitmap_first_set_bit (blocks));
   EXECUTE_IF_SET_IN_BITMAP (blocks, 0, j, bi)
     commondom = nearest_common_dominator (CDI_DOMINATORS, commondom,
-					  BASIC_BLOCK (j));
+					  cfun->cfg->get_basic_block_by_idx (j));
   BITMAP_FREE (blocks);
   return commondom;
 }
@@ -564,7 +564,7 @@ execute_sink_code (void)
   memset (&sink_stats, 0, sizeof (sink_stats));
   calculate_dominance_info (CDI_DOMINATORS);
   calculate_dominance_info (CDI_POST_DOMINATORS);
-  sink_code_in_bb (EXIT_BLOCK_PTR);
+  sink_code_in_bb (cfun->cfg->get_exit_block ());
   statistics_counter_event (cfun, "Sunk statements", sink_stats.sunk);
   free_dominance_info (CDI_POST_DOMINATORS);
   remove_fake_exit_edges ();
diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c
index c0f9ccd..722e679 100644
--- a/gcc/tree-ssa-strlen.c
+++ b/gcc/tree-ssa-strlen.c
@@ -2040,7 +2040,7 @@ tree_ssa_strlen (void)
   init_walk_dominator_tree (&walk_data);
 
   /* Recursively walk the dominator tree.  */
-  walk_dominator_tree (&walk_data, ENTRY_BLOCK_PTR);
+  walk_dominator_tree (&walk_data, cfun->cfg->get_entry_block ());
 
   /* Finalize the dominator walker.  */
   fini_walk_dominator_tree (&walk_data);
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index 9eb06f6..db173db 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -6759,7 +6759,7 @@ compute_points_to_sets (void)
   intra_create_variable_infos ();
 
   /* Now walk all statements and build the constraint set.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator gsi;
 
@@ -6814,7 +6814,7 @@ compute_points_to_sets (void)
     }
 
   /* Compute the call-used/clobbered sets.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator gsi;
 
diff --git a/gcc/tree-ssa-tail-merge.c b/gcc/tree-ssa-tail-merge.c
index 317fe4c..80f210b 100644
--- a/gcc/tree-ssa-tail-merge.c
+++ b/gcc/tree-ssa-tail-merge.c
@@ -440,7 +440,7 @@ same_succ_hash (const_same_succ e)
   int flags;
   unsigned int i;
   unsigned int first = bitmap_first_set_bit (e->bbs);
-  basic_block bb = BASIC_BLOCK (first);
+  basic_block bb = cfun->cfg->get_basic_block_by_idx (first);
   int size = 0;
   gimple_stmt_iterator gsi;
   gimple stmt;
@@ -488,8 +488,8 @@ same_succ_hash (const_same_succ e)
 
   EXECUTE_IF_SET_IN_BITMAP (e->succs, 0, s, bs)
     {
-      int n = find_edge (bb, BASIC_BLOCK (s))->dest_idx;
-      for (gsi = gsi_start_phis (BASIC_BLOCK (s)); !gsi_end_p (gsi);
+      int n = find_edge (bb, cfun->cfg->get_basic_block_by_idx (s))->dest_idx;
+      for (gsi = gsi_start_phis (cfun->cfg->get_basic_block_by_idx (s)); !gsi_end_p (gsi);
 	   gsi_next (&gsi))
 	{
 	  gimple phi = gsi_stmt (gsi);
@@ -558,8 +558,8 @@ same_succ_def::equal (const value_type *e1, const compare_type *e2)
   first1 = bitmap_first_set_bit (e1->bbs);
   first2 = bitmap_first_set_bit (e2->bbs);
 
-  bb1 = BASIC_BLOCK (first1);
-  bb2 = BASIC_BLOCK (first2);
+  bb1 = cfun->cfg->get_basic_block_by_idx (first1);
+  bb2 = cfun->cfg->get_basic_block_by_idx (first2);
 
   if (BB_SIZE (bb1) != BB_SIZE (bb2))
     return 0;
@@ -740,7 +740,7 @@ find_same_succ (void)
   same_succ same = same_succ_alloc ();
   basic_block bb;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       find_same_succ_bb (bb, &same);
       if (same == NULL)
@@ -756,11 +756,11 @@ static void
 init_worklist (void)
 {
   alloc_aux_for_blocks (sizeof (struct aux_bb_info));
-  same_succ_htab.create (n_basic_blocks);
-  same_succ_edge_flags = XCNEWVEC (int, last_basic_block);
+  same_succ_htab.create (cfun->cfg->get_n_basic_blocks ());
+  same_succ_edge_flags = XCNEWVEC (int, cfun->cfg->get_last_basic_block ());
   deleted_bbs = BITMAP_ALLOC (NULL);
   deleted_bb_preds = BITMAP_ALLOC (NULL);
-  worklist.create (n_basic_blocks);
+  worklist.create (cfun->cfg->get_n_basic_blocks ());
   find_same_succ ();
 
   if (dump_file && (dump_flags & TDF_DETAILS))
@@ -820,7 +820,7 @@ same_succ_flush_bbs (bitmap bbs)
   bitmap_iterator bi;
 
   EXECUTE_IF_SET_IN_BITMAP (bbs, 0, i, bi)
-    same_succ_flush_bb (BASIC_BLOCK (i));
+    same_succ_flush_bb (cfun->cfg->get_basic_block_by_idx (i));
 }
 
 /* Release the last vdef in BB, either normal or phi result.  */
@@ -873,7 +873,7 @@ update_worklist (void)
   same = same_succ_alloc ();
   EXECUTE_IF_SET_IN_BITMAP (deleted_bb_preds, 0, i, bi)
     {
-      bb = BASIC_BLOCK (i);
+      bb = cfun->cfg->get_basic_block_by_idx (i);
       gcc_assert (bb != NULL);
       find_same_succ_bb (bb, &same);
       if (same == NULL)
@@ -988,7 +988,7 @@ static vec<bb_cluster> all_clusters;
 static void
 alloc_cluster_vectors (void)
 {
-  all_clusters.create (n_basic_blocks);
+  all_clusters.create (cfun->cfg->get_n_basic_blocks ());
 }
 
 /* Reset all cluster vectors.  */
@@ -1001,7 +1001,7 @@ reset_cluster_vectors (void)
   for (i = 0; i < all_clusters.length (); ++i)
     delete_cluster (all_clusters[i]);
   all_clusters.truncate (0);
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     BB_CLUSTER (bb) = NULL;
 }
 
@@ -1061,7 +1061,7 @@ set_cluster (basic_block bb1, basic_block bb2)
       merge = BB_CLUSTER (bb1);
       merge_clusters (merge, old);
       EXECUTE_IF_SET_IN_BITMAP (old->bbs, 0, i, bi)
-	BB_CLUSTER (BASIC_BLOCK (i)) = merge;
+	BB_CLUSTER (cfun->cfg->get_basic_block_by_idx (i)) = merge;
       all_clusters[old->index] = NULL;
       update_rep_bb (merge, old->rep_bb);
       delete_cluster (old);
@@ -1296,7 +1296,7 @@ same_phi_alternatives (same_succ same_succ, basic_block bb1, basic_block bb2)
 
   EXECUTE_IF_SET_IN_BITMAP (same_succ->succs, 0, s, bs)
     {
-      succ = BASIC_BLOCK (s);
+      succ = cfun->cfg->get_basic_block_by_idx (s);
       e1 = find_edge (bb1, succ);
       e2 = find_edge (bb2, succ);
       if (e1->flags & EDGE_COMPLEX
@@ -1382,7 +1382,7 @@ find_clusters_1 (same_succ same_succ)
 
   EXECUTE_IF_SET_IN_BITMAP (same_succ->bbs, 0, i, bi)
     {
-      bb1 = BASIC_BLOCK (i);
+      bb1 = cfun->cfg->get_basic_block_by_idx (i);
 
       /* TODO: handle blocks with phi-nodes.  We'll have to find corresponding
 	 phi-nodes in bb1 and bb2, with the same alternatives for the same
@@ -1393,7 +1393,7 @@ find_clusters_1 (same_succ same_succ)
       nr_comparisons = 0;
       EXECUTE_IF_SET_IN_BITMAP (same_succ->bbs, i + 1, j, bj)
 	{
-	  bb2 = BASIC_BLOCK (j);
+	  bb2 = cfun->cfg->get_basic_block_by_idx (j);
 
 	  if (bb_has_non_vop_phi (bb2))
 	    continue;
@@ -1529,7 +1529,7 @@ apply_clusters (void)
       bitmap_clear_bit (c->bbs, bb2->index);
       EXECUTE_IF_SET_IN_BITMAP (c->bbs, 0, j, bj)
 	{
-	  bb1 = BASIC_BLOCK (j);
+	  bb1 = cfun->cfg->get_basic_block_by_idx (j);
 	  bitmap_clear_bit (update_bbs, bb1->index);
 
 	  replace_block_by (bb1, bb2);
@@ -1589,7 +1589,7 @@ update_debug_stmts (void)
       gimple stmt;
       gimple_stmt_iterator gsi;
 
-      bb = BASIC_BLOCK (i);
+      bb = cfun->cfg->get_basic_block_by_idx (i);
       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	{
 	  stmt = gsi_stmt (gsi);
diff --git a/gcc/tree-ssa-ter.c b/gcc/tree-ssa-ter.c
index 2a2e143..793716f 100644
--- a/gcc/tree-ssa-ter.c
+++ b/gcc/tree-ssa-ter.c
@@ -720,7 +720,7 @@ find_replaceable_exprs (var_map map)
 
   bitmap_obstack_initialize (&ter_bitmap_obstack);
   table = new_temp_expr_table (map);
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       find_replaceable_in_bb (table, bb);
       gcc_checking_assert (bitmap_empty_p (table->partition_in_use));
diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c
index 0e4cbc9..9a0525b 100644
--- a/gcc/tree-ssa-threadupdate.c
+++ b/gcc/tree-ssa-threadupdate.c
@@ -1163,7 +1163,7 @@ mark_threaded_blocks (bitmap threaded_blocks)
     {
       EXECUTE_IF_SET_IN_BITMAP (tmp, 0, i, bi)
 	{
-	  bb = BASIC_BLOCK (i);
+	  bb = cfun->cfg->get_basic_block_by_idx (i);
 	  if (EDGE_COUNT (bb->preds) > 1
 	      && !redirection_block_p (bb))
 	    {
@@ -1222,7 +1222,7 @@ thread_through_all_blocks (bool may_peel_loop_headers)
      loop structure.  */
   EXECUTE_IF_SET_IN_BITMAP (threaded_blocks, 0, i, bi)
     {
-      basic_block bb = BASIC_BLOCK (i);
+      basic_block bb = cfun->cfg->get_basic_block_by_idx (i);
 
       if (EDGE_COUNT (bb->preds) > 0)
 	retval |= thread_block (bb, true);
diff --git a/gcc/tree-ssa-uncprop.c b/gcc/tree-ssa-uncprop.c
index 1fbc524..7707cf9 100644
--- a/gcc/tree-ssa-uncprop.c
+++ b/gcc/tree-ssa-uncprop.c
@@ -54,7 +54,7 @@ associate_equivalences_with_edges (void)
 
   /* Walk over each block.  If the block ends with a control statement,
      then it might create a useful equivalence.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator gsi = gsi_last_bb (bb);
       gimple stmt;
@@ -168,7 +168,7 @@ associate_equivalences_with_edges (void)
 	      && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (cond))
 	    {
 	      int i, n_labels = gimple_switch_num_labels (stmt);
-	      tree *info = XCNEWVEC (tree, last_basic_block);
+	      tree *info = XCNEWVEC (tree, cfun->cfg->get_last_basic_block ());
 
 	      /* Walk over the case label vector.  Record blocks
 		 which are reached by a single case label which represents
@@ -188,7 +188,7 @@ associate_equivalences_with_edges (void)
 
 	      /* Now walk over the blocks to determine which ones were
 		 marked as being reached by a useful case label.  */
-	      for (i = 0; i < n_basic_blocks; i++)
+	      for (i = 0; i < cfun->cfg->get_n_basic_blocks (); i++)
 		{
 		  tree node = info[i];
 
@@ -203,7 +203,7 @@ associate_equivalences_with_edges (void)
 		      equivalency = XNEW (struct edge_equivalency);
 		      equivalency->rhs = x;
 		      equivalency->lhs = cond;
-		      find_edge (bb, BASIC_BLOCK (i))->aux = equivalency;
+		      find_edge (bb, cfun->cfg->get_basic_block_by_idx (i))->aux = equivalency;
 		    }
 		}
 	      free (info);
@@ -392,7 +392,7 @@ tree_ssa_uncprop (void)
 
   /* Recursively walk the dominator tree undoing unprofitable
      constant/copy propagations.  */
-  walk_dominator_tree (&walk_data, ENTRY_BLOCK_PTR);
+  walk_dominator_tree (&walk_data, cfun->cfg->get_entry_block ());
 
   /* Finalize and clean up.  */
   fini_walk_dominator_tree (&walk_data);
@@ -402,7 +402,7 @@ tree_ssa_uncprop (void)
      and cleanup the AUX field on the edges.  */
   val_ssa_equiv.dispose ();
   equiv_stack.release ();
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       edge e;
       edge_iterator ei;
diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c
index 9a726f1..ba2e1ad 100644
--- a/gcc/tree-ssa-uninit.c
+++ b/gcc/tree-ssa-uninit.c
@@ -184,14 +184,14 @@ compute_uninit_opnds_pos (gimple phi)
 static inline basic_block
 find_pdom (basic_block block)
 {
-   if (block == EXIT_BLOCK_PTR)
-     return EXIT_BLOCK_PTR;
+   if (block == cfun->cfg->get_exit_block ())
+     return cfun->cfg->get_exit_block ();
    else
      {
        basic_block bb
            = get_immediate_dominator (CDI_POST_DOMINATORS, block);
        if (! bb)
-         return EXIT_BLOCK_PTR;
+         return cfun->cfg->get_exit_block ();
        return bb;
      }
 }
@@ -202,13 +202,13 @@ find_pdom (basic_block block)
 static inline basic_block
 find_dom (basic_block block)
 {
-   if (block == ENTRY_BLOCK_PTR)
-     return ENTRY_BLOCK_PTR;
+   if (block == cfun->cfg->get_entry_block ())
+     return cfun->cfg->get_entry_block ();
    else
      {
        basic_block bb = get_immediate_dominator (CDI_DOMINATORS, block);
        if (! bb)
-         return ENTRY_BLOCK_PTR;
+         return cfun->cfg->get_entry_block ();
        return bb;
      }
 }
@@ -323,7 +323,7 @@ compute_control_dep_chain (basic_block bb, basic_block dep_bb,
 
           cd_bb = find_pdom (cd_bb);
           post_dom_check++;
-          if (cd_bb == EXIT_BLOCK_PTR || post_dom_check > MAX_POSTDOM_CHECK)
+          if (cd_bb == cfun->cfg->get_exit_block () || post_dom_check > MAX_POSTDOM_CHECK)
             break;
         }
       cur_cd_chain->pop ();
@@ -1994,7 +1994,7 @@ execute_late_warn_uninitialized (void)
   added_to_worklist = pointer_set_create ();
 
   /* Initialize worklist  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
       {
         gimple phi = gsi_stmt (gsi);
diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
index 2152067..05f4337 100644
--- a/gcc/tree-ssa.c
+++ b/gcc/tree-ssa.c
@@ -949,7 +949,7 @@ verify_ssa (bool check_modified_stmt)
 
   /* Now verify all the uses and make sure they agree with the definitions
      found in the previous pass.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       edge e;
       gimple phi;
@@ -1599,10 +1599,10 @@ warn_uninitialized_vars (bool warn_possibly_uninitialized)
   gimple_stmt_iterator gsi;
   basic_block bb;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       bool always_executed = dominated_by_p (CDI_POST_DOMINATORS,
-					     single_succ (ENTRY_BLOCK_PTR), bb);
+					     single_succ (cfun->cfg->get_entry_block ()), bb);
       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	{
 	  gimple stmt = gsi_stmt (gsi);
@@ -1907,7 +1907,7 @@ execute_update_addresses_taken (void)
 
   /* Collect into ADDRESSES_TAKEN all variables whose address is taken within
      the function body.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	{
@@ -2009,7 +2009,7 @@ execute_update_addresses_taken (void)
      variables and operands need to be rewritten to expose bare symbols.  */
   if (!bitmap_empty_p (suitable_for_renaming))
     {
-      FOR_EACH_BB (bb)
+      FOR_EACH_BB_CFG (bb, cfun->cfg)
 	for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi);)
 	  {
 	    gimple stmt = gsi_stmt (gsi);
diff --git a/gcc/tree-stdarg.c b/gcc/tree-stdarg.c
index 8ad9fc2..bbecadc 100644
--- a/gcc/tree-stdarg.c
+++ b/gcc/tree-stdarg.c
@@ -58,7 +58,7 @@ reachable_at_most_once (basic_block va_arg_bb, basic_block va_start_bb)
   if (! dominated_by_p (CDI_DOMINATORS, va_arg_bb, va_start_bb))
     return false;
 
-  visited = sbitmap_alloc (last_basic_block);
+  visited = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
   bitmap_clear (visited);
   ret = true;
 
@@ -88,7 +88,7 @@ reachable_at_most_once (basic_block va_arg_bb, basic_block va_start_bb)
 	  break;
 	}
 
-      gcc_assert (src != ENTRY_BLOCK_PTR);
+      gcc_assert (src != cfun->cfg->get_entry_block ());
 
       if (! bitmap_bit_p (visited, src->index))
 	{
@@ -522,7 +522,7 @@ check_all_va_list_escapes (struct stdarg_info *si)
 {
   basic_block bb;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator i;
 
@@ -689,7 +689,7 @@ execute_optimize_stdarg (void)
 			   || TREE_TYPE (cfun_va_list) == char_type_node);
   gcc_assert (is_gimple_reg_type (cfun_va_list) == va_list_simple_ptr);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator i;
 
@@ -799,7 +799,7 @@ execute_optimize_stdarg (void)
   memset (&wi, 0, sizeof (wi));
   wi.info = si.va_list_vars;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator i;
 
diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c
index 9ad7daf..b9a1239 100644
--- a/gcc/tree-switch-conversion.c
+++ b/gcc/tree-switch-conversion.c
@@ -1409,7 +1409,7 @@ do_switchconv (void)
 {
   basic_block bb;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
   {
     const char *failure_reason;
     gimple stmt = last_stmt (bb);
diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c
index c6581dc..c8572e6 100644
--- a/gcc/tree-tailcall.c
+++ b/gcc/tree-tailcall.c
@@ -796,7 +796,7 @@ eliminate_tail_call (struct tailcall *t)
 
   gcc_assert (is_gimple_call (stmt));
 
-  first = single_succ (ENTRY_BLOCK_PTR);
+  first = single_succ (cfun->cfg->get_entry_block ());
 
   /* Remove the code after call_gsi that will become unreachable.  The
      possibly unreachable code in other blocks is removed later in
@@ -817,9 +817,9 @@ eliminate_tail_call (struct tailcall *t)
 
   /* Number of executions of function has reduced by the tailcall.  */
   e = single_succ_edge (gsi_bb (t->call_gsi));
-  decrease_profile (EXIT_BLOCK_PTR, e->count, EDGE_FREQUENCY (e));
-  decrease_profile (ENTRY_BLOCK_PTR, e->count, EDGE_FREQUENCY (e));
-  if (e->dest != EXIT_BLOCK_PTR)
+  decrease_profile (cfun->cfg->get_exit_block (), e->count, EDGE_FREQUENCY (e));
+  decrease_profile (cfun->cfg->get_entry_block (), e->count, EDGE_FREQUENCY (e));
+  if (e->dest != cfun->cfg->get_exit_block ())
     decrease_profile (e->dest, e->count, EDGE_FREQUENCY (e));
 
   /* Replace the call by a jump to the start of function.  */
@@ -920,7 +920,7 @@ tree_optimize_tail_calls_1 (bool opt_tailcalls)
   bool phis_constructed = false;
   struct tailcall *tailcalls = NULL, *act, *next;
   bool changed = false;
-  basic_block first = single_succ (ENTRY_BLOCK_PTR);
+  basic_block first = single_succ (cfun->cfg->get_entry_block ());
   tree param;
   gimple stmt;
   edge_iterator ei;
@@ -930,7 +930,7 @@ tree_optimize_tail_calls_1 (bool opt_tailcalls)
   if (opt_tailcalls)
     opt_tailcalls = suitable_for_tail_call_opt_p ();
 
-  FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
+  FOR_EACH_EDGE (e, ei, cfun->cfg->get_exit_block ()->preds)
     {
       /* Only traverse the normal exits, i.e. those that end with return
 	 statement.  */
@@ -954,7 +954,7 @@ tree_optimize_tail_calls_1 (bool opt_tailcalls)
 	     or if there are existing degenerate PHI nodes.  */
 	  if (!single_pred_p (first)
 	      || !gimple_seq_empty_p (phi_nodes (first)))
-	    first = split_edge (single_succ_edge (ENTRY_BLOCK_PTR));
+	    first = split_edge (single_succ_edge (cfun->cfg->get_entry_block ()));
 
 	  /* Copy the args if needed.  */
 	  for (param = DECL_ARGUMENTS (current_function_decl);
@@ -1001,7 +1001,7 @@ tree_optimize_tail_calls_1 (bool opt_tailcalls)
   if (a_acc || m_acc)
     {
       /* Modify the remaining return statements.  */
-      FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
+      FOR_EACH_EDGE (e, ei, cfun->cfg->get_exit_block ()->preds)
 	{
 	  stmt = last_stmt (e->src);
 
diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c
index 516bd6f9..5293c7a 100644
--- a/gcc/tree-vect-generic.c
+++ b/gcc/tree-vect-generic.c
@@ -1436,7 +1436,7 @@ expand_vector_operations (void)
   basic_block bb;
   bool cfg_changed = false;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	{
diff --git a/gcc/tree-vectorizer.c b/gcc/tree-vectorizer.c
index 814f96c..40d0dae 100644
--- a/gcc/tree-vectorizer.c
+++ b/gcc/tree-vectorizer.c
@@ -171,7 +171,7 @@ execute_vect_slp (void)
 
   init_stmt_vec_info_vec ();
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       vect_location = find_bb_location (bb);
 
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index ec7ef8f..cac55c9 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -5718,13 +5718,13 @@ find_assert_locations_1 (basic_block bb, sbitmap live)
 static bool
 find_assert_locations (void)
 {
-  int *rpo = XNEWVEC (int, last_basic_block);
-  int *bb_rpo = XNEWVEC (int, last_basic_block);
-  int *last_rpo = XCNEWVEC (int, last_basic_block);
+  int *rpo = XNEWVEC (int, cfun->cfg->get_last_basic_block ());
+  int *bb_rpo = XNEWVEC (int, cfun->cfg->get_last_basic_block ());
+  int *last_rpo = XCNEWVEC (int, cfun->cfg->get_last_basic_block ());
   int rpo_cnt, i;
   bool need_asserts;
 
-  live = XCNEWVEC (sbitmap, last_basic_block);
+  live = XCNEWVEC (sbitmap, cfun->cfg->get_last_basic_block ());
   rpo_cnt = pre_and_rev_post_order_compute (NULL, rpo, false);
   for (i = 0; i < rpo_cnt; ++i)
     bb_rpo[rpo[i]] = i;
@@ -5732,7 +5732,7 @@ find_assert_locations (void)
   need_asserts = false;
   for (i = rpo_cnt - 1; i >= 0; --i)
     {
-      basic_block bb = BASIC_BLOCK (rpo[i]);
+      basic_block bb = cfun->cfg->get_basic_block_by_idx (rpo[i]);
       edge e;
       edge_iterator ei;
 
@@ -5791,7 +5791,7 @@ find_assert_locations (void)
   XDELETEVEC (rpo);
   XDELETEVEC (bb_rpo);
   XDELETEVEC (last_rpo);
-  for (i = 0; i < last_basic_block; ++i)
+  for (i = 0; i < cfun->cfg->get_last_basic_block (); ++i)
     if (live[i])
       sbitmap_free (live[i]);
   XDELETEVEC (live);
@@ -6188,7 +6188,7 @@ check_all_array_refs (void)
   basic_block bb;
   gimple_stmt_iterator si;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       edge_iterator ei;
       edge e;
@@ -6264,7 +6264,7 @@ remove_range_assertions (void)
   /* Note that the BSI iterator bump happens at the bottom of the
      loop and no bump is necessary if we're removing the statement
      referenced by the current BSI.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     for (si = gsi_start_bb (bb); !gsi_end_p (si);)
       {
 	gimple stmt = gsi_stmt (si);
@@ -6349,7 +6349,7 @@ vrp_initialize (void)
   vr_value = XCNEWVEC (value_range_t *, num_vr_values);
   vr_phi_edge_counts = XCNEWVEC (int, num_ssa_names);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple_stmt_iterator si;
 
@@ -9182,7 +9182,7 @@ identify_jump_threads (void)
      I doubt it's worth the effort for the classes of jump
      threading opportunities we are trying to identify at this
      point in compilation.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       gimple last;
 
diff --git a/gcc/tsan.c b/gcc/tsan.c
index a3b6565..b58a131 100644
--- a/gcc/tsan.c
+++ b/gcc/tsan.c
@@ -633,7 +633,7 @@ instrument_memory_accesses (void)
   gimple_stmt_iterator gsi;
   bool fentry_exit_instrument = false;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
       fentry_exit_instrument |= instrument_gimple (&gsi);
   return fentry_exit_instrument;
@@ -649,7 +649,7 @@ instrument_func_entry (void)
   tree ret_addr, builtin_decl;
   gimple g;
 
-  succ_bb = single_succ (ENTRY_BLOCK_PTR);
+  succ_bb = single_succ (cfun->cfg->get_entry_block ());
   gsi = gsi_after_labels (succ_bb);
 
   builtin_decl = builtin_decl_implicit (BUILT_IN_RETURN_ADDRESS);
@@ -679,7 +679,7 @@ instrument_func_exit (void)
   edge_iterator ei;
 
   /* Find all function exits.  */
-  exit_bb = EXIT_BLOCK_PTR;
+  exit_bb = cfun->cfg->get_exit_block ();
   FOR_EACH_EDGE (e, ei, exit_bb->preds)
     {
       gsi = gsi_last_bb (e->src);
diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index b665b1c..05c9608 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -515,7 +515,7 @@ verify_histograms (void)
 
   error_found = false;
   visited_hists = pointer_set_create ();
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
       {
 	gimple stmt = gsi_stmt (gsi);
@@ -619,7 +619,7 @@ gimple_value_profile_transformations (void)
   gimple_stmt_iterator gsi;
   bool changed = false;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	{
@@ -1863,7 +1863,7 @@ gimple_find_values_to_profile (histogram_values *values)
   histogram_value hist = NULL;
 
   values->create (0);
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
       gimple_values_to_profile (gsi_stmt (gsi), values);
 
diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c
index 8108413..2a5816c 100644
--- a/gcc/var-tracking.c
+++ b/gcc/var-tracking.c
@@ -831,16 +831,16 @@ vt_stack_adjustments (void)
   int sp;
 
   /* Initialize entry block.  */
-  VTI (ENTRY_BLOCK_PTR)->visited = true;
-  VTI (ENTRY_BLOCK_PTR)->in.stack_adjust = INCOMING_FRAME_SP_OFFSET;
-  VTI (ENTRY_BLOCK_PTR)->out.stack_adjust = INCOMING_FRAME_SP_OFFSET;
+  VTI (cfun->cfg->get_entry_block ())->visited = true;
+  VTI (cfun->cfg->get_entry_block ())->in.stack_adjust = INCOMING_FRAME_SP_OFFSET;
+  VTI (cfun->cfg->get_entry_block ())->out.stack_adjust = INCOMING_FRAME_SP_OFFSET;
 
   /* Allocate stack for back-tracking up CFG.  */
-  stack = XNEWVEC (edge_iterator, n_basic_blocks + 1);
+  stack = XNEWVEC (edge_iterator, cfun->cfg->get_n_basic_blocks () + 1);
   sp = 0;
 
   /* Push the first edge on to the stack.  */
-  stack[sp++] = ei_start (ENTRY_BLOCK_PTR->succs);
+  stack[sp++] = ei_start (cfun->cfg->get_entry_block ()->succs);
 
   while (sp)
     {
@@ -861,7 +861,7 @@ vt_stack_adjustments (void)
 	  VTI (dest)->visited = true;
 	  VTI (dest)->in.stack_adjust = offset = VTI (src)->out.stack_adjust;
 
-	  if (dest != EXIT_BLOCK_PTR)
+	  if (dest != cfun->cfg->get_exit_block ())
 	    for (insn = BB_HEAD (dest);
 		 insn != NEXT_INSN (BB_END (dest));
 		 insn = NEXT_INSN (insn))
@@ -6883,21 +6883,21 @@ vt_find_locations (void)
   timevar_push (TV_VAR_TRACKING_DATAFLOW);
   /* Compute reverse completion order of depth first search of the CFG
      so that the data-flow runs faster.  */
-  rc_order = XNEWVEC (int, n_basic_blocks - NUM_FIXED_BLOCKS);
-  bb_order = XNEWVEC (int, last_basic_block);
+  rc_order = XNEWVEC (int, cfun->cfg->get_n_basic_blocks () - NUM_FIXED_BLOCKS);
+  bb_order = XNEWVEC (int, cfun->cfg->get_last_basic_block ());
   pre_and_rev_post_order_compute (NULL, rc_order, false);
-  for (i = 0; i < n_basic_blocks - NUM_FIXED_BLOCKS; i++)
+  for (i = 0; i < cfun->cfg->get_n_basic_blocks () - NUM_FIXED_BLOCKS; i++)
     bb_order[rc_order[i]] = i;
   free (rc_order);
 
   worklist = fibheap_new ();
   pending = fibheap_new ();
-  visited = sbitmap_alloc (last_basic_block);
-  in_worklist = sbitmap_alloc (last_basic_block);
-  in_pending = sbitmap_alloc (last_basic_block);
+  visited = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
+  in_worklist = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
+  in_pending = sbitmap_alloc (cfun->cfg->get_last_basic_block ());
   bitmap_clear (in_worklist);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     fibheap_insert (pending, bb_order[bb->index], bb);
   bitmap_ones (in_pending);
 
@@ -7011,7 +7011,7 @@ vt_find_locations (void)
 		{
 		  FOR_EACH_EDGE (e, ei, bb->succs)
 		    {
-		      if (e->dest == EXIT_BLOCK_PTR)
+		      if (e->dest == cfun->cfg->get_exit_block ())
 			continue;
 
 		      if (bitmap_bit_p (visited, e->dest->index))
@@ -7057,7 +7057,7 @@ vt_find_locations (void)
     }
 
   if (success && MAY_HAVE_DEBUG_INSNS)
-    FOR_EACH_BB (bb)
+    FOR_EACH_BB_CFG (bb, cfun->cfg)
       gcc_assert (VTI (bb)->flooded);
 
   free (bb_order);
@@ -7185,7 +7185,7 @@ dump_dataflow_sets (void)
 {
   basic_block bb;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       fprintf (dump_file, "\nBasic block %d:\n", bb->index);
       fprintf (dump_file, "IN:\n");
@@ -9364,7 +9364,7 @@ vt_emit_notes (void)
 
   /* Free memory occupied by the out hash tables, as they aren't used
      anymore.  */
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     dataflow_set_clear (&VTI (bb)->out);
 
   /* Enable emitting notes by functions (mainly by set_variable_part and
@@ -9380,7 +9380,7 @@ vt_emit_notes (void)
 
   dataflow_set_init (&cur);
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       /* Emit the notes for changes of variable locations between two
 	 subsequent basic blocks.  */
@@ -9567,7 +9567,7 @@ vt_add_function_parameter (tree parm)
   if (!track_loc_p (incoming, parm, offset, false, &mode, &offset))
     return;
 
-  out = &VTI (ENTRY_BLOCK_PTR)->out;
+  out = &VTI (cfun->cfg->get_entry_block ())->out;
 
   dv = dv_from_decl (parm);
 
@@ -9748,7 +9748,7 @@ vt_initialize (void)
   changed_variables.create (10);
 
   /* Init the IN and OUT sets.  */
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       VTI (bb)->visited = false;
       VTI (bb)->flooded = false;
@@ -9896,7 +9896,7 @@ vt_initialize (void)
 
   vt_add_function_parameters ();
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       rtx insn;
       HOST_WIDE_INT pre, post = 0;
@@ -9914,7 +9914,7 @@ vt_initialize (void)
       for (;;)
 	{
 	  edge e;
-	  if (bb->next_bb == EXIT_BLOCK_PTR
+	  if (bb->next_bb == cfun->cfg->get_exit_block ()
 	      || ! single_pred_p (bb->next_bb))
 	    break;
 	  e = find_edge (bb, bb->next_bb);
@@ -10017,7 +10017,7 @@ vt_initialize (void)
     }
 
   hard_frame_pointer_adjustment = -1;
-  VTI (ENTRY_BLOCK_PTR)->flooded = true;
+  VTI (cfun->cfg->get_entry_block ())->flooded = true;
   cfa_base_rtx = NULL_RTX;
   return true;
 }
@@ -10039,7 +10039,7 @@ delete_debug_insns (void)
   if (!MAY_HAVE_DEBUG_INSNS)
     return;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       FOR_BB_INSNS_SAFE (bb, insn, next)
 	if (DEBUG_INSN_P (insn))
@@ -10082,12 +10082,12 @@ vt_finalize (void)
 {
   basic_block bb;
 
-  FOR_EACH_BB (bb)
+  FOR_EACH_BB_CFG (bb, cfun->cfg)
     {
       VTI (bb)->mos.release ();
     }
 
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     {
       dataflow_set_destroy (&VTI (bb)->in);
       dataflow_set_destroy (&VTI (bb)->out);
@@ -10143,7 +10143,7 @@ variable_tracking_main_1 (void)
       return 0;
     }
 
-  if (n_basic_blocks > 500 && n_edges / n_basic_blocks >= 20)
+  if (cfun->cfg->get_n_basic_blocks () > 500 && cfun->cfg->get_n_edges () / cfun->cfg->get_n_basic_blocks () >= 20)
     {
       vt_debug_insns_local (true);
       return 0;
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 5f62677..e36eceb 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -1581,7 +1581,7 @@ assemble_start_function (tree decl, const char *fnname)
 	 align the hot section and write out the hot section label.
 	 But if the current function is a thunk, we do not have a CFG.  */
       if (!cfun->is_thunk
-	  && BB_PARTITION (ENTRY_BLOCK_PTR->next_bb) == BB_COLD_PARTITION)
+	  && BB_PARTITION (cfun->cfg->get_entry_block ()->next_bb) == BB_COLD_PARTITION)
 	{
 	  switch_to_section (text_section);
 	  assemble_align (DECL_ALIGN (decl));
diff --git a/gcc/web.c b/gcc/web.c
index df4c84fd..c346499 100644
--- a/gcc/web.c
+++ b/gcc/web.c
@@ -351,7 +351,7 @@ web_main (void)
   df_set_flags (DF_DEFER_INSN_RESCAN);
 
   /* Assign ids to the uses.  */
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     FOR_BB_INSNS (bb, insn)
     {
       unsigned int uid = INSN_UID (insn);
@@ -379,7 +379,7 @@ web_main (void)
   use_entry = XCNEWVEC (struct web_entry, uses_num);
 
   /* Produce the web.  */
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     FOR_BB_INSNS (bb, insn)
     {
       unsigned int uid = INSN_UID (insn);
@@ -404,7 +404,7 @@ web_main (void)
 
   /* Update the instruction stream, allocating new registers for split pseudos
      in progress.  */
-  FOR_ALL_BB (bb)
+  FOR_ALL_BB_CFG (bb, cfun->cfg)
     FOR_BB_INSNS (bb, insn)
     {
       unsigned int uid = INSN_UID (insn);
-- 
1.7.11.7

