diff mbox

[pph] Allow DECL_LANG_SPECIFIC to be shared (issue4667049)

Message ID 20110629205043.CF5281DA1C6@topo.tor.corp.google.com
State New
Headers show

Commit Message

Diego Novillo June 29, 2011, 8:50 p.m. UTC
This is a patch that Lawrence and I were working on yesterday
that I need for my next patch.  We were not expecting
DECL_LANG_SPECIFIC to be shared, but in fact there are several
occasions (thunks, aliases) where it is shared.

By itself, this does not fix any tests, but it fixes a problem
exposed by the next patch.

Tested on x86_64.  Committed to the branch.

2011-06-29   Diego Novillo  <dnovillo@google.com>
 	     Lawrence Crowl  <crowl@google.com>

	* pph-streamer-in.c (pph_in_lang_specific): Expect shared
	DECL_LANG_SPECIFIC fields.


--
This patch is available for review at http://codereview.appspot.com/4667049
diff mbox

Patch

diff --git a/gcc/cp/ChangeLog.pph b/gcc/cp/ChangeLog.pph
index a62dd66..9465484 100644
--- a/gcc/cp/ChangeLog.pph
+++ b/gcc/cp/ChangeLog.pph
@@ -1,4 +1,10 @@ 
 2011-06-29   Diego Novillo  <dnovillo@google.com>
+	     Lawrence Crowl  <crowl@google.com>
+
+	* pph-streamer-in.c (pph_in_lang_specific): Expect shared
+	DECL_LANG_SPECIFIC fields.
+
+2011-06-29   Diego Novillo  <dnovillo@google.com>
 
 	* pph-streamer-in.c (pph_read_tree): Call
 	append_to_statement_list_force instead of append_to_statement_list.
diff --git a/gcc/cp/pph-streamer-in.c b/gcc/cp/pph-streamer-in.c
index 1a59640..1c71c30 100644
--- a/gcc/cp/pph-streamer-in.c
+++ b/gcc/cp/pph-streamer-in.c
@@ -881,18 +881,23 @@  pph_in_lang_specific (pph_stream *stream, tree decl)
   marker = pph_in_start_record (stream, &ix);
   if (marker == PPH_RECORD_END)
     return;
-
-  /* Since lang_decl is embedded in every decl, LD cannot
-     be shared.  */
-  gcc_assert (marker != PPH_RECORD_SHARED);
+  else if (marker == PPH_RECORD_SHARED)
+    {
+      DECL_LANG_SPECIFIC (decl) =
+	(struct lang_decl *) pph_in_shared_data (stream, ix);
+      return;
+    }
 
   /* Allocate a lang_decl structure for DECL.  */
   retrofit_lang_decl (decl);
-
   ld = DECL_LANG_SPECIFIC (decl);
-  ldb = &ld->u.base;
+
+  /* Now register it.  We would normally use ALLOC_AND_REGISTER,
+     but retrofit_lang_decl does not return a pointer.  */
+  pph_register_shared_data (stream, ld, ix);
 
   /* Read all the fields in lang_decl_base.  */
+  ldb = &ld->u.base;
   pph_in_ld_base (stream, ldb);
 
   if (ldb->selector == 0)