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