Bug 94820 - [8/9 Regression] pr94780.c fails with ICE on aarch64
Summary: [8/9 Regression] pr94780.c fails with ICE on aarch64
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 10.0
: P2 normal
Target Milestone: 8.5
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
: 94821 (view as bug list)
Depends on: 94780
Blocks:
  Show dependency treegraph
 
Reported: 2020-04-28 13:25 UTC by Christophe Lyon
Modified: 2020-09-17 17:39 UTC (History)
2 users (show)

See Also:
Host:
Target: aarch64
Build:
Known to work:
Known to fail:
Last reconfirmed: 2020-04-28 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christophe Lyon 2020-04-28 13:25:22 UTC
Hi,

The new gcc.dg/pr94780.c test causes an ICE on aarch64:

/gcc/testsuite/gcc.dg/pr94780.c: In function 'foo':
/gcc/testsuite/gcc.dg/pr94780.c:8:1: internal compiler error: Segmentation fault
0xd5f4af crash_signal
        /gcc/toplev.c:328
0xe2b238 contains_struct_check
        /gcc/tree.h:3400
0xe2b238 convert_nonlocal_reference_op
        /gcc/tree-nested.c:1065
0x10cf01b walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
        /gcc/tree.c:12000
0xa34d93 walk_gimple_op(gimple*, tree_node* (*)(tree_node**, int*, void*), walk_stmt_info*)
        /gcc/gimple-walk.c:268
0xa355e4 walk_gimple_stmt(gimple_stmt_iterator*, tree_node* (*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*), walk_stmt_info*)
        /gcc/gimple-walk.c:596
0xa357e8 walk_gimple_seq_mod(gimple**, tree_node* (*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*), walk_stmt_info*)
        /gcc/gimple-walk.c:51
0xa35682 walk_gimple_stmt(gimple_stmt_iterator*, tree_node* (*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*), walk_stmt_info*)
        /gcc/gimple-walk.c:606
0xa357e8 walk_gimple_seq_mod(gimple**, tree_node* (*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*), walk_stmt_info*)
        /gcc/gimple-walk.c:51
0xe23ac1 walk_body
        /gcc/tree-nested.c:713
0xe24508 walk_function
        /gcc/tree-nested.c:724
0xe24508 walk_all_functions
        /gcc/tree-nested.c:789
0xe2a1af lower_nested_functions(tree_node*)
        /gcc/tree-nested.c:3553
0x86f243 cgraph_node::analyze()
        /gcc/cgraphunit.c:676
0x872ae3 analyze_functions
        /gcc/cgraphunit.c:1227
0x8738a2 symbol_table::finalize_compilation_unit()
        /gcc/cgraphunit.c:2974
Comment 1 Richard Biener 2020-04-28 13:31:08 UTC
Looks like an exact duplicate of the PR but this time for aarch64.  The fix is going to be similar (and likely more targets will be affected).
Comment 2 Andreas Schwab 2020-04-28 13:51:38 UTC
*** Bug 94821 has been marked as a duplicate of this bug. ***
Comment 3 z.zhanghaijian@huawei.com 2020-04-29 01:32:18 UTC
I have an initial fix for aarch64 that is under testing.
Will post to gcc-patches when finished.
Comment 4 GCC Commits 2020-04-29 08:24:48 UTC
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:d81bc2af7d2700888e414eb5a322ff5f5b0df0bb

commit r10-8038-gd81bc2af7d2700888e414eb5a322ff5f5b0df0bb
Author: Haijian Zhang <z.zhanghaijian@huawei.com>
Date:   Wed Apr 29 10:23:11 2020 +0200

    pr94780.c fails with ICE on aarch64 [PR94820]
    
    This is a simple fix for pr94820.
    The PR was only fixed on i386, the same error was also reported on aarch64.
    This function, because it is sometimes called even outside of function bodies, uses create_tmp_var_raw rather than create_tmp_var.
    But in order for that to work, when first referenced, the VAR_DECLs need to appear in a TARGET_EXPR so that during gimplification
    the var gets the right DECL_CONTEXT and is added to local decls. Without that, e.g. tree-nested.c ICEs on those.
    
    2020-04-29  Haijian Zhang  <z.zhanghaijian@huawei.com>
    
            PR target/94820
            * config/aarch64/aarch64-builtins.c
            (aarch64_atomic_assign_expand_fenv): Use TARGET_EXPR instead of
            MODIFY_EXPR for first assignment to fenv_cr, fenv_sr and
            new_fenv_var.
Comment 5 Jakub Jelinek 2020-04-29 13:05:22 UTC
Fixed on the trunk (so far).
Comment 6 GCC Commits 2020-09-16 19:21:20 UTC
The releases/gcc-9 branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:029d813ddf3595bfc93bfb4afad645dd033d21bf

commit r9-8889-g029d813ddf3595bfc93bfb4afad645dd033d21bf
Author: Haijian Zhang <z.zhanghaijian@huawei.com>
Date:   Wed Apr 29 10:23:11 2020 +0200

    pr94780.c fails with ICE on aarch64 [PR94820]
    
    This is a simple fix for pr94820.
    The PR was only fixed on i386, the same error was also reported on aarch64.
    This function, because it is sometimes called even outside of function bodies, uses create_tmp_var_raw rather than create_tmp_var.
    But in order for that to work, when first referenced, the VAR_DECLs need to appear in a TARGET_EXPR so that during gimplification
    the var gets the right DECL_CONTEXT and is added to local decls. Without that, e.g. tree-nested.c ICEs on those.
    
    2020-04-29  Haijian Zhang  <z.zhanghaijian@huawei.com>
    
            PR target/94820
            * config/aarch64/aarch64-builtins.c
            (aarch64_atomic_assign_expand_fenv): Use TARGET_EXPR instead of
            MODIFY_EXPR for first assignment to fenv_cr, fenv_sr and
            new_fenv_var.
    
    (cherry picked from commit d81bc2af7d2700888e414eb5a322ff5f5b0df0bb)
Comment 7 Jakub Jelinek 2020-09-17 17:39:38 UTC
Fixed for 8.5 in r8-10495-g840a91477f0157a5811957b7d866489d519fb77f and by the above commit for 9.4+ too.