* Fix inliner versus nested functions and arrays of variable lengths
@ 2007-01-07 21:21 Jan Hubicka
2007-01-08 1:47 ` Eric Christopher
0 siblings, 1 reply; 2+ messages in thread
From: Jan Hubicka @ 2007-01-07 21:21 UTC (permalink / raw)
To: gcc-patches
Hi,
Razya run into problem with her IPCP merge.
In one of testsuite testcases there is nested function that refers
variable of outer function. That vairable is declared as variably sized
array. Doing this triggers interesting events leading to ICE
While duplicating the type we recurse on TYPE_SIZE parameter in
remap_type:
walk_tree (&TYPE_SIZE (new), copy_body_r, id, NULL);
walk_tree (&TYPE_SIZE_UNIT (new), copy_body_r, id, NULL);
This is correct in general, since we need to replace variables in the
case they are function local vairables. copy_body_r adds all variables
it sees to to referenced vars:
/* Global variables we didn't seen yet needs to go into referenced
vars. */
if (gimple_in_ssa_p (cfun) && TREE_CODE (*tp) == VAR_DECL)
add_referenced_var (*tp);
This is targeted to global variables not referenced by the function we
inline into as documented in the comment, however in this case tree
unnesting code keeps the type of variable in nested function to refer into
varibale of outer function (I think this is correct and I wasn't able to
reproduce problem by sizeof or something that is properly lowered).
However now inliner adds this variable as referenced. This leads to
delete_ssa while compiling the clone of nested function to clear
annotation of the variable of outer function and we finally die when
compiling the outer function.
The attached patch solve the problem by teaching copy_body_r to just add
referenced vars that are either global or local to function. It is sort
of symptomatic fix I would say, but I don't see how to fix it better.
Except perhaps making tree inliner to simply map inner function
referenced vars list into outer function referenced vars list and not
doing it within copy_body_r. This in general is less friendly to the
fact that we eliminate some vars during inlining.
Honza
Bootstrapped/regtested i686-linux
:ADDPATCH tree-optimization:
* tree-inline.c (copy_body_r): Do not add local variables of other functions.
Index: tree-inline.c
===================================================================
--- tree-inline.c (revision 120528)
+++ tree-inline.c (working copy)
@@ -691,7 +691,9 @@ copy_body_r (tree *tp, int *walk_subtree
/* Global variables we didn't seen yet needs to go into referenced
vars. */
- if (gimple_in_ssa_p (cfun) && TREE_CODE (*tp) == VAR_DECL)
+ if (gimple_in_ssa_p (cfun) && TREE_CODE (*tp) == VAR_DECL
+ && (is_global_var (*tp)
+ || decl_function_context (*tp) == current_function_decl))
add_referenced_var (*tp);
/* If EXPR has block defined, map it to newly constructed block.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Fix inliner versus nested functions and arrays of variable lengths
2007-01-07 21:21 Fix inliner versus nested functions and arrays of variable lengths Jan Hubicka
@ 2007-01-08 1:47 ` Eric Christopher
0 siblings, 0 replies; 2+ messages in thread
From: Eric Christopher @ 2007-01-08 1:47 UTC (permalink / raw)
To: Jan Hubicka; +Cc: gcc-patches
> :ADDPATCH tree-optimization:
> * tree-inline.c (copy_body_r): Do not add local variables of other
> functions.
> Index: tree-inline.c
> ===================================================================
> --- tree-inline.c (revision 120528)
> +++ tree-inline.c (working copy)
> @@ -691,7 +691,9 @@ copy_body_r (tree *tp, int *walk_subtree
>
> /* Global variables we didn't seen yet needs to go into
> referenced
> vars. */
> - if (gimple_in_ssa_p (cfun) && TREE_CODE (*tp) == VAR_DECL)
> + if (gimple_in_ssa_p (cfun) && TREE_CODE (*tp) == VAR_DECL
> + && (is_global_var (*tp)
> + || decl_function_context (*tp) == current_function_decl))
> add_referenced_var (*tp);
>
> /* If EXPR has block defined, map it to newly constructed
> block.
Can you update the comment while you're at it? FWIW to fix the
grammar as well it should be
"Global variables we haven't seen yet need to go into referenced vars."
-eric
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-01-08 1:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-07 21:21 Fix inliner versus nested functions and arrays of variable lengths Jan Hubicka
2007-01-08 1:47 ` Eric Christopher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).