https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122268

            Bug ID: 122268
           Summary: [16 Regression][OpenMP][offload:gcn/nvptx lto1] ICE
                    (during RTL pass: expand) in assign_temp, at
                    function.cc:990 for libgomp.c++/target-flex-101.C
                    (c++/16.0.0/flat_map:185:1) since
                    r16-4212-gf256a13f8aed83
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
                CC: ams at gcc dot gnu.org, jakub at gcc dot gnu.org,
                    tschwinge at gcc dot gnu.org
  Target Milestone: ---
            Target: gcn,nvptx

The regression shows up when compiling:

g++ -O1 -fopenmp -std=c++23 libgomp/testsuite/libgomp.c++/target-flex-101.C 

with optimization level -O1 or higher. The issue shows up for both Nvptx and
GCN.

* * *

Bisecting points to
commit r16-4212-gf256a13f8aed83
c++, gimplify: Implement C++26 P2795R5 - Erroneous behavior for uninitialized
reads [PR114457]

* * *

The underlying issue is presumably not new as:

* It seems as if the testcase always failed with -O0 for both GCN and nvptx,
  at least it fails now and for nvptx it also failed when the testcase was
  added (I tested GCC at r16-1007-g28a5bc2d4f7ae3, which added it, but skipped
  GCN during bisecting).

* There is a known issue for flat_map + offloadling, albeit only for GCN:
  PR120450 (GCN offloading: ICE 'during RTL pass: expand', 'in assign_temp, at
function.cc:990' for C++ 'std::flat_map', 'std::flat_multimap')

* PR117326 (depending on PR114819) is an issue might be related or not

* * *

The failing assert (gcc/function.cc:990) is:

  /* Allocating temporaries of TREE_ADDRESSABLE type must be done in the front
     end.  See also create_tmp_var for the gimplification-time check.  */
  gcc_assert (!TREE_ADDRESSABLE (type) && COMPLETE_TYPE_P (type));

Hereby:

9519          target = assign_temp (type, TREE_ADDRESSABLE (exp), 1);


(gdb) p debug(exp)

 <constructor 0x7ffff7412768
    type <record_type 0x7ffff77e4348 containers addressable cxx-odr-p BLK
        size <integer_cst 0x7ffff76e97c8 constant 384>
        unit-size <integer_cst 0x7ffff77c6f60 constant 48>
        align:64 warn_if_not_align:0 symtab:0 alias-set 61 canonical-type
0x7ffff77e4348
        fields <field_decl 0x7ffff77e2c80 keys type <record_type 0x7ffff77e4150
key_container_type>
            nonlocal BLK
/net/vbuild-02/srv/data/tburnus/projects/gcc-trunk-offload/include/c++/16.0.0/flat_map:123:21
            size <integer_cst 0x7ffff77c6ea0 constant 192>
            unit-size <integer_cst 0x7ffff77c6e88 constant 24>
            align:64 warn_if_not_align:0 offset_align 128 decl_not_flexarray: 0
            offset <integer_cst 0x7ffff76e9498 constant 0>
            bit-offset <integer_cst 0x7ffff76e94e0 constant 0> context
<record_type 0x7ffff77e4348 containers> chain <field_decl 0x7ffff77e2b40
values>> context <record_type 0x7ffff77e43f0 _Flat_map_impl>
        pointer_to_this <pointer_type 0x7ffff77e4498>>
    constant length:0>

* * *

The ICE is:

during RTL pass: expand

In member function ‘__ct ’,
    inlined from ‘__ct ’ at
/net/vbuild-02/srv/data/tburnus/projects/gcc-trunk-offload/include/c++/16.0.0/flat_map:1130:20,
    inlined from ‘_Z13test_flat_mapIiiLm10EEbRAT1__St4pairIT_T0_E._omp_fn.0’ at
libgomp/testsuite/libgomp.c++/target-flex-101.C:36:16:
/net/vbuild-02/srv/data/tburnus/projects/gcc-trunk-offload/include/c++/16.0.0/flat_map:185:11:
internal compiler error: in assign_temp, at function.cc:990
  185 |         : _M_cont(), _M_comp(__comp)
      |           ^
0x1c93ccd internal_error(char const*, ...)
       
/net/vbuild-02/srv/data/tburnus/repos/gcc/gcc/diagnostic-global-context.cc:786
0x9113fd fancy_abort(char const*, int, char const*)
       
/net/vbuild-02/srv/data/tburnus/repos/gcc/gcc/diagnostics/context.cc:1803
0x6c2f99 assign_temp(tree_node*, int, int)
        /net/vbuild-02/srv/data/tburnus/repos/gcc/gcc/function.cc:990
0xb0a887 expand_constructor
        /net/vbuild-02/srv/data/tburnus/repos/gcc/gcc/expr.cc:9519
0xaee512 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
        /net/vbuild-02/srv/data/tburnus/repos/gcc/gcc/expr.cc:11894
0xb01a51 expand_expr_real(tree_node*, rtx_def*, machine_mode, expand_modifier,
rtx_def**, bool)
        /net/vbuild-02/srv/data/tburnus/repos/gcc/gcc/expr.cc:9601
0xb01a51 expand_normal(tree_node*)
        /net/vbuild-02/srv/data/tburnus/repos/gcc/gcc/expr.h:329
0xb01a51 store_field
        /net/vbuild-02/srv/data/tburnus/repos/gcc/gcc/expr.cc:8318
0xafdae3 expand_assignment(tree_node*, tree_node*, bool)
        /net/vbuild-02/srv/data/tburnus/repos/gcc/gcc/expr.cc:6338
0x9c49f3 expand_gimple_stmt_1
        /net/vbuild-02/srv/data/tburnus/repos/gcc/gcc/cfgexpand.cc:4301
0x9c49f3 expand_gimple_stmt

Reply via email to