https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90990
--- Comment #9 from Martin Liška <marxin at gcc dot gnu.org> ---
> So it is inliner substituting the return slot which happens to be
> clobber?
Yes.
> It makes sense but I wonder how this worked w/o the patch.
> > #10 0x00000000010f9dd5 in remap_gimple_stmt (stmt=0x7ffff75311e0,
> > id=0x7fffffffd6d0) at /home/marxin/Programming/gcc/gcc/tree-inline.c:1896
Before the patch we used to have:
MEM[(struct &)&<retval>] ={v} {CLOBBER};
while now we have a nicer clobber:
<retval> ={v} {CLOBBER};
That's the difference.
>
> remap_gimple_stmt already has some code to drop clobbers after
> substitution
>
> /* For *ptr_N ={v} {CLOBBER}, if ptr_N is SSA_NAME defined
>
> in a block that we aren't copying during tree_function_versioning,
>
> just drop the clobber stmt. */
>
> if (id->blocks_to_copy && gimple_clobber_p (stmt))
>
> {
>
> tree lhs = gimple_assign_lhs (stmt);
>
> if (TREE_CODE (lhs) == MEM_REF
>
> && TREE_CODE (TREE_OPERAND (lhs, 0)) == SSA_NAME)
>
>
> perhaps we need to care about the retval here.
I can confirm the following patch works:
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 2de5e22f10f..04e60d1c9b8 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1734,10 +1734,11 @@ remap_gimple_stmt (gimple *stmt, copy_body_data *id)
/* For *ptr_N ={v} {CLOBBER}, if ptr_N is SSA_NAME defined
in a block that we aren't copying during tree_function_versioning,
just drop the clobber stmt. */
- if (id->blocks_to_copy && gimple_clobber_p (stmt))
+ if (gimple_clobber_p (stmt))
{
tree lhs = gimple_assign_lhs (stmt);
- if (TREE_CODE (lhs) == MEM_REF
+ if (id->blocks_to_copy
+ && TREE_CODE (lhs) == MEM_REF
&& TREE_CODE (TREE_OPERAND (lhs, 0)) == SSA_NAME)
{
gimple *def_stmt = SSA_NAME_DEF_STMT (TREE_OPERAND (lhs, 0));
@@ -1746,6 +1747,8 @@ remap_gimple_stmt (gimple *stmt, copy_body_data *id)
gimple_bb (def_stmt)->index))
return NULL;
}
+ else if (TREE_CODE (lhs) == RESULT_DECL)
+ return NULL;
}
if (gimple_debug_bind_p (stmt))
However, I guess we want to preserve clobber that will not end up as a
component ref, right?