https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103192
Bug ID: 103192 Summary: [12 Regression] ICE on libgomp target-in-reduction-2.{C,c} Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: jakub at gcc dot gnu.org Target Milestone: --- I see ICE when compiling these testcases in a bootstrapped compiler: ../configure --enable-languages=default,ada,obj-c++,lto,go,d --enable-checking=yes,rtl,extra && make -j32 bootstrap cd x86_64-*/libgomp make check RUNTESTFLAGS='c.exp=target-in-reduction-2.c c++.exp=target-in-reduction-2*' FAIL: libgomp.c/../libgomp.c-c++-common/target-in-reduction-2.c (internal compiler error) FAIL: libgomp.c/../libgomp.c-c++-common/target-in-reduction-2.c (test for excess errors) UNRESOLVED: libgomp.c/../libgomp.c-c++-common/target-in-reduction-2.c compilation failed to produce executable FAIL: libgomp.c++/../libgomp.c-c++-common/target-in-reduction-2.c (internal compiler error) FAIL: libgomp.c++/../libgomp.c-c++-common/target-in-reduction-2.c (test for excess errors) UNRESOLVED: libgomp.c++/../libgomp.c-c++-common/target-in-reduction-2.c compilation failed to produce executable FAIL: libgomp.c++/target-in-reduction-2.C (internal compiler error) FAIL: libgomp.c++/target-in-reduction-2.C (test for excess errors) UNRESOLVED: libgomp.c++/target-in-reduction-2.C compilation failed to produce executable but can't reproduce that with stage1 gcc. The ICE is in omp_add_variable being called with NULL first argument, but the source code has: omp_add_variable (ctx, decl, flags); if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION) && OMP_CLAUSE_REDUCTION_PLACEHOLDER (c)) { struct gimplify_omp_ctx *pctx = code == OMP_TARGET ? outer_ctx : ctx; if (pctx) omp_add_variable (pctx, OMP_CLAUSE_REDUCTION_PLACEHOLDER (c), GOVD_LOCAL | GOVD_SEEN); ^^^^^^^^^^^^^^^^ Inside of the above call if (pctx && OMP_CLAUSE_REDUCTION_DECL_PLACEHOLDER (c) && walk_tree (&OMP_CLAUSE_REDUCTION_INIT (c), find_decl_expr, OMP_CLAUSE_REDUCTION_DECL_PLACEHOLDER (c), NULL) == NULL_TREE) omp_add_variable (pctx, OMP_CLAUSE_REDUCTION_DECL_PLACEHOLDER (c), GOVD_LOCAL | GOVD_SEEN); outer_ctx can be NULL, ctx may not, but the source really should guarantee that when code is OMP_TARGET (this case) and outer_ctx is NULL, then omp_add_variable is not called. In *.strlen1 dump I still see <bb 1285> [local count: 22959172]: [../../gcc/gimplify.c:10067:33] # DEBUG pctx => iftmp.2373_1469 [../../gcc/gimplify.c:10069:8] # DEBUG BEGIN_STMT [../../gcc/gimplify.c:10069:8] if (iftmp.2373_1469 != 0B) goto <bb 1286>; [70.00%] else goto <bb 1289>; [30.00%] <bb 1286> [local count: 38024558]: [../../gcc/gimplify.c:10067:33] # DEBUG pctx => NULL [../../gcc/gimplify.c:10070:3] # DEBUG BEGIN_STMT [../../gcc/gimplify.c:10070:51] _761 = omp_clause_range_check (c_4680, 5, 7, [../../gcc/gimplify.c:10070:51] "../../gcc/gimplify.c", 10070, [../../gcc/gimplify.c:10070:51] "gimplify_scan_omp_clauses"); [../../gcc/gimplify.c:10070:51] _762 = omp_clause_elt_check (_761, 3, [../../gcc/gimplify.c:10070:51] "../../gcc/gimplify.c", 10070, [../../gcc/gimplify.c:10070:51] "gimplify_scan_omp_clauses"); [../../gcc/gimplify.c:10070:20] _763 = [../../gcc/gimplify.c:10070:20] *_762; [../../gcc/gimplify.c:10070:20] omp_add_variable (iftmp.2373_1469, _763, 129); but in threadfull2 dump I see: [../../gcc/gimplify.c:10065:12] _3356 = [../../gcc/gimplify.c:10065:12] MEM[(union tree_node * *)c_4680 + 80B]; [../../gcc/gimplify.c:10065:8] if (_3356 != 0B) goto <bb 1286>; [70.00%] else goto <bb 1621>; [30.00%] ... <bb 1286> [local count: 38024558]: [../../gcc/gimplify.c:10067:8] # DEBUG BEGIN_STMT [../../gcc/gimplify.c:10067:33] # DEBUG pctx => NULL [../../gcc/gimplify.c:10067:33] # DEBUG pctx => NULL [../../gcc/gimplify.c:10070:3] # DEBUG BEGIN_STMT [../../gcc/gimplify.c:10070:51] _761 = omp_clause_range_check (c_4680, 5, 7, [../../gcc/gimplify.c:10070:51] "../../gcc/gimplify.c", 10070, [../../gcc/gimplify.c:10070:51] "gimplify_scan_omp_clauses"); [../../gcc/gimplify.c:10070:51] _762 = omp_clause_elt_check (_761, 3, [../../gcc/gimplify.c:10070:51] "../../gcc/gimplify.c", 10070, [../../gcc/gimplify.c:10070:51] "gimplify_scan_omp_clauses"); [../../gcc/gimplify.c:10070:20] _763 = [../../gcc/gimplify.c:10070:20] *_762; [../../gcc/gimplify.c:10070:20] omp_add_variable (iftmp.2373_1469, _763, 129); which looks like OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) check to me.