From: Jan Hubicka <jh@suse.cz>
To: gcc-patches@gcc.gnu.org
Subject: Fix inliner versus nested functions and arrays of variable lengths
Date: Sun, 07 Jan 2007 21:21:00 -0000 [thread overview]
Message-ID: <20070107212109.GD9578@kam.mff.cuni.cz> (raw)
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.
next reply other threads:[~2007-01-07 21:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-07 21:21 Jan Hubicka [this message]
2007-01-08 1:47 ` Eric Christopher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070107212109.GD9578@kam.mff.cuni.cz \
--to=jh@suse.cz \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).