Remove the targetm.calls.promote_prototypes call from C, C++ and Ada
frontends.

gcc/

        PR c/48274
        PR middle-end/112877
        PR middle-end/118288
        * gimple.cc (gimple_builtin_call_types_compatible_p): Remove the
        targetm.calls.promote_prototypes call.
        * tree.cc (tree_builtin_call_types_compatible_p): Likewise.

gcc/ada/

        PR middle-end/112877
        * gcc-interface/utils.cc (create_param_decl): Remove the
        targetm.calls.promote_prototypes call.

gcc/c/

        PR c/48274
        PR middle-end/112877
        PR middle-end/118288
        * c-decl.cc (start_decl): Remove the
        targetm.calls.promote_prototypes call.
        (store_parm_decls_oldstyle): Likewise.
        (finish_function): Likewise.
        * c-typeck.cc (convert_argument): Likewise.
        (c_safe_arg_type_equiv_p): Likewise.

gcc/cp/

        PR middle-end/112877
        * call.cc (type_passed_as): Remove the
        targetm.calls.promote_prototypes call.
        (convert_for_arg_passing): Likewise.
        * typeck.cc (cxx_safe_arg_type_equiv_p): Likewise.

gcc/testsuite/

        PR middle-end/118288
        * gcc.dg/crc-pr118288.c: New test.

Signed-off-by: H.J. Lu <hjl.to...@gmail.com>
---
 gcc/ada/gcc-interface/utils.cc      | 24 -----------------
 gcc/c/c-decl.cc                     | 40 -----------------------------
 gcc/c/c-typeck.cc                   | 19 +++-----------
 gcc/cp/call.cc                      | 10 --------
 gcc/cp/typeck.cc                    | 13 +++-------
 gcc/gimple.cc                       | 10 +-------
 gcc/testsuite/gcc.dg/crc-pr118288.c | 11 ++++++++
 gcc/tree.cc                         | 14 ----------
 8 files changed, 20 insertions(+), 121 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/crc-pr118288.c

diff --git a/gcc/ada/gcc-interface/utils.cc b/gcc/ada/gcc-interface/utils.cc
index 8e8cf55ae12..cbbac5160d2 100644
--- a/gcc/ada/gcc-interface/utils.cc
+++ b/gcc/ada/gcc-interface/utils.cc
@@ -3282,30 +3282,6 @@ tree
 create_param_decl (tree name, tree type)
 {
   tree param_decl = build_decl (input_location, PARM_DECL, name, type);
-
-  /* Honor TARGET_PROMOTE_PROTOTYPES like the C compiler, as not doing so
-     can lead to various ABI violations.  */
-  if (targetm.calls.promote_prototypes (NULL_TREE)
-      && INTEGRAL_TYPE_P (type)
-      && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))
-    {
-      /* We have to be careful about biased types here.  Make a subtype
-        of integer_type_node with the proper biasing.  */
-      if (TREE_CODE (type) == INTEGER_TYPE
-         && TYPE_BIASED_REPRESENTATION_P (type))
-       {
-         tree subtype
-           = make_unsigned_type (TYPE_PRECISION (integer_type_node));
-         TREE_TYPE (subtype) = integer_type_node;
-         TYPE_BIASED_REPRESENTATION_P (subtype) = 1;
-         SET_TYPE_RM_MIN_VALUE (subtype, TYPE_MIN_VALUE (type));
-         SET_TYPE_RM_MAX_VALUE (subtype, TYPE_MAX_VALUE (type));
-         type = subtype;
-       }
-      else
-       type = integer_type_node;
-    }
-
   DECL_ARG_TYPE (param_decl) = type;
   return param_decl;
 }
diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc
index f60b2a54a17..7c351537b16 100644
--- a/gcc/c/c-decl.cc
+++ b/gcc/c/c-decl.cc
@@ -5720,26 +5720,6 @@ start_decl (struct c_declarator *declarator, struct 
c_declspecs *declspecs,
        DECL_EXTERNAL (decl) = !DECL_EXTERNAL (decl);
     }
 
-  if (TREE_CODE (decl) == FUNCTION_DECL
-      && targetm.calls.promote_prototypes (TREE_TYPE (decl)))
-    {
-      struct c_declarator *ce = declarator;
-
-      if (ce->kind == cdk_pointer)
-       ce = declarator->declarator;
-      if (ce->kind == cdk_function)
-       {
-         tree args = ce->u.arg_info->parms;
-         for (; args; args = DECL_CHAIN (args))
-           {
-             tree type = TREE_TYPE (args);
-             if (type && INTEGRAL_TYPE_P (type)
-                 && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))
-               DECL_ARG_TYPE (args) = c_type_promotes_to (type);
-           }
-       }
-    }
-
   if (TREE_CODE (decl) == FUNCTION_DECL
       && DECL_DECLARED_INLINE_P (decl)
       && DECL_UNINLINABLE (decl)
@@ -11179,13 +11159,6 @@ store_parm_decls_oldstyle (tree fndecl, const struct 
c_arg_info *arg_info)
                     useful for argument types like uid_t.  */
                  DECL_ARG_TYPE (parm) = TREE_TYPE (parm);
 
-                 if (targetm.calls.promote_prototypes (TREE_TYPE 
(current_function_decl))
-                     && INTEGRAL_TYPE_P (TREE_TYPE (parm))
-                     && (TYPE_PRECISION (TREE_TYPE (parm))
-                         < TYPE_PRECISION (integer_type_node)))
-                   DECL_ARG_TYPE (parm)
-                     = c_type_promotes_to (TREE_TYPE (parm));
-
                  /* ??? Is it possible to get here with a
                     built-in prototype or will it always have
                     been diagnosed as conflicting with an
@@ -11413,19 +11386,6 @@ finish_function (location_t end_loc)
   if (c_dialect_objc ())
     objc_finish_function ();
 
-  if (TREE_CODE (fndecl) == FUNCTION_DECL
-      && targetm.calls.promote_prototypes (TREE_TYPE (fndecl)))
-    {
-      tree args = DECL_ARGUMENTS (fndecl);
-      for (; args; args = DECL_CHAIN (args))
-       {
-         tree type = TREE_TYPE (args);
-         if (INTEGRAL_TYPE_P (type)
-             && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))
-           DECL_ARG_TYPE (args) = c_type_promotes_to (type);
-       }
-    }
-
   if (DECL_INITIAL (fndecl) && DECL_INITIAL (fndecl) != error_mark_node)
     BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
 
diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc
index dbb688cabaa..375f048f352 100644
--- a/gcc/c/c-typeck.cc
+++ b/gcc/c/c-typeck.cc
@@ -4125,12 +4125,6 @@ convert_argument (location_t ploc, tree function, tree 
fundecl,
                                         val, origtype, ic_argpass,
                                         npc, fundecl, function,
                                         parmnum + 1, warnopt);
-
-  if (targetm.calls.promote_prototypes (fundecl ? TREE_TYPE (fundecl) : 0)
-      && INTEGRAL_TYPE_P (type)
-      && (TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)))
-    parmval = default_conversion (parmval);
-
   return parmval;
 }
 
@@ -6668,17 +6662,12 @@ c_safe_arg_type_equiv_p (tree t1, tree t2)
       && TREE_CODE (t2) == POINTER_TYPE)
     return true;
 
-  /* The signedness of the parameter matters only when an integral
-     type smaller than int is promoted to int, otherwise only the
-     precision of the parameter matters.
-     This check should make sure that the callee does not see
-     undefined values in argument registers.  */
+  /* Only the precision of the parameter matters.  This check should
+     make sure that the callee does not see undefined values in argument
+     registers.  */
   if (INTEGRAL_TYPE_P (t1)
       && INTEGRAL_TYPE_P (t2)
-      && TYPE_PRECISION (t1) == TYPE_PRECISION (t2)
-      && (TYPE_UNSIGNED (t1) == TYPE_UNSIGNED (t2)
-         || !targetm.calls.promote_prototypes (NULL_TREE)
-         || TYPE_PRECISION (t1) >= TYPE_PRECISION (integer_type_node)))
+      && TYPE_PRECISION (t1) == TYPE_PRECISION (t2))
     return true;
 
   return comptypes (t1, t2);
diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
index 810594f40e1..43f9d66d623 100644
--- a/gcc/cp/call.cc
+++ b/gcc/cp/call.cc
@@ -9460,11 +9460,6 @@ type_passed_as (tree type)
   /* Pass classes with copy ctors by invisible reference.  */
   if (TREE_ADDRESSABLE (type))
     type = build_reference_type (type);
-  else if (targetm.calls.promote_prototypes (NULL_TREE)
-          && INTEGRAL_TYPE_P (type)
-          && COMPLETE_TYPE_P (type)
-          && tree_int_cst_lt (TYPE_SIZE (type), TYPE_SIZE (integer_type_node)))
-    type = integer_type_node;
 
   return type;
 }
@@ -9500,11 +9495,6 @@ convert_for_arg_passing (tree type, tree val, 
tsubst_flags_t complain)
   /* Pass classes with copy ctors by invisible reference.  */
   else if (TREE_ADDRESSABLE (type))
     val = build1 (ADDR_EXPR, build_reference_type (type), val);
-  else if (targetm.calls.promote_prototypes (NULL_TREE)
-          && INTEGRAL_TYPE_P (type)
-          && COMPLETE_TYPE_P (type)
-          && tree_int_cst_lt (TYPE_SIZE (type), TYPE_SIZE (integer_type_node)))
-    val = cp_perform_integral_promotions (val, complain);
   if (complain & tf_warning)
     {
       if (warn_suggest_attribute_format)
diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc
index 1f9a74166f4..d42c620496c 100644
--- a/gcc/cp/typeck.cc
+++ b/gcc/cp/typeck.cc
@@ -1372,17 +1372,12 @@ cxx_safe_arg_type_equiv_p (tree t1, tree t2)
       && TYPE_PTR_P (t2))
     return true;
 
-  /* The signedness of the parameter matters only when an integral
-     type smaller than int is promoted to int, otherwise only the
-     precision of the parameter matters.
-     This check should make sure that the callee does not see
-     undefined values in argument registers.  */
+  /* Only the precision of the parameter matters.  This check should
+     make sure that the callee does not see undefined values in argument
+     registers.  */
   if (INTEGRAL_TYPE_P (t1)
       && INTEGRAL_TYPE_P (t2)
-      && TYPE_PRECISION (t1) == TYPE_PRECISION (t2)
-      && (TYPE_UNSIGNED (t1) == TYPE_UNSIGNED (t2)
-         || !targetm.calls.promote_prototypes (NULL_TREE)
-         || TYPE_PRECISION (t1) >= TYPE_PRECISION (integer_type_node)))
+      && TYPE_PRECISION (t1) == TYPE_PRECISION (t2))
     return true;
 
   return same_type_p (t1, t2);
diff --git a/gcc/gimple.cc b/gcc/gimple.cc
index 715263595e2..e60cbf5704f 100644
--- a/gcc/gimple.cc
+++ b/gcc/gimple.cc
@@ -2896,15 +2896,7 @@ gimple_builtin_call_types_compatible_p (const gimple 
*stmt, tree fndecl)
        return true;
       tree arg = gimple_call_arg (stmt, i);
       tree type = TREE_VALUE (targs);
-      if (!useless_type_conversion_p (type, TREE_TYPE (arg))
-         /* char/short integral arguments are promoted to int
-            by several frontends if targetm.calls.promote_prototypes
-            is true.  Allow such promotion too.  */
-         && !(INTEGRAL_TYPE_P (type)
-              && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)
-              && targetm.calls.promote_prototypes (TREE_TYPE (fndecl))
-              && useless_type_conversion_p (integer_type_node,
-                                            TREE_TYPE (arg))))
+      if (!useless_type_conversion_p (type, TREE_TYPE (arg)))
        return false;
       targs = TREE_CHAIN (targs);
     }
diff --git a/gcc/testsuite/gcc.dg/crc-pr118288.c 
b/gcc/testsuite/gcc.dg/crc-pr118288.c
new file mode 100644
index 00000000000..db7f0ed08b5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/crc-pr118288.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target int32plus } */
+
+#include <stdint-gcc.h>
+
+int8_t crc8_data8 ()
+{
+  return __builtin_crc8_data8 ('a', 0xff, 0x12);
+}
+
+/* { dg-final { scan-assembler "crc_table_for_crc_8_polynomial_0x12|mul" } } */
diff --git a/gcc/tree.cc b/gcc/tree.cc
index eab40008e8b..22d067d8d05 100644
--- a/gcc/tree.cc
+++ b/gcc/tree.cc
@@ -8700,20 +8700,6 @@ tree_builtin_call_types_compatible_p (const_tree call, 
tree fndecl)
              && POINTER_TYPE_P (TREE_TYPE (arg))
              && tree_nop_conversion_p (type, TREE_TYPE (arg)))
            continue;
-         /* char/short integral arguments are promoted to int
-            by several frontends if targetm.calls.promote_prototypes
-            is true.  Allow such promotion too.  */
-         if (INTEGRAL_TYPE_P (type)
-             && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)
-             && INTEGRAL_TYPE_P (TREE_TYPE (arg))
-             && !TYPE_UNSIGNED (TREE_TYPE (arg))
-             && targetm.calls.promote_prototypes (TREE_TYPE (fndecl))
-             && (gimple_form
-                 ? useless_type_conversion_p (integer_type_node,
-                                              TREE_TYPE (arg))
-                 : tree_nop_conversion_p (integer_type_node,
-                                          TREE_TYPE (arg))))
-           continue;
          return false;
        }
     }
-- 
2.47.1

Reply via email to