On 12-05-15 12:04, Tom de Vries wrote:
Committed with comments below added.
Hmm, this causes an ice for s390 in gcc.dg/tree-ssa/stdarg-2.c:
...
gimplification failed:
&ap <addr_expr 0x7f132f54fb20
type <pointer_type 0x7f132f55f1f8
type <array_type 0x7f132f53fe70 va_list type <record_type
0x7f132f46b888 __va_list_tag>
sizes-gimplified BLK
size <integer_cst 0x7f132f4539f0 constant 128>
unit size <integer_cst 0x7f132f453a08 constant 16>
align 32 symtab 0 alias set -1 canonical type 0x7f132f46b9d8 domain
<integer_type 0x7f132f46b930> context <translation_unit_decl 0x7f1330fa8258 D.1477>
pointer_to_this <pointer_type 0x7f132f55f1f8>>
unsigned SI
size <integer_cst 0x7f132f453690 constant 32>
unit size <integer_cst 0x7f132f4536a8 constant 4>
align 32 symtab 0 alias set -1 canonical type 0x7f132f55f2a0>
arg 0 <var_decl 0x7f132f549630 ap type <array_type 0x7f132f53fe70 va_list>
addressable used BLK file stdarg-2.c line 32 col 11 size <integer_cst
0x7f132f4539f0 128> unit size <integer_cst 0x7f132f453a08 16>
align 32 context <function_decl 0x7f132f5434d8 f2>>
stdarg-2.c:35:15>
stdarg-2.c: In function ‘f2’:
stdarg-2.c:35:15: internal compiler error: gimplification failed
res = f2_1 (ap);
^
0xad3d02 gimplify_expr(tree_node**, gimple_statement_base**,
gimple_statement_base**, bool (*)(tree_node*), int)
/home/vries/gcc_versions/devel/devel3/src/gcc/gimplify.c:8856
0xad5762 gimplify_va_arg_internal(tree_node*, tree_node*,
gimple_statement_base**, gimple_statement_base**)
/home/vries/gcc_versions/devel/devel3/src/gcc/gimplify.c:9326
0x10a3349 expand_ifn_va_arg_1
/home/vries/gcc_versions/devel/devel3/src/gcc/tree-stdarg.c:1062
0x10a3596 expand_ifn_va_arg
/home/vries/gcc_versions/devel/devel3/src/gcc/tree-stdarg.c:1122
0x10a36d3 execute
/home/vries/gcc_versions/devel/devel3/src/gcc/tree-stdarg.c:1174
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
...
Attached patch is a tentative fix. I'll bootstrap and reg-test on x86_64.
Thanks,
- Tom
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 322d0ba..4846478 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -9302,32 +9302,6 @@ dummy_object (tree type)
return build2 (MEM_REF, type, t, t);
}
-/* Call the target expander for evaluating a va_arg call of VALIST
- and TYPE. */
-
-tree
-gimplify_va_arg_internal (tree valist, tree type, gimple_seq *pre_p,
- gimple_seq *post_p)
-{
- tree have_va_type = TREE_TYPE (valist);
- tree cano_type = targetm.canonical_va_list_type (have_va_type);
-
- if (cano_type != NULL_TREE)
- have_va_type = cano_type;
-
- /* Make it easier for the backends by protecting the valist argument
- from multiple evaluations. */
- if (TREE_CODE (have_va_type) == ARRAY_TYPE)
- {
- gcc_assert (TREE_CODE (TREE_TYPE (valist)) != ARRAY_TYPE);
- gimplify_expr (&valist, pre_p, post_p, is_gimple_val, fb_rvalue);
- }
- else
- gimplify_expr (&valist, pre_p, post_p, is_gimple_min_lval, fb_lvalue);
-
- return targetm.gimplify_va_arg_expr (valist, type, pre_p, post_p);
-}
-
/* Gimplify __builtin_va_arg, aka VA_ARG_EXPR, which is not really a
builtin function, but a very special sort of operator. */
diff --git a/gcc/gimplify.h b/gcc/gimplify.h
index 83bf525..615925c 100644
--- a/gcc/gimplify.h
+++ b/gcc/gimplify.h
@@ -82,7 +82,6 @@ extern void gimplify_function_tree (tree);
extern enum gimplify_status gimplify_va_arg_expr (tree *, gimple_seq *,
gimple_seq *);
gimple gimplify_assign (tree, tree, gimple_seq *);
-extern tree gimplify_va_arg_internal (tree, tree, gimple_seq *, gimple_seq *);
/* Return true if gimplify_one_sizepos doesn't need to gimplify
expr (when in TYPE_SIZE{,_UNIT} and similar type/decl size/bitsize
diff --git a/gcc/tree-stdarg.c b/gcc/tree-stdarg.c
index 3bede7e..f8ff70a 100644
--- a/gcc/tree-stdarg.c
+++ b/gcc/tree-stdarg.c
@@ -1059,7 +1059,14 @@ expand_ifn_va_arg_1 (function *fun)
push_gimplify_context (false);
- expr = gimplify_va_arg_internal (ap, type, &pre, &post);
+ /* Make it easier for the backends by protecting the valist argument
+ from multiple evaluations. */
+ if (do_deref == integer_one_node)
+ gimplify_expr (&ap, &pre, &post, is_gimple_min_lval, fb_lvalue);
+ else
+ gimplify_expr (&ap, &pre, &post, is_gimple_val, fb_rvalue);
+
+ expr = targetm.gimplify_va_arg_expr (ap, type, &pre, &post);
lhs = gimple_call_lhs (stmt);
if (lhs != NULL_TREE)