https://gcc.gnu.org/g:bf1e44fe55166548f369668a26cd5c302025692f

commit r17-6347-gbf1e44fe55166548f369668a26cd5c302025692f
Author: Richard Biener <[email protected]>
Date:   Wed Oct 28 17:45:31 2026 +0100

    Improve const correctness of APIs in gimple.h
    
    This fixes const correctness for several predicates, accessors, and utility
    functions in gimple.h and gimple.cc.  It also adds some missing
    pieces for consistency.
    
    Assisted-by: Claude Opus 5.5
    
            * gimple.h (is_a_helper <const gimple_statement_wce *>): New
            specialization.
            (gimple_call_nonnull_result_p, gimple_call_nonnull_arg): Accept
            const gcall *.
            (gimple_assign_copy_p, gimple_assign_ssa_name_copy_p,
            gimple_assign_unary_nop_p, gimple_assign_rhs_could_trap_p): Accept
            const gimple *.
            (gimple_copy): Accept const gimple *.
            (gimple_move_vops): Accept const gimple * for old_stmt.
            (gimple_call_copy_skip_args): Accept const gcall * and
            const_bitmap.
            (gimple_compare_field_offset): Accept const_tree parameters.
            (dump_decl_set): Accept const_bitmap.
            (nonfreeing_call_p, nonbarrier_call_p): Accept const gimple *.
            (infer_nonnull_range_by_attribute): Accept const gimple *.
            (gimple_inexpensive_call_p): Accept const gcall *.
            (gimple_or_expr_nonartificial_location): Accept const gimple *.
            (gimple_statement_structure, gimple_has_substatements): Accept
            const gimple *.
            (gimple_visited_p, gimple_plf, gimple_references_memory_p): Accept
            const gimple *.
            (gimple_ops): Add const overload returning const tree *.  Implement
            the non-const overload using it.
            (gimple_op): Avoid const_cast by using the const overload of
            gimple_ops.
            (gimple_assign_rhs3_ptr): Add gassign * overload.
            (gimple_call_from_thunk_p, gimple_call_expected_throw_p,
            gimple_call_by_descriptor_p): Accept const gcall *.
            (gimple_call_alloca_for_var_p): Accept const gcall * and
            const gimple *.
            (gimple_call_copy_flags): Accept const gcall * for orig_call.
            (gimple_wce_cleanup): Accept const gimple *.
            (gimple_phi_arg_location_from_edge): Accept const gphi *.
            (gimple_debug_bind_has_value_p): Accept const gimple *.
            (gimple_do_not_emit_location_p): Accept const gimple *.
            * gimple.cc (gimple_call_nonnull_result_p, gimple_call_nonnull_arg):
            Update parameter types to const.
            (gimple_assign_copy_p, gimple_assign_ssa_name_copy_p,
            gimple_assign_unary_nop_p, gimple_assign_rhs_could_trap_p):
            Likewise.
            (gimple_copy): Likewise.  Use as_a <const ...> to access the
            source statement.
            (gimple_move_vops): Update parameter types to const.
            (gimple_call_copy_skip_args): Likewise.
            (gimple_compare_field_offset): Likewise.
            (dump_decl_set): Likewise.
            (nonfreeing_call_p, nonbarrier_call_p): Likewise.
            (infer_nonnull_range_by_attribute): Likewise.  Use
            dyn_cast <const greturn *>.
            (gimple_inexpensive_call_p): Update parameter types to const.
            (gimple_or_expr_nonartificial_location): Likewise.

Diff:
---
 gcc/gimple.cc |  61 +++++++++++++++++-----------------
 gcc/gimple.h  | 103 +++++++++++++++++++++++++++++++++++-----------------------
 2 files changed, 95 insertions(+), 69 deletions(-)

diff --git a/gcc/gimple.cc b/gcc/gimple.cc
index 6509c02a9c5b..b00006078087 100644
--- a/gcc/gimple.cc
+++ b/gcc/gimple.cc
@@ -1784,7 +1784,7 @@ gimple_call_return_flags (const gcall *stmt)
 /* Return true if call STMT is known to return a non-zero result.  */
 
 bool
-gimple_call_nonnull_result_p (gcall *call)
+gimple_call_nonnull_result_p (const gcall *call)
 {
   tree fndecl = gimple_call_fndecl (call);
   if (!fndecl)
@@ -1810,7 +1810,7 @@ gimple_call_nonnull_result_p (gcall *call)
 /* If CALL returns a non-null result in an argument, return that arg.  */
 
 tree
-gimple_call_nonnull_arg (gcall *call)
+gimple_call_nonnull_arg (const gcall *call)
 {
   tree fndecl = gimple_call_fndecl (call);
   if (!fndecl)
@@ -1835,7 +1835,7 @@ gimple_call_nonnull_arg (gcall *call)
 /* Return true if GS is a copy assignment.  */
 
 bool
-gimple_assign_copy_p (gimple *gs)
+gimple_assign_copy_p (const gimple *gs)
 {
   return (gimple_assign_single_p (gs)
          && is_gimple_val (gimple_op (gs, 1)));
@@ -1845,7 +1845,7 @@ gimple_assign_copy_p (gimple *gs)
 /* Return true if GS is a SSA_NAME copy assignment.  */
 
 bool
-gimple_assign_ssa_name_copy_p (gimple *gs)
+gimple_assign_ssa_name_copy_p (const gimple *gs)
 {
   return (gimple_assign_single_p (gs)
          && TREE_CODE (gimple_assign_lhs (gs)) == SSA_NAME
@@ -1868,7 +1868,7 @@ gimple_assign_ssa_name_copy_p (gimple *gs)
    treatment of unary NOPs is appropriate.  */
 
 bool
-gimple_assign_unary_nop_p (gimple *gs)
+gimple_assign_unary_nop_p (const gimple *gs)
 {
   return (is_gimple_assign (gs)
           && (CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (gs))
@@ -2042,7 +2042,7 @@ gimple_set_lhs (gimple *stmt, tree lhs)
    copy isn't part of any sequence.  */
 
 gimple *
-gimple_copy (gimple *stmt)
+gimple_copy (const gimple *stmt)
 {
   enum gimple_code code = gimple_code (stmt);
   unsigned num_ops = gimple_num_ops (stmt);
@@ -2063,7 +2063,7 @@ gimple_copy (gimple *stmt)
        {
        case GIMPLE_BIND:
          {
-           gbind *bind_stmt = as_a <gbind *> (stmt);
+           const gbind *bind_stmt = as_a <const gbind *> (stmt);
            gbind *bind_copy = as_a <gbind *> (copy);
            new_seq = gimple_seq_copy (gimple_bind_body (bind_stmt));
            gimple_bind_set_body (bind_copy, new_seq);
@@ -2075,7 +2075,7 @@ gimple_copy (gimple *stmt)
 
        case GIMPLE_CATCH:
          {
-           gcatch *catch_stmt = as_a <gcatch *> (stmt);
+           const gcatch *catch_stmt = as_a <const gcatch *> (stmt);
            gcatch *catch_copy = as_a <gcatch *> (copy);
            new_seq = gimple_seq_copy (gimple_catch_handler (catch_stmt));
            gimple_catch_set_handler (catch_copy, new_seq);
@@ -2086,7 +2086,7 @@ gimple_copy (gimple *stmt)
 
        case GIMPLE_EH_FILTER:
          {
-           geh_filter *eh_filter_stmt = as_a <geh_filter *> (stmt);
+           const geh_filter *eh_filter_stmt = as_a <const geh_filter *> (stmt);
            geh_filter *eh_filter_copy = as_a <geh_filter *> (copy);
            new_seq
              = gimple_seq_copy (gimple_eh_filter_failure (eh_filter_stmt));
@@ -2098,7 +2098,7 @@ gimple_copy (gimple *stmt)
 
        case GIMPLE_EH_ELSE:
          {
-           geh_else *eh_else_stmt = as_a <geh_else *> (stmt);
+           const geh_else *eh_else_stmt = as_a <const geh_else *> (stmt);
            geh_else *eh_else_copy = as_a <geh_else *> (copy);
            new_seq = gimple_seq_copy (gimple_eh_else_n_body (eh_else_stmt));
            gimple_eh_else_set_n_body (eh_else_copy, new_seq);
@@ -2109,7 +2109,7 @@ gimple_copy (gimple *stmt)
 
        case GIMPLE_TRY:
          {
-           gtry *try_stmt = as_a <gtry *> (stmt);
+           const gtry *try_stmt = as_a <const gtry *> (stmt);
            gtry *try_copy = as_a <gtry *> (copy);
            new_seq = gimple_seq_copy (gimple_try_eval (try_stmt));
            gimple_try_set_eval (try_copy, new_seq);
@@ -2145,7 +2145,8 @@ gimple_copy (gimple *stmt)
 
        case GIMPLE_OMP_PARALLEL:
          {
-           gomp_parallel *omp_par_stmt = as_a <gomp_parallel *> (stmt);
+           const gomp_parallel *omp_par_stmt
+             = as_a <const gomp_parallel *> (stmt);
            gomp_parallel *omp_par_copy = as_a <gomp_parallel *> (copy);
            t = unshare_expr (gimple_omp_parallel_clauses (omp_par_stmt));
            gimple_omp_parallel_set_clauses (omp_par_copy, t);
@@ -2173,21 +2174,21 @@ gimple_copy (gimple *stmt)
 
        case GIMPLE_OMP_CRITICAL:
          t = unshare_expr (gimple_omp_critical_name
-                               (as_a <gomp_critical *> (stmt)));
+                               (as_a <const gomp_critical *> (stmt)));
          gimple_omp_critical_set_name (as_a <gomp_critical *> (copy), t);
          t = unshare_expr (gimple_omp_critical_clauses
-                               (as_a <gomp_critical *> (stmt)));
+                               (as_a <const gomp_critical *> (stmt)));
          gimple_omp_critical_set_clauses (as_a <gomp_critical *> (copy), t);
          goto copy_omp_body;
 
        case GIMPLE_OMP_ORDERED:
          t = unshare_expr (gimple_omp_ordered_clauses
-                               (as_a <gomp_ordered *> (stmt)));
+                               (as_a <const gomp_ordered *> (stmt)));
          gimple_omp_ordered_set_clauses (as_a <gomp_ordered *> (copy), t);
          goto copy_omp_body;
 
        case GIMPLE_OMP_SCAN:
-         t = gimple_omp_scan_clauses (as_a <gomp_scan *> (stmt));
+         t = gimple_omp_scan_clauses (as_a <const gomp_scan *> (stmt));
          t = unshare_expr (t);
          gimple_omp_scan_set_clauses (as_a <gomp_scan *> (copy), t);
          goto copy_omp_body;
@@ -2229,7 +2230,8 @@ gimple_copy (gimple *stmt)
 
        case GIMPLE_OMP_TARGET:
          {
-           gomp_target *omp_target_stmt = as_a <gomp_target *> (stmt);
+           const gomp_target *omp_target_stmt
+             = as_a <const gomp_target *> (stmt);
            gomp_target *omp_target_copy = as_a <gomp_target *> (copy);
            t = unshare_expr (gimple_omp_target_clauses (omp_target_stmt));
            gimple_omp_target_set_clauses (omp_target_copy, t);
@@ -2268,7 +2270,7 @@ gimple_copy (gimple *stmt)
 
        case GIMPLE_TRANSACTION:
          new_seq = gimple_seq_copy (gimple_transaction_body (
-                                      as_a <gtransaction *> (stmt)));
+                                      as_a <const gtransaction *> (stmt)));
          gimple_transaction_set_body (as_a <gtransaction *> (copy),
                                       new_seq);
          break;
@@ -2334,7 +2336,7 @@ gimple_copy (gimple *stmt)
    that OLD_STMT is about to be removed.  */
 
 void
-gimple_move_vops (gimple *new_stmt, gimple *old_stmt)
+gimple_move_vops (gimple *new_stmt, const gimple *old_stmt)
 {
   tree vdef = gimple_vdef (old_stmt);
   gimple_set_vuse (new_stmt, gimple_vuse (old_stmt));
@@ -2488,7 +2490,7 @@ gimple_could_trap_p (const gimple *s)
 /* Return true if RHS of a GIMPLE_ASSIGN S can trap.  */
 
 bool
-gimple_assign_rhs_could_trap_p (gimple *s)
+gimple_assign_rhs_could_trap_p (const gimple *s)
 {
   gcc_assert (is_gimple_assign (s));
   return gimple_could_trap_p_1 (s, true, false);
@@ -2590,7 +2592,7 @@ const unsigned char gimple_rhs_class_table[] = {
    the positions marked by the set ARGS_TO_SKIP.  */
 
 gcall *
-gimple_call_copy_skip_args (gcall *stmt, bitmap args_to_skip)
+gimple_call_copy_skip_args (const gcall *stmt, const_bitmap args_to_skip)
 {
   int i;
   int nargs = gimple_call_num_args (stmt);
@@ -2630,7 +2632,7 @@ gimple_call_copy_skip_args (gcall *stmt, bitmap 
args_to_skip)
    This is intended to be used on GIMPLE types only.  */
 
 bool
-gimple_compare_field_offset (tree f1, tree f2)
+gimple_compare_field_offset (const_tree f1, const_tree f2)
 {
   if (DECL_OFFSET_ALIGN (f1) == DECL_OFFSET_ALIGN (f2))
     {
@@ -3053,7 +3055,7 @@ gimple_asm_clobbers_memory_p (const gasm *stmt)
 /* Dump bitmap SET (assumed to contain VAR_DECLs) to FILE.  */
 
 void
-dump_decl_set (FILE *file, bitmap set)
+dump_decl_set (FILE *file, const_bitmap set)
 {
   if (set)
     {
@@ -3077,7 +3079,7 @@ dump_decl_set (FILE *file, bitmap set)
 /* Return true when CALL is a call stmt that definitely doesn't
    free any memory or makes it unavailable otherwise.  */
 bool
-nonfreeing_call_p (gimple *call)
+nonfreeing_call_p (const gimple *call)
 {
   if (gimple_call_builtin_p (call, BUILT_IN_NORMAL)
       && gimple_call_flags (call) & ECF_LEAF)
@@ -3123,7 +3125,7 @@ nonfreeing_call_p (gimple *call)
 /* Return true when CALL is a call stmt that definitely need not
    be considered to be a memory barrier.  */
 bool
-nonbarrier_call_p (gimple *call)
+nonbarrier_call_p (const gimple *call)
 {
   if (gimple_call_flags (call) & (ECF_PURE | ECF_CONST))
     return true;
@@ -3200,7 +3202,8 @@ infer_nonnull_range_by_dereference (gimple *stmt, tree op)
    returning true doesn't mean OP can be unconditionally inferred to be
    non-NULL, but conditionally).  */
 bool
-infer_nonnull_range_by_attribute (gimple *stmt, tree op, tree *op2, tree *op3)
+infer_nonnull_range_by_attribute (const gimple *stmt, tree op, tree *op2,
+                                 tree *op3)
 {
   if (op2)
     {
@@ -3296,7 +3299,7 @@ infer_nonnull_range_by_attribute (gimple *stmt, tree op, 
tree *op2, tree *op3)
 
   /* If this function is marked as returning non-null, then we can
      infer OP is non-null if it is used in the return statement.  */
-  if (greturn *return_stmt = dyn_cast <greturn *> (stmt))
+  if (const greturn *return_stmt = dyn_cast <const greturn *> (stmt))
     if (gimple_return_retval (return_stmt)
        && operand_equal_p (gimple_return_retval (return_stmt), op, 0)
        && lookup_attribute ("returns_nonnull",
@@ -3562,7 +3565,7 @@ maybe_remove_unused_call_args (struct function *fn, 
gimple *stmt)
 /* Return false if STMT will likely expand to real function call.  */
 
 bool
-gimple_inexpensive_call_p (gcall *stmt)
+gimple_inexpensive_call_p (const gcall *stmt)
 {
   if (gimple_call_internal_p (stmt))
     return true;
@@ -3576,7 +3579,7 @@ gimple_inexpensive_call_p (gcall *stmt)
    location information, get the location from EXPR.  */
 
 location_t
-gimple_or_expr_nonartificial_location (gimple *stmt, tree expr)
+gimple_or_expr_nonartificial_location (const gimple *stmt, tree expr)
 {
   location_t loc = gimple_nonartificial_location (stmt);
   if (loc == UNKNOWN_LOCATION && EXPR_HAS_LOCATION (expr))
diff --git a/gcc/gimple.h b/gcc/gimple.h
index f8f5b01ba85b..ea4aea0bdf93 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -1331,6 +1331,14 @@ is_a_helper <gimple_statement_wce *>::test (gimple *gs)
   return gs->code == GIMPLE_WITH_CLEANUP_EXPR;
 }
 
+template <>
+template <>
+inline bool
+is_a_helper <const gimple_statement_wce *>::test (const gimple *gs)
+{
+  return gs->code == GIMPLE_WITH_CLEANUP_EXPR;
+}
+
 template <>
 template <>
 inline bool
@@ -1636,11 +1644,11 @@ int gimple_call_arg_flags (const gcall *, unsigned);
 int gimple_call_retslot_flags (const gcall *);
 int gimple_call_static_chain_flags (const gcall *);
 int gimple_call_return_flags (const gcall *);
-bool gimple_call_nonnull_result_p (gcall *);
-tree gimple_call_nonnull_arg (gcall *);
-bool gimple_assign_copy_p (gimple *);
-bool gimple_assign_ssa_name_copy_p (gimple *);
-bool gimple_assign_unary_nop_p (gimple *);
+bool gimple_call_nonnull_result_p (const gcall *);
+tree gimple_call_nonnull_arg (const gcall *);
+bool gimple_assign_copy_p (const gimple *);
+bool gimple_assign_ssa_name_copy_p (const gimple *);
+bool gimple_assign_unary_nop_p (const gimple *);
 bool gimple_assign_load_p (const gimple *);
 void gimple_set_bb (gimple *, basic_block);
 void gimple_assign_set_rhs_from_tree (gimple_stmt_iterator *, tree);
@@ -1648,16 +1656,16 @@ void gimple_assign_set_rhs_with_ops 
(gimple_stmt_iterator *, enum tree_code,
                                     tree, tree, tree);
 tree gimple_get_lhs (const gimple *);
 void gimple_set_lhs (gimple *, tree);
-gimple *gimple_copy (gimple *);
-void gimple_move_vops (gimple *, gimple *);
+gimple *gimple_copy (const gimple *);
+void gimple_move_vops (gimple *, const gimple *);
 bool gimple_has_side_effects (const gimple *);
 bool gimple_could_trap_p_1 (const gimple *, bool, bool);
 bool gimple_could_trap_p (const gimple *);
-bool gimple_assign_rhs_could_trap_p (gimple *);
+bool gimple_assign_rhs_could_trap_p (const gimple *);
 extern void dump_gimple_statistics (void);
 unsigned get_gimple_rhs_num_ops (enum tree_code);
-gcall *gimple_call_copy_skip_args (gcall *, bitmap);
-extern bool gimple_compare_field_offset (tree, tree);
+gcall *gimple_call_copy_skip_args (const gcall *, const_bitmap);
+extern bool gimple_compare_field_offset (const_tree, const_tree);
 extern tree gimple_unsigned_type (tree);
 extern tree gimple_signed_type (tree);
 extern alias_set_type gimple_get_alias_set (tree);
@@ -1668,21 +1676,21 @@ extern bool gimple_call_builtin_p (const gimple *);
 extern bool gimple_call_builtin_p (const gimple *, enum built_in_class);
 extern bool gimple_call_builtin_p (const gimple *, enum built_in_function);
 extern bool gimple_asm_clobbers_memory_p (const gasm *);
-extern void dump_decl_set (FILE *, bitmap);
-extern bool nonfreeing_call_p (gimple *);
-extern bool nonbarrier_call_p (gimple *);
+extern void dump_decl_set (FILE *, const_bitmap);
+extern bool nonfreeing_call_p (const gimple *);
+extern bool nonbarrier_call_p (const gimple *);
 extern bool infer_nonnull_range (gimple *, tree);
 extern bool infer_nonnull_range_by_dereference (gimple *, tree);
-extern bool infer_nonnull_range_by_attribute (gimple *, tree, tree * = NULL,
-                                             tree * = NULL);
+extern bool infer_nonnull_range_by_attribute (const gimple *, tree,
+                                             tree * = NULL, tree * = NULL);
 extern void sort_case_labels (vec<tree> &);
 extern void preprocess_case_label_vec_for_gimple (vec<tree> &, tree, tree *);
 extern void gimple_seq_set_location (gimple_seq, location_t);
 extern void gimple_seq_discard (gimple_seq);
 extern void maybe_remove_unused_call_args (struct function *, gimple *);
-extern bool gimple_inexpensive_call_p (gcall *);
+extern bool gimple_inexpensive_call_p (const gcall *);
 extern bool stmt_can_terminate_bb_p (gimple *);
-extern location_t gimple_or_expr_nonartificial_location (gimple *, tree);
+extern location_t gimple_or_expr_nonartificial_location (const gimple *, tree);
 gcall *gimple_build_builtin_unreachable (location_t);
 
 /* Return the disposition for a warning (or all warnings by default)
@@ -1865,7 +1873,7 @@ gss_for_code (enum gimple_code code)
 /* Return which GSS code is used by GS.  */
 
 inline enum gimple_statement_structure_enum
-gimple_statement_structure (gimple *gs)
+gimple_statement_structure (const gimple *gs)
 {
   return gss_for_code (gimple_code (gs));
 }
@@ -1875,7 +1883,7 @@ gimple_statement_structure (gimple *gs)
    High GIMPLE statements.  */
 
 inline bool
-gimple_has_substatements (gimple *g)
+gimple_has_substatements (const gimple *g)
 {
   switch (gimple_code (g))
     {
@@ -2073,7 +2081,7 @@ gimple_set_visited (gimple *stmt, bool visited_p)
    struct gimple.  */
 
 inline bool
-gimple_visited_p (gimple *stmt)
+gimple_visited_p (const gimple *stmt)
 {
   return stmt->visited;
 }
@@ -2110,7 +2118,7 @@ gimple_set_plf (gimple *stmt, enum plf_mask plf, bool 
val_p)
    the 'plf' data member of struct gimple_statement_structure.  */
 
 inline unsigned int
-gimple_plf (gimple *stmt, enum plf_mask plf)
+gimple_plf (const gimple *stmt, enum plf_mask plf)
 {
   return stmt->plf & ((unsigned int) plf);
 }
@@ -2357,7 +2365,7 @@ gimple_in_transaction (const gimple *stmt)
 /* Return true if statement STMT may access memory.  */
 
 inline bool
-gimple_references_memory_p (gimple *stmt)
+gimple_references_memory_p (const gimple *stmt)
 {
   return gimple_has_mem_ops (stmt) && gimple_vuse (stmt);
 }
@@ -2595,8 +2603,8 @@ gimple_set_num_ops (gimple *gs, unsigned num_ops)
 
 /* Return the array of operands for statement GS.  */
 
-inline tree *
-gimple_ops (gimple *gs)
+inline const tree *
+gimple_ops (const gimple *gs)
 {
   size_t off;
 
@@ -2606,7 +2614,14 @@ gimple_ops (gimple *gs)
   off = gimple_ops_offset_[gimple_statement_structure (gs)];
   gcc_gimple_checking_assert (off != 0);
 
-  return (tree *) ((char *) gs + off);
+  return (const tree *) ((const char *) gs + off);
+}
+
+inline tree *
+gimple_ops (gimple *gs)
+{
+  /* Avoid repeating the code above.  */
+  return const_cast <tree *> (gimple_ops (const_cast <const gimple *> (gs)));
 }
 
 
@@ -2618,7 +2633,7 @@ gimple_op (const gimple *gs, unsigned i)
   if (gimple_has_ops (gs))
     {
       gcc_gimple_checking_assert (i < gimple_num_ops (gs));
-      return gimple_ops (const_cast<gimple *> (gs))[i];
+      return gimple_ops (gs)[i];
     }
   else
     return NULL_TREE;
@@ -2844,12 +2859,18 @@ gimple_assign_rhs3 (const gimple *gs)
 /* Return a pointer to the third operand on the RHS of assignment
    statement GS.  */
 
+inline tree *
+gimple_assign_rhs3_ptr (gassign *gs)
+{
+  gcc_gimple_checking_assert (gimple_num_ops (gs) >= 4);
+  return &gs->op[3];
+}
+
 inline tree *
 gimple_assign_rhs3_ptr (gimple *gs)
 {
   gassign *ass = GIMPLE_CHECK2<gassign *> (gs);
-  gcc_gimple_checking_assert (gimple_num_ops (gs) >= 4);
-  return &ass->op[3];
+  return gimple_assign_rhs3_ptr (ass);
 }
 
 
@@ -3494,7 +3515,7 @@ gimple_call_set_from_thunk (gcall *s, bool from_thunk_p)
 /* Return true if GIMPLE_CALL S is a jump from a thunk.  */
 
 inline bool
-gimple_call_from_thunk_p (gcall *s)
+gimple_call_from_thunk_p (const gcall *s)
 {
   return (s->subcode & GF_CALL_FROM_THUNK) != 0;
 }
@@ -3599,7 +3620,7 @@ gimple_call_set_expected_throw (gcall *s, bool 
expected_throw_p)
    propagating an exception than by other means.  */
 
 static inline bool
-gimple_call_expected_throw_p (gcall *s)
+gimple_call_expected_throw_p (const gcall *s)
 {
   return (gimple_call_flags (s) & ECF_XTHROW) != 0;
 }
@@ -3621,15 +3642,15 @@ gimple_call_set_alloca_for_var (gcall *s, bool for_var)
 /* Return true of S is a call to builtin_alloca emitted for VLA objects.  */
 
 inline bool
-gimple_call_alloca_for_var_p (gcall *s)
+gimple_call_alloca_for_var_p (const gcall *s)
 {
   return (s->subcode & GF_CALL_ALLOCA_FOR_VAR) != 0;
 }
 
 inline bool
-gimple_call_alloca_for_var_p (gimple *s)
+gimple_call_alloca_for_var_p (const gimple *s)
 {
-  const gcall *gc = GIMPLE_CHECK2<gcall *> (s);
+  const gcall *gc = GIMPLE_CHECK2<const gcall *> (s);
   return (gc->subcode & GF_CALL_ALLOCA_FOR_VAR) != 0;
 }
 
@@ -3648,7 +3669,7 @@ gimple_call_set_by_descriptor (gcall  *s, bool 
by_descriptor_p)
 /* Return true if S is a by-descriptor call.  */
 
 inline bool
-gimple_call_by_descriptor_p (gcall *s)
+gimple_call_by_descriptor_p (const gcall *s)
 {
   return (s->subcode & GF_CALL_BY_DESCRIPTOR) != 0;
 }
@@ -3656,7 +3677,7 @@ gimple_call_by_descriptor_p (gcall *s)
 /* Copy all the GF_CALL_* flags from ORIG_CALL to DEST_CALL.  */
 
 inline void
-gimple_call_copy_flags (gcall *dest_call, gcall *orig_call)
+gimple_call_copy_flags (gcall *dest_call, const gcall *orig_call)
 {
   dest_call->subcode = orig_call->subcode;
 }
@@ -4594,9 +4615,11 @@ gimple_wce_cleanup_ptr (gimple *gs)
 /* Return the cleanup sequence for cleanup statement GS.  */
 
 inline gimple_seq
-gimple_wce_cleanup (gimple *gs)
+gimple_wce_cleanup (const gimple *gs)
 {
-  return *gimple_wce_cleanup_ptr (gs);
+  const gimple_statement_wce *wce_stmt
+    = as_a <const gimple_statement_wce *> (gs);
+  return wce_stmt->cleanup;
 }
 
 
@@ -4811,7 +4834,7 @@ gimple_phi_arg_location (const gphi *phi, size_t i)
 /* Return the source location of the argument on edge E of phi node PHI.  */
 
 inline location_t
-gimple_phi_arg_location_from_edge (gphi *phi, edge e)
+gimple_phi_arg_location_from_edge (const gphi *phi, edge e)
 {
   return gimple_phi_arg (phi, e->dest_idx)->locus;
 }
@@ -5122,7 +5145,7 @@ gimple_debug_bind_reset_value (gimple *dbg)
    value.  */
 
 inline bool
-gimple_debug_bind_has_value_p (gimple *dbg)
+gimple_debug_bind_has_value_p (const gimple *dbg)
 {
   GIMPLE_CHECK (dbg, GIMPLE_DEBUG);
   gcc_gimple_checking_assert (gimple_debug_bind_p (dbg));
@@ -7067,7 +7090,7 @@ gimple_alloc_kind (enum gimple_code code)
    by annotate_all_with_location.  */
 
 inline bool
-gimple_do_not_emit_location_p (gimple *g)
+gimple_do_not_emit_location_p (const gimple *g)
 {
   return gimple_plf (g, GF_PLF_1);
 }

Reply via email to