public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [pph] Fix x1dynarra1, x1dynarray2a and x1dynarray2b (issue4921051)
@ 2011-08-22 15:50 Diego Novillo
  2011-08-22 17:18 ` Gabriel Charette
  0 siblings, 1 reply; 2+ messages in thread
From: Diego Novillo @ 2011-08-22 15:50 UTC (permalink / raw)
  To: reply, crowl, gchare, gcc-patches


This patch fixes some template test cases.  We were trying to 
expand functions that did not really need expanding (templates).  This
got me thinking that we are not approaching the expansion properly.

We are trying to re-create all the cgraph creation done during the
compilation of the header file.  Rather than re-creating all this, it
would be more efficient to save the state of the callgraph and varpool
at the time of pph generation and then simply recreate it at read
time.  I will experiment with that, see if it actually makes any
sense.

Tested on x86_64.  Applied to pph.

	* pph-streamer-out.c (pph_out_symtab): Mark the function as
 	having a body if it has a cgraph node associated with it.
 	* pph-streamer-in.c (pph_in_binding_level): Call pph_in_tree to
 	read BL->BLOCKS.
 	* pph-streamer-out.c (pph_out_binding_level_1): Call pph_out_tree
 	to write BL->BLOCKS.

testsuite/ChangeLog.pph
2011-08-18   Diego Novillo  <dnovillo@google.com>

	* g++.dg/pph/x1dynarray1.cc: Mark fixed.
	* g++.dg/pph/x1dynarray2a.cc: Mark fixed.
	* g++.dg/pph/x1dynarray2b.cc: Mark fixed.

diff --git a/gcc/cp/pph-streamer-in.c b/gcc/cp/pph-streamer-in.c
index 9686edf..ae3ede9 100644
--- a/gcc/cp/pph-streamer-in.c
+++ b/gcc/cp/pph-streamer-in.c
@@ -557,7 +557,7 @@ pph_in_binding_level (pph_stream *stream, cp_binding_level *to_register)
       VEC_safe_push (cp_label_binding, gc, bl->shadowed_labels, sl);
     }
 
-  bl->blocks = pph_in_chain (stream);
+  bl->blocks = pph_in_tree (stream);
   bl->this_entity = pph_in_tree (stream);
   bl->level_chain = pph_in_binding_level (stream, NULL);
   bl->dead_vars_from_for = pph_in_tree_vec (stream);
diff --git a/gcc/cp/pph-streamer-out.c b/gcc/cp/pph-streamer-out.c
index b563891..fe0758f 100644
--- a/gcc/cp/pph-streamer-out.c
+++ b/gcc/cp/pph-streamer-out.c
@@ -574,7 +574,7 @@ pph_out_binding_level_1 (pph_stream *stream, cp_binding_level *bl,
   FOR_EACH_VEC_ELT (cp_label_binding, bl->shadowed_labels, i, sl)
     pph_out_label_binding (stream, sl);
 
-  pph_out_chain (stream, bl->blocks);
+  pph_out_tree (stream, bl->blocks);
   pph_out_tree (stream, bl->this_entity);
   pph_out_binding_level (stream, bl->level_chain, filter);
   pph_out_tree_vec (stream, bl->dead_vars_from_for);
@@ -1128,7 +1128,9 @@ pph_out_symtab (pph_stream *stream)
   FOR_EACH_VEC_ELT (tree, stream->symtab.v, i, decl)
     if (TREE_CODE (decl) == FUNCTION_DECL && DECL_STRUCT_FUNCTION (decl))
       {
-	if (DECL_SAVED_TREE (decl))
+	/* If this is a regular (non-template) function with a body,
+	   mark it for expansion during reading.  */
+	if (DECL_SAVED_TREE (decl) && cgraph_get_node (decl))
 	  pph_out_symtab_marker (stream, PPH_SYMTAB_FUNCTION_BODY);
 	else
 	  pph_out_symtab_marker (stream, PPH_SYMTAB_FUNCTION);
diff --git a/gcc/testsuite/g++.dg/pph/x1dynarray1.cc b/gcc/testsuite/g++.dg/pph/x1dynarray1.cc
index 2a1f9f6..6ef279d 100644
--- a/gcc/testsuite/g++.dg/pph/x1dynarray1.cc
+++ b/gcc/testsuite/g++.dg/pph/x1dynarray1.cc
@@ -1,5 +1,4 @@
-// { dg-do link }
-// { dg-xfail-if "BOGUS" { "*-*-*" } { "-fpph-map=pph.map" } }
+// { dg-do run }
 
 #include "x0dynarray1.h"
 
diff --git a/gcc/testsuite/g++.dg/pph/x1dynarray2a.cc b/gcc/testsuite/g++.dg/pph/x1dynarray2a.cc
index f941086..252e801 100644
--- a/gcc/testsuite/g++.dg/pph/x1dynarray2a.cc
+++ b/gcc/testsuite/g++.dg/pph/x1dynarray2a.cc
@@ -1,5 +1,4 @@
-// { dg-xfail-if "BOGUS" { "*-*-*" } { "-fpph-map=pph.map" } }
-// { dg-do link }
+// { dg-do run }
 
 #include "x0dynarray2.h"
 
diff --git a/gcc/testsuite/g++.dg/pph/x1dynarray2b.cc b/gcc/testsuite/g++.dg/pph/x1dynarray2b.cc
index 8f14149..c942d9d 100644
--- a/gcc/testsuite/g++.dg/pph/x1dynarray2b.cc
+++ b/gcc/testsuite/g++.dg/pph/x1dynarray2b.cc
@@ -1,5 +1,4 @@
-// { dg-xfail-if "BOGUS" { "*-*-*" } { "-fpph-map=pph.map" } }
-// { dg-do link }
+// { dg-do run }
 
 #include "x0dynarray2.h"
 
-- 
1.7.3.1


--
This patch is available for review at http://codereview.appspot.com/4921051

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

* Re: [pph] Fix x1dynarra1, x1dynarray2a and x1dynarray2b (issue4921051)
  2011-08-22 15:50 [pph] Fix x1dynarra1, x1dynarray2a and x1dynarray2b (issue4921051) Diego Novillo
@ 2011-08-22 17:18 ` Gabriel Charette
  0 siblings, 0 replies; 2+ messages in thread
From: Gabriel Charette @ 2011-08-22 17:18 UTC (permalink / raw)
  To: Diego Novillo; +Cc: reply, crowl, gcc-patches

On Mon, Aug 22, 2011 at 8:22 AM, Diego Novillo <dnovillo@google.com> wrote:
>
> This patch fixes some template test cases.  We were trying to
> expand functions that did not really need expanding (templates).  This
> got me thinking that we are not approaching the expansion properly.
>
> We are trying to re-create all the cgraph creation done during the
> compilation of the header file.  Rather than re-creating all this, it
> would be more efficient to save the state of the callgraph and varpool
> at the time of pph generation and then simply recreate it at read
> time.  I will experiment with that, see if it actually makes any
> sense.
>

I had this idea earlier when playing with varpool for functions not
being streamed with their "rest_of_decl"compilation" state. The
problem for doing this if I remember correctly is that calling the
functions which generate those creates some unique ordering and IDs,
so that we need to do it in order of the current include order of each
pph in the current TU, and since the order of each pph in a given
compilation is not set ahead of time, I'm not sure this is possible
(at least not simple). We could probably find a way to merge those
states on the way in, but that would most likely tie us to the
implementation of those calls..

Gab

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

end of thread, other threads:[~2011-08-22 16:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-22 15:50 [pph] Fix x1dynarra1, x1dynarray2a and x1dynarray2b (issue4921051) Diego Novillo
2011-08-22 17:18 ` Gabriel Charette

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