On Sat, Nov 16, 2019 at 2:20 AM David Malcolm <dmalc...@redhat.com> wrote:
>
> This patch converts various "gimple *" to "const gimple *" and similar
> fixes for gimple subclasses, adding is_a_helper for gimple subclasses
> to support the const form of as_a, and adding a few "const" overloads
> of accessors.
>
> This is enough to make pp_gimple_stmt_1's stmt const.

Hum.  Can't the const is-a variants be somehow magically implemented
generally?  If something is a T then it is also a const T, no?  I guess
if something is a const T it isn't a T though?

Richard.

> gcc/ChangeLog:
>         * gimple-predict.h (gimple_predict_predictor): Make "gs" param
>         const.
>         (gimple_predict_outcome): Likewise.
>         * gimple-pretty-print.c (do_niy): Likewise.
>         (dump_unary_rhs): Likewise.
>         (dump_binary_rhs): Likewise.
>         (dump_ternary_rhs): Likewise.
>         (dump_gimple_assign): Likewise.
>         (dump_gimple_return): Likewise.
>         (dump_gimple_call_args): Likewise.
>         (pp_points_to_solution): Make "pt" param const.
>         (dump_gimple_call): Make "gs" param const.
>         (dump_gimple_switch): Likewise.
>         (dump_gimple_cond): Likewise.
>         (dump_gimple_label): Likewise.
>         (dump_gimple_goto): Likewise.
>         (dump_gimple_bind): Likewise.
>         (dump_gimple_try): Likewise.
>         (dump_gimple_catch): Likewise.
>         (dump_gimple_eh_filter): Likewise.
>         (dump_gimple_eh_must_not_throw): Likewise.
>         (dump_gimple_eh_else): Likewise.
>         (dump_gimple_resx): Likewise.
>         (dump_gimple_eh_dispatch): Likewise.
>         (dump_gimple_debug): Likewise.
>         (dump_gimple_omp_for): Likewise.
>         (dump_gimple_omp_continue): Likewise.
>         (dump_gimple_omp_single): Likewise.
>         (dump_gimple_omp_taskgroup): Likewise.
>         (dump_gimple_omp_target): Likewise.
>         (dump_gimple_omp_teams): Likewise.
>         (dump_gimple_omp_sections): Likewise.
>         (dump_gimple_omp_block): Likewise.
>         (dump_gimple_omp_critical): Likewise.
>         (dump_gimple_omp_ordered): Likewise.
>         (dump_gimple_omp_scan): Likewise.
>         (dump_gimple_omp_return): Likewise.
>         (dump_gimple_transaction): Likewise.
>         (dump_gimple_asm): Likewise.
>         (dump_gimple_phi): Make "phi" param const.
>         (dump_gimple_omp_parallel): Make "gs" param const.
>         (dump_gimple_omp_task): Likewise.
>         (dump_gimple_omp_atomic_load): Likewise.
>         (dump_gimple_omp_atomic_store): Likewise.
>         (dump_gimple_mem_ops): Likewise.
>         (pp_gimple_stmt_1): Likewise.  Add "const" to the various as_a <>
>         casts throughout.
>         * gimple-pretty-print.h (gimple_stmt_1): Make gimple * param const.
>         * gimple.h (is_a_helper <const gdebug *>::test): New.
>         (is_a_helper <const ggoto *>::test): New.
>         (is_a_helper <const glabel *>::test): New.
>         (is_a_helper <const geh_else *>::test): New.
>         (is_a_helper <const geh_mnt *>::test): New.
>         (is_a_helper <const gswitch *>::test): New.
>         (is_a_helper <const gtry *>::test): New.
>         (is_a_helper <const greturn *>::test): New.
>         (gimple_call_tail_p): Make param const.
>         (gimple_call_return_slot_opt_p): Likewise.
>         (gimple_call_va_arg_pack_p): Likewise.
>         (gimple_call_use_set): Add const overload.
>         (gimple_call_clobber_set): Likewise.
>         (gimple_has_lhs): Make param const.
>         (gimple_bind_body): Likewise.
>         (gimple_catch_handler): Likewise.
>         (gimple_eh_filter_failure): Likewise.
>         (gimple_eh_must_not_throw_fndecl): Likewise.
>         (gimple_eh_else_n_body): Likewise.
>         (gimple_eh_else_e_body): Likewise.
>         (gimple_try_eval): Likewise.
>         (gimple_try_cleanup): Likewise.
>         (gimple_phi_arg): Add const overload.
>         (gimple_phi_arg_def): Make param const.
>         (gimple_phi_arg_edge): Likewise.
>         (gimple_phi_arg_location): Likewise.
>         (gimple_phi_arg_has_location): Likewise.
>         (gimple_debug_bind_get_var): Likewise.
>         (gimple_debug_bind_get_value): Likewise.
>         (gimple_debug_source_bind_get_var): Likewise.
>         (gimple_debug_source_bind_get_value): Likewise.
>         (gimple_omp_body): Likewise.
>         (gimple_omp_for_collapse): Likewise.
>         (gimple_omp_for_pre_body): Likewise.
>         (gimple_transaction_body): Likewise.
>         * tree-eh.c (lookup_stmt_eh_lp_fn): Make param "t" const.
>         (lookup_stmt_eh_lp): Likewise.
>         * tree-eh.h (lookup_stmt_eh_lp_fn): Make param const.
>         (lookup_stmt_eh_lp): Likewise.
>         * tree-ssa-alias.h (pt_solution_empty_p): Make param const.
>         * tree-ssa-structalias.c (pt_solution_empty_p): Likewise.
> ---
>  gcc/gimple-predict.h       |   4 +-
>  gcc/gimple-pretty-print.c  | 159 
> +++++++++++++++++++++++----------------------
>  gcc/gimple-pretty-print.h  |   3 +-
>  gcc/gimple.h               | 156 ++++++++++++++++++++++++++++++++++----------
>  gcc/tree-eh.c              |   6 +-
>  gcc/tree-eh.h              |   4 +-
>  gcc/tree-ssa-alias.h       |   2 +-
>  gcc/tree-ssa-structalias.c |   2 +-
>  8 files changed, 213 insertions(+), 123 deletions(-)
>
> diff --git a/gcc/gimple-predict.h b/gcc/gimple-predict.h
> index 761098b..d976317 100644
> --- a/gcc/gimple-predict.h
> +++ b/gcc/gimple-predict.h
> @@ -26,7 +26,7 @@ along with GCC; see the file COPYING3.  If not see
>  /* Return the predictor of GIMPLE_PREDICT statement GS.  */
>
>  static inline enum br_predictor
> -gimple_predict_predictor (gimple *gs)
> +gimple_predict_predictor (const gimple *gs)
>  {
>    GIMPLE_CHECK (gs, GIMPLE_PREDICT);
>    return (enum br_predictor) (gs->subcode & ~GF_PREDICT_TAKEN);
> @@ -47,7 +47,7 @@ gimple_predict_set_predictor (gimple *gs, enum br_predictor 
> predictor)
>  /* Return the outcome of GIMPLE_PREDICT statement GS.  */
>
>  static inline enum prediction
> -gimple_predict_outcome (gimple *gs)
> +gimple_predict_outcome (const gimple *gs)
>  {
>    GIMPLE_CHECK (gs, GIMPLE_PREDICT);
>    return (gs->subcode & GF_PREDICT_TAKEN) ? TAKEN : NOT_TAKEN;
> diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
> index 2d5ece0..f044628 100644
> --- a/gcc/gimple-pretty-print.c
> +++ b/gcc/gimple-pretty-print.c
> @@ -59,7 +59,7 @@ along with GCC; see the file COPYING3.  If not see
>     gimple statement GS.  */
>
>  static void
> -do_niy (pretty_printer *buffer, gimple *gs)
> +do_niy (pretty_printer *buffer, const gimple *gs)
>  {
>    pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
>              gimple_code_name[(int) gimple_code (gs)]);
> @@ -327,7 +327,7 @@ dump_gimple_fmt (pretty_printer *buffer, int spc, 
> dump_flags_t flags,
>     assignment GS.  BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.  */
>
>  static void
> -dump_unary_rhs (pretty_printer *buffer, gassign *gs, int spc,
> +dump_unary_rhs (pretty_printer *buffer, const gassign *gs, int spc,
>                 dump_flags_t flags)
>  {
>    enum tree_code rhs_code = gimple_assign_rhs_code (gs);
> @@ -423,7 +423,7 @@ dump_unary_rhs (pretty_printer *buffer, gassign *gs, int 
> spc,
>     assignment GS.  BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.  */
>
>  static void
> -dump_binary_rhs (pretty_printer *buffer, gassign *gs, int spc,
> +dump_binary_rhs (pretty_printer *buffer, const gassign *gs, int spc,
>                  dump_flags_t flags)
>  {
>    const char *p;
> @@ -495,7 +495,7 @@ dump_binary_rhs (pretty_printer *buffer, gassign *gs, int 
> spc,
>     assignment GS.  BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.  */
>
>  static void
> -dump_ternary_rhs (pretty_printer *buffer, gassign *gs, int spc,
> +dump_ternary_rhs (pretty_printer *buffer, const gassign *gs, int spc,
>                   dump_flags_t flags)
>  {
>    const char *p;
> @@ -625,7 +625,7 @@ dump_ternary_rhs (pretty_printer *buffer, gassign *gs, 
> int spc,
>     pp_gimple_stmt_1.  */
>
>  static void
> -dump_gimple_assign (pretty_printer *buffer, gassign *gs, int spc,
> +dump_gimple_assign (pretty_printer *buffer, const gassign *gs, int spc,
>                     dump_flags_t flags)
>  {
>    if (flags & TDF_RAW)
> @@ -687,7 +687,7 @@ dump_gimple_assign (pretty_printer *buffer, gassign *gs, 
> int spc,
>     pp_gimple_stmt_1.  */
>
>  static void
> -dump_gimple_return (pretty_printer *buffer, greturn *gs, int spc,
> +dump_gimple_return (pretty_printer *buffer, const greturn *gs, int spc,
>                     dump_flags_t flags)
>  {
>    tree t;
> @@ -712,7 +712,8 @@ dump_gimple_return (pretty_printer *buffer, greturn *gs, 
> int spc,
>     dump_gimple_call.  */
>
>  static void
> -dump_gimple_call_args (pretty_printer *buffer, gcall *gs, dump_flags_t flags)
> +dump_gimple_call_args (pretty_printer *buffer, const gcall *gs,
> +                      dump_flags_t flags)
>  {
>    size_t i = 0;
>
> @@ -795,7 +796,7 @@ dump_gimple_call_args (pretty_printer *buffer, gcall *gs, 
> dump_flags_t flags)
>  /* Dump the points-to solution *PT to BUFFER.  */
>
>  static void
> -pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
> +pp_points_to_solution (pretty_printer *buffer, const pt_solution *pt)
>  {
>    if (pt->anything)
>      {
> @@ -868,7 +869,7 @@ pp_points_to_solution (pretty_printer *buffer, struct 
> pt_solution *pt)
>     pp_gimple_stmt_1.  */
>
>  static void
> -dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc,
> +dump_gimple_call (pretty_printer *buffer, const gcall *gs, int spc,
>                   dump_flags_t flags)
>  {
>    tree lhs = gimple_call_lhs (gs);
> @@ -876,7 +877,7 @@ dump_gimple_call (pretty_printer *buffer, gcall *gs, int 
> spc,
>
>    if (flags & TDF_ALIAS)
>      {
> -      struct pt_solution *pt;
> +      const pt_solution *pt;
>        pt = gimple_call_use_set (gs);
>        if (!pt_solution_empty_p (pt))
>         {
> @@ -1006,7 +1007,7 @@ dump_gimple_call (pretty_printer *buffer, gcall *gs, 
> int spc,
>     pp_gimple_stmt_1.  */
>
>  static void
> -dump_gimple_switch (pretty_printer *buffer, gswitch *gs, int spc,
> +dump_gimple_switch (pretty_printer *buffer, const gswitch *gs, int spc,
>                     dump_flags_t flags)
>  {
>    unsigned int i;
> @@ -1064,7 +1065,7 @@ dump_gimple_switch (pretty_printer *buffer, gswitch 
> *gs, int spc,
>     pp_gimple_stmt_1.  */
>
>  static void
> -dump_gimple_cond (pretty_printer *buffer, gcond *gs, int spc,
> +dump_gimple_cond (pretty_printer *buffer, const gcond *gs, int spc,
>                   dump_flags_t flags)
>  {
>    if (flags & TDF_RAW)
> @@ -1131,7 +1132,7 @@ dump_gimple_cond (pretty_printer *buffer, gcond *gs, 
> int spc,
>     TDF_* in dumpfils.h).  */
>
>  static void
> -dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc,
> +dump_gimple_label (pretty_printer *buffer, const glabel *gs, int spc,
>                    dump_flags_t flags)
>  {
>    tree label = gimple_label_label (gs);
> @@ -1155,7 +1156,7 @@ dump_gimple_label (pretty_printer *buffer, glabel *gs, 
> int spc,
>     TDF_* in dumpfile.h).  */
>
>  static void
> -dump_gimple_goto (pretty_printer *buffer, ggoto *gs, int spc,
> +dump_gimple_goto (pretty_printer *buffer, const ggoto *gs, int spc,
>                   dump_flags_t flags)
>  {
>    tree label = gimple_goto_dest (gs);
> @@ -1171,7 +1172,7 @@ dump_gimple_goto (pretty_printer *buffer, ggoto *gs, 
> int spc,
>     TDF_* in dumpfile.h).  */
>
>  static void
> -dump_gimple_bind (pretty_printer *buffer, gbind *gs, int spc,
> +dump_gimple_bind (pretty_printer *buffer, const gbind *gs, int spc,
>                   dump_flags_t flags)
>  {
>    if (flags & TDF_RAW)
> @@ -1205,7 +1206,7 @@ dump_gimple_bind (pretty_printer *buffer, gbind *gs, 
> int spc,
>     dumpfile.h).  */
>
>  static void
> -dump_gimple_try (pretty_printer *buffer, gtry *gs, int spc,
> +dump_gimple_try (pretty_printer *buffer, const gtry *gs, int spc,
>                  dump_flags_t flags)
>  {
>    if (flags & TDF_RAW)
> @@ -1280,7 +1281,7 @@ dump_gimple_try (pretty_printer *buffer, gtry *gs, int 
> spc,
>     dumpfile.h).  */
>
>  static void
> -dump_gimple_catch (pretty_printer *buffer, gcatch *gs, int spc,
> +dump_gimple_catch (pretty_printer *buffer, const gcatch *gs, int spc,
>                    dump_flags_t flags)
>  {
>    if (flags & TDF_RAW)
> @@ -1297,7 +1298,7 @@ dump_gimple_catch (pretty_printer *buffer, gcatch *gs, 
> int spc,
>     dumpfile.h).  */
>
>  static void
> -dump_gimple_eh_filter (pretty_printer *buffer, geh_filter *gs, int spc,
> +dump_gimple_eh_filter (pretty_printer *buffer, const geh_filter *gs, int spc,
>                        dump_flags_t flags)
>  {
>    if (flags & TDF_RAW)
> @@ -1315,7 +1316,7 @@ dump_gimple_eh_filter (pretty_printer *buffer, 
> geh_filter *gs, int spc,
>
>  static void
>  dump_gimple_eh_must_not_throw (pretty_printer *buffer,
> -                              geh_mnt *gs, int spc, dump_flags_t flags)
> +                              const geh_mnt *gs, int spc, dump_flags_t flags)
>  {
>    if (flags & TDF_RAW)
>      dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
> @@ -1331,7 +1332,7 @@ dump_gimple_eh_must_not_throw (pretty_printer *buffer,
>     dumpfile.h).  */
>
>  static void
> -dump_gimple_eh_else (pretty_printer *buffer, geh_else *gs, int spc,
> +dump_gimple_eh_else (pretty_printer *buffer, const geh_else *gs, int spc,
>                      dump_flags_t flags)
>  {
>    if (flags & TDF_RAW)
> @@ -1350,7 +1351,7 @@ dump_gimple_eh_else (pretty_printer *buffer, geh_else 
> *gs, int spc,
>     dumpfile.h).  */
>
>  static void
> -dump_gimple_resx (pretty_printer *buffer, gresx *gs, int spc,
> +dump_gimple_resx (pretty_printer *buffer, const gresx *gs, int spc,
>                   dump_flags_t flags)
>  {
>    if (flags & TDF_RAW)
> @@ -1363,8 +1364,8 @@ dump_gimple_resx (pretty_printer *buffer, gresx *gs, 
> int spc,
>  /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER.  */
>
>  static void
> -dump_gimple_eh_dispatch (pretty_printer *buffer, geh_dispatch *gs, int spc,
> -                        dump_flags_t flags)
> +dump_gimple_eh_dispatch (pretty_printer *buffer, const geh_dispatch *gs,
> +                        int spc, dump_flags_t flags)
>  {
>    if (flags & TDF_RAW)
>      dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
> @@ -1379,7 +1380,7 @@ dump_gimple_eh_dispatch (pretty_printer *buffer, 
> geh_dispatch *gs, int spc,
>     in dumpfile.h).  */
>
>  static void
> -dump_gimple_debug (pretty_printer *buffer, gdebug *gs, int spc,
> +dump_gimple_debug (pretty_printer *buffer, const gdebug *gs, int spc,
>                    dump_flags_t flags)
>  {
>    switch (gs->subcode)
> @@ -1433,7 +1434,7 @@ dump_gimple_debug (pretty_printer *buffer, gdebug *gs, 
> int spc,
>
>  /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER.  */
>  static void
> -dump_gimple_omp_for (pretty_printer *buffer, gomp_for *gs, int spc,
> +dump_gimple_omp_for (pretty_printer *buffer, const gomp_for *gs, int spc,
>                      dump_flags_t flags)
>  {
>    size_t i;
> @@ -1566,7 +1567,7 @@ dump_gimple_omp_for (pretty_printer *buffer, gomp_for 
> *gs, int spc,
>  /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER.  */
>
>  static void
> -dump_gimple_omp_continue (pretty_printer *buffer, gomp_continue *gs,
> +dump_gimple_omp_continue (pretty_printer *buffer, const gomp_continue *gs,
>                           int spc, dump_flags_t flags)
>  {
>    if (flags & TDF_RAW)
> @@ -1591,7 +1592,7 @@ dump_gimple_omp_continue (pretty_printer *buffer, 
> gomp_continue *gs,
>  /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER.  */
>
>  static void
> -dump_gimple_omp_single (pretty_printer *buffer, gomp_single *gs,
> +dump_gimple_omp_single (pretty_printer *buffer, const gomp_single *gs,
>                         int spc, dump_flags_t flags)
>  {
>    if (flags & TDF_RAW)
> @@ -1620,7 +1621,7 @@ dump_gimple_omp_single (pretty_printer *buffer, 
> gomp_single *gs,
>  /* Dump a GIMPLE_OMP_TASKGROUP tuple on the pretty_printer BUFFER.  */
>
>  static void
> -dump_gimple_omp_taskgroup (pretty_printer *buffer, gimple *gs,
> +dump_gimple_omp_taskgroup (pretty_printer *buffer, const gimple *gs,
>                            int spc, dump_flags_t flags)
>  {
>    if (flags & TDF_RAW)
> @@ -1649,7 +1650,7 @@ dump_gimple_omp_taskgroup (pretty_printer *buffer, 
> gimple *gs,
>  /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER.  */
>
>  static void
> -dump_gimple_omp_target (pretty_printer *buffer, gomp_target *gs,
> +dump_gimple_omp_target (pretty_printer *buffer, const gomp_target *gs,
>                         int spc, dump_flags_t flags)
>  {
>    const char *kind;
> @@ -1742,7 +1743,7 @@ dump_gimple_omp_target (pretty_printer *buffer, 
> gomp_target *gs,
>  /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER.  */
>
>  static void
> -dump_gimple_omp_teams (pretty_printer *buffer, gomp_teams *gs, int spc,
> +dump_gimple_omp_teams (pretty_printer *buffer, const gomp_teams *gs, int spc,
>                        dump_flags_t flags)
>  {
>    if (flags & TDF_RAW)
> @@ -1771,7 +1772,7 @@ dump_gimple_omp_teams (pretty_printer *buffer, 
> gomp_teams *gs, int spc,
>  /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER.  */
>
>  static void
> -dump_gimple_omp_sections (pretty_printer *buffer, gomp_sections *gs,
> +dump_gimple_omp_sections (pretty_printer *buffer, const gomp_sections *gs,
>                           int spc, dump_flags_t flags)
>  {
>    if (flags & TDF_RAW)
> @@ -1808,7 +1809,7 @@ dump_gimple_omp_sections (pretty_printer *buffer, 
> gomp_sections *gs,
>     pretty_printer BUFFER.  */
>
>  static void
> -dump_gimple_omp_block (pretty_printer *buffer, gimple *gs, int spc,
> +dump_gimple_omp_block (pretty_printer *buffer, const gimple *gs, int spc,
>                        dump_flags_t flags)
>  {
>    if (flags & TDF_RAW)
> @@ -1845,7 +1846,7 @@ dump_gimple_omp_block (pretty_printer *buffer, gimple 
> *gs, int spc,
>  /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER.  */
>
>  static void
> -dump_gimple_omp_critical (pretty_printer *buffer, gomp_critical *gs,
> +dump_gimple_omp_critical (pretty_printer *buffer, const gomp_critical *gs,
>                           int spc, dump_flags_t flags)
>  {
>    if (flags & TDF_RAW)
> @@ -1877,7 +1878,7 @@ dump_gimple_omp_critical (pretty_printer *buffer, 
> gomp_critical *gs,
>  /* Dump a GIMPLE_OMP_ORDERED tuple on the pretty_printer BUFFER.  */
>
>  static void
> -dump_gimple_omp_ordered (pretty_printer *buffer, gomp_ordered *gs,
> +dump_gimple_omp_ordered (pretty_printer *buffer, const gomp_ordered *gs,
>                          int spc, dump_flags_t flags)
>  {
>    if (flags & TDF_RAW)
> @@ -1902,7 +1903,7 @@ dump_gimple_omp_ordered (pretty_printer *buffer, 
> gomp_ordered *gs,
>  /* Dump a GIMPLE_OMP_SCAN tuple on the pretty_printer BUFFER.  */
>
>  static void
> -dump_gimple_omp_scan (pretty_printer *buffer, gomp_scan *gs,
> +dump_gimple_omp_scan (pretty_printer *buffer, const gomp_scan *gs,
>                       int spc, dump_flags_t flags)
>  {
>    if (flags & TDF_RAW)
> @@ -1930,7 +1931,7 @@ dump_gimple_omp_scan (pretty_printer *buffer, gomp_scan 
> *gs,
>  /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER.  */
>
>  static void
> -dump_gimple_omp_return (pretty_printer *buffer, gimple *gs, int spc,
> +dump_gimple_omp_return (pretty_printer *buffer, const gimple *gs, int spc,
>                         dump_flags_t flags)
>  {
>    if (flags & TDF_RAW)
> @@ -1961,7 +1962,7 @@ dump_gimple_omp_return (pretty_printer *buffer, gimple 
> *gs, int spc,
>  /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER.  */
>
>  static void
> -dump_gimple_transaction (pretty_printer *buffer, gtransaction *gs,
> +dump_gimple_transaction (pretty_printer *buffer, const gtransaction *gs,
>                          int spc, dump_flags_t flags)
>  {
>    unsigned subcode = gimple_transaction_subcode (gs);
> @@ -2063,7 +2064,8 @@ dump_gimple_transaction (pretty_printer *buffer, 
> gtransaction *gs,
>     dumpfile.h).  */
>
>  static void
> -dump_gimple_asm (pretty_printer *buffer, gasm *gs, int spc, dump_flags_t 
> flags)
> +dump_gimple_asm (pretty_printer *buffer, const gasm *gs, int spc,
> +                dump_flags_t flags)
>  {
>    unsigned int i, n, f, fields;
>
> @@ -2282,7 +2284,7 @@ dump_ssaname_info_to_file (FILE *file, tree node, int 
> spc)
>     pretty printer.  If COMMENT is true, print this after #.  */
>
>  static void
> -dump_gimple_phi (pretty_printer *buffer, gphi *phi, int spc, bool comment,
> +dump_gimple_phi (pretty_printer *buffer, const gphi *phi, int spc, bool 
> comment,
>                  dump_flags_t flags)
>  {
>    size_t i;
> @@ -2339,7 +2341,7 @@ dump_gimple_phi (pretty_printer *buffer, gphi *phi, int 
> spc, bool comment,
>     dumpfile.h).  */
>
>  static void
> -dump_gimple_omp_parallel (pretty_printer *buffer, gomp_parallel *gs,
> +dump_gimple_omp_parallel (pretty_printer *buffer, const gomp_parallel *gs,
>                           int spc, dump_flags_t flags)
>  {
>    if (flags & TDF_RAW)
> @@ -2393,7 +2395,7 @@ dump_gimple_omp_parallel (pretty_printer *buffer, 
> gomp_parallel *gs,
>     dumpfile.h).  */
>
>  static void
> -dump_gimple_omp_task (pretty_printer *buffer, gomp_task *gs, int spc,
> +dump_gimple_omp_task (pretty_printer *buffer, const gomp_task *gs, int spc,
>                       dump_flags_t flags)
>  {
>    if (flags & TDF_RAW)
> @@ -2455,7 +2457,7 @@ dump_gimple_omp_task (pretty_printer *buffer, gomp_task 
> *gs, int spc,
>     in dumpfile.h).  */
>
>  static void
> -dump_gimple_omp_atomic_load (pretty_printer *buffer, gomp_atomic_load *gs,
> +dump_gimple_omp_atomic_load (pretty_printer *buffer, const gomp_atomic_load 
> *gs,
>                              int spc, dump_flags_t flags)
>  {
>    if (flags & TDF_RAW)
> @@ -2489,7 +2491,7 @@ dump_gimple_omp_atomic_load (pretty_printer *buffer, 
> gomp_atomic_load *gs,
>
>  static void
>  dump_gimple_omp_atomic_store (pretty_printer *buffer,
> -                             gomp_atomic_store *gs, int spc,
> +                             const gomp_atomic_store *gs, int spc,
>                               dump_flags_t flags)
>  {
>    if (flags & TDF_RAW)
> @@ -2517,7 +2519,7 @@ dump_gimple_omp_atomic_store (pretty_printer *buffer,
>     FLAGS are as in pp_gimple_stmt_1.  */
>
>  static void
> -dump_gimple_mem_ops (pretty_printer *buffer, gimple *gs, int spc,
> +dump_gimple_mem_ops (pretty_printer *buffer, const gimple *gs, int spc,
>                      dump_flags_t flags)
>  {
>    tree vdef = gimple_vdef (gs);
> @@ -2548,14 +2550,14 @@ dump_gimple_mem_ops (pretty_printer *buffer, gimple 
> *gs, int spc,
>     pp_flush on BUFFER to finalize the pretty printer.  */
>
>  void
> -pp_gimple_stmt_1 (pretty_printer *buffer, gimple *gs, int spc,
> +pp_gimple_stmt_1 (pretty_printer *buffer, const gimple *gs, int spc,
>                   dump_flags_t flags)
>  {
>    if (!gs)
>      return;
>
>    if (flags & TDF_STMTADDR)
> -    pp_printf (buffer, "<&%p> ", (void *) gs);
> +    pp_printf (buffer, "<&%p> ", (const void *) gs);
>
>    if ((flags & TDF_LINENO) && gimple_has_location (gs))
>      dump_location (buffer, gimple_location (gs));
> @@ -2580,31 +2582,31 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple *gs, 
> int spc,
>    switch (gimple_code (gs))
>      {
>      case GIMPLE_ASM:
> -      dump_gimple_asm (buffer, as_a <gasm *> (gs), spc, flags);
> +      dump_gimple_asm (buffer, as_a <const gasm *> (gs), spc, flags);
>        break;
>
>      case GIMPLE_ASSIGN:
> -      dump_gimple_assign (buffer, as_a <gassign *> (gs), spc, flags);
> +      dump_gimple_assign (buffer, as_a <const gassign *> (gs), spc, flags);
>        break;
>
>      case GIMPLE_BIND:
> -      dump_gimple_bind (buffer, as_a <gbind *> (gs), spc, flags);
> +      dump_gimple_bind (buffer, as_a <const gbind *> (gs), spc, flags);
>        break;
>
>      case GIMPLE_CALL:
> -      dump_gimple_call (buffer, as_a <gcall *> (gs), spc, flags);
> +      dump_gimple_call (buffer, as_a <const gcall *> (gs), spc, flags);
>        break;
>
>      case GIMPLE_COND:
> -      dump_gimple_cond (buffer, as_a <gcond *> (gs), spc, flags);
> +      dump_gimple_cond (buffer, as_a <const gcond *> (gs), spc, flags);
>        break;
>
>      case GIMPLE_LABEL:
> -      dump_gimple_label (buffer, as_a <glabel *> (gs), spc, flags);
> +      dump_gimple_label (buffer, as_a <const glabel *> (gs), spc, flags);
>        break;
>
>      case GIMPLE_GOTO:
> -      dump_gimple_goto (buffer, as_a <ggoto *> (gs), spc, flags);
> +      dump_gimple_goto (buffer, as_a <const ggoto *> (gs), spc, flags);
>        break;
>
>      case GIMPLE_NOP:
> @@ -2612,62 +2614,62 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple *gs, 
> int spc,
>        break;
>
>      case GIMPLE_RETURN:
> -      dump_gimple_return (buffer, as_a <greturn *> (gs), spc, flags);
> +      dump_gimple_return (buffer, as_a <const greturn *> (gs), spc, flags);
>        break;
>
>      case GIMPLE_SWITCH:
> -      dump_gimple_switch (buffer, as_a <gswitch *> (gs), spc, flags);
> +      dump_gimple_switch (buffer, as_a <const gswitch *> (gs), spc, flags);
>        break;
>
>      case GIMPLE_TRY:
> -      dump_gimple_try (buffer, as_a <gtry *> (gs), spc, flags);
> +      dump_gimple_try (buffer, as_a <const gtry *> (gs), spc, flags);
>        break;
>
>      case GIMPLE_PHI:
> -      dump_gimple_phi (buffer, as_a <gphi *> (gs), spc, false, flags);
> +      dump_gimple_phi (buffer, as_a <const gphi *> (gs), spc, false, flags);
>        break;
>
>      case GIMPLE_OMP_PARALLEL:
> -      dump_gimple_omp_parallel (buffer, as_a <gomp_parallel *> (gs), spc,
> +      dump_gimple_omp_parallel (buffer, as_a <const gomp_parallel *> (gs), 
> spc,
>                                 flags);
>        break;
>
>      case GIMPLE_OMP_TASK:
> -      dump_gimple_omp_task (buffer, as_a <gomp_task *> (gs), spc, flags);
> +      dump_gimple_omp_task (buffer, as_a <const gomp_task *> (gs), spc, 
> flags);
>        break;
>
>      case GIMPLE_OMP_ATOMIC_LOAD:
> -      dump_gimple_omp_atomic_load (buffer, as_a <gomp_atomic_load *> (gs),
> +      dump_gimple_omp_atomic_load (buffer, as_a <const gomp_atomic_load *> 
> (gs),
>                                    spc, flags);
>        break;
>
>      case GIMPLE_OMP_ATOMIC_STORE:
>        dump_gimple_omp_atomic_store (buffer,
> -                                   as_a <gomp_atomic_store *> (gs),
> +                                   as_a <const gomp_atomic_store *> (gs),
>                                     spc, flags);
>        break;
>
>      case GIMPLE_OMP_FOR:
> -      dump_gimple_omp_for (buffer, as_a <gomp_for *> (gs), spc, flags);
> +      dump_gimple_omp_for (buffer, as_a <const gomp_for *> (gs), spc, flags);
>        break;
>
>      case GIMPLE_OMP_CONTINUE:
> -      dump_gimple_omp_continue (buffer, as_a <gomp_continue *> (gs), spc,
> +      dump_gimple_omp_continue (buffer, as_a <const gomp_continue *> (gs), 
> spc,
>                                 flags);
>        break;
>
>      case GIMPLE_OMP_SINGLE:
> -      dump_gimple_omp_single (buffer, as_a <gomp_single *> (gs), spc,
> +      dump_gimple_omp_single (buffer, as_a <const gomp_single *> (gs), spc,
>                               flags);
>        break;
>
>      case GIMPLE_OMP_TARGET:
> -      dump_gimple_omp_target (buffer, as_a <gomp_target *> (gs), spc,
> +      dump_gimple_omp_target (buffer, as_a <const gomp_target *> (gs), spc,
>                               flags);
>        break;
>
>      case GIMPLE_OMP_TEAMS:
> -      dump_gimple_omp_teams (buffer, as_a <gomp_teams *> (gs), spc,
> +      dump_gimple_omp_teams (buffer, as_a <const gomp_teams *> (gs), spc,
>                              flags);
>        break;
>
> @@ -2676,7 +2678,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple *gs, 
> int spc,
>        break;
>
>      case GIMPLE_OMP_SECTIONS:
> -      dump_gimple_omp_sections (buffer, as_a <gomp_sections *> (gs),
> +      dump_gimple_omp_sections (buffer, as_a <const gomp_sections *> (gs),
>                                 spc, flags);
>        break;
>
> @@ -2695,49 +2697,50 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple *gs, 
> int spc,
>        break;
>
>      case GIMPLE_OMP_ORDERED:
> -      dump_gimple_omp_ordered (buffer, as_a <gomp_ordered *> (gs), spc,
> +      dump_gimple_omp_ordered (buffer, as_a <const gomp_ordered *> (gs), spc,
>                                flags);
>        break;
>
>      case GIMPLE_OMP_SCAN:
> -      dump_gimple_omp_scan (buffer, as_a <gomp_scan *> (gs), spc,
> +      dump_gimple_omp_scan (buffer, as_a <const gomp_scan *> (gs), spc,
>                             flags);
>        break;
>
>      case GIMPLE_OMP_CRITICAL:
> -      dump_gimple_omp_critical (buffer, as_a <gomp_critical *> (gs), spc,
> +      dump_gimple_omp_critical (buffer, as_a <const gomp_critical *> (gs), 
> spc,
>                                 flags);
>        break;
>
>      case GIMPLE_CATCH:
> -      dump_gimple_catch (buffer, as_a <gcatch *> (gs), spc, flags);
> +      dump_gimple_catch (buffer, as_a <const gcatch *> (gs), spc, flags);
>        break;
>
>      case GIMPLE_EH_FILTER:
> -      dump_gimple_eh_filter (buffer, as_a <geh_filter *> (gs), spc, flags);
> +      dump_gimple_eh_filter (buffer, as_a <const geh_filter *> (gs), spc,
> +                            flags);
>        break;
>
>      case GIMPLE_EH_MUST_NOT_THROW:
>        dump_gimple_eh_must_not_throw (buffer,
> -                                    as_a <geh_mnt *> (gs),
> +                                    as_a <const geh_mnt *> (gs),
>                                      spc, flags);
>        break;
>
>      case GIMPLE_EH_ELSE:
> -      dump_gimple_eh_else (buffer, as_a <geh_else *> (gs), spc, flags);
> +      dump_gimple_eh_else (buffer, as_a <const geh_else *> (gs), spc, flags);
>        break;
>
>      case GIMPLE_RESX:
> -      dump_gimple_resx (buffer, as_a <gresx *> (gs), spc, flags);
> +      dump_gimple_resx (buffer, as_a <const gresx *> (gs), spc, flags);
>        break;
>
>      case GIMPLE_EH_DISPATCH:
> -      dump_gimple_eh_dispatch (buffer, as_a <geh_dispatch *> (gs), spc,
> +      dump_gimple_eh_dispatch (buffer, as_a <const geh_dispatch *> (gs), spc,
>                                flags);
>        break;
>
>      case GIMPLE_DEBUG:
> -      dump_gimple_debug (buffer, as_a <gdebug *> (gs), spc, flags);
> +      dump_gimple_debug (buffer, as_a <const gdebug *> (gs), spc, flags);
>        break;
>
>      case GIMPLE_PREDICT:
> @@ -2751,7 +2754,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple *gs, 
> int spc,
>        break;
>
>      case GIMPLE_TRANSACTION:
> -      dump_gimple_transaction (buffer, as_a <gtransaction *> (gs), spc,
> +      dump_gimple_transaction (buffer, as_a <const gtransaction *> (gs), spc,
>                                flags);
>        break;
>
> diff --git a/gcc/gimple-pretty-print.h b/gcc/gimple-pretty-print.h
> index 8d8e105..186f2cf 100644
> --- a/gcc/gimple-pretty-print.h
> +++ b/gcc/gimple-pretty-print.h
> @@ -31,7 +31,8 @@ extern void print_gimple_stmt (FILE *, gimple *, int, 
> dump_flags_t = TDF_NONE);
>  extern void debug (gimple &ref);
>  extern void debug (gimple *ptr);
>  extern void print_gimple_expr (FILE *, gimple *, int, dump_flags_t = 
> TDF_NONE);
> -extern void pp_gimple_stmt_1 (pretty_printer *, gimple *, int, dump_flags_t);
> +extern void pp_gimple_stmt_1 (pretty_printer *, const gimple *, int,
> +                             dump_flags_t);
>  extern void gimple_dump_bb (FILE *, basic_block, int, dump_flags_t);
>  extern void gimple_dump_bb_for_graph (pretty_printer *, basic_block);
>  extern void dump_ssaname_info_to_file (FILE *, tree, int);
> diff --git a/gcc/gimple.h b/gcc/gimple.h
> index cf1f8da..10a4b8b 100644
> --- a/gcc/gimple.h
> +++ b/gcc/gimple.h
> @@ -1017,6 +1017,14 @@ is_a_helper <gdebug *>::test (gimple *gs)
>  template <>
>  template <>
>  inline bool
> +is_a_helper <const gdebug *>::test (const gimple *gs)
> +{
> +  return gs->code == GIMPLE_DEBUG;
> +}
> +
> +template <>
> +template <>
> +inline bool
>  is_a_helper <ggoto *>::test (gimple *gs)
>  {
>    return gs->code == GIMPLE_GOTO;
> @@ -1025,6 +1033,14 @@ is_a_helper <ggoto *>::test (gimple *gs)
>  template <>
>  template <>
>  inline bool
> +is_a_helper <const ggoto *>::test (const gimple *gs)
> +{
> +  return gs->code == GIMPLE_GOTO;
> +}
> +
> +template <>
> +template <>
> +inline bool
>  is_a_helper <glabel *>::test (gimple *gs)
>  {
>    return gs->code == GIMPLE_LABEL;
> @@ -1033,6 +1049,14 @@ is_a_helper <glabel *>::test (gimple *gs)
>  template <>
>  template <>
>  inline bool
> +is_a_helper <const glabel *>::test (const gimple *gs)
> +{
> +  return gs->code == GIMPLE_LABEL;
> +}
> +
> +template <>
> +template <>
> +inline bool
>  is_a_helper <gresx *>::test (gimple *gs)
>  {
>    return gs->code == GIMPLE_RESX;
> @@ -1057,6 +1081,14 @@ is_a_helper <geh_else *>::test (gimple *gs)
>  template <>
>  template <>
>  inline bool
> +is_a_helper <const geh_else *>::test (const gimple *gs)
> +{
> +  return gs->code == GIMPLE_EH_ELSE;
> +}
> +
> +template <>
> +template <>
> +inline bool
>  is_a_helper <geh_filter *>::test (gimple *gs)
>  {
>    return gs->code == GIMPLE_EH_FILTER;
> @@ -1073,6 +1105,14 @@ is_a_helper <geh_mnt *>::test (gimple *gs)
>  template <>
>  template <>
>  inline bool
> +is_a_helper <const geh_mnt *>::test (const gimple *gs)
> +{
> +  return gs->code == GIMPLE_EH_MUST_NOT_THROW;
> +}
> +
> +template <>
> +template <>
> +inline bool
>  is_a_helper <gomp_atomic_load *>::test (gimple *gs)
>  {
>    return gs->code == GIMPLE_OMP_ATOMIC_LOAD;
> @@ -1219,6 +1259,14 @@ is_a_helper <gswitch *>::test (gimple *gs)
>  template <>
>  template <>
>  inline bool
> +is_a_helper <const gswitch *>::test (const gimple *gs)
> +{
> +  return gs->code == GIMPLE_SWITCH;
> +}
> +
> +template <>
> +template <>
> +inline bool
>  is_a_helper <gtransaction *>::test (gimple *gs)
>  {
>    return gs->code == GIMPLE_TRANSACTION;
> @@ -1235,6 +1283,14 @@ is_a_helper <gtry *>::test (gimple *gs)
>  template <>
>  template <>
>  inline bool
> +is_a_helper <const gtry *>::test (const gimple *gs)
> +{
> +  return gs->code == GIMPLE_TRY;
> +}
> +
> +template <>
> +template <>
> +inline bool
>  is_a_helper <gimple_statement_wce *>::test (gimple *gs)
>  {
>    return gs->code == GIMPLE_WITH_CLEANUP_EXPR;
> @@ -1429,6 +1485,14 @@ is_a_helper <const gphi *>::test (const gimple *gs)
>  template <>
>  template <>
>  inline bool
> +is_a_helper <const greturn *>::test (const gimple *gs)
> +{
> +  return gs->code == GIMPLE_RETURN;
> +}
> +
> +template <>
> +template <>
> +inline bool
>  is_a_helper <const gtransaction *>::test (const gimple *gs)
>  {
>    return gs->code == GIMPLE_TRANSACTION;
> @@ -3254,7 +3318,7 @@ gimple_call_set_tail (gcall *s, bool tail_p)
>  /* Return true if GIMPLE_CALL S is marked as a tail call.  */
>
>  static inline bool
> -gimple_call_tail_p (gcall *s)
> +gimple_call_tail_p (const gcall *s)
>  {
>    return (s->subcode & GF_CALL_TAILCALL) != 0;
>  }
> @@ -3296,7 +3360,7 @@ gimple_call_set_return_slot_opt (gcall *s, bool 
> return_slot_opt_p)
>  /* Return true if S is marked for return slot optimization.  */
>
>  static inline bool
> -gimple_call_return_slot_opt_p (gcall *s)
> +gimple_call_return_slot_opt_p (const gcall *s)
>  {
>    return (s->subcode & GF_CALL_RETURN_SLOT_OPT) != 0;
>  }
> @@ -3341,7 +3405,7 @@ gimple_call_set_va_arg_pack (gcall *s, bool 
> pass_arg_pack_p)
>     argument pack in its argument list.  */
>
>  static inline bool
> -gimple_call_va_arg_pack_p (gcall *s)
> +gimple_call_va_arg_pack_p (const gcall *s)
>  {
>    return (s->subcode & GF_CALL_VA_ARG_PACK) != 0;
>  }
> @@ -3443,6 +3507,13 @@ gimple_call_use_set (gcall *call_stmt)
>    return &call_stmt->call_used;
>  }
>
> +/* As above, but const.  */
> +
> +static inline const pt_solution *
> +gimple_call_use_set (const gcall *call_stmt)
> +{
> +  return &call_stmt->call_used;
> +}
>
>  /* Return a pointer to the points-to solution for the set of call-used
>     variables of the call CALL_STMT.  */
> @@ -3453,16 +3524,24 @@ gimple_call_clobber_set (gcall *call_stmt)
>    return &call_stmt->call_clobbered;
>  }
>
> +/* As above, but const.  */
> +
> +static inline const pt_solution *
> +gimple_call_clobber_set (const gcall *call_stmt)
> +{
> +  return &call_stmt->call_clobbered;
> +}
> +
>
>  /* Returns true if this is a GIMPLE_ASSIGN or a GIMPLE_CALL with a
>     non-NULL lhs.  */
>
>  static inline bool
> -gimple_has_lhs (gimple *stmt)
> +gimple_has_lhs (const gimple *stmt)
>  {
>    if (is_gimple_assign (stmt))
>      return true;
> -  if (gcall *call = dyn_cast <gcall *> (stmt))
> +  if (const gcall *call = dyn_cast <const gcall *> (stmt))
>      return gimple_call_lhs (call) != NULL_TREE;
>    return false;
>  }
> @@ -3760,9 +3839,9 @@ gimple_bind_body_ptr (gbind *bind_stmt)
>  /* Return the GIMPLE sequence contained in the GIMPLE_BIND statement GS.  */
>
>  static inline gimple_seq
> -gimple_bind_body (gbind *gs)
> +gimple_bind_body (const gbind *gs)
>  {
> -  return *gimple_bind_body_ptr (gs);
> +  return *gimple_bind_body_ptr (const_cast <gbind *> (gs));
>  }
>
>
> @@ -4034,9 +4113,9 @@ gimple_catch_handler_ptr (gcatch *catch_stmt)
>     GIMPLE_CATCH statement CATCH_STMT.  */
>
>  static inline gimple_seq
> -gimple_catch_handler (gcatch *catch_stmt)
> +gimple_catch_handler (const gcatch *catch_stmt)
>  {
> -  return *gimple_catch_handler_ptr (catch_stmt);
> +  return *gimple_catch_handler_ptr (const_cast <gcatch *> (catch_stmt));
>  }
>
>
> @@ -4094,9 +4173,9 @@ gimple_eh_filter_failure_ptr (gimple *gs)
>     statement fails.  */
>
>  static inline gimple_seq
> -gimple_eh_filter_failure (gimple *gs)
> +gimple_eh_filter_failure (const gimple *gs)
>  {
> -  return *gimple_eh_filter_failure_ptr (gs);
> +  return *gimple_eh_filter_failure_ptr (const_cast <gimple *> (gs));
>  }
>
>
> @@ -4123,7 +4202,7 @@ gimple_eh_filter_set_failure (geh_filter 
> *eh_filter_stmt,
>  /* Get the function decl to be called by the MUST_NOT_THROW region.  */
>
>  static inline tree
> -gimple_eh_must_not_throw_fndecl (geh_mnt *eh_mnt_stmt)
> +gimple_eh_must_not_throw_fndecl (const geh_mnt *eh_mnt_stmt)
>  {
>    return eh_mnt_stmt->fndecl;
>  }
> @@ -4146,9 +4225,9 @@ gimple_eh_else_n_body_ptr (geh_else *eh_else_stmt)
>  }
>
>  static inline gimple_seq
> -gimple_eh_else_n_body (geh_else *eh_else_stmt)
> +gimple_eh_else_n_body (const geh_else *eh_else_stmt)
>  {
> -  return *gimple_eh_else_n_body_ptr (eh_else_stmt);
> +  return *gimple_eh_else_n_body_ptr (const_cast <geh_else *> (eh_else_stmt));
>  }
>
>  static inline gimple_seq *
> @@ -4158,9 +4237,9 @@ gimple_eh_else_e_body_ptr (geh_else *eh_else_stmt)
>  }
>
>  static inline gimple_seq
> -gimple_eh_else_e_body (geh_else *eh_else_stmt)
> +gimple_eh_else_e_body (const geh_else *eh_else_stmt)
>  {
> -  return *gimple_eh_else_e_body_ptr (eh_else_stmt);
> +  return *gimple_eh_else_e_body_ptr (const_cast <geh_else *> (eh_else_stmt));
>  }
>
>  static inline void
> @@ -4224,9 +4303,9 @@ gimple_try_eval_ptr (gimple *gs)
>  /* Return the sequence of statements used as the body for GIMPLE_TRY GS.  */
>
>  static inline gimple_seq
> -gimple_try_eval (gimple *gs)
> +gimple_try_eval (const gimple *gs)
>  {
> -  return *gimple_try_eval_ptr (gs);
> +  return *gimple_try_eval_ptr (const_cast <gimple *> (gs));
>  }
>
>
> @@ -4245,9 +4324,9 @@ gimple_try_cleanup_ptr (gimple *gs)
>     GIMPLE_TRY GS.  */
>
>  static inline gimple_seq
> -gimple_try_cleanup (gimple *gs)
> +gimple_try_cleanup (const gimple *gs)
>  {
> -  return *gimple_try_cleanup_ptr (gs);
> +  return *gimple_try_cleanup_ptr (const_cast <gimple *> (gs));
>  }
>
>
> @@ -4406,6 +4485,13 @@ gimple_phi_arg (gphi *gs, unsigned index)
>    return &(gs->args[index]);
>  }
>
> +static inline const phi_arg_d *
> +gimple_phi_arg (const gphi *gs, unsigned index)
> +{
> +  gcc_gimple_checking_assert (index < gs->nargs);
> +  return &(gs->args[index]);
> +}
> +
>  static inline struct phi_arg_d *
>  gimple_phi_arg (gimple *gs, unsigned index)
>  {
> @@ -4445,7 +4531,7 @@ phi_nodes_ptr (basic_block bb)
>  /* Return the tree operand for argument I of PHI node GS.  */
>
>  static inline tree
> -gimple_phi_arg_def (gphi *gs, size_t index)
> +gimple_phi_arg_def (const gphi *gs, size_t index)
>  {
>    return gimple_phi_arg (gs, index)->def;
>  }
> @@ -4468,7 +4554,7 @@ gimple_phi_arg_def_ptr (gphi *phi, size_t index)
>  /* Return the edge associated with argument I of phi node PHI.  */
>
>  static inline edge
> -gimple_phi_arg_edge (gphi *phi, size_t i)
> +gimple_phi_arg_edge (const gphi *phi, size_t i)
>  {
>    return EDGE_PRED (gimple_bb (phi), i);
>  }
> @@ -4476,7 +4562,7 @@ gimple_phi_arg_edge (gphi *phi, size_t i)
>  /* Return the source location of gimple argument I of phi node PHI.  */
>
>  static inline location_t
> -gimple_phi_arg_location (gphi *phi, size_t i)
> +gimple_phi_arg_location (const gphi *phi, size_t i)
>  {
>    return gimple_phi_arg (phi, i)->locus;
>  }
> @@ -4500,7 +4586,7 @@ gimple_phi_arg_set_location (gphi *phi, size_t i, 
> location_t loc)
>  /* Return TRUE if argument I of phi node PHI has a location record.  */
>
>  static inline bool
> -gimple_phi_arg_has_location (gphi *phi, size_t i)
> +gimple_phi_arg_has_location (const gphi *phi, size_t i)
>  {
>    return gimple_phi_arg_location (phi, i) != UNKNOWN_LOCATION;
>  }
> @@ -4668,7 +4754,7 @@ gimple_debug_bind_p (const gimple *s)
>  /* Return the variable bound in a GIMPLE_DEBUG bind statement.  */
>
>  static inline tree
> -gimple_debug_bind_get_var (gimple *dbg)
> +gimple_debug_bind_get_var (const gimple *dbg)
>  {
>    GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
>    gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
> @@ -4679,7 +4765,7 @@ gimple_debug_bind_get_var (gimple *dbg)
>     statement.  */
>
>  static inline tree
> -gimple_debug_bind_get_value (gimple *dbg)
> +gimple_debug_bind_get_value (const gimple *dbg)
>  {
>    GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
>    gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
> @@ -4760,7 +4846,7 @@ gimple_debug_source_bind_p (const gimple *s)
>  /* Return the variable bound in a GIMPLE_DEBUG source bind statement.  */
>
>  static inline tree
> -gimple_debug_source_bind_get_var (gimple *dbg)
> +gimple_debug_source_bind_get_var (const gimple *dbg)
>  {
>    GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
>    gcc_gimple_checking_assert (gimple_debug_source_bind_p (dbg));
> @@ -4771,7 +4857,7 @@ gimple_debug_source_bind_get_var (gimple *dbg)
>     statement.  */
>
>  static inline tree
> -gimple_debug_source_bind_get_value (gimple *dbg)
> +gimple_debug_source_bind_get_value (const gimple *dbg)
>  {
>    GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
>    gcc_gimple_checking_assert (gimple_debug_source_bind_p (dbg));
> @@ -4872,9 +4958,9 @@ gimple_omp_body_ptr (gimple *gs)
>  /* Return the body for the OMP statement GS.  */
>
>  static inline gimple_seq
> -gimple_omp_body (gimple *gs)
> +gimple_omp_body (const gimple *gs)
>  {
> -  return *gimple_omp_body_ptr (gs);
> +  return *gimple_omp_body_ptr (const_cast <gimple *> (gs));
>  }
>
>  /* Set BODY to be the body for the OMP statement GS.  */
> @@ -5139,9 +5225,9 @@ gimple_omp_for_set_clauses (gimple *gs, tree clauses)
>  /* Get the collapse count of the OMP_FOR statement GS.  */
>
>  static inline size_t
> -gimple_omp_for_collapse (gimple *gs)
> +gimple_omp_for_collapse (const gimple *gs)
>  {
> -  gomp_for *omp_for_stmt = as_a <gomp_for *> (gs);
> +  const gomp_for *omp_for_stmt = as_a <const gomp_for *> (gs);
>    return omp_for_stmt->collapse;
>  }
>
> @@ -5316,9 +5402,9 @@ gimple_omp_for_pre_body_ptr (gimple *gs)
>     statement GS starts.  */
>
>  static inline gimple_seq
> -gimple_omp_for_pre_body (gimple *gs)
> +gimple_omp_for_pre_body (const gimple *gs)
>  {
> -  return *gimple_omp_for_pre_body_ptr (gs);
> +  return *gimple_omp_for_pre_body_ptr (const_cast <gimple *> (gs));
>  }
>
>
> @@ -6303,7 +6389,7 @@ gimple_transaction_body_ptr (gtransaction 
> *transaction_stmt)
>  /* Return the body for the GIMPLE_TRANSACTION statement TRANSACTION_STMT.  */
>
>  static inline gimple_seq
> -gimple_transaction_body (gtransaction *transaction_stmt)
> +gimple_transaction_body (const gtransaction *transaction_stmt)
>  {
>    return transaction_stmt->body;
>  }
> diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
> index 54502e6..b996f49 100644
> --- a/gcc/tree-eh.c
> +++ b/gcc/tree-eh.c
> @@ -139,19 +139,19 @@ remove_stmt_from_eh_lp (gimple *t)
>     statement is not recorded in the region table.  */
>
>  int
> -lookup_stmt_eh_lp_fn (struct function *ifun, gimple *t)
> +lookup_stmt_eh_lp_fn (struct function *ifun, const gimple *t)
>  {
>    if (ifun->eh->throw_stmt_table == NULL)
>      return 0;
>
> -  int *lp_nr = ifun->eh->throw_stmt_table->get (t);
> +  int *lp_nr = ifun->eh->throw_stmt_table->get (const_cast <gimple *> (t));
>    return lp_nr ? *lp_nr : 0;
>  }
>
>  /* Likewise, but always use the current function.  */
>
>  int
> -lookup_stmt_eh_lp (gimple *t)
> +lookup_stmt_eh_lp (const gimple *t)
>  {
>    /* We can get called from initialized data when -fnon-call-exceptions
>       is on; prevent crash.  */
> diff --git a/gcc/tree-eh.h b/gcc/tree-eh.h
> index 511bb84..ca3b521 100644
> --- a/gcc/tree-eh.h
> +++ b/gcc/tree-eh.h
> @@ -27,8 +27,8 @@ extern void using_eh_for_cleanups (void);
>  extern void add_stmt_to_eh_lp (gimple *, int);
>  extern bool remove_stmt_from_eh_lp_fn (struct function *, gimple *);
>  extern bool remove_stmt_from_eh_lp (gimple *);
> -extern int lookup_stmt_eh_lp_fn (struct function *, gimple *);
> -extern int lookup_stmt_eh_lp (gimple *);
> +extern int lookup_stmt_eh_lp_fn (struct function *, const gimple *);
> +extern int lookup_stmt_eh_lp (const gimple *);
>  extern bool make_eh_dispatch_edges (geh_dispatch *);
>  extern void make_eh_edges (gimple *);
>  extern edge redirect_eh_edge (edge, basic_block);
> diff --git a/gcc/tree-ssa-alias.h b/gcc/tree-ssa-alias.h
> index 6d72c2f..de85312 100644
> --- a/gcc/tree-ssa-alias.h
> +++ b/gcc/tree-ssa-alias.h
> @@ -162,7 +162,7 @@ extern void dump_alias_stats (FILE *);
>
>  /* In tree-ssa-structalias.c  */
>  extern unsigned int compute_may_aliases (void);
> -extern bool pt_solution_empty_p (struct pt_solution *);
> +extern bool pt_solution_empty_p (const pt_solution *);
>  extern bool pt_solution_singleton_or_null_p (struct pt_solution *, unsigned 
> *);
>  extern bool pt_solution_includes_global (struct pt_solution *);
>  extern bool pt_solution_includes (struct pt_solution *, const_tree);
> diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
> index 75c6fae..b248dfa 100644
> --- a/gcc/tree-ssa-structalias.c
> +++ b/gcc/tree-ssa-structalias.c
> @@ -6801,7 +6801,7 @@ pt_solution_ior_into (struct pt_solution *dest, struct 
> pt_solution *src)
>  /* Return true if the points-to solution *PT is empty.  */
>
>  bool
> -pt_solution_empty_p (struct pt_solution *pt)
> +pt_solution_empty_p (const pt_solution *pt)
>  {
>    if (pt->anything
>        || pt->nonlocal)
> --
> 1.8.5.3
>

Reply via email to