https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119835
Thomas Schwinge <tschwinge at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Assignee|unassigned at gcc dot gnu.org |tschwinge at gcc dot gnu.org Status|UNCONFIRMED |ASSIGNED CC| |rguenth at gcc dot gnu.org Keywords| |openacc Last reconfirmed| |2025-05-20 --- Comment #1 from Thomas Schwinge <tschwinge at gcc dot gnu.org> --- So, this issue can generally be triggered with code that return a struct. For example, offload-compiling ('-fopenacc' or '-fopenmp') 'libgomp.oacc-c-c++-common/abi-struct-1.c' with '-O1 -fno-inline', we get for 'rempty' (but also 'rschar', for example): Breakpoint 2, (anonymous namespace)::pass_nrv::execute (this=0x24e0670, fun=0x7ffff790add0) at ../../source-gcc/gcc/tree-nrv.cc:137 137 { (gdb) n 138 tree result = DECL_RESULT (current_function_decl); [...] 173 if (greturn *return_stmt = dyn_cast <greturn *> (stmt)) (gdb) n 178 ret_val = gimple_return_retval (return_stmt); (gdb) n 179 if (ret_val) (gdb) n 180 gcc_assert (ret_val == result); (gdb) print result $4 = (tree) 0x7ffff77fb300 (gdb) call debug_tree(result) <result_decl 0x7ffff77fb300 D.1834 type <record_type 0x7ffff77b0b28 empty BLK size <integer_cst 0x7ffff76eb4e0 constant 0> unit-size <integer_cst 0x7ffff76eb498 constant 0> align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7ffff77b0a80> ignored BLK source-gcc/libgomp/testsuite/libgomp.oacc-c-c++-common/abi-struct-1.c:19:14 size <integer_cst 0x7ffff76eb4e0 0> unit-size <integer_cst 0x7ffff76eb498 0> align:8 warn_if_not_align:0 context <function_decl 0x7ffff77e0000 rempty>> (gdb) print ret_val $5 = (tree) 0x7ffff77f4a18 (gdb) call debug_tree(ret_val) <var_decl 0x7ffff77f4a18 D.1835 type <record_type 0x7ffff77b0b28 empty BLK size <integer_cst 0x7ffff76eb4e0 constant 0> unit-size <integer_cst 0x7ffff76eb498 constant 0> align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7ffff77b0a80> ignored BLK source-gcc/libgomp/testsuite/libgomp.oacc-c-c++-common/abi-struct-1.c:21:11 size <integer_cst 0x7ffff76eb4e0 0> unit-size <integer_cst 0x7ffff76eb498 0> align:8 warn_if_not_align:0 context <function_decl 0x7ffff77e0000 rempty>> ..., so there is indeed a disconnect between 'DECL_RESULT' and 'gimple_return_retval'. The source code says: "In a function with an aggregate return value, the gimplifier has changed all non-empty RETURN_EXPRs to return the RESULT_DECL.", so I suppose the issue is that for offloading we're rewriting some DECLs, but are missing to update something? If I disable this local check (the 'ret_val' variable isn't used for anything other than the 'assert'), the ICE goes away -- and the pass doesn't do any transformations (for 'libgomp.oacc-c-c++-common/abi-struct-1.c'), so not sure whether that finding implies anything useful.