This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix tree body copying
On Tue, 7 Jul 2009, Richard Guenther wrote:
>
> This is a split-out from the gimplify-unit-at-a-time patch which relies
> on copy_tree_body_r properly copying GENERIC bodies.
>
> There are several issues with the current implementation, the most
> prominent being that statement-list copying is completely hosed
> because of the 'optimization' tsi_link_after performs. Fixed by
> providing a non-optimizing variant for tsi_link_after.
>
> Other issues are that the FE requires the type on the statement-list
> properly copied and TARGET_EXPR handled the same as SAVE_EXPR.
>
> Separate bootstrap and regtest is running, I will apply this after
> it succeeded.
A somewhat simpler patch for the statement list copying would be
Index: tree-inline.c
===================================================================
--- tree-inline.c (revision 149318)
+++ tree-inline.c (working copy)
@@ -603,7 +603,12 @@ copy_statement_list (tree *tp)
*tp = new_tree;
for (; !tsi_end_p (oi); tsi_next (&oi))
- tsi_link_after (&ni, tsi_stmt (oi), TSI_NEW_STMT);
+ {
+ tree stmt = tsi_stmt (oi);
+ if (TREE_CODE (stmt) == STATEMENT_LIST)
+ copy_statement_list (&stmt);
+ tsi_link_after (&ni, stmt, TSI_CONTINUE_LINKING);
+ }
}
static void
This doesn't preserve statement-list in statement-list during
copying (but instead expands the nested statement-list inline, but
properly).
Any opinion on if that is more correct? (that is, is the
statement-list in statement-list input considered incorrect instead
of the inlined output?)
Thanks,
Richard.