public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Fix LTO parameter sharing
@ 2009-11-11 20:23 Jan Hubicka
  2009-11-11 20:41 ` Diego Novillo
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Hubicka @ 2009-11-11 20:23 UTC (permalink / raw)
  To: gcc-patches, rguenther

Hi,
this is Richi's patch fixing importantbug in LTO ipa-cp.  At moment we read in
summaries first and then when reading function bodies, we change parameter
lists.  This cause IPA-CP to create clones but not really propagate anything
into them. Also we get ICE with enable-checking compiler in SPEC gzip since the
unshared params get garbage collected.

I've bootstrapped/regtested patch on x86_64-linux and intend to check it in shortly.

Honza

	* lto-streamer-out.c (output_function): Output head of argument list
	earlier.
	* lto-streamer-in.c (input_function): Re-map arguments into merged
	declaration.
Index: lto-streamer-out.c
===================================================================
*** lto-streamer-out.c	(revision 154095)
--- lto-streamer-out.c	(working copy)
*************** output_function (struct cgraph_node *nod
*** 1870,1875 ****
--- 1870,1878 ----
    /* Output all the local variables in the function.  */
    lto_output_tree_ref (ob, fn->local_decls);
  
+   /* Output the head of the arguments list.  */
+   lto_output_tree_ref (ob, DECL_ARGUMENTS (function));
+ 
    /* Output all the SSA names used in the function.  */
    output_ssa_names (ob, fn);
  
*************** output_function (struct cgraph_node *nod
*** 1880,1888 ****
       lexical scopes.  */
    lto_output_tree (ob, DECL_INITIAL (function), true);
  
-   /* Output the head of the arguments list.  */
-   lto_output_tree_ref (ob, DECL_ARGUMENTS (function));
- 
    /* We will renumber the statements.  The code that does this uses
       the same ordering that we use for serializing them so we can use
       the same code on the other end and not have to write out the
--- 1883,1888 ----
Index: lto-streamer-in.c
===================================================================
*** lto-streamer-in.c	(revision 154095)
--- lto-streamer-in.c	(working copy)
*************** input_function (tree fn_decl, struct dat
*** 1262,1267 ****
--- 1262,1268 ----
    basic_block bb;
    struct bitpack_d *bp;
    struct cgraph_node *node;
+   tree args, narg, oarg;
  
    fn = DECL_STRUCT_FUNCTION (fn_decl);
    tag = input_record_start (ib);
*************** input_function (tree fn_decl, struct dat
*** 1296,1301 ****
--- 1297,1318 ----
    /* Read all the local symbols.  */
    fn->local_decls = lto_input_tree (ib, data_in);
  
+   /* Read all function arguments.  We need to re-map them here to the
+      arguments of the merged function declaration.  */
+   args = lto_input_tree (ib, data_in); 
+   for (oarg = args, narg = DECL_ARGUMENTS (fn_decl);
+        oarg && narg;
+        oarg = TREE_CHAIN (oarg), narg = TREE_CHAIN (narg))
+     {
+       int ix;
+       bool res;
+       res = lto_streamer_cache_lookup (data_in->reader_cache, oarg, &ix);
+       gcc_assert (res);
+       /* Replace the argument in the streamer cache.  */
+       lto_streamer_cache_insert_at (data_in->reader_cache, narg, ix);
+     }
+   gcc_assert (!oarg && !narg);
+ 
    /* Read all the SSA names.  */
    input_ssa_names (ib, data_in, fn);
  
*************** input_function (tree fn_decl, struct dat
*** 1307,1315 ****
    gcc_assert (DECL_INITIAL (fn_decl));
    DECL_SAVED_TREE (fn_decl) = NULL_TREE;
  
-   /* Read all function arguments.  */
-   DECL_ARGUMENTS (fn_decl) = lto_input_tree (ib, data_in); 
- 
    /* Read all the basic blocks.  */
    tag = input_record_start (ib);
    while (tag)
--- 1324,1329 ----

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-11-11 20:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-11 20:23 Fix LTO parameter sharing Jan Hubicka
2009-11-11 20:41 ` Diego Novillo
2009-11-11 20:42   ` Richard Guenther
2009-11-11 20:50     ` Diego Novillo

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).