public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [pph] Fix in-memory marking (take 2) (issue5540069)
@ 2012-01-17 16:35 Diego Novillo
  0 siblings, 0 replies; only message in thread
From: Diego Novillo @ 2012-01-17 16:35 UTC (permalink / raw)
  To: reply, crowl, gcc-patches


My previous patch moved the in_memory marker to the wrong place.
We need to prevent a file from being re-read by an #include from one
of its included children images.  This is common in system headers.

We mark the file as resident in-memory right before we start reading
its includes.  Before, we were marking it when the file was initially
registered.  This was causing us to completely ignore needed
PPH images.

	* pph-core.c (pph_stream_register): Move in-memory marking...
	* pph-in.c (pph_read_file_1): ... here.

diff --git a/gcc/cp/pph-core.c b/gcc/cp/pph-core.c
index 9f7f063..6d34bd0 100644
--- a/gcc/cp/pph-core.c
+++ b/gcc/cp/pph-core.c
@@ -953,10 +953,6 @@ pph_stream_register (pph_stream *stream)
 
   /* Add a mapping between STREAM's PPH file name and STREAM.  */
   pph_stream_registry_add_name (stream, stream->name);
-
-  /* Mark this file as being in memory.  This prevents opening the
-     same file more than twice.  */
-  stream->in_memory_p = true;
 }
 
 
diff --git a/gcc/cp/pph-in.c b/gcc/cp/pph-in.c
index e9a5563..827c8fd 100644
--- a/gcc/cp/pph-in.c
+++ b/gcc/cp/pph-in.c
@@ -2839,11 +2839,17 @@ pph_read_file_1 (pph_stream *stream)
   VEC(tree,gc) *file_unemitted_tinfo_decls;
   source_location cpp_token_replay_loc;
 
-  /* If we have opened STREAM before, we do not need to re-read the rest
-     of its body.  */
+  /* If we already have STREAM in memory (or are reading it), ignore
+     this request.  */
   if (stream->in_memory_p)
     return;
 
+  /* Mark this file as being in memory.  This prevents multiple reads
+     from the same file.  This scenario can happen in #include chains
+     where the top header file is also included by one of its children
+     (common in system headers).  */
+  stream->in_memory_p = true;
+
   if (flag_pph_tracer >= 1)
     fprintf (pph_logfile, "PPH: Reading %s\n", stream->name);
 

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-01-17 16:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-17 16:35 [pph] Fix in-memory marking (take 2) (issue5540069) 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).