https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128173
Bug ID: 128173
Summary: [OpenMP] ICE in gimplify_var_or_parm_decl via
gimplify_adjust_omp_clauses
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: ice-on-valid-code, openmp
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: burnus at gcc dot gnu.org
CC: sandra at gcc dot gnu.org
Target Milestone: ---
Created attachment 65963
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65963&action=edit
Testcase - compile with "gcc/g++ -fopenmp"
As mapper and iterator are new, it is technically a GCC 16/17 regression.
As the testcase shows, it works when there is only a mapper or only an
iterator.
foo.c: In Funktion »sum_and_map_it«:
foo.c:17:55: internal compiler error: in gimplify_var_or_parm_decl, at
gimplify.cc:3298
17 | #pragma omp target map(iterator(int i=0:5), to: s[i].t) map(from:sum)
The fail occurs for:
16225 gimplify_omp_ctxp = ctx->outer_context;
16226 if (gimplify_expr (pd, seq_p, NULL, is_gimple_lvalue,
16227 fb_lvalue) == GS_ERROR)
note the 'lvalue' check part.
with 'pd' (alias gimplify_expr's expr_p) being exactly what's visible above:
<component_ref 0x7ffff6e1f390
type <record_type 0x7ffff71df690 T TI
arg:0 <array_ref 0x7ffff6e15f18
arg:0 <var_decl 0x7ffff6e19000 s type <array_type 0x7ffff6e180a8>
arg:1 <var_decl 0x7ffff6e19130 i type <integer_type 0x7ffff701d5e8 int>
arg:1 <field_decl 0x7ffff702caa0 t type <record_type 0x7ffff71df690 T>
This then ends up for
(gdb) p code
$3 = COMPONENT_REF
20544 case COMPONENT_REF:
20545 ret = gimplify_compound_lval (expr_p, pre_p, post_p,
20546 fallback ? fallback :
fb_rvalue);
20547 break;
The problem is the gimplification of 'i' which seems to be not available:
21063 ret = gimplify_var_or_parm_decl (expr_p);
(gdb) p debug_tree(*expr_p)
<var_decl 0x7ffff6e19130 i
type <integer_type 0x7ffff701d5e8 int sizes-gimplified public SI
size <integer_cst 0x7ffff701f210 constant 32>
unit-size <integer_cst 0x7ffff701f228 constant 4>
align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff701d5e8 precision:32 min <integer_cst 0x7ffff701f1c8 -2147483648> max
<integer_cst 0x7ffff701f1e0 2147483647>
pointer_to_this <pointer_type 0x7ffff7025b28>>
used read SI foo.c:17:39 size <integer_cst 0x7ffff701f210 32> unit-size
<integer_cst 0x7ffff701f228 4>
align:32 warn_if_not_align:0 context <function_decl 0x7ffff71f1500
sum_and_map_it>>
running there into the assert:
3293 if (VAR_P (decl)
3294 && !DECL_SEEN_IN_BIND_EXPR_P (decl)
(gdb)
3295 && !TREE_STATIC (decl) && !DECL_EXTERNAL (decl)
3296 && decl_function_context (decl) == current_function_decl)
3297 {
3298 gcc_assert (seen_error ());
3299 return GS_ERROR;
3300 }