Promote integer arguments smaller than int if TARGET_PROMOTE_PROTOTYPES
returns true.
PR middle-end/14907
* calls.c (initialize_argument_information): Promote small integer
arguments if TARGET_PROMOTE_PROTOTYPES returns true.
Signed-off-by: H.J. Lu <[email protected]>
---
gcc/calls.cc | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/gcc/calls.cc b/gcc/calls.cc
index 01c4ef51545..60eb74e5945 100644
--- a/gcc/calls.cc
+++ b/gcc/calls.cc
@@ -1375,6 +1375,11 @@ initialize_argument_information (int num_actuals
ATTRIBUTE_UNUSED,
}
}
+ bool promote_p
+ = targetm.calls.promote_prototypes (fndecl
+ ? TREE_TYPE (fndecl)
+ : fntype);
+
/* I counts args in order (to be) pushed; ARGPOS counts in order written. */
for (argpos = 0; argpos < num_actuals; i--, argpos++)
{
@@ -1384,6 +1389,10 @@ initialize_argument_information (int num_actuals
ATTRIBUTE_UNUSED,
/* Replace erroneous argument with constant zero. */
if (type == error_mark_node || !COMPLETE_TYPE_P (type))
args[i].tree_value = integer_zero_node, type = integer_type_node;
+ else if (promote_p
+ && INTEGRAL_TYPE_P (type)
+ && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))
+ type = integer_type_node;
/* If TYPE is a transparent union or record, pass things the way
we would pass the first field of the union or record. We have
--
2.47.0