Hi, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79908 shows a case where pass_stdarg ICEs attempting to gimplify a COMPLEX_EXPR with side effects as an lvalue. This occurs when the LHS of a VA_ARG has been cast away. The previous patch (reverted) used force_gimple_operand to instantiate the necessary side effects rather than gimplify_expr using is_gimple_lvalue. This proved to cause problems on some targets where the gimple expression produced by targetm.gimplify_va_arg_expr contains un-gimplified side effects using raw var_decls (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80136). After some investigation, the right fix seems to be to just call gimplify_and_add on the expression.
I've bootstrapped and tested this on powerpc64le-unknown-linux-gnu with no regressions. I've also built a ppc64le->aarch64 cross and verified that Christophe's original report from PR80136 is now fixed. I don't have immediate access to an aarch64 native system (compile farm authentication issues), so I would appreciate it if James could run a native bootstrap to see if his issues are resolved. Provided there are no issues uncovered with aarch64 native bootstrap, is this ok for trunk? Thanks, Bill [gcc] 2017-03-21 Bill Schmidt <wschm...@linux.vnet.ibm.com> Richard Biener <rgue...@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-21 Bill Schmidt <wschm...@linux.vnet.ibm.com> Richard Biener <rguent...@suse.de> PR tree-optimization/79908 PR tree-optimization/80136 * gcc.dg/torture/pr79908.c: New file. Index: gcc/testsuite/gcc.dg/torture/pr79908.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr79908.c (revision 246334) +++ gcc/testsuite/gcc.dg/torture/pr79908.c (working copy) @@ -0,0 +1,12 @@ +/* { dg-do compile } */ + +/* Used to fail in the stdarg pass before fix for PR79908. */ + +typedef __builtin_va_list __gnuc_va_list; +typedef __gnuc_va_list va_list; + +void testva (int n, ...) +{ + va_list ap; + _Complex int i = __builtin_va_arg (ap, _Complex int); +} Index: gcc/tree-stdarg.c =================================================================== --- gcc/tree-stdarg.c (revision 246334) +++ gcc/tree-stdarg.c (working copy) @@ -1058,7 +1058,7 @@ expand_ifn_va_arg_1 (function *fun) gimplify_assign (lhs, expr, &pre); } else - gimplify_expr (&expr, &pre, &post, is_gimple_lvalue, fb_lvalue); + gimplify_and_add (expr, &pre); input_location = saved_location; pop_gimplify_context (NULL);