Bug 102492 - [12 Regression] ICE in scan_sharing_clauses, at omp-low.c:1205
Summary: [12 Regression] ICE in scan_sharing_clauses, at omp-low.c:1205
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 12.0
: P3 normal
Target Milestone: 12.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code, openmp
Depends on:
Blocks:
 
Reported: 2021-09-26 14:53 UTC by Arseny Solokha
Modified: 2021-10-16 06:35 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Testcase (437 bytes, text/plain)
2021-09-26 14:53 UTC, Arseny Solokha
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Arseny Solokha 2021-09-26 14:53:42 UTC
Created attachment 51510 [details]
Testcase

g++-12.0.0-alpha20210919 snapshot (g:32731fa5b0abf092029b8e2be64319b978bda514) ICEs when compiling the attached testcase, partially reduced from libstdc++-v3/testsuite/26_numerics/pstl/numeric_ops/reduce.cc, w/ -fopenmp:

% g++-12.0.0 -fopenmp -c vksbmhow.cc
vksbmhow.cc: In function 'void __simd_transform_reduce(_Size, _Tp, _BinaryOperation) [with _Size = int; _Tp = Number; _BinaryOperation = int]':
vksbmhow.cc:25:9: error: no matching function for call to 'Number::Number()'
   25 | #pragma omp simd
      |         ^~~
vksbmhow.cc:2:3: note: candidate: 'Number::Number(int)'
    2 |   Number(int);
      |   ^~~~~~
vksbmhow.cc:2:3: note:   candidate expects 1 argument, 0 provided
vksbmhow.cc:1:8: note: candidate: 'constexpr Number::Number(const Number&)'
    1 | struct Number {
      |        ^~~~~~
vksbmhow.cc:1:8: note:   candidate expects 1 argument, 0 provided
vksbmhow.cc:1:8: note: candidate: 'constexpr Number::Number(Number&&)'
vksbmhow.cc:1:8: note:   candidate expects 1 argument, 0 provided
during GIMPLE pass: omplower
vksbmhow.cc:25:9: internal compiler error: in scan_sharing_clauses, at omp-low.c:1205
   25 | #pragma omp simd
      |         ^~~
0x7c90d0 scan_sharing_clauses
	/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20210919/work/gcc-12-20210919/gcc/omp-low.c:1205
0x1014514 scan_omp_for
	/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20210919/work/gcc-12-20210919/gcc/omp-low.c:2820
0x1015c00 scan_omp_1_stmt
	/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20210919/work/gcc-12-20210919/gcc/omp-low.c:4137
0xe7deea walk_gimple_stmt(gimple_stmt_iterator*, tree_node* (*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*), walk_stmt_info*)
	/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20210919/work/gcc-12-20210919/gcc/gimple-walk.c:602
0xe7e120 walk_gimple_seq_mod(gimple**, tree_node* (*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*), walk_stmt_info*)
	/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20210919/work/gcc-12-20210919/gcc/gimple-walk.c:51
0xe7dfd5 walk_gimple_stmt(gimple_stmt_iterator*, tree_node* (*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*), walk_stmt_info*)
	/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20210919/work/gcc-12-20210919/gcc/gimple-walk.c:711
0xe7e120 walk_gimple_seq_mod(gimple**, tree_node* (*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*), walk_stmt_info*)
	/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20210919/work/gcc-12-20210919/gcc/gimple-walk.c:51
0xe7dfd5 walk_gimple_stmt(gimple_stmt_iterator*, tree_node* (*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*), walk_stmt_info*)
	/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20210919/work/gcc-12-20210919/gcc/gimple-walk.c:711
0xe7e120 walk_gimple_seq_mod(gimple**, tree_node* (*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*), walk_stmt_info*)
	/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20210919/work/gcc-12-20210919/gcc/gimple-walk.c:51
0x10213e5 scan_omp
	/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20210919/work/gcc-12-20210919/gcc/omp-low.c:4241
0x10213e5 execute_lower_omp
	/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20210919/work/gcc-12-20210919/gcc/omp-low.c:14292
0x10213e5 execute
	/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20210919/work/gcc-12-20210919/gcc/omp-low.c:14350
Comment 1 Jakub Jelinek 2021-09-27 13:33:37 UTC
It started with my r12-3654-ge5597f2ad55219092929dc12ea15e1edba06df18 then.
Shorter testcase:
struct S { S (int); };
void bar (S &);

void
foo ()
{
  #pragma omp simd
  for (int i = 0; i < 64; i++)
    {
      S s = 26;
      bar (s);
    }
}
Comment 2 GCC Commits 2021-09-28 09:42:32 UTC
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:4f07769057c45ec9e751ab1c23e0fe4750102840

commit r12-3917-g4f07769057c45ec9e751ab1c23e0fe4750102840
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Sep 28 11:38:03 2021 +0200

    openmp: Don't call omp_finish_clause on implicitly added private clauses on simd [PR102492]
    
    The gimplifier adds implicit private clauses on SIMD constructs for local
    variables in the SIMD body if they are addressable to make sure they use
    the magic arrays with "omp simd array" attribute (such that each SIMD lane
    has its own copy), but we actually don't need to default privatize etc. those,
    the construction for them is done in the SIMD body and so is destruction.
    omp_finish_clause for C++ now requires default constructor (and dtor) for private,
    so that OpenMP 5.1 default(private) works, but that will never be needed on
    SIMD.  So, this patch just doesn't call omp_finish_clause for private on simd.
    The C and Fortran langhooks don't do anything for private.
    
    2021-09-28  Jakub Jelinek  <jakub@redhat.com>
    
            PR middle-end/102492
            * gimplify.c (gimplify_adjust_omp_clauses_1): Don't call the
            omp_finish_clause langhook on implicitly added OMP_CLAUSE_PRIVATE
            clauses on SIMD constructs.
    
            * g++.dg/gomp/simd-3.C: New test.
Comment 3 Jakub Jelinek 2021-10-16 06:35:06 UTC
Should be fixed now.