aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-inline.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-09-11 15:40:14 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2007-09-11 15:40:14 +0200
commitab0e176c5b252f6cf61e520b36f6c0d313a3281d (patch)
tree79484e03a465253f9b84c8b8966f361bbe454ca5 /gcc/tree-inline.c
parente6ebd07f479b258643f61e4b49dc954b336142d5 (diff)
downloadgcc-ab0e176c5b252f6cf61e520b36f6c0d313a3281d.zip
gcc-ab0e176c5b252f6cf61e520b36f6c0d313a3281d.tar.gz
gcc-ab0e176c5b252f6cf61e520b36f6c0d313a3281d.tar.bz2
builtins.def (BUILT_IN_VA_ARG_PACK_LEN): New builtin.
* builtins.def (BUILT_IN_VA_ARG_PACK_LEN): New builtin. * builtins.c (expand_builtin) <case BUILT_IN_VA_ARG_PACK_LEN>: Issue error if __builtin_va_arg_pack_len () wasn't optimized out during inlining. * tree-inline.c (copy_bb): Replace __builtin_va_arg_pack_len () with the number of inline's anonymous arguments. * doc/extend.texi: Document __builtin_va_arg_pack_len (). * gcc.dg/va-arg-pack-len-1.c: New test. * g++.dg/va-arg-pack-len-1.C: New test. From-SVN: r128376
Diffstat (limited to 'gcc/tree-inline.c')
-rw-r--r--gcc/tree-inline.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index d49c3c8..d50b2c7 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -867,6 +867,33 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, int count_scal
stmt = *stmtp;
update_stmt (stmt);
}
+ else if (call
+ && id->call_expr
+ && (decl = get_callee_fndecl (call))
+ && DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL
+ && DECL_FUNCTION_CODE (decl)
+ == BUILT_IN_VA_ARG_PACK_LEN)
+ {
+ /* __builtin_va_arg_pack_len () should be replaced by
+ the number of anonymous arguments. */
+ int nargs = call_expr_nargs (id->call_expr);
+ tree count, *call_ptr, p;
+
+ for (p = DECL_ARGUMENTS (id->src_fn); p; p = TREE_CHAIN (p))
+ nargs--;
+
+ count = build_int_cst (integer_type_node, nargs);
+ call_ptr = stmtp;
+ if (TREE_CODE (*call_ptr) == GIMPLE_MODIFY_STMT)
+ call_ptr = &GIMPLE_STMT_OPERAND (*call_ptr, 1);
+ if (TREE_CODE (*call_ptr) == WITH_SIZE_EXPR)
+ call_ptr = &TREE_OPERAND (*call_ptr, 0);
+ gcc_assert (*call_ptr == call && call_ptr != stmtp);
+ *call_ptr = count;
+ stmt = *stmtp;
+ update_stmt (stmt);
+ call = NULL_TREE;
+ }
/* Statements produced by inlining can be unfolded, especially
when we constant propagated some operands. We can't fold