Patchwork [pph] Rebuild compilation context from PPH images (0/6) (issue4400048)

login
register
mail settings
Submitter Diego Novillo
Date April 14, 2011, 7:40 p.m.
Message ID <20110414194031.B6192A00D@topo.tor.corp.google.com>
Download mbox | patch
Permalink /patch/91281/
State New
Headers show

Comments

Diego Novillo - April 14, 2011, 7:40 p.m.
This patch is the first of a series of 7 patches to reconstruct the
compilation context out of a PPH image.

Currently, there are 32 failures in the PPH testsuite.  Most are
assembly miscomparisons.  There are still missing bits in the images
that we are not pickling properly, but I think it makes more sense to
commit this so we can continue fixing the problems from here.

With these patches the branch is up to the point where simple
declarations in headers are handled properly.  For instance:

$ cat a.h
#ifndef _A_H
#define _A_H
float y;
int b;
struct X {
    float a;
    int b;
};
#endif

$ cat a.cc
#include "a.h"

struct X x;
main()
{
 y = 4.2;
 b = 42;
 x.a = y - b;
 return 0;
}

$ bin/g++ -fpph-hdr=a -o a.pph a.h
$ bin/g++ -fpph-hdr=a -o a a.cc
$ echo $?
0

But, it gets confused easily too.  So, now we need to debug it until
it works.

Tested on x86_64.
    
    	* pph.c (pph_read_file_contents): Re-instate call to
    	pph_add_names_to_namespace.
    	(pph_include_handler): Return false if the file has been
    	read from an image.


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

Patch

diff --git a/gcc/cp/pph.c b/gcc/cp/pph.c
index bf37915..6584e72 100644
--- a/gcc/cp/pph.c
+++ b/gcc/cp/pph.c
@@ -1978,20 +1978,13 @@  pph_read_file_contents (pph_stream *stream)
     report_validation_error (stream->name, bad_use->ident_str, cur_def,
                              bad_use->before_str, bad_use->after_str);
 
-  /* FIXME pph - Temporary workaround.  Instantiating PPH images
-     causes several failures in the PPH testsuite.  */
-  if (0)
-    {
-      /* Re-instantiate all the pre-processor symbols defined by STREAM.  */
-      cpp_lt_replay (parse_in, &idents_used);
+  /* Re-instantiate all the pre-processor symbols defined by STREAM.  */
+  cpp_lt_replay (parse_in, &idents_used);
 
-      /* Read global_namespace from STREAM and add all the names defined
-	 there to the current global_namespace.  */
-      file_ns = pph_input_tree (stream);
-      pph_add_names_to_namespace (global_namespace, file_ns);
-    }
-  else
-    pph_input_tree (stream);
+  /* Read global_namespace from STREAM and add all the names defined
+     there to the current global_namespace.  */
+  file_ns = pph_input_tree (stream);
+  pph_add_names_to_namespace (global_namespace, file_ns);
 }
 
 
@@ -2075,9 +2068,7 @@  pph_include_handler (cpp_reader *reader,
   if (pph_file != NULL && !cpp_included_before (reader, name, input_location))
     {
       pph_read_file (pph_file);
-      /* FIXME pph - Temporary workaround.  Instantiating PPH images
-	 causes several failures in the PPH testsuite.  */
-      read_text_file_p = /*false*/ true;
+      read_text_file_p = false;
     }
 
   return read_text_file_p;