aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-stdarg.c
diff options
context:
space:
mode:
authorTom de Vries <tom@codesourcery.com>2015-05-12 09:46:47 +0000
committerTom de Vries <vries@gcc.gnu.org>2015-05-12 09:46:47 +0000
commitc7b38fd54552f2ff37becfb1a71ab3c2e1f8462d (patch)
treec10f8ac5291a1a6a12e7472c1ad1acd14764ffef /gcc/tree-stdarg.c
parentfed8bd87d5832d9c61c648ed2a2103f853fad00a (diff)
downloadgcc-c7b38fd54552f2ff37becfb1a71ab3c2e1f8462d.zip
gcc-c7b38fd54552f2ff37becfb1a71ab3c2e1f8462d.tar.gz
gcc-c7b38fd54552f2ff37becfb1a71ab3c2e1f8462d.tar.bz2
Don't take address of ap unless necessary
2015-05-12 Tom de Vries <tom@codesourcery.com> PR tree-optimization/66010 * gimplify.c (gimplify_modify_expr): Handle new do_deref argument of ifn_va_arg. * gimplify.h (gimplify_va_arg_internal): Remove loc parameter. (gimplify_va_arg_internal): Remove loc parameter. Assert no array-typed va_lists are passed, and remove corresponding handling. (gimplify_va_arg_expr): Only take address of ap if necessary. Add do_deref argument to ifn_va_arg. * tree-stdarg.c (expand_ifn_va_arg_1): Handle new do_deref argument of ifn_va_arg. * c-common.c (build_va_arg): Don't mark ap addressable unless necessary. * gcc.dg/tree-ssa/stdarg-2.c: Undo scan xfails for f15. From-SVN: r223054
Diffstat (limited to 'gcc/tree-stdarg.c')
-rw-r--r--gcc/tree-stdarg.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/gcc/tree-stdarg.c b/gcc/tree-stdarg.c
index 1356374..3bede7e 100644
--- a/gcc/tree-stdarg.c
+++ b/gcc/tree-stdarg.c
@@ -1042,7 +1042,7 @@ expand_ifn_va_arg_1 (function *fun)
for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i))
{
gimple stmt = gsi_stmt (i);
- tree ap, expr, lhs, type;
+ tree ap, expr, lhs, type, do_deref;
gimple_seq pre = NULL, post = NULL;
if (!gimple_call_ifn_va_arg_p (stmt))
@@ -1052,24 +1052,27 @@ expand_ifn_va_arg_1 (function *fun)
type = TREE_TYPE (TREE_TYPE (gimple_call_arg (stmt, 1)));
ap = gimple_call_arg (stmt, 0);
- ap = build_fold_indirect_ref (ap);
+ do_deref = gimple_call_arg (stmt, 2);
+
+ if (do_deref == integer_one_node)
+ ap = build_fold_indirect_ref (ap);
push_gimplify_context (false);
- expr = gimplify_va_arg_internal (ap, type, gimple_location (stmt),
- &pre, &post);
+ expr = gimplify_va_arg_internal (ap, type, &pre, &post);
lhs = gimple_call_lhs (stmt);
if (lhs != NULL_TREE)
{
+ unsigned int nargs = gimple_call_num_args (stmt);
gcc_assert (useless_type_conversion_p (TREE_TYPE (lhs), type));
- if (gimple_call_num_args (stmt) == 3)
+ if (nargs == 4)
{
/* We've transported the size of with WITH_SIZE_EXPR here as
- the 3rd argument of the internal fn call. Now reinstate
+ the last argument of the internal fn call. Now reinstate
it. */
- tree size = gimple_call_arg (stmt, 2);
+ tree size = gimple_call_arg (stmt, nargs - 1);
expr = build2 (WITH_SIZE_EXPR, TREE_TYPE (expr), expr, size);
}