This corresponds to:
  [PATCH 86/89] Concretize gimple_call_copy_flags and ipa_modify_call_arguments
  https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01175.html
from the original 89-patch kit

That earlier patch was approved by Jeff:
> OK when prereqs go in.
in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00855.html

gcc/
        * gimple.h (gimple_call_copy_flags): Require gimple_calls.

        * ipa-prop.c (ipa_modify_call_arguments): Require a gimple_call.
        * ipa-prop.h (ipa_modify_call_arguments): Likewise.

        * tree-inline.c (copy_bb): Replace is_gimple_call with new local
        and call to dyn_cast<gimple_call>, updating gimple_call_ uses to
        use the type-checked local.

        * tree-sra.c (convert_callers): Replace check for GIMPLE_CALL with
        a dyn_cast.
---
 gcc/ChangeLog.gimple-classes | 16 ++++++++++++++++
 gcc/gimple.h                 |  4 +---
 gcc/ipa-prop.c               |  2 +-
 gcc/ipa-prop.h               |  2 +-
 gcc/tree-inline.c            | 20 +++++++++++---------
 gcc/tree-sra.c               |  5 +++--
 6 files changed, 33 insertions(+), 16 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index 572fe5a..9255151 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,21 @@
 2014-10-24  David Malcolm  <[email protected]>
 
+       Concretize gimple_call_copy_flags and ipa_modify_call_arguments
+
+       * gimple.h (gimple_call_copy_flags): Require gimple_calls.
+
+       * ipa-prop.c (ipa_modify_call_arguments): Require a gimple_call.
+       * ipa-prop.h (ipa_modify_call_arguments): Likewise.
+
+       * tree-inline.c (copy_bb): Replace is_gimple_call with new local
+       and call to dyn_cast<gimple_call>, updating gimple_call_ uses to
+       use the type-checked local.
+
+       * tree-sra.c (convert_callers): Replace check for GIMPLE_CALL with
+       a dyn_cast.
+
+2014-10-24  David Malcolm  <[email protected]>
+
        Concretize gimple_assign_nontemporal_move_p
 
        * gimple.h (gimple_assign_nontemporal_move_p): Require a
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 5570c54..1722b6c 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -2948,10 +2948,8 @@ gimple_call_alloca_for_var_p (gimple_call s)
 /* Copy all the GF_CALL_* flags from ORIG_CALL to DEST_CALL.  */
 
 static inline void
-gimple_call_copy_flags (gimple dest_call, gimple orig_call)
+gimple_call_copy_flags (gimple_call dest_call, gimple_call orig_call)
 {
-  GIMPLE_CHECK (dest_call, GIMPLE_CALL);
-  GIMPLE_CHECK (orig_call, GIMPLE_CALL);
   dest_call->subcode = orig_call->subcode;
 }
 
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index 5a861f8..93fda45 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -4147,7 +4147,7 @@ ipa_modify_formal_parameters (tree fndecl, 
ipa_parm_adjustment_vec adjustments)
    contain the corresponding call graph edge.  */
 
 void
-ipa_modify_call_arguments (struct cgraph_edge *cs, gimple stmt,
+ipa_modify_call_arguments (struct cgraph_edge *cs, gimple_call stmt,
                           ipa_parm_adjustment_vec adjustments)
 {
   struct cgraph_node *current_node = cgraph_node::get (current_function_decl);
diff --git a/gcc/ipa-prop.h b/gcc/ipa-prop.h
index 7a06af9..1beec51 100644
--- a/gcc/ipa-prop.h
+++ b/gcc/ipa-prop.h
@@ -705,7 +705,7 @@ typedef vec<ipa_parm_adjustment> ipa_parm_adjustment_vec;
 vec<tree> ipa_get_vector_of_formal_parms (tree fndecl);
 vec<tree> ipa_get_vector_of_formal_parm_types (tree fntype);
 void ipa_modify_formal_parameters (tree fndecl, ipa_parm_adjustment_vec);
-void ipa_modify_call_arguments (struct cgraph_edge *, gimple,
+void ipa_modify_call_arguments (struct cgraph_edge *, gimple_call,
                                ipa_parm_adjustment_vec);
 ipa_parm_adjustment_vec ipa_combine_adjustments (ipa_parm_adjustment_vec,
                                                 ipa_parm_adjustment_vec);
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index a0a299b..faa4656 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1725,10 +1725,12 @@ copy_bb (copy_body_data *id, basic_block bb, int 
frequency_scale,
       do
        {
          tree fn;
+         gimple_call call_stmt;
 
          stmt = gsi_stmt (copy_gsi);
-         if (is_gimple_call (stmt)
-             && gimple_call_va_arg_pack_p (as_a <gimple_call> (stmt))
+         call_stmt = dyn_cast <gimple_call> (stmt);
+         if (call_stmt
+             && gimple_call_va_arg_pack_p (call_stmt)
              && id->gimple_call)
            {
              /* __builtin_va_arg_pack () should be replaced by
@@ -1743,33 +1745,33 @@ copy_bb (copy_body_data *id, basic_block bb, int 
frequency_scale,
                nargs--;
 
              /* Create the new array of arguments.  */
-             n = nargs + gimple_call_num_args (stmt);
+             n = nargs + gimple_call_num_args (call_stmt);
              argarray.create (n);
              argarray.safe_grow_cleared (n);
 
              /* Copy all the arguments before '...'  */
              memcpy (argarray.address (),
-                     gimple_call_arg_ptr (stmt, 0),
-                     gimple_call_num_args (stmt) * sizeof (tree));
+                     gimple_call_arg_ptr (call_stmt, 0),
+                     gimple_call_num_args (call_stmt) * sizeof (tree));
 
              /* Append the arguments passed in '...'  */
-             memcpy (argarray.address () + gimple_call_num_args (stmt),
+             memcpy (argarray.address () + gimple_call_num_args (call_stmt),
                      gimple_call_arg_ptr (id->gimple_call, 0)
                        + (gimple_call_num_args (id->gimple_call) - nargs),
                      nargs * sizeof (tree));
 
-             new_call = gimple_build_call_vec (gimple_call_fn (stmt),
+             new_call = gimple_build_call_vec (gimple_call_fn (call_stmt),
                                                argarray);
 
              argarray.release ();
 
              /* Copy all GIMPLE_CALL flags, location and block, except
                 GF_CALL_VA_ARG_PACK.  */
-             gimple_call_copy_flags (new_call, stmt);
+             gimple_call_copy_flags (new_call, call_stmt);
              gimple_call_set_va_arg_pack (new_call, false);
              gimple_set_location (new_call, gimple_location (stmt));
              gimple_set_block (new_call, gimple_block (stmt));
-             gimple_call_set_lhs (new_call, gimple_call_lhs (stmt));
+             gimple_call_set_lhs (new_call, gimple_call_lhs (call_stmt));
 
              gsi_replace (&copy_gsi, new_call, false);
              stmt = new_call;
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index 50464f1..81e6f93 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -4884,9 +4884,10 @@ convert_callers (struct cgraph_node *node, tree old_decl,
 
       for (gsi = gsi_start_bb (this_block); !gsi_end_p (gsi); gsi_next (&gsi))
         {
-         gimple stmt = gsi_stmt (gsi);
+         gimple_call stmt;
          tree call_fndecl;
-         if (gimple_code (stmt) != GIMPLE_CALL)
+         stmt = dyn_cast <gimple_call> (gsi_stmt (gsi));
+         if (!stmt)
            continue;
          call_fndecl = gimple_call_fndecl (stmt);
          if (call_fndecl == old_decl)
-- 
1.8.5.3

Reply via email to