Created attachment 40890 [details] test-case Following test-case taken from LLVM ICEs: ppc64le-linux-gnu-gcc ppc64-varargs-complex.c -O1 gimplification failed: COMPLEX_EXPR <D.2511, D.2514> <complex_expr 0x7f64a7351398 type <complex_type 0x7f64a71d2f18 complex int type <integer_type 0x7f64a71bd738 int public SI size <integer_cst 0x7f64a71c7558 constant 32> unit size <integer_cst 0x7f64a71c7570 constant 4> align 32 symtab 0 alias set -1 canonical type 0x7f64a71bd738 precision 32 min <integer_cst 0x7f64a71c7510 -2147483648> max <integer_cst 0x7f64a71c7528 2147483647> pointer_to_this <pointer_type 0x7f64a731ca80>> sizes-gimplified CSI size <integer_cst 0x7f64a71c7318 constant 64> unit size <integer_cst 0x7f64a71c7330 constant 8> align 32 symtab 0 alias set -1 canonical type 0x7f64a71d2f18 pointer_to_this <pointer_type 0x7f64a731c9d8>> arg 0 <var_decl 0x7f64a8934f30 D.2511 type <integer_type 0x7f64a71bd738 int> used ignored SI file ppc64-varargs-complex.c line 10 col 16 size <integer_cst 0x7f64a71c7558 32> unit size <integer_cst 0x7f64a71c7570 4> align 32 context <function_decl 0x7f64a7320300 testva> chain <var_decl 0x7f64a8934ea0 D.2510 type <pointer_type 0x7f64a71d6bd0> used unsigned ignored DI file ppc64-varargs-complex.c line 10 col 16 size <integer_cst 0x7f64a71c7318 64> unit size <integer_cst 0x7f64a71c7330 8> align 64 context <function_decl 0x7f64a7320300 testva> chain <var_decl 0x7f64a8934e10 D.2509>>> arg 1 <var_decl 0x7f64a7357120 D.2514 type <integer_type 0x7f64a71bd738 int> used ignored SI file ppc64-varargs-complex.c line 10 col 16 size <integer_cst 0x7f64a71c7558 32> unit size <integer_cst 0x7f64a71c7570 4> align 32 context <function_decl 0x7f64a7320300 testva> chain <var_decl 0x7f64a7357090 D.2513 type <pointer_type 0x7f64a71d6bd0> used unsigned ignored DI file ppc64-varargs-complex.c line 10 col 16 size <integer_cst 0x7f64a71c7318 64> unit size <integer_cst 0x7f64a71c7330 8> align 64 context <function_decl 0x7f64a7320300 testva> chain <var_decl 0x7f64a7357000 D.2512>>>> ppc64-varargs-complex.c: In function ‘testva’: ppc64-varargs-complex.c:10:16: internal compiler error: gimplification failed _Complex int i = va_arg(ap, _Complex int); ^ 0x8fe8e9 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) .././../gcc/gimplify.c:12155 0xd99b9b expand_ifn_va_arg_1 .././../gcc/tree-stdarg.c:1061 0xd99b9b expand_ifn_va_arg .././../gcc/tree-stdarg.c:1101 0xd9ba6b execute .././../gcc/tree-stdarg.c:1154 Please submit a full bug report,
Minimal test: #include <stdarg.h> void testva (int n, ...) { va_list ap; _Complex int i = va_arg (ap, _Complex int); } The use of a _Complex type is required to exhibit the bug (plain old int and double work fine). The optimizer recognizes that the assignment to i is dead, but the side effects of va_arg present it from similarly going dead, so we end up with: testva (int n) { char * ap; <bb 2> [100.00%]: VA_ARG (&ap, 0B, 0B); ap ={v} {CLOBBER}; return; } which the gimplifier doesn't know what to do with for complex cases. Not a target bug; changing to tree-optimization component. Confirmed, btw.
Patch under test: Index: gcc/tree-stdarg.c =================================================================== --- gcc/tree-stdarg.c (revision 246109) +++ gcc/tree-stdarg.c (working copy) @@ -1057,7 +1057,7 @@ expand_ifn_va_arg_1 (function *fun) types. */ gimplify_assign (lhs, expr, &pre); } - else + else if (is_gimple_addressable (expr)) gimplify_expr (&expr, &pre, &post, is_gimple_lvalue, fb_lvalue); input_location = saved_location;
Patch isn't acceptable; still investigating.
Any fix for this must also handle this reduced test case: typedef __builtin_va_list __gnuc_va_list; typedef __gnuc_va_list va_list; void foo (va_list args) { va_list ap; __builtin_va_copy (ap, args); (void)__builtin_va_arg (ap, int); __builtin_va_end(ap); }
Author: wschmidt Date: Tue Mar 21 13:57:20 2017 New Revision: 246319 URL: https://gcc.gnu.org/viewcvs?rev=246319&root=gcc&view=rev Log: [gcc] 2017-03-21 Bill Schmidt <wschmidt@linux.vnet.ibm.com> Richard Biener <rguenth@suse.com> PR tree-optimization/79908 * tree-stdarg.c (expand_ifn_va_arg_1): For a VA_ARG whose LHS has been cast away, use force_gimple_operand to construct the side effects. [gcc/testsuite] 2017-03-21 Bill Schmidt <wschmidt@linux.vnet.ibm.com> Richard Biener <rguenther@suse.de> PR tree-optimization/79908 * gcc.dg/torture/pr79908.c: New file. Added: trunk/gcc/testsuite/gcc.dg/torture/pr79908.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-stdarg.c
Fixed.
This is causing failures all over on aarch64; see PR 80136 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80136). Going to revert this fix for now.
Author: wschmidt Date: Tue Mar 21 18:14:42 2017 New Revision: 246330 URL: https://gcc.gnu.org/viewcvs?rev=246330&root=gcc&view=rev Log: [gcc] 2017-03-21 Bill Schmidt <wschmidt@linux.vnet.ibm.com> PR tree-optimization/79908 * tree-stdarg.c (expand_ifn_va_arg_1): Revert the following change: For a VA_ARG whose LHS has been cast away, use force_gimple_operand to construct the side effects. [gcc/testsuite] 2017-03-21 Bill Schmidt <wschmidt@linux.vnet.ibm.com> PR tree-optimization/79908 * gcc.dg/torture/pr79908.c: Revert addition of new file. Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gcc.dg/torture/pr79908.c trunk/gcc/tree-stdarg.c
Author: wschmidt Date: Thu Mar 23 13:13:44 2017 New Revision: 246418 URL: https://gcc.gnu.org/viewcvs?rev=246418&root=gcc&view=rev Log: [gcc] 2017-03-23 Bill Schmidt <wschmidt@linux.vnet.ibm.com> Richard Biener <rguenth@suse.com> PR tree-optimization/79908 PR tree-optimization/80136 * tree-stdarg.c (expand_ifn_va_arg_1): For a VA_ARG whose LHS has been cast away, gimplify_and_add suffices. [gcc/testsuite] 2017-03-23 Bill Schmidt <wschmidt@linux.vnet.ibm.com> Richard Biener <rguenther@suse.de> PR tree-optimization/79908 PR tree-optimization/80136 * gcc.dg/torture/pr79908.c: New file. Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gcc.dg/torture/pr79908.c trunk/gcc/tree-stdarg.c
Fixed now. Note: I will be unavailable from 2017-03-24 to 2017-03-27, so if regressions occur, please revert and I will review upon my return.