Hi

On 21 March 2017 at 09:03, Richard Biener <richard.guent...@gmail.com> wrote:
> On Mon, Mar 20, 2017 at 8:15 PM, Bill Schmidt
> <wschm...@linux.vnet.ibm.com> wrote:
>> 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.  This patch, credit to Richard Biener, uses
>> force_gimple_operand to instantiate the necessary side effects rather
>> than gimplify_expr using is_gimple_lvalue.  The test case is taken
>> wholesale from the bug report.
>>
>> Bootstrapped and tested on powerpc64le-unknown-linux-gnu with no
>> regressions.  Is this ok for trunk?
>
> Ok!
>

Since this was committed (r246319), I've noticed that
GCC cross-compiler fails to build glibc for target aarch64-linux-gnu.

I'm seeing:
In function '_IO_vfscanf_internal':
cc1: internal compiler error: in gimplify_modify_expr, at gimplify.c:5627
0x8ae5bf gimplify_modify_expr
        
/tmp/1882393_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/gimplify.c:5627
0x8902b4 gimplify_expr(tree_node**, gimple**, gimple**, bool
(*)(tree_node*), int)
        
/tmp/1882393_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/gimplify.c:11198
0x8963c8 gimplify_stmt(tree_node**, gimple**)
        
/tmp/1882393_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/gimplify.c:6477
0x89bf55 gimplify_cond_expr
        
/tmp/1882393_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/gimplify.c:3971
0x890273 gimplify_expr(tree_node**, gimple**, gimple**, bool
(*)(tree_node*), int)
        /tmp/1882393_6.tmpdir/aci-In function '_IO_vfscanf_internal':
cc1: internal compiler error: in gimplify_modify_expr, at gimplify.c:5627
0x8ae5bf gimplify_modify_expr
        
/tmp/1882393_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/gimplify.c:5627
0x8902b4 gimplify_expr(tree_node**, gimple**, gimple**, bool
(*)(tree_node*), int)
        
/tmp/1882393_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/gimplify.c:11198
0x8963c8 gimplify_stmt(tree_node**, gimple**)
        
/tmp/1882393_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/gimplify.c:6477
0x89bf55 gimplify_cond_expr
        
/tmp/1882393_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/gimplify.c:3971
0x890273 gimplify_expr(tree_node**, gimple**, gimple**, bool
(*)(tree_node*), int)
        
/tmp/1882393_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/gimplify.c:11154
0x8963c8 gimplify_stmt(tree_node**, gimple**)
        
/tmp/1882393_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/gimplify.c:6477
0x89b803 gimplify_cond_expr
        
/tmp/1882393_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/gimplify.c:3864
0x890273 gimplify_expr(tree_node**, gimple**, gimple**, bool
(*)(tree_node*), int)
        
/tmp/1882393_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/gimplify.c:11154
0x89328f gimplify_expr(tree_node**, gimple**, gimple**, bool
(*)(tree_node*), int)
        
/tmp/1882393_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/gimplify.c:11356
0x8b49f9 force_gimple_operand_1(tree_node*, gimple**, bool
(*)(tree_node*), tree_node*)
        
/tmp/1882393_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/gimplify-me.c:78
0xda0f16 expand_ifn_va_arg_1
        
/tmp/1882393_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/tree-stdarg.c:1064
0xda0f16 expand_ifn_va_arg
        
/tmp/1882393_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/tree-stdarg.c:1105
0xda494b execute
        
/tmp/1882393_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/tree-stdarg.c:1158
gcc-fsf/sources/gcc-fsf/gccsrc/gcc/gimplify.c:11154
0x8963c8 gimplify_stmt(tree_node**, gimple**)
        
/tmp/1882393_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/gimplify.c:6477
0x89b803 gimplify_cond_expr
        
/tmp/1882393_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/gimplify.c:3864
0x890273 gimplify_expr(tree_node**, gimple**, gimple**, bool
(*)(tree_node*), int)
        
/tmp/1882393_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/gimplify.c:11154
0x89328f gimplify_expr(tree_node**, gimple**, gimple**, bool
(*)(tree_node*), int)
        
/tmp/1882393_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/gimplify.c:11356
0x8b49f9 force_gimple_operand_1(tree_node*, gimple**, bool
(*)(tree_node*), tree_node*)
        
/tmp/1882393_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/gimplify-me.c:78
0xda0f16 expand_ifn_va_arg_1
        
/tmp/1882393_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/tree-stdarg.c:1064
0xda0f16 expand_ifn_va_arg
        
/tmp/1882393_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/tree-stdarg.c:1105
0xda494b execute
        
/tmp/1882393_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/tree-stdarg.c:1158


I can start a manual build if you need a .i file.

Thanks,

Christophe

> Thanks,
> Richard.
>
>> Thanks,
>> Bill
>>
>>
>> [gcc]
>>
>> 2017-03-20  Bill Schmidt  <wschm...@linux.vnet.ibm.com>
>>             Richard Biener  <rgue...@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-20  Bill Schmidt  <wschm...@linux.vnet.ibm.com>
>>             Richard Biener  <rguent...@suse.de>
>>
>>         PR tree-optimization/79908
>>         * gcc.dg/torture/pr79908.c: New file.
>>
>>
>> Index: gcc/testsuite/gcc.dg/torture/pr79908.c
>> ===================================================================
>> --- gcc/testsuite/gcc.dg/torture/pr79908.c      (nonexistent)
>> +++ 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 246286)
>> +++ gcc/tree-stdarg.c   (working copy)
>> @@ -33,6 +33,7 @@ along with GCC; see the file COPYING3.  If not see
>>  #include "gimple-iterator.h"
>>  #include "gimple-walk.h"
>>  #include "gimplify.h"
>> +#include "gimplify-me.h"
>>  #include "tree-into-ssa.h"
>>  #include "tree-cfg.h"
>>  #include "tree-stdarg.h"
>> @@ -1058,12 +1059,16 @@ expand_ifn_va_arg_1 (function *fun)
>>             gimplify_assign (lhs, expr, &pre);
>>           }
>>         else
>> -         gimplify_expr (&expr, &pre, &post, is_gimple_lvalue, fb_lvalue);
>> +         {
>> +           gimple_seq tmp_seq;
>> +           force_gimple_operand (expr, &tmp_seq, false, NULL_TREE);
>> +           gimple_seq_add_seq_without_update (&pre, tmp_seq);
>> +         }
>>
>>         input_location = saved_location;
>>         pop_gimplify_context (NULL);
>>
>> -       gimple_seq_add_seq (&pre, post);
>> +       gimple_seq_add_seq_without_update (&pre, post);
>>         update_modified_stmts (pre);
>>
>>         /* Add the sequence after IFN_VA_ARG.  This splits the bb right
>> @@ -1072,11 +1077,10 @@ expand_ifn_va_arg_1 (function *fun)
>>         gimple_find_sub_bbs (pre, &i);
>>
>>         /* Remove the IFN_VA_ARG gimple_call.  It's the last stmt in the
>> -          bb.  */
>> +          bb if we added any stmts.  */
>>         unlink_stmt_vdef (stmt);
>>         release_ssa_name_fn (fun, gimple_vdef (stmt));
>>         gsi_remove (&i, true);
>> -       gcc_assert (gsi_end_p (i));
>>
>>         /* We're walking here into the bbs which contain the expansion of
>>            IFN_VA_ARG, and will not contain another IFN_VA_ARG that needs
>>

Reply via email to