Re: [pph] Ignore line number in diff checksum (issue4800046)

2011-07-22 Thread Lawrence Crowl
On 7/22/11, Gabriel Charette gch...@google.com wrote:
 The recent implementation of comparing expected diff checksum had a problem:
 different configs generate different assembly (and although the diff itself
 was still the same in both case, the actual differences were on different
 lines; thus the checksum of the diff was different).

 Added logic to only diff on the actual differences.

 Couldn't find a good TCL solution... had to revert to using 'exec grep', if
 anyone has a good solution, I'm willing to change it...

 I also made a small modification to break down a line that was accidently
 longer than 80 columns in a previous checkin.

 Tested with pph regression testing.

 Gab

 diff --git a/gcc/testsuite/ChangeLog.pph b/gcc/testsuite/ChangeLog.pph
 index 7ffeaf2..c90ab86 100644
 --- a/gcc/testsuite/ChangeLog.pph
 +++ b/gcc/testsuite/ChangeLog.pph
 @@ -1,3 +1,10 @@
 +2011-07-22  Gabriel Charette  gch...@google.com
 +
 + * g++.dg/pph/c1eabi1.cc: Change expected diff checksum.
 + * g++.dg/pph/p4eabi1.cc: Change expected diff checksum.
 + * lib/dg-pph.exp (dg-pph-pos): Ignore line numbers in diff checksum.
 + Split long output message, using sumMessage, to respect 80 cols limit.
 +
  2011-07-18  Gabriel Charette  gch...@google.com

   * lib/dg-pph.exp (dg-pph-pos): Output actualSum on unexpected diff.
 diff --git a/gcc/testsuite/g++.dg/pph/c1eabi1.cc
 b/gcc/testsuite/g++.dg/pph/c1eabi1.cc
 index 3321870..d26900f 100644
 --- a/gcc/testsuite/g++.dg/pph/c1eabi1.cc
 +++ b/gcc/testsuite/g++.dg/pph/c1eabi1.cc
 @@ -1,5 +1,5 @@
  // { dg-options -w -fpermissive }
 -// pph asm xdiff 36206
 +// pph asm xdiff 60950

  #include c0eabi1.h

 diff --git a/gcc/testsuite/g++.dg/pph/p4eabi1.cc
 b/gcc/testsuite/g++.dg/pph/p4eabi1.cc
 index 2f0715f..9b4739e 100644
 --- a/gcc/testsuite/g++.dg/pph/p4eabi1.cc
 +++ b/gcc/testsuite/g++.dg/pph/p4eabi1.cc
 @@ -1,5 +1,5 @@
  // { dg-options -w -fpermissive }
 -// pph asm xdiff 15662
 +// pph asm xdiff 06317

  #include p4eabi1.h

 diff --git a/gcc/testsuite/lib/dg-pph.exp b/gcc/testsuite/lib/dg-pph.exp
 index 013ccfe..677fcd7 100644
 --- a/gcc/testsuite/lib/dg-pph.exp
 +++ b/gcc/testsuite/lib/dg-pph.exp
 @@ -142,13 +142,18 @@ proc dg-pph-pos { subdir test options mapflag suffix }
 {
   file_on_host delete $bname.s+pph
  } elseif { $adiff == 1 } {
  verbose -log Diff obtained:\n$diff_result
 - set actualSum [lindex [split [exec sum  $diff_result]  ] 0]
 +
 + #only checksum on the actual differences, ignore line numbers
 + set checksumed_diff [exec grep -E ^(|).*  $diff_result]
 + verbose -log Diff checksumed:\n$checksumed_diff
 + set actualSum [lindex [split [exec sum  $checksumed_diff]  ] 0]
   if { $xdiff } {
   set expectedSum [lindex [split $xdiff_entry  \}] 3]
   if { $expectedSum == $actualSum } {
   xfail $nshort $options (assembly comparison)
   } else {
 - fail $nshort $options (assembly comparison, sums
 $expectedSum=$actualSum)
 + set sumMessage sums $expectedSum=$actualSum
 + fail $nshort $options (assembly comparison, $sumMessage)
   }
   } else {
   fail $nshort $options (assembly comparison, sum=$actualSum)

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


LGTM

-- 
Lawrence Crowl


Re: [pph] Save pending and specialized templates (issue4814054)

2011-07-28 Thread Lawrence Crowl
On 7/26/11, Gabriel Charette gch...@google.com wrote:
 +/* Load a tinst_level list.  */
 +
 +static struct tinst_level *
 +pph_in_tinst_level (pph_stream *stream)
 +{
 +  struct tinst_level *last = NULL;
 +  unsigned count = pph_in_uint (stream);
 +  /* FIXME pph: This leaves the list in reverse order.  Issue?  */
 +  for (; count  0; --count)
 +{
 +  struct tinst_level *cur = ggc_alloc_tinst_level ();
 +  cur-next = last;

 -  cur-next = last;
 + if(last)
 +   last-next = cur;

 +  cur-decl = pph_in_tree (stream);
 +  cur-locus = pph_in_location (stream);
 +  cur-errors = pph_in_uint (stream);
 +  cur-in_system_header_p = pph_in_uint (stream);
 +  last = cur;
 +}

 if (last)
   last-next = NULL;

 +  return last;
 +}
 +

 If you do the changes above, the list won't be in reverse order.

That code loses the pointer to the head of the list.  However, I
take your point and will avoid the comment by doing the forward list.

 Also if you do it as I did in pph_in_cxx_binding, using the cache
 markers, you do need to output count, you can simply use the cache
 mechanism which will know how to output/input NULL (I used that in
 pph_in/out_cxx_binding).

I think I like the count better in this instance.

 +/* Load and merge a spec_entry TABLE from STREAM.  */
 +
 +static void
 +pph_in_spec_entry_htab (pph_stream *stream, htab_t *table)
 +{
 +  spec_entry **slot = NULL;

 This variable is shadowed by

 +  unsigned count = pph_in_uint (stream);
 +  if (flag_pph_debug = 2)
 +fprintf (stderr, loading %d spec_entries\n, count );
 +  for (; count  0; --count)
 +{
 +  hashval_t hash;
 +  spec_entry **slot;

 ...this one??

 +  struct spec_entry *se = ggc_alloc_spec_entry ();
 +  se-tmpl = pph_in_tree (stream);
 +  se-args = pph_in_tree (stream);
 +  se-spec = pph_in_tree (stream);
 +  hash = hash_specialization (se);
 +  slot = htab_find_slot_with_hash (*table, se, hash, INSERT);
 +  *slot = se;
 +}
 +}

I must have removed that earlier.

 +/* Read and return a location_t from STREAM.  */
 +static inline location_t
 +pph_in_location (pph_stream *stream)
 +{
 +  location_t loc = lto_input_location (stream-ib, stream-data_in);
 +  if (flag_pph_tracer = 4)
 +pph_trace_location (stream, loc);
 +  return loc;
 +}
 +

 I was actually going to create pph_in/out_location. I
 will need to make them a streamer_hook so that all calls to
 lto_input/output_location actually are redirected to those when
 lto wants to in/out a source_location. Of course it would no
 longer call lto_input/output_location, rather it would output
 the source_location directly, and apply the calculated offset
 (discussed in Linemap and pph) on the way in. It's great that
 you implemented a tracer for this as it will be easy for me to
 debug my implementation of this, thanks!

 Is there anything you implementation depends on I should be careful
 about, from what I see, it doesn't look like it (as long as the
 source_location you get back from pph_in_location are correct).

No particular dependences.  The templates needed locations but
weren't in trees.  They aren't doing anything special with them
that I saw.

 +extern void lto_output_location (struct output_block *ob, location_t loc);

 lto_input/ouput will again no longer need to be extern when I make
 my patch for pph to handle those differently, I will make sure
 (remind me if I don't) to remove this change.

Okay.

-- 
Lawrence Crowl


[pph] Put tinst_level list in forward order (issue4823059)

2011-07-28 Thread Lawrence Crowl
Place the tinst_level list in forward order.

Tested on x64.


Index: gcc/cp/ChangeLog.pph

2011-07-28   Lawrence Crowl  cr...@google.com

* pt.c (pph_in_tinst_level): Put tinst_level list in forward order.


Index: gcc/cp/pt.c
===
--- gcc/cp/pt.c (revision 176905)
+++ gcc/cp/pt.c (working copy)
@@ -19738,20 +19738,24 @@ pph_dump_tinst_level (FILE *stream, stru
 static struct tinst_level *
 pph_in_tinst_level (pph_stream *stream)
 {
+  struct tinst_level *head = NULL;
   struct tinst_level *last = NULL;
   unsigned count = pph_in_uint (stream);
-  /* FIXME pph: This leaves the list in reverse order.  Issue?  */
   for (; count  0; --count)
 {
   struct tinst_level *cur = ggc_alloc_tinst_level ();
-  cur-next = last;
+  cur-next = NULL;
   cur-decl = pph_in_tree (stream);
   cur-locus = pph_in_location (stream);
   cur-errors = pph_in_uint (stream);
   cur-in_system_header_p = pph_in_uint (stream);
+  if (head == NULL)
+  head = cur;
+  else
+  last-next = cur;
   last = cur;
 }
-  return last;
+  return head;
 }
 
 

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


Re: [pph] Free buffers used during tree encoding/decoding

2011-07-28 Thread Lawrence Crowl
)
  pph_trace_bitpack (stream, bp);
lto_output_bitpack (bp);
 @@ -320,7 +321,7 @@ pph_out_bitpack (pph_stream *stream, str
  static inline unsigned int
  pph_in_uint (pph_stream *stream)
  {
 -  HOST_WIDE_INT unsigned n = lto_input_uleb128 (stream-ib);
 +  HOST_WIDE_INT unsigned n = lto_input_uleb128 (stream-encoder.r.ib);
gcc_assert (n == (unsigned) n);
if (flag_pph_tracer = 4)
  pph_trace_uint (stream, n);
 @@ -331,7 +332,7 @@ pph_in_uint (pph_stream *stream)
  static inline unsigned char
  pph_in_uchar (pph_stream *stream)
  {
 -  unsigned char n = lto_input_1_unsigned (stream-ib);
 +  unsigned char n = lto_input_1_unsigned (stream-encoder.r.ib);
if (flag_pph_tracer = 4)
  pph_trace_uint (stream, n);
return n;
 @@ -342,7 +343,7 @@ pph_in_uchar (pph_stream *stream)
  static inline void
  pph_in_bytes (pph_stream *stream, void *p, size_t n)
  {
 -  lto_input_data_block (stream-ib, p, n);
 +  lto_input_data_block (stream-encoder.r.ib, p, n);
if (flag_pph_tracer = 4)
  pph_trace_bytes (stream, p, n);
  }
 @@ -352,7 +353,8 @@ pph_in_bytes (pph_stream *stream, void *
  static inline const char *
  pph_in_string (pph_stream *stream)
  {
 -  const char *s = lto_input_string (stream-data_in, stream-ib);
 +  const char *s = lto_input_string (stream-encoder.r.data_in,
 + stream-encoder.r.ib);
if (flag_pph_tracer = 4)
  pph_trace_string (stream, s);
return s;
 @@ -362,7 +364,8 @@ pph_in_string (pph_stream *stream)
  static inline location_t
  pph_in_location (pph_stream *stream)
  {
 -  location_t loc = lto_input_location (stream-ib, stream-data_in);
 +  location_t loc = lto_input_location (stream-encoder.r.ib,
 +stream-encoder.r.data_in);
if (flag_pph_tracer = 4)
  pph_trace_location (stream, loc);
return loc;
 @@ -372,7 +375,7 @@ pph_in_location (pph_stream *stream)
  static inline tree
  pph_in_tree (pph_stream *stream)
  {
 -  tree t = lto_input_tree (stream-ib, stream-data_in);
 +  tree t = lto_input_tree (stream-encoder.r.ib,
 stream-encoder.r.data_in);
if (flag_pph_tracer = 4)
  pph_trace_tree (stream, t);
return t;
 @@ -387,7 +390,7 @@ pph_in_tree_array (pph_stream *stream, t
size_t i;
for (i = 0; i  c; ++i)
  {
 -  tree t = lto_input_tree (stream-ib, stream-data_in);
 +  tree t = lto_input_tree (stream-encoder.r.ib,
 stream-encoder.r.data_in);
if (flag_pph_tracer = 4)
  pph_trace_tree (stream, t, false); /* FIXME pph: always false? */
a[i] = t;
 @@ -405,7 +408,7 @@ pph_in_tree_VEC (pph_stream *stream, VEC
unsigned int c = pph_in_uint (stream);
for (i = 0; i  c; ++i)
  {
 -  tree t = lto_input_tree (stream-ib, stream-data_in);
 +  tree t = lto_input_tree (stream-encoder.r.ib,
 stream-encoder.r.data_in);
if (flag_pph_tracer = 4)
  pph_trace_tree (stream, t, false); /* FIXME pph: always false? */
VEC_safe_push (tree, gc, v, t);
 @@ -417,7 +420,7 @@ pph_in_tree_VEC (pph_stream *stream, VEC
  static inline tree
  pph_in_chain (pph_stream *stream)
  {
 -  tree t = lto_input_chain (stream-ib, stream-data_in);
 +  tree t = lto_input_chain (stream-encoder.r.ib,
 stream-encoder.r.data_in);
if (flag_pph_tracer = 2)
  pph_trace_chain (stream, t);
return t;
 @@ -427,7 +430,7 @@ pph_in_chain (pph_stream *stream)
  static inline struct bitpack_d
  pph_in_bitpack (pph_stream *stream)
  {
 -  struct bitpack_d bp = lto_input_bitpack (stream-ib);
 +  struct bitpack_d bp = lto_input_bitpack (stream-encoder.r.ib);
if (flag_pph_tracer = 4)
  pph_trace_bitpack (stream, bp);
return bp;



-- 
Lawrence Crowl


Re: [cxx-conversion] New Hash Table (issue6244048)

2012-05-28 Thread Lawrence Crowl
On 5/28/12, Jakub Jelinek ja...@redhat.com wrote:
 On Fri, May 25, 2012 at 02:42:39PM -0700, Lawrence Crowl wrote:
  On 5/24/12, Jakub Jelinek ja...@redhat.com wrote:
   On Thu, May 24, 2012 at 09:43:42AM -0700, Lawrence Crowl wrote:
Add a type-safe hash table, typed_htab.  Uses of this table
replace uses of libiberty's htab_t.  The benefits include
less boiler-plate code, full type safety, and improved
performance.
  
   You haven't looked at the most important problem of that
   approach - code bloat.
 
  Are you claiming that the size of the binary is more important
  than run-time performance, type safety, and source code size?

 Runtime performance goes in hand with the size of the binary,
 at least size of frequently used code.

Well, yes and no.  We need to worry about total size, memory resident
size, and cache resident size.  The patch clearly increases total
size, but I doubt that is much of a factor because most systems
lazily load pages from the image.  I don't think we have enough
information to assess the memory resident size, and I don't think it
matters because large compilations are large because the data space
is much larger than the code space.  The patch reduces the cache
resident size because the dynamic path of instructions is shorter.

 By converting just a couple of hash tables you can't really
 measure it, you'd need to convert a significant number of them,
 then you can see what effect it has on runtime performance.

Well, I have a performance improvement with eight of them, of which
one isn't exercised in the bootstrap.

 As said earlier, GCC has lots of hash tables, and many of them
 are used in performance critical code, by increasing the I-cache
 footprint of that performance criticial code there is risk of
 reducing performance.  The common C++ programming techniques often
 lead to significant code bloat which really shouldn't be ignored.

But the patch potentially reduces the I-cache footprint.  The new
implementation eliminates pointer tests, it turns indirect
function calls into direct function calls, it enables inlining
those functions, etc.  If the compiler is suboptimal in dealing
with that, we should fix the compiler.  (I think the compiler is
behaving reasonably.)

If changing a table does not deliver performance, we can choose
not to convert that table.  We do not need to convert all of them.

-- 
Lawrence Crowl


Re: [cxx-conversion] New Hash Table (issue6244048)

2012-05-29 Thread Lawrence Crowl
On 5/24/12, Gabriel Dos Reis g...@integrable-solutions.net wrote:
 On May 24, 2012 Lawrence Crowl cr...@google.com wrote:
  Add a type-safe hash table, typed_htab.  Uses of this table
  replace uses of libiberty's htab_t.  The benefits include less
  boiler-plate code, full type safety, and improved performance.

 Lawrence, is there any chance you could just call it hash_table?
 After the conversion, we will be living most of the time in a
 typed world, so the typed_ prefix will be redundant if not
 confusing :-)

The name hash_table is already taken in libcpp/include/symtab.h.
Do you have any other suggestions?

-- 
Lawrence Crowl


Re: [cxx-conversion] New Hash Table (issue6244048)

2012-05-29 Thread Lawrence Crowl
On 5/28/12, Eric Botcazou ebotca...@adacore.com wrote:
  My main concern is that the precise collector we have in place
  now requires substantial care to use.  It is supported by a tool
  that does not really understand C, let alone C++.  We avoid the
  problems when annotations are unnecessary.  We can do that in one
  of two ways, either by upgrading GTY to understand more of the
  language so that it infers the right things from regular code,
  or by changing the implementation strategy so that the garbage
  collector does not need type information.  I prefer the latter
  approach, as it makes our experience closer to our customers'
  experience.

 Are you really saying that, because our customers might have
 different ways of doing garbage collection in their code, we should
 drop our implementation that might well be superior to theirs?
 That would be a weak argument IMO, all the more so that, in the
 end, this might degrade the GCC experience for them.

No, I am suggesting that the current GTY approach requires more
manual care than is desireable.  There are several ways to fix that.

One way is to improve GTY so that less manual effort is needed.
However, any work we spend on GTY would not affect our customers
except, perhaps, in the data size of the compiler.

Another way is to use C++ containers that manage the storage for us,
and to back that up with a conservative collector.  If we do so, then
we are operating in the same environment as our customers.  We can
fix performance issues in the compiler by generating better code.
That better code helps our customers with their code.  The intent
in living as our customers do is to improve the overall experience
of our customers.

Having said that, let me be clear.  There is no proposal as yet to
change anything about garbage collection in gcc other than upgrade
it as we need.  (See Diego's vec patch.)  We are just having a
friendly philosophical discussion.  :-)

-- 
Lawrence Crowl


Re: [cxx-conversion] New Hash Table (issue6244048)

2012-05-29 Thread Lawrence Crowl
On 5/29/12, Richard Guenther richard.guent...@gmail.com wrote:
 On May 25, 2012 Mike Stump mikest...@comcast.net wrote:
  On May 25, 2012, at 10:50 AM, Lawrence Crowl wrote:
   Diego and I looked long and hard at this issue.  It all came
   down to a sequence of problems.  First, libstdc++ isn't rigged
   for GTY,
 
  If portability to other C++ compilers wasn't a concern, we could
  extend out g++ to make supporting GTY better, so that we can
  simplify and refine the GTY stuff.  I fear we need some light
  weight reflection, might make a nice language feature for a
  future C++ standard, if done well.

 Seconded.  It points the finger of my #1 concern with the C++
 conversion - our GC.  We need a GC scheme that allows us to use
 standard library containers, and the scheme that was outlined
 earlier would work.

Using the standard library containers is not a prerequisite to
using C++, nor is it the source of primary benefit.  You can build
the compiler completely independently of the standard library.
There are even good reasons to do so.

More importantly, the standard library containers have different
operations, different semantics, and different performance
implications from the existing containers.  Replacing any existing
container uses with standard library uses is actually many tasks,
which should be done incrementally after the infrastructure is
in place.  More importantly, some of that replacement would not be
trivial, and the specialists in particular data structures might
be better suited to it.

 Are the TR1 hash table implementations using any non-C++98/03
 features?  If not then I would suggest to use our TR1 hash tables.

Almost by definition they are not using non-C++03 features.  I do
not think we should try to make that change in one step, but make
it an eventual goal.

-- 
Lawrence Crowl


Re: [cxx-conversion] New Hash Table (issue6244048)

2012-05-30 Thread Lawrence Crowl
On 5/29/12, Michael Matz m...@suse.de wrote:
 On Sun, 27 May 2012, Gabriel Dos Reis wrote:
   people actually working on it and used to that style.
   We don't want to have a mixture of several different styles in
   the compiler.  I (and I expect many others) don't want anyone
   working around the latter by going over the whole source base
   and reindent everything.  Hence inventing a new coding standard
   for GCC-in-C++ (by reusing existing ones or doing something
   new) that isn't mostly the same as GCC-in-C isn't going to fly.
 
  if this coding standard is going to be adopted as a GNU coding
  convention, then you have to be flexible and allow yourself
  to see beyond the past written in C. You have to ask yourself:
  how do I want the codebase to look like in 10, 15, 20, 25 years.

 ...  And thanks for making clear what the whole GCC-in-c++ stunt
 is about. ( ...  ) Namely useless noise and source change activity
 for the sake of it.

The conversion to C++ is not a stunt.  It is an attempt to reduce
the cost of developing GCC and to ease the path for more developers
to contribute.  I believe progress on those goals is necessary to the
long-term health of GCC.  Do you wish to see progress to those goals?
If so, what you have us do differently?

We need a coding standard for C++ if we are to use C++.  A whole
new coding standard would be disruptive, and so the proposals on
the table are incremental changes to the existing C conventions.
There have been discussions about potential future changes, more
in line with industry practice, but they are not present proposals.

That activity is part of the construction work.  Any construction
work is always going to have a few pardon the inconvenience signs.
If there is anything we can do to reduce that, but still make
progress, please let us know.

-- 
Lawrence Crowl


[cxx-conversion] Change check functions from templates to overloads. (issue6256075)

2012-05-30 Thread Lawrence Crowl
Change the check functions from templates to overloads.

Add set unwindonsignal on to gdbinit.in to gracefully handle aborts
in functions used from gdb.

Tested on x86-64.


Index: gcc/ChangeLog.cxx-conversion

2012-05-30   Lawrence Crowl  cr...@google.com

* tree.h (tree_check): Change from template to const overload.
(tree_not_check): Likewise.
(tree_check2): Likewise.
(tree_not_check2): Likewise.
(tree_check3): Likewise.
(tree_not_check3): Likewise.
(tree_check4): Likewise.
(tree_not_check4): Likewise.
(tree_check5): Likewise.
(tree_not_check5): Likewise.
(contains_struct_check): Likewise.
(tree_class_check): Likewise.
(tree_range_check): Likewise.
(omp_clause_subcode_check): Likewise.
(omp_clause_range_check): Likewise.
(expr_check): Likewise.
(non_type_check): Likewise.
(tree_vec_elt_check): Likewise.
(omp_clause_elt_check): Likewise.
(tree_operand_check): Likewise.
(tree_operand_check_code): Likewise.
(tree_operand_length): Merge duplicate copy.
* gdbinit.in (set unwindonsignal on): New.


Index: gcc/tree.h
===
--- gcc/tree.h  (revision 187989)
+++ gcc/tree.h  (working copy)
@@ -3598,18 +3598,17 @@ union GTY ((ptr_alias (union lang_tree_n
 };
 
 #if defined ENABLE_TREE_CHECKING  (GCC_VERSION = 2007)
-template typename Tree
-inline Tree
-tree_check (Tree __t, const char *__f, int __l, const char *__g, tree_code __c)
+
+inline tree
+tree_check (tree __t, const char *__f, int __l, const char *__g, tree_code __c)
 {
   if (TREE_CODE (__t) != __c)
 tree_check_failed (__t, __f, __l, __g, __c, 0);
   return __t;
 }
 
-template typename Tree
-inline Tree
-tree_not_check (Tree __t, const char *__f, int __l, const char *__g,
+inline tree
+tree_not_check (tree __t, const char *__f, int __l, const char *__g,
 enum tree_code __c)
 {
   if (TREE_CODE (__t) == __c)
@@ -3617,9 +3616,8 @@ tree_not_check (Tree __t, const char *__
   return __t;
 }
 
-template typename Tree
-inline Tree
-tree_check2 (Tree __t, const char *__f, int __l, const char *__g,
+inline tree
+tree_check2 (tree __t, const char *__f, int __l, const char *__g,
  enum tree_code __c1, enum tree_code __c2)
 {
   if (TREE_CODE (__t) != __c1
@@ -3628,9 +3626,8 @@ tree_check2 (Tree __t, const char *__f, 
   return __t;
 }
 
-template typename Tree
-inline Tree
-tree_not_check2 (Tree __t, const char *__f, int __l, const char *__g,
+inline tree
+tree_not_check2 (tree __t, const char *__f, int __l, const char *__g,
  enum tree_code __c1, enum tree_code __c2)
 {
   if (TREE_CODE (__t) == __c1
@@ -3639,9 +3636,8 @@ tree_not_check2 (Tree __t, const char *_
   return __t;
 }
 
-template typename Tree
-inline Tree
-tree_check3 (Tree __t, const char *__f, int __l, const char *__g,
+inline tree
+tree_check3 (tree __t, const char *__f, int __l, const char *__g,
  enum tree_code __c1, enum tree_code __c2, enum tree_code __c3)
 {
   if (TREE_CODE (__t) != __c1
@@ -3651,9 +3647,8 @@ tree_check3 (Tree __t, const char *__f, 
   return __t;
 }
 
-template typename Tree
-inline Tree
-tree_not_check3 (Tree __t, const char *__f, int __l, const char *__g,
+inline tree
+tree_not_check3 (tree __t, const char *__f, int __l, const char *__g,
  enum tree_code __c1, enum tree_code __c2, enum tree_code __c3)
 {
   if (TREE_CODE (__t) == __c1
@@ -3663,9 +3658,8 @@ tree_not_check3 (Tree __t, const char *_
   return __t;
 }
 
-template typename Tree
-inline Tree
-tree_check4 (Tree __t, const char *__f, int __l, const char *__g,
+inline tree
+tree_check4 (tree __t, const char *__f, int __l, const char *__g,
  enum tree_code __c1, enum tree_code __c2, enum tree_code __c3,
  enum tree_code __c4)
 {
@@ -3677,9 +3671,8 @@ tree_check4 (Tree __t, const char *__f, 
   return __t;
 }
 
-template typename Tree
-inline Tree
-tree_not_check4 (Tree __t, const char *__f, int __l, const char *__g,
+inline tree
+tree_not_check4 (tree __t, const char *__f, int __l, const char *__g,
  enum tree_code __c1, enum tree_code __c2, enum tree_code __c3,
  enum tree_code __c4)
 {
@@ -3691,9 +3684,8 @@ tree_not_check4 (Tree __t, const char *_
   return __t;
 }
 
-template typename Tree
-inline Tree
-tree_check5 (Tree __t, const char *__f, int __l, const char *__g,
+inline tree
+tree_check5 (tree __t, const char *__f, int __l, const char *__g,
  enum tree_code __c1, enum tree_code __c2, enum tree_code __c3,
  enum tree_code __c4, enum tree_code __c5)
 {
@@ -3706,9 +3698,8 @@ tree_check5 (Tree __t, const char *__f, 
   return __t;
 }
 
-template typename Tree
-inline Tree
-tree_not_check5 (Tree __t, const char *__f, int __l, const char *__g,
+inline tree
+tree_not_check5 (tree __t, const char *__f, int __l, const

Re: [wwwdocs] Make codingconventions.html pass W3 validator.

2012-06-05 Thread Lawrence Crowl
On 6/5/12, Gerald Pfeifer ger...@pfeifer.com wrote:
 On Mon, 4 Jun 2012, Lawrence Crowl wrote:
  The following source change enables coddingconventions.html to
  pass the HTML validator at validator.w3.org.

 the web pages will be preprocessed before the are put on the server
 (this transparently happens upon checkin) and as part of that

  ?xml version=1.0 encoding=ISO-8859-1?
  !DOCTYPE html
PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;

 are going to be prepended to any page, plus the standard CSS
 reference and footer are added, for example.

Okay, but now I have questions!

Where do these prepended pages come from?  How do I test the page
as it will appear?  I guess maybe I'm asking for the makefile that
produces what one would see.  I want to validate that.

BTW, part of the problem is that the pages are complete enough as
they are to be considered complete.  I.e. they are not obviously
fragments.  Would it be better to make them clearly fragments?

Doesn't the prepending prevent incremental migration to new
standards?

 Since you ran into this, I would like to document this better.
 Would http://gcc.gnu.org/projects/web.html be a good place,
 or do you have a different suggestion?

My entry point was http://gcc.gnu.org/cvs.html, so at a minimum it
need to be cross linked with http://gcc.gnu.org/projects/web.html.

-- 
Lawrence Crowl


Make timevar phases mutually exclusive. (issue6302064)

2012-06-11 Thread Lawrence Crowl
The intent of the phases was to have a high-level but mutually exclusive
accounting of compile time.  We want to track compile time in a way that
tells us which conceptual phases are taking the most time.  That intent
is not currently satisfied.  This patch restores that intent.

Add code to verify that the sum of the phase times is less than the total
time, to detect when phases are overlapped.  A slight amount of leeway
is required due to time jitters.  This verification is done as the last
step in printing timevars so that any timevar information is not lost.

Rename the phases to be clearer about what they measure, so that they are
less likely to be modified to be overlapping.  The primary example is
to change TV_PHASE_GENERATE to TV_PHASE_LATE_ASM, meaning late work on
the assembly.  This name change avoids confusion n moving the timevar
start call after the call to lang_hooks.decls.final_write_globals,
which prevents overlapping phases.

Each implementation of lang_hooks.decls.final_write_globals, is
responsible for starting and stopping its own phases.  Each implementation
currently has a first phase of TV_PHASE_DEFERRED for front-end work
deferred until after parsing is complete.  The second phase has been
renamed from TV_PHASE_CGRAPH to TV_PHASE_OPT_GEN, to better reflect its
use as the main optimization and generation phase.  This phase accounts
for 70%-80% of compilation time.  The third phase is TV_PHASE_DBGINFO,
except in cp/decl2.c, where it is TV_PHASE_CHECK_DBGINFO because
cc1plus mixes checking in with debug info generation.  In langhooks.c,
write_global_declarations was using TV_PHASE_CHECK_DBGINFO, but it was
doing no checking.  So, it now uses TV_PHASE_DBGINFO.

The changes to LTO are significant.  First, initialization now uses
TV_PHASE_SETUP.  Reading files now uses TV_PHASE_STREAM_IN.  Writing files
now uses TV_PHASE_STREAM_OUT.  The remaining phase is TV_PHASE_OPT_GEN
(formerly TV_PHASE_CGRAPH).

Tested on x86_64.

Okay for trunk?


Index: gcc/ChangeLog

2012-06-11  Lawrence Crowl  cr...@google.com

* timevar.def (TV_PHASE_GENERATE): Rename to TV_PHASE_LATE_ASM.
(TV_PHASE_CGRAPH): Rename to TV_PHASE_OPT_GEN.
(TV_PHASE_STREAM_IN): New.
(TV_PHASE_STREAM_OUT): New.
* timevar.c (validate_phases): New.
(timevar_print): Call validate_phases.
* c-decl.c (c_write_global_declarations): Rename use of TV_PHASE_CGRAPH
to TV_PHASE_OPT_GEN.
* langhooks.c (write_global_declarations): Rename use of
TV_PHASE_CGRAPH to TV_PHASE_OPT_GEN.  Use TV_PHASE_DBGINFO instead of
TV_PHASE_CHECK_DBGINFO.
* toplev.c (compile_file): Rename use of TV_PHASE_GENERATE to
TV_PHASE_LATE_ASM.  Move start of TV_PHASE_LATE_ASM to after call to
lang_hooks.decls.final_write_globals.

Index: gcc/cp/ChangeLog

2012-06-11  Lawrence Crowl  cr...@google.com

* decl2.c (cp_write_global_declarations): Rename use of TV_PHASE_CGRAPH
to TV_PHASE_OPT_GEN.

Index: gcc/lto/ChangeLog

2012-06-11  Lawrence Crowl  cr...@google.com

* lto.c (do_whole_program_analysis):  Rename use of TV_PHASE_CGRAPH to
TV_PHASE_OPT_GEN.  Use new timevar TV_PHASE_STREAM_OUT around the call
to lto_wpa_write_files.
(lto_main):  Rename use of TV_PHASE_CGRAPH to TV_PHASE_OPT_GEN.  Move
start of TV_PHASE_OPT_GEN to include call to materialize_cgraph.  Use
TV_PHASE_SETUP for the call to lto_init.  Use new timevar
TV_PHASE_STREAM_IN around the call to read_cgraph_and_symbols.

Index: gcc/toplev.c
===
--- gcc/toplev.c(revision 188335)
+++ gcc/toplev.c(working copy)
@@ -558,18 +558,15 @@ compile_file (void)
   if (flag_syntax_only || flag_wpa)
 return;
 
-  timevar_start (TV_PHASE_GENERATE);
-
   ggc_protect_identifiers = false;
 
   /* This must also call finalize_compilation_unit.  */
   lang_hooks.decls.final_write_globals ();
 
   if (seen_error ())
-{
-  timevar_stop (TV_PHASE_GENERATE);
-  return;
-}
+return;
+
+  timevar_start (TV_PHASE_LATE_ASM);
 
   /* Compilation unit is finalized.  When producing non-fat LTO object, we are
  basically finished.  */
@@ -670,7 +667,7 @@ compile_file (void)
  assembly file after this point.  */
   targetm.asm_out.file_end ();
 
-  timevar_stop (TV_PHASE_GENERATE);
+  timevar_stop (TV_PHASE_LATE_ASM);
 }
 
 /* Print version information to FILE.
Index: gcc/cp/decl2.c
===
--- gcc/cp/decl2.c  (revision 188335)
+++ gcc/cp/decl2.c  (working copy)
@@ -4017,11 +4017,11 @@ cp_write_global_declarations (void)
   candidates = collect_candidates_for_java_method_aliases ();
 
   timevar_stop (TV_PHASE_DEFERRED);
-  timevar_start (TV_PHASE_CGRAPH);
+  timevar_start (TV_PHASE_OPT_GEN);
 
   finalize_compilation_unit ();
 
-  timevar_stop (TV_PHASE_CGRAPH);
+  timevar_stop

Re: [wwwdocs] Update coding conventions for C++

2012-06-18 Thread Lawrence Crowl
=defaultDefault Arguments/a/h4
+
+p
+Expensive default arguments can cause hard-to-identify performance
problems.
+/p
+
+p
+Default arguments cause confusion
+when attempting to take the address of a function.
+They clause client code taking the address of a function
+to break when a default argument is replaced by a specialized overload.
+So, default arguments should generally not be used
+in customer-facing interfaces.
+Consider function overloading instead.
+/p
+
+
+h4a name=namespaceNamespaces/a/h4
+
+p
+Putting codeusing/code directives
+or namespace-scope codeusing/code declarations
+into header files can change client code in surprising ways.
+/p
+
+p
+Using them within an implementation file can help conciseness.
+/p
+
+
+h4a name=RTTIRTTI and codedynamic_cast/code/a/h4
+
+p
+Disabling RTTI will save space in the compiler.
+/p
+
+p
+Checking the type of a class at runtime usually indicates a design
problem.
+If you need classes to behave differently at runtime, use a virtual
method.
+If you need to know the type of a class for some other reason,
+use an enum or a virtual member function
+that coverts a pointer to the more derived class.
+For example,
+/p
+
+blockquoteprecode
+common_type *p = ;
+if (specific_type *q = p-gt;to_specific ()) {
+  // We have and can use a specific_type pointed to by q.
+}
+/code/pre/blockquote
+
+h4a name=castsOther Casts/a/h4
+
+p
+C++-style casts are very explicit in the intended transformation.
+Making intent clear avoids bugs and helps with other programmers.
+/p
+
+
+h4a name=exceptionsExceptions/a/h4
+
+p
+The current compiler code is not exception safe.
+/p
+
+p
+Disabling exceptions will permit
+the compiler itself to be slightly more optimized.
+/p
+
+p
+Aborting the compiler is a reasonable response to unexpected problems.
+/p
+
+p
+We would like the compiler to be exception safe,
+to permit reconsideration of the exception convention.
+This change would require a significant change in style,
+adopting resource acquisition is initialization (RAII).
+We would be using
+codeshared_ptr/code (from TR1's codelt;memorygt;/code)
+or codeunique_ptr/code (from C++11).
+/p
+
+h4a name=stdlibThe Standard Library/a/h4
+
+p
+At present, C++ provides no great advantage for i18n.
+GCC does type checking for codeprintf/code arguments,
+so the type insecurity of codeprintf/code is moot,
+but the clarity in layout persists.
+For quick debugging output, lt;iostreamgt; requires less work.
+/p
+
+h3Formatting Conventions/h3
+
+h4a href=namesNames/a/h4
+
+p
+Naming data members with a trailing underscore
+highlights the extra overhead of access to fields over local variables.
+Think of the trailing underscore
+like you would Pascal's postfix code^/code dereference operator.
+/p
+
+p
+When using the above convention,
+the constructor parameter names
+and getter member function names
+can use the more concise non-underscore form.
+/p
+
+/body
+/html

-- 
Lawrence Crowl


Re: Make timevar phases mutually exclusive. (issue6302064)

2012-06-18 Thread Lawrence Crowl
On 6/13/12, Diego Novillo dnovi...@google.com wrote:
 On 12-06-13 08:46 , Diego Novillo wrote:
  The LTO bits are fine. I would prefer if an FE maintainer takes
  a second look over the other bits. Jason, Joseph?

 Incidentally, could you please test it with an LTO-enabled bootstrap?

 $ ../src/configure --with-build-config=bootstrap-lto
 --enable-languages=c++,fortran
 $ make profiledbootstrap

 If you cut and paste one of the -flto compiles you see during
 bootstrap, you can add -ftime-report to it to make sure that the
 LTO timers are properly setup.

I had to make a slight adjustment here.  LTO runs as a front-end,
and the parse timers are automatically started for the front ends.
But LTO is not parsing.  Rather than change every front end to
handle those timers, I turned the timers off and then back on again
within LTO.

Committed.

-- 
Lawrence Crowl


Re: [wwwdocs] Update coding conventions for C++

2012-06-25 Thread Lawrence Crowl
On 6/25/12, Joseph S. Myers jos...@codesourcery.com wrote:
 On Mon, 25 Jun 2012, Diego Novillo wrote:
  [ Added doc maintainers in CC ]
 
  While I'm not particularly interested in the details of the
  coding conventions, I am interested in getting them in getting
  them installed before we merge cxx-conversion to trunk.
 
  Joseph, Gerald, do we have a process for accepting changes to
  coding conventions?

 I suggest sending smaller (so easier to review) patches that are
 concrete and avoid speculation about possible future changes.

The speculative parts come from the wiki.  Unless I had specific
reason to remove them, I left them.

   +nbsp;nbsp;nbsp;nbsp;a href=#C_OptionsCompiler Options/abr /

 I don't like this repeated nbsp; presentational markup; use
 appropriate logical markup instead.

Done.

   +p
   +We will periodically pick a stable version of GCC,
   +and require that that version of GCC be able to build
   +all versions of GCC up to and including the next stable version.
   +E.g., we may decide that all newer versions of GCC
   +should be buildable with GCC 4.3.5.

 The current version required is more important than speculation
 about future changes.  E.g., say that code must build with GCC
 4.1 and later.

After some off-line discussion with Diego, I have removed some of
text in this area.  It now focuses on being portable, rather than
on arbitrary version numbers.

   +h4a name=AssertionsAssertions/a/h4
   +
   +pCode should use codegcc_assert(EXPR)/code to check invariants.
   +Use codegcc_unreachable()/code to mark places that should never be
   +reachable (such as an unreachable codedefault/code case of a
   +switch).  Do not use codegcc_assert(0)/code for such purposes, as
   +codegcc_unreachable/code gives the compiler more information.  The
   +assertions are enabled unless explicitly configured off with
   +code--enable-checking=none/code.  Do not use codeabort/code.
   +User input should never be validated by either codegcc_assert/code
   +or codegcc_unreachable/code.  If the checks are expensive or the
   +compiler can reasonably carry on after the error, they may be
   +conditioned on code--enable-checking/code./p

 I don't think any of this is new - perhaps you could separate
 rearrangement from the actual changes and C++ conventions?

The section titles are new, but the text itself is not.  There did
not seem to be a reasonable way to separate the rearrangment from
the new context in which it was placed.

   +h4a name=CallsFunction Calls/a/h4
   +
   +p
   +All current GCC code uses a space between the function name
   +and the left parenthesis in a function call.
   +Essentially all C++ code omits that space,
   +which is more consistent with C++ syntax.
   +For the present we will retain the space.
   +It is possible that in the future we will switch the code with a flag 
   day.
   +/p

 Avoid speculation.  Avoid duplicating the GNU Coding Standards.
 Formatting can be assumed to follow the GNU Coding Standards
 except where they are meaningless for C++ or something explicitly
 overrides them.

That paragraph came from the wiki.  I have removed it.

   +p
   +Think carefully about the size and performance impact
   +of virtual functions and virtual bases
   +before using them.
   +/p

 Explain in more detail what the size and performance impact is
 for people not familiar with the details of how C++ features
 are implemented.

I have added a bit more in the rationale, reached through the link
at the end of that section.

   +p
   +Indent protection labels by one space.
   +/p
   +
   +p
   +Indent class members by two spaces.

 Do all the listed indentation rules correspond to what a TAB
 will do by default when editing C++ code in GNU Emacs?  If not,
 we have conflicting notions of GNU C++ indentation conventions.

I have no idea.  I don't use emacs.  The two-space rule for members
comes from the wiki.  The one-space rule for protection labels is
common practice.  If folks want something else, changes are fine
with me.

I have also made a few other edits requested offline by Benjamin
Kosnik.

-- 
Lawrence Crowl


Re: [wwwdocs] Update coding conventions for C++

2012-06-25 Thread Lawrence Crowl
On 6/25/12, Lawrence Crowl cr...@google.com wrote:
 On 6/25/12, Joseph S. Myers jos...@codesourcery.com wrote:
 On Mon, 25 Jun 2012, Diego Novillo wrote:
  [ Added doc maintainers in CC ]
 
  While I'm not particularly interested in the details of the
  coding conventions, I am interested in getting them in getting
  them installed before we merge cxx-conversion to trunk.
 
  Joseph, Gerald, do we have a process for accepting changes to
  coding conventions?

 I suggest sending smaller (so easier to review) patches that are
 concrete and avoid speculation about possible future changes.

 The speculative parts come from the wiki.  Unless I had specific
 reason to remove them, I left them.

   +nbsp;nbsp;nbsp;nbsp;a href=#C_OptionsCompiler Options/abr
   /

 I don't like this repeated nbsp; presentational markup; use
 appropriate logical markup instead.

 Done.

   +p
   +We will periodically pick a stable version of GCC,
   +and require that that version of GCC be able to build
   +all versions of GCC up to and including the next stable version.
   +E.g., we may decide that all newer versions of GCC
   +should be buildable with GCC 4.3.5.

 The current version required is more important than speculation
 about future changes.  E.g., say that code must build with GCC
 4.1 and later.

 After some off-line discussion with Diego, I have removed some of
 text in this area.  It now focuses on being portable, rather than
 on arbitrary version numbers.

   +h4a name=AssertionsAssertions/a/h4
   +
   +pCode should use codegcc_assert(EXPR)/code to check
   invariants.
   +Use codegcc_unreachable()/code to mark places that should never
   be
   +reachable (such as an unreachable codedefault/code case of a
   +switch).  Do not use codegcc_assert(0)/code for such purposes,
   as
   +codegcc_unreachable/code gives the compiler more information.
   The
   +assertions are enabled unless explicitly configured off with
   +code--enable-checking=none/code.  Do not use codeabort/code.
   +User input should never be validated by either
   codegcc_assert/code
   +or codegcc_unreachable/code.  If the checks are expensive or the
   +compiler can reasonably carry on after the error, they may be
   +conditioned on code--enable-checking/code./p

 I don't think any of this is new - perhaps you could separate
 rearrangement from the actual changes and C++ conventions?

 The section titles are new, but the text itself is not.  There did
 not seem to be a reasonable way to separate the rearrangment from
 the new context in which it was placed.

   +h4a name=CallsFunction Calls/a/h4
   +
   +p
   +All current GCC code uses a space between the function name
   +and the left parenthesis in a function call.
   +Essentially all C++ code omits that space,
   +which is more consistent with C++ syntax.
   +For the present we will retain the space.
   +It is possible that in the future we will switch the code with a flag
   day.
   +/p

 Avoid speculation.  Avoid duplicating the GNU Coding Standards.
 Formatting can be assumed to follow the GNU Coding Standards
 except where they are meaningless for C++ or something explicitly
 overrides them.

 That paragraph came from the wiki.  I have removed it.

   +p
   +Think carefully about the size and performance impact
   +of virtual functions and virtual bases
   +before using them.
   +/p

 Explain in more detail what the size and performance impact is
 for people not familiar with the details of how C++ features
 are implemented.

 I have added a bit more in the rationale, reached through the link
 at the end of that section.

   +p
   +Indent protection labels by one space.
   +/p
   +
   +p
   +Indent class members by two spaces.

 Do all the listed indentation rules correspond to what a TAB
 will do by default when editing C++ code in GNU Emacs?  If not,
 we have conflicting notions of GNU C++ indentation conventions.

 I have no idea.  I don't use emacs.  The two-space rule for members
 comes from the wiki.  The one-space rule for protection labels is
 common practice.  If folks want something else, changes are fine
 with me.

 I have also made a few other edits requested offline by Benjamin
 Kosnik.

 --
 Lawrence Crowl

Sorry, I forgot to add the patch.  Note that I have removed some
html headers that cause gcc mail grief.


Index: htdocs/codingconventions.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/codingconventions.html,v
retrieving revision 1.66
diff -u -u -r1.66 codingconventions.html
--- htdocs/codingconventions.html   19 Feb 2012 00:45:34 -  1.66
+++ htdocs/codingconventions.html   25 Jun 2012 22:19:46 -
@@ -15,8 +19,71 @@
 code to follow these conventions, it is best to send changes to follow
 the conventions separately from any other changes to the code./p

+ul
+lia href=#DocumentationDocumentation/a/li
+lia href=#ChangeLogsChangeLogs/a/li
+lia href=#PortabilityPortability/a/li
+lia href

Re: [wwwdocs] Update coding conventions for C++

2012-06-25 Thread Lawrence Crowl
On 6/25/12, Benjamin Kosnik b...@redhat.com wrote:
 The only remaining issue for me is the fuzzyness/handwaving
 around inlining.  I think the only way to really enforce what
 can be inlined is not to have people use their best judgement,
 or what they think is a small function, or what they intend
 for the compiler to inline, but to have -Winline mandatory.
 And thus flag things that are written as inlined, but cannot then
 be inlined by the compiler.

 This area seems historically fraught, in terms of expectations.
 I'm not trying to poke at the hornets nest here.

I see two problems with trying to use -Winline.

First, the implication is that if the compiler does not complain with
-Winline, then the inlining is fine.  The compiler only warns when
it cannot inline, not when that inlining is counter productive.  That
is, we want inlining when we win in either space or time, an -Winline
does not tell us that.  So, in a sense, the warning is too weak.

Second, together -Winline and -Werror lead to a tempermental build.
The documentation for -Winline says:

  Warn if a function can not be inlined and it was declared as
  inline. Even with this option, the compiler will not warn about
  failures to inline functions declared in system headers.

  The compiler uses a variety of heuristics to determine whether
  or not to inline a function. For example, the compiler takes
  into account the size of the function being inlined and the
  amount of inlining that has already been done in the current
  function. Therefore, seemingly insignificant changes in the
  source program can cause the warnings produced by -Winline to
  appear or disappear.

IIUC, a small change to a function in a header file could cause
a hundred other functions to suddenly start emitting the warning,
causing the edit of files that would not normally be considered part
of the patch.  In the worst case, these functions would shift from
header to source file, causing even more source churn.  Even more
disconcerting, the warning might not show up until later in the boot.

If everyone keeps their inlines small and clean, maybe the second
problem will not be so much of a problem.  My concern is that writing
it into the coding conventions shifts the practical consequences
to places that are hard to anticipate and hard to deal with.
For instance, suppose I inline foo() to meet performance goals,
but in doing so bar() becomes to large to inline.  Was bar() too
performance critical to make non-inline?  If so, how do I best
refactor bar()?  Will I need another maintainer to review the code
because of that refactoring?

With that concern stated, I will write into the conventions whatever
concensus arises.

Of course, I have no objection to an occasional inline cleanup.
That is, build with -Werror and adjusting inlines that have,
through the course of time, become larger than is useful.

-- 
Lawrence Crowl


Re: [wwwdocs] Update coding conventions for C++

2012-06-26 Thread Lawrence Crowl
On 6/25/12, Alexandre Oliva aol...@redhat.com wrote:
 On Jun 25, 2012, Lawrence Crowl cr...@google.com wrote:
 +These conventions will change over time,
 +but changing them requires that a convincing rationale.

 s/that//

 +Complex heirarchies are to be avoided.

 s/heir/hier/

Both fixed.

-- 
Lawrence Crowl


Re: [wwwdocs] Update coding conventions for C++

2012-06-26 Thread Lawrence Crowl
On 6/26/12, Martin Jambor mjam...@suse.cz wrote:
 On Mon, Jun 25, 2012 at 03:26:01PM -0700, Lawrence Crowl wrote:
   I have no idea.  I don't use emacs.  The two-space rule for
   members comes from the wiki.  The one-space rule for protection
   labels is common practice.  If folks want something else,
   changes are fine with me.

 I'll also need an emacs C++ indentation style that conforms to
 this in order to really be able to produce complying code myself.
 So if anybody else will be working on that, I'm interested (to
 use it and perhaps help crafting it) and I guess a number of
 other people on this list are too...

Alternatively, one could change the conventions to match an emacs
style.  Either is fine we me, as long as the style is reasonable.

  -h2Miscellaneous Conventions/h2
  -
  -pCode should use codegcc_assert(EXPR)/code to check invariants.
  -Use codegcc_unreachable()/code to mark places that should never be
  -reachable (such as an unreachable codedefault/code case of a
  -switch).  Do not use codegcc_assert(0)/code for such purposes, as
  -codegcc_unreachable/code gives the compiler more information.  The
  -assertions are enabled unless explicitly configured off with
  -code--enable-checking=none/code.  Do not use codeabort/code.
  -User input should never be validated by either codegcc_assert/code
  -or codegcc_unreachable/code.  If the checks are expensive or the
  -compiler can reasonably carry on after the error, they may be
  -conditioned on code--enable-checking/code./p

 It seems we should mention gcc_checking_assert here then.

Jason had a suggestion, and I used that.

  +p
  +Single inheritance is permitted.
  +Use public inheritance to describe interface inheritance,
  +i.e. 'is-a' relationships.
  +Use private and protected inheritance
  +to describe implementation inheritance.
  +Implementation inheritance can be expediant,

 s/expediant/expedient/

Fixed.

  +but think twice before using it in code
  +intended to last a long time.

 I think all committed code should be expected to have long-lasting
 quality.  I would not encourage people to think otherwise and would
 drop the long time reference here.  If anybody ever commits
 something ugly to bridge a short time period, it should only be done
 under the maintainers grant exceptions rule anyway.

  +/p +p
  +For long-term code, at least for now,
  +we will continue to use codeprintf/code style I/O
  +rather than codelt;iostreamgt;/code style I/O.
  +For quick debugging code,
  +codelt;iostreamgt;/code is permitted.
  +/p

 Similarly here, no quick and dirty debugging output should ever be
 committed, we should not

  +h4a name=stdlibThe Standard Library/a/h4
  +
  +p
  +At present, C++ provides no great advantage for i18n.
  +GCC does type checking for codeprintf/code arguments,
  +so the type insecurity of codeprintf/code is moot,
  +but the clarity in layout persists.
  +For quick debugging output, lt;iostreamgt; requires less work.
  +/p

 The same applies here.

The value of these changes depends on when the rules are enforced.
If they are enforced only on trunk, then the changes seem fine
to me.  However, if they are enforced on branches, then they could
unnecessarily slow down development.

Comments?

-- 
Lawrence Crowl


Re: [wwwdocs] Update coding conventions for C++

2012-06-26 Thread Lawrence Crowl
On 6/26/12, Jason Merrill ja...@redhat.com wrote:
 On 06/25/2012 06:26 PM, Lawrence Crowl wrote:
  +orcodegcc_unreachable/code.  If the checks are expensive or the
  +compiler can reasonably carry on after the error, they may be
  +conditioned oncode--enable-checking/code./p

 by using codegcc_checking_assert/code

I inserted that suggestion, but note that I did not create that text,
only moved it.

 [Rationale]
  +FIXME: Discussion of deleting inappropraite special members.

 Is this FIXME still needed?  The text following it seems to cover the
 issue well enough.

No longer needed.

  +However, by default, RTTI is not permitted
  +and the compiler must build cleanly with code-fno-rtti/code.

 This seems like an unnecessary restriction to me.

  +Disabling RTTI will save space in the compiler.

 This is a fine reason to disable RTTI if it isn't used, but doesn't
 seem like a strong reason to prohibit using it.  The information is
 only emitted for classes with virtual functions, isn't very large,
 is typically emitted in only one object file, and since it lives
 in .rodata it can be shared between multiple compiler processes.

  +Checking the type of a class at runtime usually indicates a design problem.

 The tree_contains_struct machinery recently added to GCC maps
 directly onto dynamic_cast;

 if (CODE_CONTAINS_STRUCT(TREE_CODE(t),TS_DECL_WRTL))
   /* do something with t-decl_with_rtl */

 translates roughly to to

 if (decl_with_rtl *p = dynamic_cast decl_with_rtl *(t))
   /* do something with p */

 When new interfaces are added partway down an inheritance tree,
 dynamic_cast is the right way to access them.  This isn't checking
 what the type is, it's checking whether the object supports a
 particular method.

 The fact that we've gone to the trouble to implement this
 functionality in C suggests to me that using it isn't always
 indicative of a design problem.  :)

Personally, I am fine with using dynamic_cast.  I was writing up what
I thought was a consensus on the wiki.  I can live without it, or I
can use it profitably.  Whatever you all decide, I will write up.

  +If you need to know the type of a class for some other reason,
  +use an enum or a virtual member function
  +that coverts a pointer to the more derived class.
  +For example,
  +/p
  +
  +blockquoteprecode
  +common_type *p = ;
  +if (specific_type *q = p-gt;to_specific ()) {
  +  // We have and can use a specific_type pointed to by q.
  +}
  +/code/pre/blockquote

 This is basically equivalent to dynamic_cast except that you need
 to clutter up your root base class with one virtual function for
 each derived class you want to be able to convert to.

Note quite equivalent, as you can implement to_specific with
non-virtual classes using the TREE_CODE.  Thus would could implement
a type-save dynamic pointer converter before converting to virtual
classes.

OTOH, we could probably work up a template function that looks like
dynamic_cast but uses the TREE_CODE instead, achieving the same
intermediate step.

I agree that it does clutter up the base class.

Shall we enable RTTI?

-- 
Lawrence Crowl


Re: [wwwdocs] Update coding conventions for C++

2012-06-27 Thread Lawrence Crowl
On 6/27/12, Martin Jambor mjam...@suse.cz wrote:
 On Tue, Jun 26, 2012 at 11:06:15AM -0700, Lawrence Crowl wrote:
  On 6/26/12, Martin Jambor mjam...@suse.cz wrote:
   On Mon, Jun 25, 2012 at 03:26:01PM -0700, Lawrence Crowl wrote:
+but think twice before using it in code
+intended to last a long time.
  
   I think all committed code should be expected to have
   long-lasting quality.  I would not encourage people to think
   otherwise and would drop the long time reference here.
   If anybody ever commits something ugly to bridge a short time
   period, it should only be done under the maintainers grant
   exceptions rule anyway.
  
+/p +p
+For long-term code, at least for now,
+we will continue to use codeprintf/code style I/O
+rather than codelt;iostreamgt;/code style I/O.
+For quick debugging code,
+codelt;iostreamgt;/code is permitted.
+/p
  
   Similarly here, no quick and dirty debugging output should
   ever be committed, we should not
  
+h4a name=stdlibThe Standard Library/a/h4
+
+p
+At present, C++ provides no great advantage for i18n.
+GCC does type checking for codeprintf/code arguments,
+so the type insecurity of codeprintf/code is moot,
+but the clarity in layout persists.
+For quick debugging output, lt;iostreamgt; requires less work.
+/p
  
   The same applies here.
 
  The value of these changes depends on when the rules are
  enforced.  If they are enforced only on trunk, then the changes
  seem fine to me.  However, if they are enforced on branches,
  then they could unnecessarily slow down development.
 
  Comments?

 I think that if you have a private branch, you are basically
 its maintainer and can grant yourself any exception from any
 rule you want.  Of course, that might make your life harder if
 you later want to contribute the changes to the trunk, release
 branches, other peple's branches and generally anywhere.

I am not concerned about private branches, but public branches for
which sharing might be needed, but for which cleanup before going
into trunk or a release is reasonable.

C++ streams are much more convenient for free-form output than
C-based solutions.  Having said that, does anyone object to removing
the permission to use C++ streams?

-- 
Lawrence Crowl


Re: [wwwdocs] Update coding conventions for C++

2012-06-28 Thread Lawrence Crowl
On 6/27/12, Lawrence Crowl cr...@google.com wrote:
 ..., does anyone object to removing the permission to use C++
 streams?

Having heard no objection, I removed the permission.

The following patch is the current state of the changes.  Since the
discussion appears to have died down, can I commit this patch?

BTW, as before, I have removed the html tags from this patch,
as they cause the mail server to reject the patch.


Index: htdocs/codingconventions.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/codingconventions.html,v
retrieving revision 1.66
diff -u -u -r1.66 codingconventions.html
--- htdocs/codingconventions.html   19 Feb 2012 00:45:34 -  1.66
+++ htdocs/codingconventions.html   28 Jun 2012 22:03:38 -
@@ -15,8 +19,73 @@
 code to follow these conventions, it is best to send changes to follow
 the conventions separately from any other changes to the code./p

+ul
+lia href=#DocumentationDocumentation/a/li
+lia href=#ChangeLogsChangeLogs/a/li
+lia href=#PortabilityPortability/a/li
+lia href=#MakefilesMakefiles/a/li
+lia href=#TestsuiteTestsuite Conventions/a/li
+lia href=#DiagnosticsDiagnostics Conventions/a/li
+lia href=#SpellingSpelling, terminology and markup/a/li
+lia href=#CandCxxC and C++ Language Conventions/a
+ul
+lia href=#C_OptionsCompiler Options/a/li
+lia href=#C_LanguageLanguage Use/a
+ul
+lia href=#AssertionsAssertions/a/li
+lia href=#CharacterCharacter Testing/a/li
+lia href=#ErrorError Node Testing/a/li
+lia href=#GeneratedParameters Affecting Generated Code/a/li
+lia href=#C_InliningInlining Functions/a/li
+/ul
+/li
+lia href=#C_FormattingFormatting Conventions/a
+ul
+lia href=#LineLine Length/a/li
+lia href=#C_NamesNames/a/li
+lia href=#ExpressionsExpressions/a/li
+/ul
+/li
+/ul
+/li
+lia href=#Cxx_ConventionsC++ Language Conventions/a
+ul
+lia href=#Cxx_LanguageLanguage Use/a
+ul
+lia href=#VariableVariable Definitions/a/li
+lia href=#Struct_UseStruct Definitions/a/li
+lia href=#Class_UseClass Definitions/a/li
+lia href=#ConstructorsConstructors and Destructors/a/li
+lia href=#ConversionsConversions/a/li
+lia href=#Over_FuncOverloading Functions/a/li
+lia href=#Over_OperOverloading Operators/a/li
+lia href=#DefaultDefault Arguments/a/li
+lia href=#Cxx_InliningInlining Functions/a/li
+lia href=#Template_UseTemplates/a/li
+lia href=#Namespace_UseNamespaces/a/li
+lia href=#RTTIRTTI and codedynamic_cast/code/a/li
+lia href=#CastsOther Casts/a/li
+lia href=#ExceptionsExceptions/a/li
+lia href=#Standard_LibraryThe Standard Library/a/li
+/ul
+/li
+lia href=#Cxx_FormattingFormatting Conventions/a
+ul
+lia href=#Cxx_NamesNames/a/li
+lia href=#Struct_FormStruct Definitions/a/li
+lia href=#Class_FormClass Definitions/a/li
+lia href=#Member_FormClass Member Definitions/a/li
+lia href=#Template_FormTemplates/a/li
+lia href=#ExternCExtern C/a/li
+lia href=#Namespace_FormNamespaces/a/li
+/ul
+/li
+/ul
+/li
+/ul

-h2Documentation/h2
+
+h2a name=DocumentationDocumentation/a/h2

 pDocumentation, both of user interfaces and of internals, must be
 maintained and kept up to date.  In particular:/p
@@ -43,7 +112,7 @@
 /ul


-h2ChangeLogs/h2
+h2a name=ChangeLogsChangeLogs/a/h2

 pGCC requires ChangeLog entries for documentation changes; for the web
 pages (apart from codejava//code and codelibstdc++//code) the CVS
@@ -71,20 +140,40 @@
 codejava/58/code is the actual number of the PR) at the top
 of the ChangeLog entry./p

-h2Portability/h2
+h2a name=PortabilityPortability/a/h2

 pThere are strict requirements for portability of code in GCC to
-older systems whose compilers do not implement all of the ISO C standard.
-GCC requires at least an ANSI C89 or ISO C90 host compiler, and code
-should avoid pre-standard style function definitions, unnecessary
-function prototypes and use of the now deprecated @code{PARAMS} macro.
+older systems whose compilers do not implement all of the
+latest ISO C and C++ standards.
+/p
+
+p
+The directories
+codegcc/code, codelibcpp/code and codefixincludes/code
+may use C++03.
+They may also use the codelong long/code type
+if the host C++ compiler supports it.
+These directories should use reasonably portable parts of C++03,
+so that it is possible to build GCC with C++ compilers other than GCC itself.
+If testing reveals that
+reasonably recent versions of non-GCC C++ compilers cannot compile GCC,
+then GCC code should be adjusted accordingly.
+(Avoiding unusual language constructs helps immensely.)
+Furthermore,
+these directories emshould/em also be compatible with C++11.
+/p
+
+p
+The directories libiberty and libdecnumber must use C

Re: [wwwdocs] Update coding conventions for C++

2012-06-29 Thread Lawrence Crowl
Resend, as I replied to a message that didn't have the usual suspects
on the cc line.

On 6/27/12, Lawrence Crowl cr...@google.com wrote:
 ..., does anyone object to removing the permission to use C++
 streams?

Having heard no objection, I removed the permission.

The following patch is the current state of the changes.  Since the
discussion appears to have died down, can I commit this patch?

BTW, as before, I have removed the html tags from this patch,
as they cause the mail server to reject the patch.


Index: htdocs/codingconventions.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/codingconventions.html,v
retrieving revision 1.66
diff -u -u -r1.66 codingconventions.html
--- htdocs/codingconventions.html   19 Feb 2012 00:45:34 -  1.66
+++ htdocs/codingconventions.html   28 Jun 2012 22:03:38 -
@@ -15,8 +19,73 @@
 code to follow these conventions, it is best to send changes to follow
 the conventions separately from any other changes to the code./p

+ul
+lia href=#DocumentationDocumentation/a/li
+lia href=#ChangeLogsChangeLogs/a/li
+lia href=#PortabilityPortability/a/li
+lia href=#MakefilesMakefiles/a/li
+lia href=#TestsuiteTestsuite Conventions/a/li
+lia href=#DiagnosticsDiagnostics Conventions/a/li
+lia href=#SpellingSpelling, terminology and markup/a/li
+lia href=#CandCxxC and C++ Language Conventions/a
+ul
+lia href=#C_OptionsCompiler Options/a/li
+lia href=#C_LanguageLanguage Use/a
+ul
+lia href=#AssertionsAssertions/a/li
+lia href=#CharacterCharacter Testing/a/li
+lia href=#ErrorError Node Testing/a/li
+lia href=#GeneratedParameters Affecting Generated
Code/a/li
+lia href=#C_InliningInlining Functions/a/li
+/ul
+/li
+lia href=#C_FormattingFormatting Conventions/a
+ul
+lia href=#LineLine Length/a/li
+lia href=#C_NamesNames/a/li
+lia href=#ExpressionsExpressions/a/li
+/ul
+/li
+/ul
+/li
+lia href=#Cxx_ConventionsC++ Language Conventions/a
+ul
+lia href=#Cxx_LanguageLanguage Use/a
+ul
+lia href=#VariableVariable Definitions/a/li
+lia href=#Struct_UseStruct Definitions/a/li
+lia href=#Class_UseClass Definitions/a/li
+lia href=#ConstructorsConstructors and Destructors/a/li
+lia href=#ConversionsConversions/a/li
+lia href=#Over_FuncOverloading Functions/a/li
+lia href=#Over_OperOverloading Operators/a/li
+lia href=#DefaultDefault Arguments/a/li
+lia href=#Cxx_InliningInlining Functions/a/li
+lia href=#Template_UseTemplates/a/li
+lia href=#Namespace_UseNamespaces/a/li
+lia href=#RTTIRTTI and codedynamic_cast/code/a/li
+lia href=#CastsOther Casts/a/li
+lia href=#ExceptionsExceptions/a/li
+lia href=#Standard_LibraryThe Standard Library/a/li
+/ul
+/li
+lia href=#Cxx_FormattingFormatting Conventions/a
+ul
+lia href=#Cxx_NamesNames/a/li
+lia href=#Struct_FormStruct Definitions/a/li
+lia href=#Class_FormClass Definitions/a/li
+lia href=#Member_FormClass Member Definitions/a/li
+lia href=#Template_FormTemplates/a/li
+lia href=#ExternCExtern C/a/li
+lia href=#Namespace_FormNamespaces/a/li
+/ul
+/li
+/ul
+/li
+/ul

-h2Documentation/h2
+
+h2a name=DocumentationDocumentation/a/h2

 pDocumentation, both of user interfaces and of internals, must be
 maintained and kept up to date.  In particular:/p
@@ -43,7 +112,7 @@
 /ul


-h2ChangeLogs/h2
+h2a name=ChangeLogsChangeLogs/a/h2

 pGCC requires ChangeLog entries for documentation changes; for the web
 pages (apart from codejava//code and codelibstdc++//code) the CVS
@@ -71,20 +140,40 @@
 codejava/58/code is the actual number of the PR) at the top
 of the ChangeLog entry./p

-h2Portability/h2
+h2a name=PortabilityPortability/a/h2

 pThere are strict requirements for portability of code in GCC to
-older systems whose compilers do not implement all of the ISO C standard.
-GCC requires at least an ANSI C89 or ISO C90 host compiler, and code
-should avoid pre-standard style function definitions, unnecessary
-function prototypes and use of the now deprecated @code{PARAMS} macro.
+older systems whose compilers do not implement all of the
+latest ISO C and C++ standards.
+/p
+
+p
+The directories
+codegcc/code, codelibcpp/code and codefixincludes/code
+may use C++03.
+They may also use the codelong long/code type
+if the host C++ compiler supports it.
+These directories should use reasonably portable parts of C++03,
+so that it is possible to build GCC with C++ compilers other than GCC
itself.
+If testing reveals that
+reasonably recent versions of non-GCC C++ compilers cannot compile GCC,
+then GCC code should be adjusted accordingly.
+(Avoiding unusual language constructs helps immensely.)
+Furthermore,
+these directories emshould/em also

Re: [wwwdocs] Update coding conventions for C++

2012-07-03 Thread Lawrence Crowl
On 7/1/12, Gabriel Dos Reis g...@integrable-solutions.net wrote:
 On Fri, Jun 29, 2012 at 1:17 PM, Lawrence Crowl cr...@google.com wrote:
 Resend, as I replied to a message that didn't have the usual suspects
 on the cc line.

 On 6/27/12, Lawrence Crowl cr...@google.com wrote:
 ..., does anyone object to removing the permission to use C++
 streams?

 Having heard no objection, I removed the permission.

 This is an area where I think we should not be too prescriptive.
 Clearly, the diagnostics machinery will be used for anything
 diagnostics -- so whether IOStreams are allowed or not would
 not change that.  On the other hand, I feel we should defer to
 maintainers' discretion in specific areas whether people are
 implementing dumping or other I/O facilities not related to
 diagnostics, since as I you correctly pointed out, there is an
 added value of flexibility and expressivity.

 In summary: Instead of blanket ban, I would suggest that uses for
 C++ I/O streams be reserved for non-diagnostics purposes and left
 at the discretion of maintainers.

Given that maintainers have discretion to grant exceptions
anyway, would you be willing to let the wording stand without
that permission?

I'd like to get the document committed in some form so that we can
make progress on the dependent activities.  At present, none of
those activities depend on this issue.

-- 
Lawrence Crowl


Re: [wwwdocs] Update coding conventions for C++

2012-07-03 Thread Lawrence Crowl
On 7/1/12, Jason Merrill ja...@redhat.com wrote:
 On 06/29/2012 02:17 PM, Lawrence Crowl wrote:
  +h4a name=RTTIRTTI andcodedynamic_cast/code/a/h4
  +
  +p
  +Run-time type information (RTTI) is permitted
  +when certain non-defaultcode--enable-checking/code  options are
  enabled,
  +so as to allow checkers to report dynamic types.
  +However, by default, RTTI is not permitted
  +and the compiler must build cleanly withcode-fno-rtti/code.
  +/p

 As discussed, I would say that RTTI is currently not permitted
 but could be added later.

But isn't could be added later always true?  Other folks have
objected to such wording on the grounds that it adds no information,
so I hesistate to add such wording now.

 For the rationale, I would say that disabling RTTI saves some space
 for classes with virtual functions when it isn't used, but could
 be enabled if it would be useful in some part of the compiler.
 And then remove the rest of the rationale.

I think you're objecting to Checking the type of a class at
runtime usually indicates a design problem.  I copied this text
from the wiki.  Does anyone object to me removing it?

I'd like to get the document committed in some form so that we can
make progress on the dependent activities.  At present, none of
those activities depend on this issue.

-- 
Lawrence Crowl


Re: [wwwdocs] Update coding conventions for C++

2012-07-09 Thread Lawrence Crowl
On 7/4/12, Jason Merrill ja...@redhat.com wrote:
 On 07/03/2012 04:37 PM, Lawrence Crowl wrote:
 On 7/1/12, Jason Merrillja...@redhat.com  wrote:
 As discussed, I would say that RTTI is currently not permitted
 but could be added later.

 But isn't could be added later always true?  Other folks have
 objected to such wording on the grounds that it adds no information,
 so I hesistate to add such wording now.

 I suppose.

 For the rationale, I would say that disabling RTTI saves some space
 for classes with virtual functions when it isn't used, but could
 be enabled if it would be useful in some part of the compiler.
 And then remove the rest of the rationale.

 I think you're objecting to Checking the type of a class at
 runtime usually indicates a design problem.  I copied this text
 from the wiki.  Does anyone object to me removing it?

 I also object to the rest of the rationale.  I would be OK with just
 leaving Disabling RTTI will save space in the compiler and removing
 the rest.

Done.  New patch attached, but note that the html tags have been
stripped from the patch to avoid mailer problems.

-- 
Lawrence Crowl
Index: htdocs/codingconventions.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/codingconventions.html,v
retrieving revision 1.66
diff -u -u -r1.66 codingconventions.html
--- htdocs/codingconventions.html   19 Feb 2012 00:45:34 -  1.66
+++ htdocs/codingconventions.html   9 Jul 2012 15:48:37 -
@@ -15,8 +19,73 @@
 code to follow these conventions, it is best to send changes to follow
 the conventions separately from any other changes to the code./p
 
+ul
+lia href=#DocumentationDocumentation/a/li
+lia href=#ChangeLogsChangeLogs/a/li
+lia href=#PortabilityPortability/a/li
+lia href=#MakefilesMakefiles/a/li
+lia href=#TestsuiteTestsuite Conventions/a/li
+lia href=#DiagnosticsDiagnostics Conventions/a/li
+lia href=#SpellingSpelling, terminology and markup/a/li
+lia href=#CandCxxC and C++ Language Conventions/a
+ul
+lia href=#C_OptionsCompiler Options/a/li
+lia href=#C_LanguageLanguage Use/a
+ul
+lia href=#AssertionsAssertions/a/li
+lia href=#CharacterCharacter Testing/a/li
+lia href=#ErrorError Node Testing/a/li
+lia href=#GeneratedParameters Affecting Generated Code/a/li
+lia href=#C_InliningInlining Functions/a/li
+/ul
+/li
+lia href=#C_FormattingFormatting Conventions/a
+ul
+lia href=#LineLine Length/a/li
+lia href=#C_NamesNames/a/li
+lia href=#ExpressionsExpressions/a/li
+/ul
+/li
+/ul
+/li
+lia href=#Cxx_ConventionsC++ Language Conventions/a
+ul
+lia href=#Cxx_LanguageLanguage Use/a
+ul
+lia href=#VariableVariable Definitions/a/li
+lia href=#Struct_UseStruct Definitions/a/li
+lia href=#Class_UseClass Definitions/a/li
+lia href=#ConstructorsConstructors and Destructors/a/li
+lia href=#ConversionsConversions/a/li
+lia href=#Over_FuncOverloading Functions/a/li
+lia href=#Over_OperOverloading Operators/a/li
+lia href=#DefaultDefault Arguments/a/li
+lia href=#Cxx_InliningInlining Functions/a/li
+lia href=#Template_UseTemplates/a/li
+lia href=#Namespace_UseNamespaces/a/li
+lia href=#RTTIRTTI and codedynamic_cast/code/a/li
+lia href=#CastsOther Casts/a/li
+lia href=#ExceptionsExceptions/a/li
+lia href=#Standard_LibraryThe Standard Library/a/li
+/ul
+/li
+lia href=#Cxx_FormattingFormatting Conventions/a
+ul
+lia href=#Cxx_NamesNames/a/li
+lia href=#Struct_FormStruct Definitions/a/li
+lia href=#Class_FormClass Definitions/a/li
+lia href=#Member_FormClass Member Definitions/a/li
+lia href=#Template_FormTemplates/a/li
+lia href=#ExternCExtern C/a/li
+lia href=#Namespace_FormNamespaces/a/li
+/ul
+/li
+/ul
+/li
+/ul
 
-h2Documentation/h2
+
+h2a name=DocumentationDocumentation/a/h2
 
 pDocumentation, both of user interfaces and of internals, must be
 maintained and kept up to date.  In particular:/p
@@ -43,7 +112,7 @@
 /ul
 
 
-h2ChangeLogs/h2
+h2a name=ChangeLogsChangeLogs/a/h2
 
 pGCC requires ChangeLog entries for documentation changes; for the web
 pages (apart from codejava//code and codelibstdc++//code) the CVS
@@ -71,20 +140,40 @@
 codejava/58/code is the actual number of the PR) at the top
 of the ChangeLog entry./p
 
-h2Portability/h2
+h2a name=PortabilityPortability/a/h2
 
 pThere are strict requirements for portability of code in GCC to
-older systems whose compilers do not implement all of the ISO C standard.
-GCC requires at least an ANSI C89 or ISO C90 host compiler, and code
-should avoid pre-standard style function definitions, unnecessary
-function prototypes and use of the now deprecated @code{PARAMS} macro.
+older systems whose compilers do not implement all

Re: [wwwdocs] Update coding conventions for C++

2012-07-16 Thread Lawrence Crowl
On 7/10/12, Gabriel Dos Reis g...@cs.tamu.edu wrote:
 Jason Merrill ja...@redhat.com writes:

 | On 07/09/2012 06:00 PM, Lawrence Crowl wrote:
 |  Done.  New patch attached, but note that the html tags have been
 |  stripped from the patch to avoid mailer problems.
 |
 | Thanks.  If nobody else has any comments, I think this is good to go.

 Great!

Committed!

-- 
Lawrence Crowl


[pph] Various Merging Fixes (issue5330048)

2011-10-28 Thread Lawrence Crowl
Add namespace merging.  This change generalizes pph_out_merge_keys on
the global namespace to all namspaces.  Preallocate decl_lang_specific
for namespaces with streaming in their keys.  Stream out namespace
members in declaration order.  This change mysteriously fixes
mysterious bugs.

Add initial support for type merging.  This support includes
references to merge keys.  It modifies the key hash to include the
tree code, because type decls and types otherwise have the same
hash.  Types do not appear on a chain, so merging into a null chain is
avoided.  Type merging is off at the moment to test namespaces.

Handle unnamed decls by using the location instead of the mangled name
in creating the hash string.

Change the pph_trace_tree function from a set of bool parameters to a
single enum pph_trace_kind.  This change captures more information and
avoids printing trees before their contents are streamed in.  Change
the call sites to uniformly use a postorder traversal for tracing.
This makes in and out traces directly comparable.

Bootstrapped on x64.


Index: gcc/cp/ChangeLog.pph

2011-10-28   Lawrence Crowl  cr...@google.com

* pph.c (pph_dump_tree_name): Remove dead code.  Dump tree_code also.
* pph-streamer.h (enum pph_trace_kind): New.
(pph_trace_tree): Change bool parameters to a single enum parameter.
Update callers to match.
(pph_tree_is_mergeable): All decls and types are mergeable.
* pph-streamer.c (pph_trace_tree): Avoid printing names for unmerge
keys, as they are too sparse to print.  Change bool parameters to a
single enum parameter.  Update body to match.
* pph-streamer-out.c (pph_out_start_merge_key_record): Handle reference
merge keys.  Return status.
(pph_out_merge_body_vec): New.
(pph_out_merge_body_chain): New.
(pph_out_merge_keys): Replace with general binding routines below.
(pph_out_binding_merge_keys): New.
(pph_out_binding_merge_bodies): New.
(pph_out_global_binding): Use the above.
(pph_merge_name): Handle types as well as decls.  Handle unnamed decls.
Handle namespaces.  Add disabled handling of types.
(pph_out_tree): Move tracing to postorder traversal to match tracing of
input streaming.
* pph-streamer-in.c (htab_merge_key_hash): Hash in tree code.
(pph_merge_into_chain): Do not merge into null chains.
(pph_in_binding_level): Split ALLOC_AND_REGISTER into constituents
for future registration of previously allocated binding level.
(pph_in_merge_keys): Replace with general binding routines below.
(pph_in_binding_merge_keys): New.
(pph_in_binding_merge_bodies): New.
(pph_in_global_binding): Use the above.
(pph_in_lang_specific): Avoid reallocating DECL_LANG_SPECIFIC.
(pph_in_merge_key_tree): Reformat comment.  Handle null and reference
markers, which may be needed for types.  Add handling of namespaces.
Add disabled handling of classes and types.


Index: gcc/cp/pph.c
===
--- gcc/cp/pph.c(revision 180550)
+++ gcc/cp/pph.c(working copy)
@@ -78,34 +78,20 @@ pph_dump_min_decl (FILE *file, tree decl
 void
 pph_dump_tree_name (FILE *file, tree t, int flags)
 {
-#if 0
   enum tree_code code = TREE_CODE (t);
-  fprintf (file, %s\t, pph_tree_code_text (code));
-  if (code == FUNCTION_TYPE || code == METHOD_TYPE)
-{
-  dump_function_to_file (t, file, flags);
-}
-  else
-{
-  print_generic_expr (file, TREE_TYPE (t), flags);
-  /* FIXME pph: fprintf (file,  , cxx_printable_name (t, 0)); */
-  fprintf (file,   );
-  print_generic_expr (file, t, flags);
-}
-  fprintf (file, \n);
-#else
+  const char *text = pph_tree_code_text (code);
   if (DECL_P (t))
-fprintf (file, %s\n, decl_as_string (t, flags));
+fprintf (file, %s %s\n, text, decl_as_string (t, flags));
   else if (TYPE_P (t))
-fprintf (file, %s\n, type_as_string (t, flags));
+fprintf (file, %s %s\n, text, type_as_string (t, flags));
   else if (EXPR_P (t))
-fprintf (file, %s\n, expr_as_string (t, flags));
+fprintf (file, %s %s\n, text, expr_as_string (t, flags));
   else
 {
+  fprintf (file, %s , text );
   print_generic_expr (file, t, flags);
   fprintf (file, \n);
 }
-#endif
 }
 
 
Index: gcc/cp/pph-streamer-in.c
===
--- gcc/cp/pph-streamer-in.c(revision 180550)
+++ gcc/cp/pph-streamer-in.c(working copy)
@@ -750,7 +750,8 @@ htab_merge_key_hash (const void *p)
   const merge_toc_entry *key = (const merge_toc_entry *) p;
   hashval_t context_val = htab_hash_pointer (key-context);
   hashval_t name_val = htab_hash_string (key-name);
-  return iterative_hash_hashval_t (context_val, name_val);
+  hashval_t id_val = iterative_hash_hashval_t (name_val, TREE_CODE

[pph] Merge static_decls. (issue5335042)

2011-11-01 Thread Lawrence Crowl
Add merging of static_decls in bindings.  Due to the current
structure, this change is currently only effective at namespace scope.
Consequently, there are no changes to test status.  We may need to
make all bindings merged by default.


Index: gcc/cp/ChangeLog.pph

2011-11-01   Lawrence Crowl  cr...@google.com

* pph-streamer-out.c (pph_out_binding_level_1): Remove streaming of
static_decls.
(pph_out_binding_level): Add streaming of static_decls.
(pph_out_binding_merge_bodies): Likewise.
* pph-streamer-in.c (pph_is_tree_element_of_vec): New.
(pph_union_two_tree_vecs): New.
(pph_union_into_tree_vec): New.
(pph_in_binding_level_1): Remove streaming of static_decls.
(pph_in_binding_level): Add streaming of static_decls.
(pph_in_binding_merge_bodies): Add merging of static_decls from
streamer into existing binding.  Needs new function parameter.
(pph_in_merge_key_tree): Preallocate namespace cp_binding_level.
(pph_in_global_binding): Update call to pph_in_binding_merge_bodies.


Index: gcc/cp/pph-streamer-in.c
===
--- gcc/cp/pph-streamer-in.c(revision 180705)
+++ gcc/cp/pph-streamer-in.c(working copy)
@@ -677,6 +677,66 @@ pph_in_tree_pair_vec (pph_stream *stream
 }
 
 
+/* Test whether tree T is an element of vector V.  */
+
+static bool
+pph_is_tree_element_of_vec (tree t, VEC(tree,gc) *v)
+{
+  unsigned i;
+  tree s;
+  FOR_EACH_VEC_ELT (tree, v, i, s)
+if (s == t)
+  return true;
+  return false;
+}
+
+
+/* Return the union of two tree vecs.  The argument vectors are unmodified.  */
+
+static VEC(tree,gc) *
+pph_union_two_tree_vecs (VEC(tree,gc) *left, VEC(tree,gc) *right)
+{
+  /* FIXME pph: This O(left)+O(left*right) union may become a problem.
+ In the long run, we probably want to copy both into a hash table
+ and then copy the table into the result.  */
+  unsigned i;
+  tree t;
+  VEC(tree,gc) *unioned = VEC_copy (tree, gc, left);
+  FOR_EACH_VEC_ELT (tree, right, i, t)
+{
+  if (!pph_is_tree_element_of_vec (t, left))
+   VEC_safe_push (tree, gc, unioned, t);
+}
+  return unioned;
+}
+
+
+/* Union FROM one tree vec with and INTO a tree vec.  The INTO argument will
+   have an updated value.  The FROM argument is no longer valid.  */
+
+static void
+pph_union_into_tree_vec (VEC(tree,gc) **into, VEC(tree,gc) *from)
+{
+  if (!VEC_empty (tree, from))
+{
+  if (*into == NULL)
+   *into = from;
+  else if (VEC_empty (tree, *into))
+   {
+ VEC_free (tree, gc, *into);
+ *into = from;
+   }
+  else
+   {
+ VEC(tree,gc) *unioned = pph_union_two_tree_vecs (*into, from);
+ VEC_free (tree, gc, *into);
+ VEC_free (tree, gc, from);
+ *into = unioned;
+   }
+}
+}
+
+
 / chains */
 
 
@@ -967,7 +1027,6 @@ pph_in_binding_level_1 (pph_stream *stre
   struct bitpack_d bp;
 
   bl-this_entity = pph_in_tree (stream);
-  bl-static_decls = pph_in_tree_vec (stream);
 
   num = pph_in_uint (stream);
   bl-class_shadowed = NULL;
@@ -1029,6 +1088,7 @@ pph_in_binding_level (pph_stream *stream
   bl-namespaces = pph_in_chain (stream);
   bl-usings = pph_in_chain (stream);
   bl-using_directives = pph_in_chain (stream);
+  bl-static_decls = pph_in_tree_vec (stream);
   pph_in_binding_level_1 (stream, bl);
 
   return bl;
@@ -1051,12 +,13 @@ pph_in_binding_merge_keys (pph_stream *s
 /* Read all the merge bodies from STREAM into the cp_binding_level BL.  */
 
 static void
-pph_in_binding_merge_bodies (pph_stream *stream)
+pph_in_binding_merge_bodies (pph_stream *stream, cp_binding_level *bl)
 {
   pph_in_merge_body_chain (stream);
   pph_in_merge_body_chain (stream);
   pph_in_merge_body_chain (stream);
   pph_in_merge_body_chain (stream);
+  pph_union_into_tree_vec (bl-static_decls, pph_in_tree_vec (stream));
 }
 
 
@@ -1951,11 +2012,11 @@ pph_in_merge_key_tree (pph_stream *strea
 {
   if (TREE_CODE (expr) == NAMESPACE_DECL)
 {
- /* struct lang_decl *ld; */
-  retrofit_lang_decl (expr);
- /* ld = DECL_LANG_SPECIFIC (expr); */
- /* FIXME NOW: allocate binding.  */
-  pph_in_binding_merge_keys (stream, NAMESPACE_LEVEL (expr));
+ cp_binding_level *bl;
+ retrofit_lang_decl (expr);
+ bl = ggc_alloc_cleared_cp_binding_level ();
+ NAMESPACE_LEVEL (expr) = bl;
+ pph_in_binding_merge_keys (stream, bl);
 }
 #if 0
 /* FIXME pph: Disable type merging for the moment.  */
@@ -2438,7 +2499,7 @@ pph_in_global_binding (pph_stream *strea
  same slot IX that the writer used, the trees read now will be
  bound to scope_chain-bindings.  */
   pph_in_binding_merge_keys (stream, bl);
-  pph_in_binding_merge_bodies (stream);
+  pph_in_binding_merge_bodies (stream, bl);
 
   /* FIXME

[pph] Partial namespace merging. (issue5341047)

2011-11-07 Thread Lawrence Crowl
Add merging of namespaces.

Add testcase for namespace merging. test fails because lookup fails
for reasons apparently associated with identifiers.

Add tracing of both front and back of trees so as to better identify
the tree structure.

Add tracing of record markers.

Various formatting fixes.

Tested on x64.


Index: gcc/testsuite/ChangeLog.pph

2011-11-07   Lawrence Crowl  cr...@google.com

* lib/dg-pph.exp (dg-pph-pos): Recognize bogus errors.
* g++.dg/pph/x0namespace2.h: New.
* g++.dg/pph/x4namespace.cc: New.

Index: gcc/cp/ChangeLog.pph

2011-11-07   Lawrence Crowl  cr...@google.com

* pph.c (pph_tree_code_text): Fix formatting.
* pph-streamer.h (enum pph_trace_end): New.
(pph_trace_tree): Add 'which end' parameter.
(pph_trace_marker): New.
* gcc/cp/pph-streamer.c (marker_strings[]): New.
(tag_strings[]): New.
(pph_trace_marker): New.
(pph_trace_tree): Add tree prefix tracing.
* pph-streamer-out.c: Add section separators.
(pph_out_stream): Move to stream initialization section.
(pph_out_record_marker): Add record tracing.
(chain2vec_filter): Disable assert on 'none' filter.
(pph_out_chain_filtered): Likewise.
(pph_out_binding_merge_bodies): Add more merge fodder.
(pph_out_merge_key_tree): Add tree prefix tracing.
(pph_out_tree): Likewise.
* pph-streamer-in.c: Add section separators.
(ALLOC_AND_REGISTER): Move to record handling section.
(pph_loc_offset): Move to source information section.
(pph_in_record_marker): Add record tracing.
(pph_in_binding_level): Factor into pph_in_binding_level and
pph_in_binding_level_start.
(pph_in_binding_merge_bodies): Factor actual merging into separate
pph_in_binding_merge_bodies_1.
(pph_in_ld_ns): Merge into a binding if one already exists.
(pph_in_tree_body): Add debugging code.
(pph_in_merge_key_tree): Add tree prefix tracing.
Do not allocate a namespace binding if one exists already.
(pph_in_tree): Add prefix tracing.
(pph_in_global_binding): Call pph_in_binding_merge_bodies_1 to avoid
allocation.


Index: gcc/testsuite/lib/dg-pph.exp
===
--- gcc/testsuite/lib/dg-pph.exp(revision 180802)
+++ gcc/testsuite/lib/dg-pph.exp(working copy)
@@ -143,7 +143,8 @@ proc dg-pph-pos { subdir test options ma
 if { ![file_on_host exists $bname.s] } {
# Expect assembly to be missing when the compile is an
# expected fail.
-   if { ![llength [grep $test dg-xfail-if.*-fpph-map]] } {
+   if { ![llength [grep $test dg-xfail-if.*-fpph-map]]
+ ![llength [grep $test dg-bogus.*error:]] } {
fail $nshort $options (pph assembly missing)
}
return
Index: gcc/testsuite/g++.dg/pph/x4namespace.cc
===
--- gcc/testsuite/g++.dg/pph/x4namespace.cc (revision 0)
+++ gcc/testsuite/g++.dg/pph/x4namespace.cc (revision 0)
@@ -0,0 +1,29 @@
+// { dg-bogus x4namespace.cc:11:1: error: 'C' does not name a type  { 
xfail *-*-* } 0 }
+// { dg-bogus x4namespace.cc:27:5: error: 'z' is not a member of 'A'  { 
xfail *-*-* } 0 }
+
+#include x0namespace.h
+#include x0namespace2.h
+
+namespace A {
+int x = 3;
+int x2 = 5;
+
+C int  z;
+C2 int  z2;
+
+} // namespace A
+
+int y = 4;
+int y2 = 6;
+
+int D::method()
+{ return y; }
+
+int D2::method()
+{ return y2; }
+
+int main()
+{
+A::z.method();
+A::z2.method();
+}
Index: gcc/testsuite/g++.dg/pph/x0namespace2.h
===
--- gcc/testsuite/g++.dg/pph/x0namespace2.h (revision 0)
+++ gcc/testsuite/g++.dg/pph/x0namespace2.h (revision 0)
@@ -0,0 +1,22 @@
+#ifndef X0NAMESPACE2_H
+#define X0NAMESPACE2_H
+namespace A {
+extern int x2;
+struct B2;
+template typename T 
+struct C2 {
+T* b;
+int method();
+int another()
+{ return *b; }
+};
+template typename T 
+int C2 T ::method()
+{ return x2; }
+} // namespace A
+struct D2 : A::C2 int  {
+int method();
+int another()
+{ return *b; }
+};
+#endif
Index: gcc/cp/pph.c
===
--- gcc/cp/pph.c(revision 180802)
+++ gcc/cp/pph.c(working copy)
@@ -45,7 +45,7 @@ FILE *pph_logfile = NULL;
 
 /* Convert a checked tree_code CODE to a string.  */
 
-const char*
+const char *
 pph_tree_code_text (enum tree_code code)
 {
   gcc_assert (code  MAX_TREE_CODES);
Index: gcc/cp/pph-streamer-in.c
===
--- gcc/cp/pph-streamer-in.c(revision 180802)
+++ gcc/cp/pph-streamer-in.c(working copy)
@@ -35,10 +35,25 @@ along with GCC; see the file COPYING3.  
 #include parser.h
 #include pointer-set.h

[pph] Prepare for not streaming identifier bindings. (issue5437095)

2011-11-30 Thread Lawrence Crowl
The identifier bindings are causing trouble in merging.  This patch is
phase one of getting rid if binding information for identifiers within
pph files.  The bindings will be reconstructed after pph files have
been read in.  The core code enabling this switch has been disabled.

We determine when all pph files are loaded when the parser calls
pph_loaded, which it does when creating the parser.

The identifier bindings are re-assigned in name-lookup.c.

The stream read needs a different code path for merging, so several
routines get factored.


Index: gcc/testsuite/ChangeLog.pph

2011-11-30   Lawrence Crowl  cr...@google.com

* g++.dg/pph/c0anticipated.h: New.
* g++.dg/pph/c1anticipated.cc: New.
* g++.dg/pph/x0samename1.h: New.
* g++.dg/pph/x0samename2.h: New.
* g++.dg/pph/x4samename.cc: New.

Index: gcc/cp/ChangeLog.pph

2011-11-30   Lawrence Crowl  cr...@google.com

* pph.h (pph_loaded): New.
(pph_set_global_identifier_bindings): New.
(pph_out_binding_table): Add extern.
(pph_in_binding_table): Add extern.
* pph-core.c (pph_loaded): New.
* parser.c (c_parse_file): Call pph_loaded.
* name-lookup.c (pph_set_chain_identifier_bindings): New.
(pph_set_global_identifier_bindings): New.
* pph-out.c (pph_out_identifier_bindings): New.
(pph_out_tree_body): Call above function.
(pph_out_tree): Call above functions for builtins.
* pph-in.c (pph_in_merge_ld_base): New.
(pph_in_ref_lang_specific): Factored from pph_in_lang_specific.
(pph_in_lang_specific): Call pph_in_ref_lang_specific.
(pph_in_merge_lang_specific): New.
(pph_in_tcc_declaration_tail): Factored from pph_in_tcc_declaration.
(pph_in_tcc_declaration): Call pph_in_tcc_declaration_tail.
(pph_in_merge_tcc_declaration): New.
(pph_in_identifier_bindings): New.
(pph_in_tree_body): Call above function.
(pph_in_merge_tree_body): New.
(pph_in_tree): Call pph_in_identifier_bindings functions for builtins.
Call pph_in_merge_tree_body for merge bodies.


Index: gcc/testsuite/g++.dg/pph/x4samename.cc
===
--- gcc/testsuite/g++.dg/pph/x4samename.cc  (revision 0)
+++ gcc/testsuite/g++.dg/pph/x4samename.cc  (revision 0)
@@ -0,0 +1,13 @@
+// { dg-bogus x4samename.cc:11:18: error: expected unqualified-id before '=' 
token  { xfail *-*-* } 0 }
+// { dg-bogus x4samename.cc:12:43: error: cannot convert 'const char.' to 
'double' for argument '1' to 'int func.double.'  { xfail *-*-* } 0 }
+
+#include x0samename2.h
+#include x0samename1.h
+
+extern struct doppelgaenger out;
+
+int main() {
+   int x = out.field;
+   doppelgaenger = 3;
+   return func(3.14) + func((const char*)0);
+}
Index: gcc/testsuite/g++.dg/pph/c1anticipated.cc
===
--- gcc/testsuite/g++.dg/pph/c1anticipated.cc   (revision 0)
+++ gcc/testsuite/g++.dg/pph/c1anticipated.cc   (revision 0)
@@ -0,0 +1,12 @@
+#include c0anticipated.h
+
+int max_solutions;
+int solution_count;
+
+int main(int argc, char **argv) {
+   if(argc  1)
+  max_solutions = atoi(argv[1]);
+   printf(%d solutions found\n\n, solution_count);
+   pretty('b');
+   return 0;
+}
Index: gcc/testsuite/g++.dg/pph/x0samename1.h
===
--- gcc/testsuite/g++.dg/pph/x0samename1.h  (revision 0)
+++ gcc/testsuite/g++.dg/pph/x0samename1.h  (revision 0)
@@ -0,0 +1,8 @@
+#ifndef X0SAMENAME1
+#define X0SAMENAME1
+
+extern int func(double arg);
+
+struct doppelgaenger { int field; };
+
+#endif
Index: gcc/testsuite/g++.dg/pph/x0samename2.h
===
--- gcc/testsuite/g++.dg/pph/x0samename2.h  (revision 0)
+++ gcc/testsuite/g++.dg/pph/x0samename2.h  (revision 0)
@@ -0,0 +1,8 @@
+#ifndef X0SAMENAME2
+#define X0SAMENAME2
+
+extern int func(const char *arg);
+
+int doppelgaenger;
+
+#endif
Index: gcc/testsuite/g++.dg/pph/c0anticipated.h
===
--- gcc/testsuite/g++.dg/pph/c0anticipated.h(revision 0)
+++ gcc/testsuite/g++.dg/pph/c0anticipated.h(revision 0)
@@ -0,0 +1,18 @@
+#ifndef C0ANTICIPATED_H
+#define C0ANTICIPATED_H
+extern  C {
+  typedef __SIZE_TYPE__ size_t;
+  void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
+  int printf(const char *, ...);
+  int atoi(const char *);
+}
+
+/* pretty print a board in the specified hexagonal format */
+void pretty(char b) {
+   int i;
+   for(i = 0; i  1; i += 10) {
+  printf(%c , b + i);
+   }
+   printf(\n);
+}
+#endif
Index: gcc/cp/pph-core.c
===
--- gcc/cp/pph-core.c   (revision 181856)
+++ gcc/cp/pph-core.c   (working copy)
@@ -796,6 +796,21 @@ pph_add_include (pph_stream

[pph] Macro Validation Correction (issue4425041)

2011-04-14 Thread Lawrence Crowl

An earlier change reduced the number of bits in cpp_hashnode.directive_index
from 7 to 5, as that was sufficient for indexing the directives.  Tom Tromey
asked for a static check on the size.  This patch adds that check.

Unfortunately, five bits are not sufficient for the alternate use of
cpp_hashnode.directive_index as a named operator index.  So, I have reverted
the number of bits from five back to seven.  As a result, we now have 34 bits
in small fields, and the size of cpp_hashnode will increase from two to three
words on 32-bit systems.  The size on 64-bit systems remains unchanged because
these bits go into an alignment gap.

Index: libcpp/ChangeLog.pph

2011-04-14  Lawrence Crowl  cr...@google.com

* include/cpplib.h (cpp_hashnode):  Use a macro for the number of bits
in the directive_index bitfield.  Change the number of bits back to 7.
* directives.c (DIRECTIVE_TABLE):  Add a gcc-build-time check that the
index of the directive table fits within the number of bits above.
* init.c (operator_array):  Separate the named operator table into a
macro.  Use it in operator_array.  Test that the values fit within the
number of bits above.



Index: libcpp/directives.c
===
--- libcpp/directives.c (revision 172457)
+++ libcpp/directives.c (working copy)
@@ -137,10 +137,7 @@ static void cpp_pop_definition (cpp_read
pcmcia-cs-3.0.9).  This is no longer important as directive lookup
is now O(1).  All extensions other than #warning, #include_next,
and #import are deprecated.  The name is where the extension
-   appears to have come from.
-
-   Make sure the bitfield directive_index in include/cpplib.h is large
-   enough to index the entire table.  */
+   appears to have come from.  */
 
 #define DIRECTIVE_TABLE
\
 D(define,  T_DEFINE = 0,   KANDR, IN_I)   /* 270554 */ \
@@ -181,6 +178,13 @@ enum
 };
 #undef D
 
+/* Make sure the bitfield directive_index in include/cpplib.h is large
+   enough to index the entire table.  */
+
+unsigned char too_many_directives_for_bitfield[
+N_DIRECTIVES = (1  CPP_HASHNODE_INDEX_BITS)
+? 1 : -1];
+
 #define D(name, t, origin, flags) \
 { do_##name, (const uchar *) #name, \
   sizeof #name - 1, origin, flags },
Index: libcpp/include/cpplib.h
===
--- libcpp/include/cpplib.h (revision 172457)
+++ libcpp/include/cpplib.h (working copy)
@@ -650,12 +650,14 @@ union GTY(()) _cpp_hashnode_value {
   unsigned short GTY ((tag (NTV_ARGUMENT))) arg_index;
 };
 
+#define CPP_HASHNODE_INDEX_BITS 7
+
 struct GTY(()) cpp_hashnode {
   struct ht_identifier ident;
   unsigned int is_directive : 1;
-  unsigned int directive_index : 5;/* If is_directive,
-  then index into directive table.
-  Otherwise, a NODE_OPERATOR.  */
+  unsigned int directive_index : CPP_HASHNODE_INDEX_BITS;
+   /* If is_directive, then index into directive table.
+  Otherwise, a NODE_OPERATOR.  */
   unsigned int used_by_directive : 1;  /* In an active #if, #define etc.  */
   unsigned int expanded_to_text : 1;   /* Produces tokens for parser.  */
   unsigned char rid_code;  /* Rid code - for front ends.  */
Index: libcpp/init.c
===
--- libcpp/init.c   (revision 172457)
+++ libcpp/init.c   (working copy)
@@ -375,23 +375,34 @@ struct builtin_operator
   const unsigned short value;
 };
 
-#define B(n, t){ DSC(n), t }
+#define NAMED_OPER_TABLE \
+  B(and, CPP_AND_AND) \
+  B(and_eq,  CPP_AND_EQ) \
+  B(bitand,  CPP_AND) \
+  B(bitor,   CPP_OR) \
+  B(compl,   CPP_COMPL) \
+  B(not, CPP_NOT) \
+  B(not_eq,  CPP_NOT_EQ) \
+  B(or,  CPP_OR_OR) \
+  B(or_eq,   CPP_OR_EQ) \
+  B(xor, CPP_XOR) \
+  B(xor_eq,  CPP_XOR_EQ) \
+
+#define B(n, t){ DSC(n), t },
 static const struct builtin_operator operator_array[] =
 {
-  B(and, CPP_AND_AND),
-  B(and_eq,  CPP_AND_EQ),
-  B(bitand,  CPP_AND),
-  B(bitor,   CPP_OR),
-  B(compl,   CPP_COMPL),
-  B(not, CPP_NOT),
-  B(not_eq,  CPP_NOT_EQ),
-  B(or,  CPP_OR_OR),
-  B(or_eq,   CPP_OR_EQ),
-  B(xor, CPP_XOR),
-  B(xor_eq,  CPP_XOR_EQ)
+  NAMED_OPER_TABLE
 };
 #undef B
 
+/* Verify that the indicies of the named operators fit within the
+   number of bits available. */
+
+#define B(n, t) unsigned char t ## _too_large_for_bitfield[ \
+   t  (1  CPP_HASHNODE_INDEX_BITS) ? 1 : -1];
+NAMED_OPER_TABLE
+#undef B
+
 /* Mark the C++ named operators in the hash table.  */
 static void
 mark_named_operators (cpp_reader *pfile, int flags)

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


[pph] Clean positive tests. (issue4423044)

2011-04-15 Thread Lawrence Crowl

This patch cleans up positive tests.  First, stop on first failure so
as to avoid littering the logfile.  Second, change the extensions of
the generated assembly files to .s-pph and .s+pph to be clear on the
provenence of each file.


Index: gcc/testsuite/ChangeLog.pph

2011-04-15  Lawrence Crowl  cr...@google.com

* lib/dg-pph.exp (dg-pph-pos): Stop on first failure.  Change names of
assembly files to be clear on which is with and without PPH.


Index: gcc/testsuite/lib/dg-pph.exp
===
--- gcc/testsuite/lib/dg-pph.exp(revision 172457)
+++ gcc/testsuite/lib/dg-pph.exp(working copy)
@@ -74,13 +74,13 @@ proc dg-pph-pos { subdir test options ma
 if { $have_errs } {
verbose -log regular compilation failed
fail $nshort $options, regular compilation failed
-return
+   return
 }
 
 if { ! [ file_on_host exists $bname.s ] } {
-   verbose -log assembly file '$bname.s' missing
-   fail $nshort $options, assembly comparison
-return
+   verbose -log regular assembly file '$bname.s' missing
+   fail $nshort $options, regular assembly missing
+   return
 }
 
 # Rename the .s file into .s-pph to compare it after the second build.
@@ -89,19 +89,33 @@ proc dg-pph-pos { subdir test options ma
 
 # Compile a second time using the pph files.
 dg-test -keep-output $test $options $mapflag -I. 
-remote_upload host $bname.s
+
+if { $have_errs } {
+   verbose -log PPH compilation failed
+   fail $nshort $options, PPH compilation failed
+   return
+}
+
+if { ! [ file_on_host exists $bname.s ] } {
+   verbose -log PPH assembly file '$bname.s' missing
+   fail $nshort $options, PPH assembly missing
+   return
+}
+
+# Rename the .s file into .s+pph to compare it.
+remote_upload host $bname.s $bname.s+pph
+remote_download host $bname.s+pph
 
 # Compare the two assembly files.  They should be identical.
-set tmp [ diff $bname.s $bname.s-pph ]
+set tmp [ diff $bname.s-pph $bname.s+pph ]
 if { $tmp == 0 } {
-verbose -log assembly file '$bname.s', '$bname.s-pph' comparison 
error
-fail $nshort $options assembly comparison
+   verbose -log assembly file '$bname.s-pph', '$bname.s+pph' comparison 
error
+   fail $nshort $options assembly comparison
 } elseif { $tmp == 1 } {
-pass $nshort $options assembly comparison
+   pass $nshort $options assembly comparison
+   file_on_host delete $bname.s-pph
+   file_on_host delete $bname.s+pph
 } else {
-fail $nshort $options assembly comparison
+   fail $nshort $options assembly comparison
 }
-file_on_host delete $bname.s
-file_on_host delete $bname.s-pph
-
 }

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


Re: [pph] Macro Validation Correction (issue4425041)

2011-04-18 Thread Lawrence Crowl
On 4/16/11, Diego Novillo dnovi...@google.com wrote:
 On Apr 14, 2011 Lawrence Crowl cr...@google.com wrote:
  Unfortunately, five bits are not sufficient for the alternate
  use of cpp_hashnode.directive_index as a named operator index.
  So, I have reverted the number of bits from five back to seven.
  As a result, we now have 34 bits in small fields, and the
  size of cpp_hashnode will increase from two to three words on
  32-bit systems.  The size on 64-bit systems remains unchanged
  because these bits go into an alignment gap.

 I don't think this is a big issue.  Tom?

  +/* Make sure the bitfield directive_index in include/cpplib.h is large
  +   enough to index the entire table.  */
  +
  +unsigned char too_many_directives_for_bitfield[
  +N_DIRECTIVES = (1  CPP_HASHNODE_INDEX_BITS)
  +? 1 : -1];

 Heh, I'm not sure what to think of this trick. I think I like
 it, though.

It is used elsewhere in gcc.  I took that use as permission to
reuse the technique.

  +/* Verify that the indicies of the named operators fit within the
  +   number of bits available. */

 s/indicies/indices/

In the queue.

-- 
Lawrence Crowl


[pph] Namespaces, step 1. Trace formatting. (issue4433054)

2011-04-18 Thread Lawrence Crowl

First stab at getting namespaces working with PPH.  This change will
put top-level namespaces into the global namespace.  It does not,
however, appear to their members in any place useful.

Some tuning of tracing output.

Index: gcc/cp/ChangeLog.pph

2011-04-18  Lawrence Crowl cr...@google.com

* pph.c (pth_save_identifiers): Fix FIXME comment.
(pph_add_names_to_namespace): Add contained namespaces to scope as
well as regular symbols.
* pph-streamer.c (enum pph_trace_type): Add a trace for refs.
(pph_stream_trace): Add the ref printing.  Reduce bulk of trace
messages.  Filter off uninteresting traces, primarily traces of null
pointers.
(pph_stream_trace_tree): Convert ref_p to trace value.
* pph-streamer.h: Adjust flag_pph_tracer comparisons for better traces.
(pph_stream_trace_tree): Add ref_p parameter.  Propogate such
parameters at all call sites.
(pph_output_tree_lst): New.  Like pph_output_tree, but for list and
chain contexts.
(pph_stream_write_tree): The callback is auxillary.
(pph_output_chain_filtered): Call pph_output_tree_lst.

Index: libcpp/ChangeLog.pph

2011-04-18  Lawrence Crowl  cr...@google.com

* init.c: Fix spelling in comment.


Index: gcc/cp/pph.c
===
--- gcc/cp/pph.c(revision 172514)
+++ gcc/cp/pph.c(working copy)
@@ -792,7 +792,7 @@ pth_save_identifiers (cpp_idents_used *i
   if (!(entry-used_by_directive || entry-expanded_to_text))
 continue;
 
-  /* FIX pph: We are wasting space; ident_len, used_by_directive
+  /* FIXME pph: We are wasting space; ident_len, used_by_directive
   and expanded_to_text together could fit into a single uint. */
 
   pph_output_uint (stream, entry-used_by_directive);
@@ -1956,6 +1956,21 @@ pph_add_names_to_namespace (tree ns, tre
   chain = DECL_CHAIN (t);
   pushdecl_with_scope (t, level, /*is_friend=*/false);
 }
+
+  for (t = new_level-namespaces; t; t = chain)
+{
+  /* Pushing a decl into a scope clobbers its DECL_CHAIN.
+Preserve it.  */
+  /* FIXME pph: we should first check to see if it isn't already there.  */
+  chain = DECL_CHAIN (t);
+  pushdecl_with_scope (t, level, /*is_friend=*/false);
+  /* FIXME pph: The change above enables the namespace,
+ but its symbols are still missing.
+ The recursive call below causes multiple errors.
+  pph_add_names_to_namespace (t, t);
+  */
+}
+
 }
 
 
Index: gcc/cp/pph-streamer.c
===
--- gcc/cp/pph-streamer.c   (revision 172514)
+++ gcc/cp/pph-streamer.c   (working copy)
@@ -118,6 +118,7 @@ pph_stream_close (pph_stream *stream)
 enum pph_trace_type
 {
 PPH_TRACE_TREE,
+PPH_TRACE_REF,
 PPH_TRACE_UINT,
 PPH_TRACE_BYTES,
 PPH_TRACE_STRING,
@@ -134,11 +135,15 @@ static void
 pph_stream_trace (pph_stream *stream, const void *data, unsigned int nbytes,
  enum pph_trace_type type)
 {
-  const char *op = (stream-write_p) ? write : read;
-  const char *type_s[] = { tree, uint, bytes, string, chain,
+  const char *op = (stream-write_p) ?  : ;
+  const char *type_s[] = { tree, ref, uint, bytes, string, chain,
bitpack };
 
-  fprintf (pph_logfile, *** %s: op=%s, type=%s, size=%u, value=,
+  if ((type == PPH_TRACE_TREE || type == PPH_TRACE_CHAIN)
+   !data  flag_pph_tracer = 3)
+return;
+
+  fprintf (pph_logfile, *** %s: %s%s/%u, value=,
   stream-name, op, type_s[type], (unsigned) nbytes);
 
   switch (type)
@@ -157,6 +162,20 @@ pph_stream_trace (pph_stream *stream, co
   }
   break;
 
+case PPH_TRACE_REF:
+  {
+   const_tree t = (const_tree) data;
+   if (t)
+ {
+   print_generic_expr (pph_logfile, CONST_CAST (union tree_node *, t),
+   0);
+   fprintf (pph_logfile, , code=%s, tree_code_name[TREE_CODE (t)]);
+ }
+   else
+ fprintf (pph_logfile, NULL_TREE);
+  }
+  break;
+
 case PPH_TRACE_UINT:
   {
unsigned int val = *((const unsigned int *) data);
@@ -212,10 +231,10 @@ pph_stream_trace (pph_stream *stream, co
 /* Show tracing information for T on STREAM.  */
 
 void
-pph_stream_trace_tree (pph_stream *stream, tree t)
+pph_stream_trace_tree (pph_stream *stream, tree t, bool ref_p)
 {
   pph_stream_trace (stream, t, t ? tree_code_size (TREE_CODE (t)) : 0,
-   PPH_TRACE_TREE);
+   ref_p ? PPH_TRACE_REF : PPH_TRACE_TREE);
 }
 
 
Index: gcc/cp/pph-streamer.h
===
--- gcc/cp/pph-streamer.h   (revision 172514)
+++ gcc/cp/pph-streamer.h   (working copy)
@@ -93,7 +93,7 @@ enum chain_filter { NONE, NO_BUILTINS };
 /* In pph-streamer.c.  */
 pph_stream

Re: [pph] Namespaces, step 1. Trace formatting. (issue4433054)

2011-04-20 Thread Lawrence Crowl
On 4/20/11, dnovi...@google.com dnovi...@google.com wrote:
 http://codereview.appspot.com/4433054/diff/1/gcc/cp/pph-streamer.c
 File gcc/cp/pph-streamer.c (right):

 http://codereview.appspot.com/4433054/diff/1/gcc/cp/pph-streamer.c#newcode144
 gcc/cp/pph-streamer.c:144: return;
 +  if ((type == PPH_TRACE_TREE || type == PPH_TRACE_CHAIN)
 +   !data  flag_pph_tracer = 3)
 +return;

 Line up the predicates vertically.

Can you be more specific?


 http://codereview.appspot.com/4433054/diff/1/gcc/cp/pph-streamer.c#newcode172
 gcc/cp/pph-streamer.c:172: fprintf (pph_logfile, , code=%s,
 tree_code_name[TREE_CODE (t)]);
 case PPH_TRACE_REF:
 +  {
 + const_tree t = (const_tree) data;
 + if (t)
 +   {
 + print_generic_expr (pph_logfile, CONST_CAST (union tree_node *,
 t),
 + 0);
 + fprintf (pph_logfile, , code=%s, tree_code_name[TREE_CODE (t)]);


 But how are we going to tell if this is a REF instead of a tree?

The type_s array is indexed by PPH_TRACE_REF.

 The output seems identical to the PPH_TRACE_TREE case.

Well, the case in those branches is identical.  The splitting was
a bit preemptive, as I was planning to see what changes I needed
after seeing what items were refs.  None actually were refs, so
the distinction isn't there.

 http://codereview.appspot.com/4433054/diff/1/gcc/cp/pph-streamer.h
 File gcc/cp/pph-streamer.h (right):

 http://codereview.appspot.com/4433054/diff/1/gcc/cp/pph-streamer.h#newcode149
 gcc/cp/pph-streamer.h:149: }
 pph_output_tree_lst (pph_stream *stream, tree t, bool ref_p)
 +{
 +  if (flag_pph_tracer = 2)
 +pph_stream_trace_tree (stream, t, ref_p);
 +  lto_output_tree (stream-ob, t, ref_p);
 +}

 I don't really like all this code duplication.  Wouldn't it be better if
 instead of having pph_output_tree_aux and pph_output_tree_lst, we added
 another argument to pph_output_tree?  The argument would be an enum and
 we could have a default 'DONT_CARE' value.

I'm not sure that would save much code.  It would induce some
runtime overhead (unless the compiler specialized routines).
It would also change the callbacks.

 http://codereview.appspot.com/4433054/diff/1/gcc/cp/pph-streamer.h#newcode298
 gcc/cp/pph-streamer.h:298: pph_stream_trace_tree (stream, t, false); /*
 FIXME pph: always false? */
 @@ -285,7 +295,7 @@ pph_input_tree (pph_stream *stream)
   {
 tree t = lto_input_tree (stream-ib, stream-data_in);
 if (flag_pph_tracer = 4)
 -pph_stream_trace_tree (stream, t);
 +pph_stream_trace_tree (stream, t, false); /* FIXME pph: always
 false?

 Yes, on input we can't tell if we read a reference or a real tree.  We
 could, but not at this level.  That's inside the actual LTO streaming
 code.

It would be nice to have an indication, but it is not something I want
to do now.


 http://codereview.appspot.com/4433054/

-- 
Lawrence Crowl


Re: [patch] Split Parse Timevar (issue4378056)

2011-04-22 Thread Lawrence Crowl
On 4/21/11, Jason Merrill ja...@redhat.com wrote:
 On 04/21/2011 07:17 PM, Lawrence Crowl wrote:
 @@ -1911,7 +1911,7 @@ ggc_collect (void)
 -  timevar_push (TV_GC);
 +  timevar_start (TV_GC);

 Why this change?  GC time shouldn't be counted against whatever we
 happen to be parsing when it happens.

 If not, then code that generates lots of garbage does not get
 charged for the cost to collect it.  I thought it best to separate
 these issues.

 Sure, but the problem is that the collection doesn't always happen in
 the same place that generated most of the garbage.

True, but I expect it usually does.  At any rate, I will revert
the timevar to push/pop.

 +DEFTIMEVAR (TV_PHASE_C_WRAPUP_CHECK  , phase C wrapup  check)
 +DEFTIMEVAR (TV_PHASE_CP_DEFERRED , phase C++ deferred)

 Why do these need to be different timevars?

 The are measuring different things.  They are less different now
 than they were during earlier development.  We can make them the
 same if you want.

 I think we could describe both as language-specific finalization.

Okay.

 +DEFTIMEVAR (TV_PARSE_INMETH  , parser inl. meth. body)

 Is it really important to distinguish this from other functions?

 This distinction is here to help evaluate potential speedup due to
 lazy parsing.  It might make some sense to separate functions and
 inline functions, which also wouldn't have to be parsed immediately.

 That makes sense.  Inlines in the class aren't significantly different
 from inlines outside the class, but inlines are significantly different
 from non-inlines for our purposes.

Do you have a quick hint for how to make that distinction?

 -DEFTIMEVAR (TV_TEMPLATE_INSTANTIATION, template instantiation)
 +DEFTIMEVAR (TV_INSTANTIATE_TEMPLATE  , instantiate template)

 Why these changes?

 Just to shorten the names.

 I'd prefer to keep it in the noun form.

Okay.  This on in particular was making the output wide.

 -DEFTIMEVAR (TV_NAME_LOOKUP   , name lookup)
 -DEFTIMEVAR (TV_OVERLOAD  , overload resolution)
 +DEFTIMEVAR (TV_NAME_LOOKUP   , |name lookup)
 +DEFTIMEVAR (TV_RESOLVE_OVERLOAD  , |overload resolution)

 And here you significantly lengthened one. :)

Ah, but it wasn't the long pole and hence more clarity didn't hurt.

 The | (also in TV_GC) indicates that these vars are collecting
 time concurrently with the other non-phase variables.  It is intended
 to remind readers not to add those times into totals.

 Hmm, I guess that makes sense, but it should be documented.  And perhaps
 move these timevars to the beginning or end so that they don't look like
 subsets of template instantiation.

Okay.

 @@ -564,6 +564,8 @@ compile_file (void)
 +  timevar_start (TV_PHASE_PARSING);

 Why does this happen before...

 +  timevar_push (TV_PARSE_GLOBAL);

 ...this?  I would think the bits in there should be part of _SETUP.

 We could do that, though it would involve splitting the start/stop
 calls into different functions.  That seemed hard to manage.
 As it stands, TV_PHASE_SETUP is entirely before compile_file()
 and TV_PHASE_FINALIZE is entirely after.  Thoughts?

 The code is cleaner the way you have it, but not as correct, as there's
 some initialization being charged to parsing.

Would you prefer moving that initialization out or placing the
start/stop into different routines?

-- 
Lawrence Crowl


Re: [pph] Macro Validation Correction (issue4425041)

2011-04-25 Thread Lawrence Crowl
On 4/22/11, Hans-Peter Nilsson h...@bitrange.com wrote:
 On Sat, 16 Apr 2011, Diego Novillo wrote:
 On Thu, Apr 14, 2011 at 22:01, Lawrence Crowl cr...@google.com wrote:
  +unsigned char too_many_directives_for_bitfield[
  +N_DIRECTIVES = (1  CPP_HASHNODE_INDEX_BITS)
  +? 1 : -1];

 Heh, I'm not sure what to think of this trick. I think I like it, though.

 One up: better make it a declaration: prepend with extern.

I will fold that into my next patch.

-- 
Lawrence Crowl


[pph] Enable nested namespaces (issue4431071)

2011-04-27 Thread Lawrence Crowl


Add a flag -fpph-dump-tree to dump the namespace trees read and written by PPH.
This dump could use some clarification, but it can wait for another day.

Replace PPH calls to pushdecl_with_scope with pushdecl_into_namespace.  It
turns out that pushdecl_with_scope always inserts into the current namespace,
not the given namespace.  Enable recursive call for nested namespace.

The pushdecl_into_namespace function works by saving and restoring
the current namespace around calls to pushdecl_with_scope, There may
be a better way, such as the disabled call to pushdecl_maybe_friend,
available at the time of cleanup.  There are subsequent segfaults still.

Fix formatting of a conditional in pph-streamer.c.

In libcpp/directives.c, make the too_many_directives_for_bitfield
static assert into an extern to avoid allocating storage.

Index: gcc/c-family/ChangeLog.pph

2011-04-20  Lawrence Crowl  cr...@google.com

* c.opt (fpph-dump-tree): Add.

Index: gcc/cp/ChangeLog.pph

2011-04-26  Lawrence Crowl cr...@google.com

* cp-tree.h (pushdecl_into_namespace): Add.
* name-lookup.c (pushdecl_into_namespace): Add.
* pph.c: Add include of tree-dump.h.
(pph_dump_tree_name): Add.
(pph_dump_namespace): Add.
(pph_write_file_contents): Call pph_dump_namespace when appropriate.
(pph_read_file_contents): Call pph_dump_namespace when appropriate.
(pph_add_names_to_namespace): Use pushdecl_into_namespace rather than
pushdecl_with_scope.  Make associated changes.  Enable recursive call
for nested namespace.
* pph-streamer.c (pph_stream_trace): Reformat conditionals.

Index: libcpp/ChangeLog.pph

2011-04-17  Lawrence Crowl  cr...@google.com

* directives.c (too_many_directives_for_bitfield): Make static assert
extern to avoid allocating any storage.


Index: gcc/c-family/c.opt
===
--- gcc/c-family/c.opt  (revision 172998)
+++ gcc/c-family/c.opt  (working copy)
@@ -937,6 +937,10 @@ fpph-decls-debug=
 C++ Joined RejectNegative UInteger Var(flag_pph_decls_debug)
 -fpph-decls=N   Enable declaration identifier output at level N from PPH 
support
 
+fpph-dump-tree
+C++ Var(flag_pph_dump_tree)
+-fpph-dump-treeDump global namespace tree around PPH reads/writes.
+
 fpph-hdr=
 C++ ObjC++ Joined MissingArgError(missing filename after %qs)
 -fpph-hdr=base-name   A mapping from base-name.h to base-name.pph
Index: gcc/cp/pph.c
===
--- gcc/cp/pph.c(revision 172998)
+++ gcc/cp/pph.c(working copy)
@@ -31,6 +31,7 @@ along with GCC; see the file COPYING3.  
 #include fixed-value.h
 #include md5.h
 #include tree-pass.h
+#include tree-dump.h
 #include tree-inline.h
 #include tree-pretty-print.h
 #include parser.h
@@ -1863,12 +1864,65 @@ pth_file_change (cpp_reader *reader, con
 }
 
 
+/* Dump a complicated name for tree T to FILE using FLAGS.
+   See TDF_* in tree-pass.h for flags.  */
+
+static void
+pph_dump_tree_name (FILE *file, tree t, int flags)
+{
+  enum tree_code code = TREE_CODE (t);
+  fprintf (file, %s\t, tree_code_name[code]);
+  if (code == FUNCTION_TYPE || code == METHOD_TYPE)
+{
+  dump_function_to_file (t, file, flags);
+}
+  else
+{
+  print_generic_expr (file, TREE_TYPE (t), flags);
+  /* FIXME pph: fprintf (file,  , cxx_printable_name (t, 0)); */
+  fprintf (file,   );
+  print_generic_expr (file, t, flags);
+}
+  fprintf (file, \n);
+}
+
+
+/* Dump namespace NS for PPH.  */
+
+static void
+pph_dump_namespace (FILE *file, tree ns)
+{
+  struct cp_binding_level *level;
+  tree t, chain;
+  level = NAMESPACE_LEVEL (ns);
+
+  fprintf (file, namespace );
+  print_generic_expr (file, ns, 0);
+  fprintf (file,  {\n);
+  for (t = level-names; t; t = chain)
+{
+  chain = DECL_CHAIN (t);
+  if (!DECL_IS_BUILTIN (t))
+pph_dump_tree_name (file, t, 0);
+}
+  for (t = level-namespaces; t; t = chain)
+{
+  chain = DECL_CHAIN (t);
+  if (!DECL_IS_BUILTIN (t))
+pph_dump_namespace (file, t);
+}
+  fprintf (file, }\n);
+}
+
+
 /* Write PPH output symbols and IDENTS_USED to STREAM as an object.  */
 
 static void
 pph_write_file_contents (pph_stream *stream, cpp_idents_used *idents_used)
 { 
   pth_save_identifiers (idents_used, stream);
+  if (flag_pph_dump_tree)
+pph_dump_namespace (pph_logfile, global_namespace);
   pph_output_tree (stream, global_namespace, false);
 }
 
@@ -1943,34 +1997,26 @@ report_validation_error (const char *fil
 static void
 pph_add_names_to_namespace (tree ns, tree new_ns)
 {
-  struct cp_binding_level *new_level, *level;
   tree t, chain;
+  struct cp_binding_level *level = NAMESPACE_LEVEL (new_ns);
 
-  level = NAMESPACE_LEVEL (ns);
-  new_level = NAMESPACE_LEVEL (new_ns);
-
-  for (t = new_level-names; t; t = chain)
+  for (t = level-names; t; t = chain

Re: [patch] Split Parse Timevar (issue4378056)

2011-04-27 Thread Lawrence Crowl
This discussion continues in the thread
[patch] Split Parse Timevar (rev 2) (issue4433076)
which has a new uploaded patch.

On 4/23/11, Jason Merrill ja...@redhat.com wrote:
 On 04/22/2011 06:41 PM, Lawrence Crowl wrote:
 On 4/21/11, Jason Merrillja...@redhat.com  wrote:
 On 04/21/2011 07:17 PM, Lawrence Crowl wrote:

 That makes sense.  Inlines in the class aren't significantly different
 from inlines outside the class, but inlines are significantly different
 from non-inlines for our purposes.

 Do you have a quick hint for how to make that distinction?

 Check DECL_DECLARED_INLINE_P after we've parsed the declarator.

 -DEFTIMEVAR (TV_TEMPLATE_INSTANTIATION, template instantiation)
 +DEFTIMEVAR (TV_INSTANTIATE_TEMPLATE  , instantiate template)

 Why these changes?

 Just to shorten the names.

 I'd prefer to keep it in the noun form.

 Okay.  This on in particular was making the output wide.

 I wouldn't mind shortening it to TV_TEMPLATE_INST, I just object to the
 change from noun (instantiation) to verb (instantiate).

 The code is cleaner the way you have it, but not as correct, as there's
 some initialization being charged to parsing.

 Would you prefer moving that initialization out or placing the
 start/stop into different routines?

 I think moving the initialization out would be better.

 Jason



-- 
Lawrence Crowl


Re: C++ PATCH for libstdc++/48760 (list-initialization of complex)

2011-04-27 Thread Lawrence Crowl
On 4/27/11, Jason Merrill ja...@redhat.com wrote:
 On 04/27/2011 09:36 PM, Jason Merrill wrote:
 A a = { 1, 2 };

 a.c is initialized to 1+0i rather than 1+2i as it has been previously,

 This should have said a.c is initialized to 1+0i, as it has been
 previously, rather than 1+2i, as it would be if it were an aggregate.

This looks right to me.  It's more in line with C99.

-- 
Lawrence Crowl


[pph] Save/restore PARM_DECL DECL_ARG_TYPE (issue4441079)

2011-04-28 Thread Lawrence Crowl
This patch saves and restores the PARM_DECL DECL_ARG_TYPE in the PPH file.

Index: gcc/cp/ChangeLog.pph

2011-04-28  Lawrence Crowl cr...@google.com

* pph-streamer-out.c (pph_stream_write_tree): Write PARM_DECL
DECL_ARG_TYPE.
* pph-streamer-in.c (pph_stream_read_tree): Read PARM_DECL
DECL_ARG_TYPE.


Index: gcc/cp/pph-streamer-in.c
===
--- gcc/cp/pph-streamer-in.c(revision 173124)
+++ gcc/cp/pph-streamer-in.c(working copy)
@@ -791,6 +791,8 @@ pph_stream_read_tree (struct lto_input_b
  pph_stream_read_lang_specific (stream, expr);
  if (TREE_CODE (expr) == FUNCTION_DECL)
DECL_SAVED_TREE (expr) = pph_input_tree (stream);
+ else if (TREE_CODE (expr) == PARM_DECL)
+   DECL_ARG_TYPE (expr) = pph_input_tree (stream);
}
 
   if (TREE_CODE (expr) == TYPE_DECL)
Index: gcc/cp/pph-streamer-out.c
===
--- gcc/cp/pph-streamer-out.c   (revision 173124)
+++ gcc/cp/pph-streamer-out.c   (working copy)
@@ -796,6 +796,8 @@ pph_stream_write_tree (struct output_blo
 
  if (TREE_CODE (expr) == FUNCTION_DECL)
pph_output_tree_or_ref_1 (stream, DECL_SAVED_TREE (expr), ref_p, 3);
+ else if (TREE_CODE (expr) == PARM_DECL)
+   pph_output_tree_or_ref_1 (stream, DECL_ARG_TYPE (expr), ref_p, 3);
}
 
   if (TREE_CODE (expr) == TYPE_DECL)

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


[pph] DECL_INITIAL instead of DECL_ARG_TYPE (issue4442102)

2011-04-29 Thread Lawrence Crowl
In the pph file, save and restore DECL_INITIAL instead of just
PARM_DECL DECL_ARG_TYPE.

Index: gcc/cp/ChangeLog.pph

2011-04-29  Lawrence Crowl cr...@google.com

* pph-streamer-out.c (pph_stream_write_tree): Write DECL_INITIAL
instead of PARM_DECL DECL_ARG_TYPE.
* pph-streamer-in.c (pph_stream_read_tree): Read DECL_INITIAL
instead of PARM_DECL DECL_ARG_TYPE.

Index: gcc/cp/pph-streamer-in.c
===
--- gcc/cp/pph-streamer-in.c(revision 173189)
+++ gcc/cp/pph-streamer-in.c(working copy)
@@ -783,6 +783,8 @@ pph_stream_read_tree (struct lto_input_b
 
   if (DECL_P (expr))
 {
+  DECL_INITIAL (expr) = pph_input_tree (stream);
+
   if (TREE_CODE (expr) == FUNCTION_DECL
  || TREE_CODE (expr) == NAMESPACE_DECL
  || TREE_CODE (expr) == PARM_DECL
@@ -791,8 +793,6 @@ pph_stream_read_tree (struct lto_input_b
  pph_stream_read_lang_specific (stream, expr);
  if (TREE_CODE (expr) == FUNCTION_DECL)
DECL_SAVED_TREE (expr) = pph_input_tree (stream);
- else if (TREE_CODE (expr) == PARM_DECL)
-   DECL_ARG_TYPE (expr) = pph_input_tree (stream);
}
 
   if (TREE_CODE (expr) == TYPE_DECL)
Index: gcc/cp/pph-streamer-out.c
===
--- gcc/cp/pph-streamer-out.c   (revision 173189)
+++ gcc/cp/pph-streamer-out.c   (working copy)
@@ -787,6 +787,8 @@ pph_stream_write_tree (struct output_blo
 
   if (DECL_P (expr))
 {
+  pph_output_tree_or_ref_1 (stream, DECL_INITIAL (expr), ref_p, 3);
+
   if (TREE_CODE (expr) == FUNCTION_DECL
  || TREE_CODE (expr) == NAMESPACE_DECL
  || TREE_CODE (expr) == PARM_DECL
@@ -796,8 +798,6 @@ pph_stream_write_tree (struct output_blo
 
  if (TREE_CODE (expr) == FUNCTION_DECL)
pph_output_tree_or_ref_1 (stream, DECL_SAVED_TREE (expr), ref_p, 3);
- else if (TREE_CODE (expr) == PARM_DECL)
-   pph_output_tree_or_ref_1 (stream, DECL_ARG_TYPE (expr), ref_p, 3);
}
 
   if (TREE_CODE (expr) == TYPE_DECL)

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


Re: [pph] Save/restore PARM_DECL DECL_ARG_TYPE (issue4441079)

2011-04-29 Thread Lawrence Crowl
On 4/29/11, Diego Novillo dnovi...@google.com wrote:
 On Apr 29, 2011 Richard Guenther richard.guent...@gmail.com wrote:
  On Apr 29, 2011 Lawrence Crowl cr...@google.com wrote:
   This patch saves and restores the PARM_DECL DECL_ARG_TYPE in the
   PPH file.
 
  Should be already streamed via lto_output_ts_decl_common_tree_pointers
  as it is aliased to DECL_INITIAL.

 No, I moved the streaming of DECL_INITIAL to a streamer hook because
 in the gimple case we do more than streaming the initial value.  We
 get the varpool node for the symbol and only stream the initial value
 if we can find it.

 Lawrence, I think we should just simply stream DECL_INITIAL in the
 DECL_P case.  We are missing initializer expressions in every
 variable, otherwise.

Done.  It seems to have fixed one more unexpected failure.

-- 
Lawrence Crowl


Re: [patch] Split Parse Timevar (rev 2) (issue4433076)

2011-05-13 Thread Lawrence Crowl
On 5/13/11, Jason Merrill ja...@redhat.com wrote:
 I'm applying this patch to fix a crash that I get when running cc1plus
 directly without -quiet; all the other TV_OVERLOAD bits use
 timevar_cond_*, so it seems that these should too.

 Tested x86_64-pc-linux-gnu, applying to trunk.

Looks good to me.

-- 
Lawrence Crowl


[pph] Various Tree Fields (issue4550064)

2011-05-20 Thread Lawrence Crowl
Split C++ test x1funcstatic.cc into a C test and a C++ test.
Stream out and in various C++ tree members.

Index: gcc/testsuite/ChangeLog.pph

2011-05-20  Lawrence Crowl  cr...@google.com

* x1funcstatic.h: Rename to c1funcstatic.h, as contents are C only.
* x1funcstatic.c: Use c1funcstatic.h instead of x1funcstatic.h.
* c1funcstatic.c: Add to test C functionality.

Index: gcc/cp/ChangeLog.pph

2011-05-20  Lawrence Crowl cr...@google.com

* pph-streamer-in.c (pph_stream_read_qual_use_vec): Add.
(pph_stream_read_tree_vec_none): Add.
(pph_stream_read_tree): Add read of various C++ fields.
* pph-streamer-out.c (pph_stream_write_qual_use_vec): Add.
(pph_stream_write_tree_vec_none): Add.
(pph_stream_write_tree): Add write of various C++ fields.



Index: gcc/testsuite/g++.dg/pph/c1funcstatic.cc
===
--- gcc/testsuite/g++.dg/pph/c1funcstatic.cc(revision 0)
+++ gcc/testsuite/g++.dg/pph/c1funcstatic.cc(revision 0)
@@ -0,0 +1,2 @@
+#include c1funcstatic.h
+int g() { return f(); }
Index: gcc/testsuite/g++.dg/pph/c1funcstatic.h
===
--- gcc/testsuite/g++.dg/pph/c1funcstatic.h (revision 0)
+++ gcc/testsuite/g++.dg/pph/c1funcstatic.h (revision 0)
@@ -0,0 +1,7 @@
+#ifndef C1FUNCSTATIC_H
+#define C1FUNCSTATIC_H
+static int f() {
+static int x = 3;
+return x++;
+}
+#endif
Index: gcc/testsuite/g++.dg/pph/x1funcstatic.h
===
--- gcc/testsuite/g++.dg/pph/x1funcstatic.h (revision 173763)
+++ gcc/testsuite/g++.dg/pph/x1funcstatic.h (working copy)
@@ -1,7 +0,0 @@
-#ifndef X1FUNCSTATIC_H
-#define X1FUNCSTATIC_H
-static int f() {
-static int x = 3;
-return x++;
-}
-#endif
Index: gcc/testsuite/g++.dg/pph/x1funcstatic.cc
===
--- gcc/testsuite/g++.dg/pph/x1funcstatic.cc(revision 173763)
+++ gcc/testsuite/g++.dg/pph/x1funcstatic.cc(working copy)
@@ -1,2 +1,2 @@
-#include x1funcstatic.h
+#include c1funcstatic.h
 int a = f();
Index: gcc/cp/pph-streamer-in.c
===
--- gcc/cp/pph-streamer-in.c(revision 173763)
+++ gcc/cp/pph-streamer-in.c(working copy)
@@ -224,7 +224,7 @@ pph_stream_read_ld_min (pph_stream *stre
 }
 
 
-/* Read and return a VEC of trees from STREAM.  */
+/* Read and return a gc VEC of trees from STREAM.  */
 
 VEC(tree,gc) *
 pph_stream_read_tree_vec (pph_stream *stream)
@@ -243,6 +243,46 @@ pph_stream_read_tree_vec (pph_stream *st
   return v;
 }
 
+
+/* Read and return a gc VEC of qualified_typedef_usage_t from STREAM.  */
+
+static VEC(qualified_typedef_usage_t,gc) *
+pph_stream_read_qual_use_vec (pph_stream *stream)
+{
+  unsigned i, num;
+  VEC(qualified_typedef_usage_t,gc) *v;
+
+  num = pph_input_uint (stream);
+  v = NULL;
+  for (i = 0; i  num; i++)
+{
+  qualified_typedef_usage_t q;
+  q.typedef_decl = pph_input_tree (stream);
+  q.context = pph_input_tree (stream);
+  /* FIXME pph: also read location.  */
+  VEC_safe_push (qualified_typedef_usage_t, gc, v, q);
+}
+
+  return v;
+}
+
+
+/* Read a trees from STREAM and write into a none VEC v.  */
+
+static VEC(tree,none) *
+pph_stream_read_tree_vec_none (pph_stream *stream, VEC(tree,none) *v)
+{
+  unsigned i, num;
+
+  num = pph_input_uint (stream);
+  VEC_embedded_init (tree, v, num);
+  for (i = 0; i  num; i++)
+VEC_quick_push (tree, v, pph_input_tree (stream));
+
+  return v;
+}
+
+
 /* Forward declaration to break cyclic dependencies.  */
 static struct cp_binding_level *pph_stream_read_binding_level (pph_stream *);
 
@@ -784,6 +824,7 @@ pph_stream_read_tree (struct lto_input_b
   if (DECL_P (expr))
 {
   DECL_INITIAL (expr) = pph_input_tree (stream);
+  /* FIXME pph: DECL_NAME (expr) = pph_input_tree (stream); */
 
   if (TREE_CODE (expr) == FUNCTION_DECL
  || TREE_CODE (expr) == NAMESPACE_DECL
@@ -817,4 +858,57 @@ pph_stream_read_tree (struct lto_input_b
   TYPE_BINFO (expr) = pph_input_tree (stream);
 }
 }
+  else if (TREE_CODE (expr) == OVERLOAD)
+{
+  OVL_FUNCTION (expr) = pph_input_tree (stream);
+}
+  else if (TREE_CODE (expr) == IDENTIFIER_NODE)
+{
+  const char *str;
+  struct lang_identifier *id = LANG_IDENTIFIER_CAST(expr);
+  TREE_TYPE (expr) = pph_input_tree (stream);
+  str = pph_input_string (stream);
+  /* FIXME pph: There must be a better way.  */
+  IDENTIFIER_NODE_CHECK (expr)-identifier.id.str
+  = (const unsigned char *)str;
+  IDENTIFIER_LENGTH (expr) = strlen (str);
+  id-namespace_bindings = pph_stream_read_cxx_binding (stream);
+  id-bindings = pph_stream_read_cxx_binding (stream);
+  id-class_template_info = pph_input_tree (stream);
+  id-label_value

Re: [pph] Various Tree Fields (issue4550064)

2011-05-24 Thread Lawrence Crowl
On 5/20/11, dnovi...@google.com dnovi...@google.com wrote:

 http://codereview.appspot.com/4550064/diff/1/gcc/cp/pph-streamer-in.c
 File gcc/cp/pph-streamer-in.c (right):

 http://codereview.appspot.com/4550064/diff/1/gcc/cp/pph-streamer-in.c#newcode251
 gcc/cp/pph-streamer-in.c:251: {
 +static VEC(qualified_typedef_usage_t,gc) *
 +pph_stream_read_qual_use_vec (pph_stream *stream)
 +{

 This breaks bootstrap.  This function is never used.  I think you meant
 to call it from the TEMPLATE_INFO handler, right?

 Does this look like the right fix?


 diff --git a/gcc/cp/pph-streamer-in.c b/gcc/cp/pph-streamer-in.c
 index d40fd17..c426466 100644
 --- a/gcc/cp/pph-streamer-in.c
 +++ b/gcc/cp/pph-streamer-in.c
 @@ -904,7 +904,7 @@ pph_stream_read_tree (struct lto_input_block *ib
 ATTRIBUTE_UNUSED,
 else if (TREE_CODE (expr) == TEMPLATE_INFO)
   {
 TI_TYPEDEFS_NEEDING_ACCESS_CHECKING (expr)
 -  = pph_stream_read_tree_vec (stream);
 +  = pph_stream_read_qual_use_vec (stream);
   }
 else if (TREE_CODE (expr) == TREE_LIST)
   ; /* FIXME pph: already handled?  */

 http://codereview.appspot.com/4550064/


LGTM

-- 
Lawrence Crowl


[pph] Regularize Streaming (issue4528096)

2011-05-24 Thread Lawrence Crowl
Add a new flag -fpph-untree.

In pph_stream_read_tree and pph_stream_write_tree:

   Refactor from nested if statements to a switch statement.
   Remove handling of TREE_BINFO, as it is redundant.
   For TEMPLATE_DECL, also stream DECL_MEMBER_TEMPLATE_P.
   Report unhandled trees when -fpph-untree.

Remove pph_stream_read_tree_vec_none and pph_stream_write_tree_vec_none,
which are unused with the removal of the handling of TREE_BINFO above.

The code edits do NOT conform with the gcc style.  This is deliberate
so that diff reports sensible differences.  I will make a separate
patch to fix the style.


Index: gcc/c-family/ChangeLog.pph

2011-05-24  Lawrence Crowl  cr...@google.com

* c.opt (fpph-untree): Add.

Index: gcc/cp/ChangeLog.pph

2011-05-24  Lawrence Crowl  cr...@google.com

* pph-streamer-in.c (pph_stream_read_tree): Refactor
from nested if statements to a switch statement.
For TEMPLATE_DECL, also input DECL_MEMBER_TEMPLATE_P.
Report unhandled trees when -fpph-untree.
Add already completely handled trees as separate cases.
(pph_stream_read_tree_vec_none): Remove.
* pph-streamer-out.c (pph_stream_write_tree): Refactor
from nested if statements to a switch statement.
For TEMPLATE_DECL, also output DECL_MEMBER_TEMPLATE_P.
Report unhandled trees when -fpph-untree.
Add already completely handled trees as separate cases.
(pph_stream_write_tree_vec_none): Remove.


Index: gcc/c-family/c.opt
===
--- gcc/c-family/c.opt  (revision 174130)
+++ gcc/c-family/c.opt  (working copy)
@@ -961,6 +961,10 @@ fpph-tracer=
 C++ Joined RejectNegative UInteger Var(flag_pph_tracer)
 -fpph-tracer   Enable tracing of PPH streaming operations
 
+fpph-untree
+C++ Var(flag_pph_untree)
+-fpph-untree   Report unrecognized trees while streaming PPH.
+
 fpreprocessed
 C ObjC C++ ObjC++
 Treat the input file as already preprocessed
Index: gcc/cp/pph-streamer-in.c
===
--- gcc/cp/pph-streamer-in.c(revision 174130)
+++ gcc/cp/pph-streamer-in.c(working copy)
@@ -267,22 +267,6 @@ pph_stream_read_qual_use_vec (pph_stream
 }
 
 
-/* Read a trees from STREAM and write into a none VEC v.  */
-
-static VEC(tree,none) *
-pph_stream_read_tree_vec_none (pph_stream *stream, VEC(tree,none) *v)
-{
-  unsigned i, num;
-
-  num = pph_input_uint (stream);
-  VEC_embedded_init (tree, v, num);
-  for (i = 0; i  num; i++)
-VEC_quick_push (tree, v, pph_input_tree (stream));
-
-  return v;
-}
-
-
 /* Forward declaration to break cyclic dependencies.  */
 static struct cp_binding_level *pph_stream_read_binding_level (pph_stream *);
 
@@ -821,24 +805,45 @@ pph_stream_read_tree (struct lto_input_b
 {
   pph_stream *stream = (pph_stream *) data_in-sdata;
 
-  if (DECL_P (expr))
+  switch (TREE_CODE (expr))
 {
+case DEBUG_EXPR_DECL:
+case IMPORTED_DECL:
+case LABEL_DECL:
+case RESULT_DECL:
   DECL_INITIAL (expr) = pph_input_tree (stream);
+  break;
 
-  if (TREE_CODE (expr) == FUNCTION_DECL
- || TREE_CODE (expr) == NAMESPACE_DECL
- || TREE_CODE (expr) == PARM_DECL
- || LANG_DECL_HAS_MIN (expr))
+case CONST_DECL:
+case FIELD_DECL:
+case NAMESPACE_DECL:
+case PARM_DECL:
+case USING_DECL:
+case VAR_DECL:
{
+  /* FIXME pph: Should we merge DECL_INITIAL into lang_specific? */
+  DECL_INITIAL (expr) = pph_input_tree (stream);
  pph_stream_read_lang_specific (stream, expr);
- if (TREE_CODE (expr) == FUNCTION_DECL)
+  break;
+}
+
+case FUNCTION_DECL:
+{
+  DECL_INITIAL (expr) = pph_input_tree (stream);
+  pph_stream_read_lang_specific (stream, expr);
DECL_SAVED_TREE (expr) = pph_input_tree (stream);
+  break;
}
 
-  if (TREE_CODE (expr) == TYPE_DECL)
+case TYPE_DECL:
+{
+  DECL_INITIAL (expr) = pph_input_tree (stream);
+  pph_stream_read_lang_specific (stream, expr);
DECL_ORIGINAL_TYPE (expr) = pph_input_tree (stream);
+  break;
 }
-  else if (TREE_CODE (expr) == STATEMENT_LIST)
+
+case STATEMENT_LIST:
 {
   HOST_WIDE_INT i, num_trees = pph_input_uint (stream);
   for (i = 0; i  num_trees; i++)
@@ -846,56 +851,90 @@ pph_stream_read_tree (struct lto_input_b
  tree stmt = pph_input_tree (stream);
  append_to_statement_list (stmt, expr);
}
+  break;
 }
-  else if (TYPE_P (expr))
+
+case ARRAY_TYPE:
+case BOOLEAN_TYPE:
+case COMPLEX_TYPE:
+case ENUMERAL_TYPE:
+case FIXED_POINT_TYPE:
+case FUNCTION_TYPE:
+case INTEGER_TYPE:
+case LANG_TYPE:
+case METHOD_TYPE:
+case NULLPTR_TYPE:
+case OFFSET_TYPE:
+case POINTER_TYPE:
+case REAL_TYPE:
+case REFERENCE_TYPE:
+case VECTOR_TYPE:
+case VOID_TYPE

[pph] Reformat (issue4515140)

2011-05-25 Thread Lawrence Crowl
In pph_stream_read_tree and pph_stream_write_tree, reformat for style.
This step was skipped in the last patch to make diffs more sensible.

Index: gcc/cp/ChangeLog.pph

2011-05-25  Lawrence Crowl  cr...@google.com

* pph-streamer-in.c (pph_stream_read_tree): Reformat for style.
* pph-streamer-out.c (pph_stream_write_tree): Reformat for style.


Index: gcc/cp/pph-streamer-in.c
===
--- gcc/cp/pph-streamer-in.c(revision 174166)
+++ gcc/cp/pph-streamer-in.c(working copy)
@@ -820,39 +820,33 @@ pph_stream_read_tree (struct lto_input_b
 case PARM_DECL:
 case USING_DECL:
 case VAR_DECL:
-   {
   /* FIXME pph: Should we merge DECL_INITIAL into lang_specific? */
   DECL_INITIAL (expr) = pph_input_tree (stream);
- pph_stream_read_lang_specific (stream, expr);
+  pph_stream_read_lang_specific (stream, expr);
   break;
-}
 
 case FUNCTION_DECL:
-{
   DECL_INITIAL (expr) = pph_input_tree (stream);
   pph_stream_read_lang_specific (stream, expr);
-   DECL_SAVED_TREE (expr) = pph_input_tree (stream);
+  DECL_SAVED_TREE (expr) = pph_input_tree (stream);
   break;
-   }
 
 case TYPE_DECL:
-{
   DECL_INITIAL (expr) = pph_input_tree (stream);
   pph_stream_read_lang_specific (stream, expr);
-   DECL_ORIGINAL_TYPE (expr) = pph_input_tree (stream);
+  DECL_ORIGINAL_TYPE (expr) = pph_input_tree (stream);
   break;
-}
 
 case STATEMENT_LIST:
-{
-  HOST_WIDE_INT i, num_trees = pph_input_uint (stream);
-  for (i = 0; i  num_trees; i++)
-   {
- tree stmt = pph_input_tree (stream);
- append_to_statement_list (stmt, expr);
-   }
+  {
+HOST_WIDE_INT i, num_trees = pph_input_uint (stream);
+for (i = 0; i  num_trees; i++)
+ {
+   tree stmt = pph_input_tree (stream);
+   append_to_statement_list (stmt, expr);
+ }
+  }
   break;
-}
 
 case ARRAY_TYPE:
 case BOOLEAN_TYPE:
@@ -870,62 +864,48 @@ pph_stream_read_tree (struct lto_input_b
 case REFERENCE_TYPE:
 case VECTOR_TYPE:
 case VOID_TYPE:
-{
   pph_stream_read_lang_type (stream, expr);
   break;
-}
 
 case QUAL_UNION_TYPE:
 case RECORD_TYPE:
 case UNION_TYPE:
-{
-  pph_stream_read_lang_type (stream, expr);
-{
-  TYPE_BINFO (expr) = pph_input_tree (stream);
-}
+  pph_stream_read_lang_type (stream, expr);
+  TYPE_BINFO (expr) = pph_input_tree (stream);
   break;
-}
 
 case OVERLOAD:
-{
   OVL_FUNCTION (expr) = pph_input_tree (stream);
   break;
-}
 
 case IDENTIFIER_NODE:
-{
-  struct lang_identifier *id = LANG_IDENTIFIER_CAST (expr);
-  id-namespace_bindings = pph_stream_read_cxx_binding (stream);
-  id-bindings = pph_stream_read_cxx_binding (stream);
-  id-class_template_info = pph_input_tree (stream);
-  id-label_value = pph_input_tree (stream);
+  {
+struct lang_identifier *id = LANG_IDENTIFIER_CAST (expr);
+id-namespace_bindings = pph_stream_read_cxx_binding (stream);
+id-bindings = pph_stream_read_cxx_binding (stream);
+id-class_template_info = pph_input_tree (stream);
+id-label_value = pph_input_tree (stream);
+  }
   break;
-}
 
 case BASELINK:
-{
   BASELINK_BINFO (expr) = pph_input_tree (stream);
   BASELINK_FUNCTIONS (expr) = pph_input_tree (stream);
   BASELINK_ACCESS_BINFO (expr) = pph_input_tree (stream);
   break;
-}
 
 case TEMPLATE_DECL:
-{
   DECL_INITIAL (expr) = pph_input_tree (stream);
   pph_stream_read_lang_specific (stream, expr);
   DECL_TEMPLATE_RESULT (expr) = pph_input_tree (stream);
   DECL_TEMPLATE_PARMS (expr) = pph_input_tree (stream);
   DECL_CONTEXT (expr) = pph_input_tree (stream);
   break;
-}
 
 case TEMPLATE_INFO:
-{
   TI_TYPEDEFS_NEEDING_ACCESS_CHECKING (expr)
   = pph_stream_read_qual_use_vec (stream);
   break;
-}
 
 case TREE_LIST:
 case TREE_BINFO:
Index: gcc/cp/pph-streamer-out.c
===
--- gcc/cp/pph-streamer-out.c   (revision 174166)
+++ gcc/cp/pph-streamer-out.c   (working copy)
@@ -821,45 +821,39 @@ pph_stream_write_tree (struct output_blo
 case PARM_DECL:
 case USING_DECL:
 case VAR_DECL:
-   {
   /* FIXME pph: Should we merge DECL_INITIAL into lang_specific? */
   pph_output_tree_or_ref_1 (stream, DECL_INITIAL (expr), ref_p, 3);
- pph_stream_write_lang_specific (stream, expr, ref_p);
+  pph_stream_write_lang_specific (stream, expr, ref_p);
   break;
-}
 
 case FUNCTION_DECL:
-{
   pph_output_tree_or_ref_1 (stream, DECL_INITIAL (expr), ref_p, 3);
   pph_stream_write_lang_specific (stream, expr, ref_p

[pph] Clear test commit conflict. (issue4815093)

2011-08-08 Thread Lawrence Crowl
This patch updates tests to clear conflicting commits.

The change needed for x6rtti.cc does not make sense to me.

Tested on x64.


Index: gcc/testsuite/ChangeLog.pph

2011-08-08  Lawrence Crowl  cr...@google.com

* (g++.dg/pph/x6dynarray4.cc): Remove dg-prune-output.
* (g++.dg/pph/x4keyed.cc): Adjust line numbers to conflicting commit.
Remove 'previously defined' match.
* (g++.dg/pph/c3rawstruct.s): Remove inadvertently committed temporary
file.
* (g++.dg/pph/x6dynarray5.h): Add bogus error.
* (g++.dg/pph/x6rtti.cc): Remove dg-bogus lines.  (The errors are
present and bogus, but matching is not working.)
* (g++.dg/pph/x7rtti.cc): Adjust line numbers to conflicting commit.


Index: gcc/testsuite/g++.dg/pph/x6dynarray4.cc
===
--- gcc/testsuite/g++.dg/pph/x6dynarray4.cc (revision 177575)
+++ gcc/testsuite/g++.dg/pph/x6dynarray4.cc (working copy)
@@ -1,6 +1,5 @@
 // { dg-xfail-if BOGUS { *-*-* } { -fpph-map=pph.map } }
 // { dg-bogus error: Cannot open PPH file for reading: x6dynarray5.pph: No 
such file or directory  { xfail *-*-* } 0 }
-// { dg-prune-output In file included from }
 
 #include x6dynarray5.h
 
Index: gcc/testsuite/g++.dg/pph/x4keyed.cc
===
--- gcc/testsuite/g++.dg/pph/x4keyed.cc (revision 177575)
+++ gcc/testsuite/g++.dg/pph/x4keyed.cc (working copy)
@@ -1,6 +1,5 @@
 // { dg-xfail-if BOGUS { *-*-* } { -fpph-map=pph.map } }
-// { dg-bogus a0keyed.h:14:1: error: redefinition of .const char _ZTS5keyed 
[].  { xfail *-*-* } 0 }
-// { dg-bogus a0keyed.h:14:1: error: .const char _ZTS5keyed .7.. previously 
defined here  { xfail *-*-* } 0 }
+// { dg-bogus x0keyed2.h:11:1: error: redefinition of 'const char _ZTS5keyed 
..'  { xfail *-*-* } 0 }
 
 #include x0keyed1.h
 #include x0keyed2.h
Index: gcc/testsuite/g++.dg/pph/c3rawstruct.s
===
--- gcc/testsuite/g++.dg/pph/c3rawstruct.s  (revision 177575)
+++ gcc/testsuite/g++.dg/pph/c3rawstruct.s  (working copy)
@@ -1,80 +0,0 @@
-   .file   c3rawstruct.cc
-   .text
-.globl _Z1gv
-   .type   _Z1gv, @function
-_Z1gv:
-.LFB0:
-   .cfi_startproc
-   .cfi_personality 0x3,__gxx_personality_v0
-   pushq   %rbp
-   .cfi_def_cfa_offset 16
-   movq%rsp, %rbp
-   .cfi_offset 6, -16
-   .cfi_def_cfa_register 6
-   movl$1, -16(%rbp)
-   movl$2, -12(%rbp)
-   movl-16(%rbp), %eax
-   leave
-   ret
-   .cfi_endproc
-.LFE0:
-   .size   _Z1gv, .-_Z1gv
-.globl _Z1hv
-   .type   _Z1hv, @function
-_Z1hv:
-.LFB1:
-   .cfi_startproc
-   .cfi_personality 0x3,__gxx_personality_v0
-   pushq   %rbp
-   .cfi_def_cfa_offset 16
-   movq%rsp, %rbp
-   .cfi_offset 6, -16
-   .cfi_def_cfa_register 6
-   movl$3, -16(%rbp)
-   movl$4, -12(%rbp)
-   movl-12(%rbp), %eax
-   leave
-   ret
-   .cfi_endproc
-.LFE1:
-   .size   _Z1hv, .-_Z1hv
-.globl s
-   .data
-   .align 4
-   .type   s, @object
-   .size   s, 8
-s:
-   .long   5
-   .long   6
-   .text
-.globl main
-   .type   main, @function
-main:
-.LFB2:
-   .cfi_startproc
-   .cfi_personality 0x3,__gxx_personality_v0
-   pushq   %rbp
-   .cfi_def_cfa_offset 16
-   movq%rsp, %rbp
-   .cfi_offset 6, -16
-   .cfi_def_cfa_register 6
-   pushq   %rbx
-   subq$8, %rsp
-   .cfi_offset 3, -24
-   call_Z1gv
-   movl%eax, %ebx
-   call_Z1hv
-   leal(%rbx,%rax), %edx
-   movls(%rip), %eax
-   addl%eax, %edx
-   movls+4(%rip), %eax
-   leal(%rdx,%rax), %eax
-   addq$8, %rsp
-   popq%rbx
-   leave
-   ret
-   .cfi_endproc
-.LFE2:
-   .size   main, .-main
-   .ident  GCC: (Ubuntu 4.4.3-4ubuntu5) 4.4.3
-   .section.note.GNU-stack,,@progbits
Index: gcc/testsuite/g++.dg/pph/x6dynarray5.h
===
--- gcc/testsuite/g++.dg/pph/x6dynarray5.h  (revision 177575)
+++ gcc/testsuite/g++.dg/pph/x6dynarray5.h  (working copy)
@@ -1,5 +1,6 @@
 // { dg-xfail-if BOGUS { *-*-* } { -fpph-map=pph.map } }
 // { dg-bogus a0dynarray-dfn1b.hi:3:19: error: there are no arguments to 
'alloc' that depend on a template parameter, so a declaration of 'alloc' must 
be available  { xfail *-*-* } 0 }
+// { dg-bogus a0dynarray-dfn3b.hi:2:36: error: no 'void 
tst::dynarrayT::check.tst::dynarrayT::size_type.' member function declared 
in class 'tst::dynarrayT'  { xfail *-*-* } 0 }
 
 #ifndef X6DYNARRAY5_H
 #define X6DYNARRAY5_H
Index: gcc/testsuite/g++.dg/pph/x7rtti.cc
===
--- gcc/testsuite/g++.dg/pph/x7rtti.cc  (revision 177575)
+++ gcc

Re: [pph] small multi-pph tests (issue4810074)

2011-08-09 Thread Lawrence Crowl
Let me know if my recent push has not solved this problem.

On 8/5/11, Gabriel Charette gch...@google.com wrote:
 I now get the following test failure output after pulling this patch
 (potentially from the almost concurrent checkin of my linetable
 patch?)

 I can send you my diff's if you need to compare.

 FAIL: g++.dg/pph/c4inline.cc  (assembly comparison, sums 46031=36250)
 FAIL: g++.dg/pph/x1keyed.cc  (assembly comparison, sums 17458=63070)
 FAIL: g++.dg/pph/x1keyno.cc  (assembly comparison, sums 20949=46318)
 XPASS: g++.dg/pph/x4keyed.cc  -fpph-map=pph.map -I.  (test for bogus
 messages, line )
 XPASS: g++.dg/pph/x4keyed.cc  -fpph-map=pph.map -I.  (test for bogus
 messages, line )
 FAIL: g++.dg/pph/x4keyno.cc  (assembly comparison, sums 64958=17472)
 FAIL: g++.dg/pph/x4template.cc  (assembly comparison, sums 23306=52012)
 XPASS: g++.dg/pph/x6rtti.cc  -fpph-map=pph.map -I.  (test for bogus
 messages, line )
 XPASS: g++.dg/pph/x6rtti.cc  -fpph-map=pph.map -I.  (test for bogus
 messages, line )
 XPASS: g++.dg/pph/x7rtti.cc  -fpph-map=pph.map -I.  (test for bogus
 messages, line )
 XPASS: g++.dg/pph/x7rtti.cc  -fpph-map=pph.map -I.  (test for bogus
 messages, line )
 XPASS: g++.dg/pph/x7rtti.cc  -fpph-map=pph.map -I.  (test for bogus
 messages, line )
 XPASS: g++.dg/pph/x7rtti.cc  -fpph-map=pph.map -I.  (test for bogus
 messages, line )
 XPASS: g++.dg/pph/x7rtti.cc  -fpph-map=pph.map -I.  (test for bogus
 messages, line )
 XPASS: g++.dg/pph/x7rtti.cc  -fpph-map=pph.map -I.  (test for bogus
 messages, line )
 XPASS: g++.dg/pph/x7rtti.cc  -fpph-map=pph.map -I.  (test for bogus
 messages, line )
 XPASS: g++.dg/pph/x7rtti.cc  -fpph-map=pph.map -I.  (test for bogus
 messages, line )
 XPASS: g++.dg/pph/x7rtti.cc  -fpph-map=pph.map -I.  (test for bogus
 messages, line )
 XPASS: g++.dg/pph/x7rtti.cc  -fpph-map=pph.map -I.  (test for bogus
 messages, line )
 XPASS: g++.dg/pph/x7rtti.cc  -fpph-map=pph.map -I.  (test for bogus
 messages, line )
 # of expected passes  277
 # of unexpected failures  5
 # of unexpected successes 45
 # of expected failures42

 Gab

 On Fri, Aug 5, 2011 at 11:15 AM, Lawrence Crowl cr...@google.com wrote:
 This patch ads a bunch of small tests for multi-pph includes.

 Tested on x64.


 Index: gcc/testsuite/ChangeLog.pph

 2011-08-04  Lawrence Crowl  cr...@google.com

* g++.dg/pph/README: Add new file types.
* g++.dg/pph/a0expinstinl.h: New.
* g++.dg/pph/a0expinstnin.h: New.
* g++.dg/pph/a0inline.h: New.
* g++.dg/pph/a0keyed.h: New.
* g++.dg/pph/a0keyno.h: New.
* g++.dg/pph/a0noninline.h: New.
* g++.dg/pph/a0nontrivinit.h: New.
* g++.dg/pph/a0rawstruct.h: New.
* g++.dg/pph/a0rtti.h: New.
* g++.dg/pph/a0template.h: New.
* g++.dg/pph/a0tmplclass.h: New.
* g++.dg/pph/a0typedef.h: New.
* g++.dg/pph/a0variables1.h: New.
* g++.dg/pph/a0variables2.h: New.
* g++.dg/pph/c0inline1.h: New.
* g++.dg/pph/c0inline2.h: New.
* g++.dg/pph/c0rawstruct1.h: New.
* g++.dg/pph/c0rawstruct2.h: New.
* g++.dg/pph/c0typedef1.h: New.
* g++.dg/pph/c0typedef2.h: New.
* g++.dg/pph/c0variables.h: Contents to a0variables.h.
Renamed to c0variables1.h.
* g++.dg/pph/c0variables1.h: New.
* g++.dg/pph/c0variables2.h: New.
* g++.dg/pph/c0variables3.h: New.
* g++.dg/pph/c0variables4.h: New.
* g++.dg/pph/c1variables.cc: Handle renaming.
* g++.dg/pph/c3rawstruct.cc: New.
* g++.dg/pph/c3rawstruct.s: New.
* g++.dg/pph/c3typedef.cc: New.
* g++.dg/pph/c3variables.cc: New.
* g++.dg/pph/c4inline.cc: New.
* g++.dg/pph/e0noninline1.h: New.
* g++.dg/pph/e0noninline2.h: New.
* g++.dg/pph/e4noninline.cc: New.
* g++.dg/pph/e4variables.cc: New.
* g++.dg/pph/pph.exp: Add FIXME.
* g++.dg/pph/x0keyed1.h: New.
* g++.dg/pph/x0keyed2.h: New.
* g++.dg/pph/x0keyno1.h: New.
* g++.dg/pph/x0keyno2.h: New.
* g++.dg/pph/x0nontrivinit.h: Contents to a0nontrivinit.h.
Renamed to x0nontrivinit1.h.
* g++.dg/pph/x0nontrivinit1.h: Renamed from x0nontrivinit.h.
* g++.dg/pph/x0nontrivinit2.h: New.
* g++.dg/pph/x0template.h: Contents to a0template.h.
Renamed to x0template1.h.
* g++.dg/pph/x0template1.h: Renamed from x0template.
* g++.dg/pph/x0template2.h: New.
* g++.dg/pph/x0tmplclass.h: Contents to a0tmplclass.h.
Renamed to x0tmplclass1.h.
* g++.dg/pph/x0tmplclass1.h: Renamed from x0tmplclass.h.
* g++.dg/pph/x0tmplclass2.h: New.
* g++.dg/pph/x1keyed.cc: New.
* g++.dg/pph/x1keyno.cc: New.
* g++.dg/pph/x1nontrivinit.cc: Handle renaming.
* g++.dg/pph/x1template.cc: Handle renaming.
* g++.dg/pph/x1tmplclass.cc: Handle renaming.
* g++.dg/pph/x1variables.h: Handle

[pph] Template test upgrade. (issue4864041)

2011-08-10 Thread Lawrence Crowl
This patch adds new well-factored PPH template tests.  In the process,
some old template tests get removed.

Enable the e and z tests for PPH files with unsharable headers.
Add xdiff markers where appropriate.

Compile tests with -fno-dwarf2-cfi-asm to reduce environmental differences.

Tests run on x64.


Index: gcc/testsuite/ChangeLog.pph

2011-08-10  Lawrence Crowl  cr...@google.com

* lib/dg-pph.exp: Compile with -fno-dwarf2-cfi-asm to reduce
environmental differences.
* g++.dg/pph/z0expinstnin1.h: Remove in favor of new tests.
* g++.dg/pph/x0tmplfuncninl3.h: New.
* g++.dg/pph/x0tmplclass12.h: New.
* g++.dg/pph/a0tmplfuncninl_u.h: New.
* g++.dg/pph/x4tmplfuncninl.cc: New.
* g++.dg/pph/z4tmplfuncninl.cc: New.
* g++.dg/pph/x0tmplclass2.h: Remove in favor of new tests.
* g++.dg/pph/x1tmplfunc.cc: Remove in favor of new tests.
* g++.dg/pph/x0tmplfunc.h: Remove in favor of new tests.
* g++.dg/pph/x0tmplfuncinln3.h: New.
* g++.dg/pph/x0template2.h: Remove in favor of new tests.
* g++.dg/pph/z4expinstinl.cc: Remove in favor of new tests.
* g++.dg/pph/x0tmplclass21.h: New.
* g++.dg/pph/a0tmplfuncinln_u.h: New.
* g++.dg/pph/x4tmplfuncinln.cc: New.
* g++.dg/pph/z4tmplfuncinln.cc: New.
* g++.dg/pph/z0expinstnin2.h: Remove in favor of new tests.
* g++.dg/pph/a0template.h: Remove in favor of new tests.
* g++.dg/pph/pph.exp: Enable e and z tests.
* g++.dg/pph/z4tmplclass2.cc: New.
* g++.dg/pph/x0tmplfuncninl4.h: New.
* g++.dg/pph/a0tmplclass2_g.h: New.
* g++.dg/pph/x0tmplclass13.h: New.
* g++.dg/pph/x1template.cc: Remove in favor of new tests.
* g++.dg/pph/a0tmplclass2_s.h: New.
* g++.dg/pph/a0tmplclass1_u.h: New.
* g++.dg/pph/x4tmplclass1.cc: New.
* g++.dg/pph/x0tmplfuncinln4.h: New.
* g++.dg/pph/x1tmplclass.cc: Remove in favor of new tests.
* g++.dg/pph/a0expinstinl.h: Remove in favor of new tests.
* g++.dg/pph/x0tmplclass22.h: New.
* g++.dg/pph/x1tmplfuncninl.cc: New.
* g++.dg/pph/a0tmplclass.h: Remove in favor of new tests.
* g++.dg/pph/x4template.cc: Remove in favor of new tests.
* g++.dg/pph/x1tmplclass1.cc: New.
* g++.dg/pph/z4nontrivinit.cc: Add xdiff.
* g++.dg/pph/e4variables.cc: Add xdiff.
* g++.dg/pph/a0tmplfuncninl_g.h: New.
* g++.dg/pph/x0tmplfuncninl1.h: New.
* g++.dg/pph/z4expinstnin.cc: Remove in favor of new tests.
* g++.dg/pph/a0tmplfuncninl_s.h: New.
* g++.dg/pph/x0tmplclass14.h: New.
* g++.dg/pph/a0expinstnin.h: Remove in favor of new tests.
* g++.dg/pph/x1tmplfuncinln.cc: New.
* g++.dg/pph/z0expinstinl1.h: Remove in favor of new tests.
* g++.dg/pph/a0tmplfuncinln_g.h: New.
* g++.dg/pph/x0tmplfuncinln1.h: New.
* g++.dg/pph/a0tmplfuncinln_s.h: New.
* g++.dg/pph/x0tmplclass23.h: New.
* g++.dg/pph/x4tmplclass2.cc: New.
* g++.dg/pph/x0tmplfuncninl2.h: New.
* g++.dg/pph/a0tmplclass1_g.h: New.
* g++.dg/pph/x0tmplclass11.h: New.
* g++.dg/pph/e4noninline.cc: Remove xdiff.
* g++.dg/pph/a0tmplclass1_s.h: New.
* g++.dg/pph/z0expinstinl2.h: Remove in favor of new tests.
* g++.dg/pph/a0tmplclass2_u.h: New.
* g++.dg/pph/x0tmplclass1.h: Remove in favor of new tests.
* g++.dg/pph/x1tmplclass2.cc: New.
* g++.dg/pph/z4tmplclass1.cc: New.
* g++.dg/pph/x0tmplfuncinln2.h: New.
* g++.dg/pph/x0template1.h: Remove in favor of new tests.
* g++.dg/pph/x0tmplclass24.h: New.


Index: gcc/testsuite/lib/dg-pph.exp
===
--- gcc/testsuite/lib/dg-pph.exp(revision 177632)
+++ gcc/testsuite/lib/dg-pph.exp(working copy)
@@ -54,7 +54,7 @@ proc dg-pph-neg { subdir test options ma
 verbose -log \nTesting $nshort, $options
 
 set dg-do-what-default compile
-dg-test -keep-output $test $options $mapflag -I. 
+dg-test -keep-output $test -fno-dwarf2-cfi-asm $options $mapflag -I. 
 
 if { [file_on_host exists $bname.s] } {
file_on_host delete $bname.s
@@ -76,7 +76,7 @@ proc dg-pph-pos { subdir test options ma
 
 # Compile the file the first time for a base case.
 set dg-do-what-default compile
-dg-test -keep-output $test $options -I. 
+dg-test -keep-output $test -fno-dwarf2-cfi-asm $options -I. 
 
 # Determine whether this is an assembly comparison test
 set is_exec [llength [grep $test dg-do run]]
@@ -102,7 +102,7 @@ proc dg-pph-pos { subdir test options ma
 verbose -log 
 
 # Compile a second time using the pph files.
-dg-test -keep-output $test $options $mapflag -I. 
+dg-test -keep-output $test -fno-dwarf2-cfi-asm $options $mapflag -I. 
 
 if { !$is_asm } {
# No assembly

Re: [cxx-mem-model] alternate fetch operations

2011-08-11 Thread Lawrence Crowl
On 8/11/11, Andrew MacLeod amacl...@redhat.com wrote:
 The __sync_mem_fetch_{add,sub,and,xor,or} routines perform the operation
 atomically, and return the value that was in memory before the operation
 was performed.  As I was working on switching the c++ wrappers to use
 these new routines, I discovered we also need the versions which return
 the *result* of the operation atomically.

You don't need after routines for C++, all the operations can be
implemented on top of before routines.

int add_after(atomicint ai, int i) {
return add_before(ai, i) + i;
}

 I implemented them initially to add a flag to indicate whether we wanted
 the value before or after the operation, but in actual practice it was a
 bit awkward to use and I was not happy with it. Instead, I simply reused
 as much internal code as I could, and added new __sync routines.

 The names for the previous set implies the fetch is done before the
 operation, so the new ones simply drop the fetch and simply use the
 operation name. I found sync_mem_op_fetch slightly less clear.  the new
 routines documentation looks like:

 TYPE __sync_mem_add (TYPE *ptr, TYPE val, int memmodel)
 TYPE __sync_mem_sub (TYPE *ptr, TYPE val, int memmodel)
 TYPE __sync_mem_and (TYPE *ptr, TYPE val, int memmodel)
 TYPE __sync_mem_xor (TYPE *ptr, TYPE val, int memmodel)
 TYPE __sync_mem_or (TYPE *ptr, TYPE val, int memmodel)
   These builtins perform the operation suggested by the name, and
   return the result of the operation. That is,

{ *ptr OP= val; return *ptr; }

   All memory models are valid.

 I also decided to change the testcases around (again).  I merged all the
 different fetch_op tests into one, and added all the new tests.  now
 there is simply 5 tests files sync-mem-op-[1-5].c to test all these
 routines for (1)char, (2)short, (3)int, (4)long long, and (5)__int128_t.

 Bootstrapped and no new regressions on x86-64.  (I am re-verifying
 overnight however).  OK for the branch?

 Andrew




-- 
Lawrence Crowl


[pph] Overload tests and other corrections. (issue4974050)

2011-08-29 Thread Lawrence Crowl
This patch adds new tests for overload resolution.  In contrast to
prior tests, we want these tests to have assembly differences because
PPH binds overloads at header compilation time, not based on accident
of include order.  The test control files change as a consequence.

Changed the compiler command line slightly to make copy/paste searches
easier.

Corrected the keyno test to actually not have a key method.  (There
were incomplete copy/paste/edit actions in the original change.)
However, the incorrect tests were failing for other reasons, and that
test has been preserved as a new test.

Test x7rtti.cc was unresolved because the run test was failing to
compile.  Updated test x7rtti.cc to supress the dg-run, until the
compile problems are fixed.

Tests run on x64.


Index: gcc/testsuite/ChangeLog.pph

2011-08-29   Lawrence Crowl  cr...@google.com

* lib/dg-pph.exp: Move -fno-dwarf2-cfi-asm to end of command line.
Add recognition of pph asm xwant when we desire assembly differences
between pph and non-pph.
* g++.dg/pph/x0keyno1.h: Correct test to not have a key method.
* g++.dg/pph/x0keyno2.h: Likewise.
* g++.dg/pph/x1keyno.cc: Likewise.
* g++.dg/pph/x4keyno.cc: Likewise.
* g++.dg/pph/x4keyex.cc: New.  Add test to capture the broken behavior
in the original key4no.cc.
* g++.dg/pph/x7rtti.cc: Eliminate an unresolved test by turning off
dg-run until the compilation problems are fixed.
* g++.dg/pph/x0resolve1.h: New test for overload behavior.
* g++.dg/pph/x0resolve2.h: Likewise.
* g++.dg/pph/x1resolve1.cc: Likewise.
* g++.dg/pph/x1resolve2.cc: Likewise.
* g++.dg/pph/x4resolve1.cc: Likewise.
* g++.dg/pph/x4resolve2.cc: Likewise.


Index: gcc/testsuite/lib/dg-pph.exp
===
--- gcc/testsuite/lib/dg-pph.exp(revision 178269)
+++ gcc/testsuite/lib/dg-pph.exp(working copy)
@@ -54,7 +54,7 @@ proc dg-pph-neg { subdir test options ma
 verbose -log \nTesting $nshort, $options
 
 set dg-do-what-default compile
-dg-test -keep-output $test -fno-dwarf2-cfi-asm $options $mapflag -I. 
+dg-test -keep-output $test $options $mapflag -I. -fno-dwarf2-cfi-asm 
 
 if { [file_on_host exists $bname.s] } {
file_on_host delete $bname.s
@@ -76,7 +76,7 @@ proc dg-pph-pos { subdir test options ma
 
 # Compile the file the first time for a base case.
 set dg-do-what-default compile
-dg-test -keep-output $test -fno-dwarf2-cfi-asm $options -I. 
+dg-test -keep-output $test $options -I. -fno-dwarf2-cfi-asm 
 
 # Determine whether this is an assembly comparison test
 set is_exec [llength [grep $test dg-do run]]
@@ -102,7 +102,7 @@ proc dg-pph-pos { subdir test options ma
 verbose -log 
 
 # Compile a second time using the pph files.
-dg-test -keep-output $test -fno-dwarf2-cfi-asm $options $mapflag -I. 
+dg-test -keep-output $test $options $mapflag -I. -fno-dwarf2-cfi-asm 
 
 if { !$is_asm } {
# No assembly means we cannot compare them,
@@ -127,16 +127,24 @@ proc dg-pph-pos { subdir test options ma
 
 verbose -log 
 
-# Compare the two assembly files.  They should be identical.
+# Compare the two assembly files.
+# In most tests, they should be identical.
+# Tests involving overload injection and such will have different assembly.
 set adiff [catch {exec diff $bname.s-pph $bname.s+pph} diff_result]
 # The sources mark when they expect the comparison to differ.
+# When marked with xdiff, the difference is a problem.
+# When marked with xwant, the difference is what we want.
 set xdiff_entry [grep $test pph asm xdiff( )*\[0-9\]*]
+set xwant_entry [grep $test pph asm xwant( )*\[0-9\]*]
 set xdiff [llength $xdiff_entry]
+set xwant [llength $xwant_entry]
 if { $adiff == 0 } {
if { $xdiff } {
-   xpass $nshort $options (assembly comparison)
+   xpass $nshort $options (assembly equality)
+   } elseif { $xwant } {
+   fail $nshort $options (assembly difference)
} else {
-   pass $nshort $options (assembly comparison)
+   pass $nshort $options (assembly equality)
}
file_on_host delete $bname.s-pph
file_on_host delete $bname.s+pph
@@ -150,13 +158,21 @@ proc dg-pph-pos { subdir test options ma
if { $xdiff } {
set expectedSum [lindex [split $xdiff_entry  \}] 3]
if { $expectedSum == $actualSum } {
-   xfail $nshort $options (assembly comparison)
+   xfail $nshort $options (assembly equality)
} else {
set sumMessage sums $expectedSum=$actualSum
-   fail $nshort $options (assembly comparison, $sumMessage)
+   fail $nshort $options (assembly equality, $sumMessage)
+   }
+   } elseif { $xwant } {
+   set

[pph] Merge micro tests. (issue4988047)

2011-09-07 Thread Lawrence Crowl
This patch adds new tests for overload resolution.  In contrast to
prior tests, we want these tests to have assembly differences because
PPH binds overloads at header compilation time, not based on accident
of include order.  The test control files change as a consequence.

Changed the compiler command line slightly to make copy/paste searches
easier.

Corrected the keyno test to actually not have a key method.  (There
were incomplete copy/paste/edit actions in the original change.)
However, the incorrect tests were failing for other reasons, and that
test has been preserved as a new test.

Test x7rtti.cc was unresolved because the run test was failing to
compile.  Updated test x7rtti.cc to supress the dg-run, until the
compile problems are fixed.

Tests run on x64.


Index: gcc/testsuite/ChangeLog.pph

2011-09-07   Lawrence Crowl  cr...@google.com

* a0vardef.h: New.
* c0vardef1.h: New.
* x4structover1.cc: New.
* c0vardef2.h: New.
* x0structover1.h: New.
* c4vardef.cc: New.
* x4structover2.cc: New.
* x0structover2.h: New.
* x4resolve1.cc: Add more overloaded calls.
* x4resolve2.cc: Add more overloaded calls.


Index: gcc/testsuite/g++.dg/pph/x4resolve1.cc
===
--- gcc/testsuite/g++.dg/pph/x4resolve1.cc  (revision 178657)
+++ gcc/testsuite/g++.dg/pph/x4resolve1.cc  (working copy)
@@ -1,9 +1,12 @@
-// pph asm xwant 53261
+// pph asm xwant 03374
 
 #include x0resolve1.h
 #include x0resolve2.h
 
 int caller()
 {
-return overloader1() + overloader2();
+int t = intfunc(3l) + fltfunc(2.0);
+t += intfunc(3) + fltfunc(2.0f);
+t += overloader1() + overloader2();
+return t;
 }
Index: gcc/testsuite/g++.dg/pph/a0vardef.h
===
--- gcc/testsuite/g++.dg/pph/a0vardef.h (revision 0)
+++ gcc/testsuite/g++.dg/pph/a0vardef.h (revision 0)
@@ -0,0 +1,4 @@
+#ifndef A0VARDEF_H 
+#define A0VARDEF_H 
+int variable = 1;
+#endif
Index: gcc/testsuite/g++.dg/pph/c0vardef1.h
===
--- gcc/testsuite/g++.dg/pph/c0vardef1.h(revision 0)
+++ gcc/testsuite/g++.dg/pph/c0vardef1.h(revision 0)
@@ -0,0 +1,4 @@
+#ifndef C0VARDEF1_H 
+#define C0VARDEF1_H 
+#include a0vardef.h
+#endif
Index: gcc/testsuite/g++.dg/pph/x4resolve2.cc
===
--- gcc/testsuite/g++.dg/pph/x4resolve2.cc  (revision 178657)
+++ gcc/testsuite/g++.dg/pph/x4resolve2.cc  (working copy)
@@ -1,9 +1,12 @@
-// pph asm xwant 12527
+// pph asm xwant 37643
 
 #include x0resolve2.h
 #include x0resolve1.h
 
 int caller()
 {
-return overloader1() + overloader2();
+int t = intfunc(3l) + fltfunc(2.0);
+t += intfunc(3) + fltfunc(2.0f);
+t += overloader1() + overloader2();
+return t;
 }
Index: gcc/testsuite/g++.dg/pph/x4structover1.cc
===
--- gcc/testsuite/g++.dg/pph/x4structover1.cc   (revision 0)
+++ gcc/testsuite/g++.dg/pph/x4structover1.cc   (revision 0)
@@ -0,0 +1,9 @@
+// { dg-xfail-if BOGUS { *-*-* } { -fpph-map=pph.map } }
+
+
+#include x0structover1.h
+#include x0structover2.h
+
+int func2() {
+return func( (S*)0 );
+}
Index: gcc/testsuite/g++.dg/pph/c0vardef2.h
===
--- gcc/testsuite/g++.dg/pph/c0vardef2.h(revision 0)
+++ gcc/testsuite/g++.dg/pph/c0vardef2.h(revision 0)
@@ -0,0 +1,4 @@
+#ifndef C0VARDEF2_H 
+#define C0VARDEF2_H 
+#include a0vardef.h
+#endif
Index: gcc/testsuite/g++.dg/pph/x0structover1.h
===
--- gcc/testsuite/g++.dg/pph/x0structover1.h(revision 0)
+++ gcc/testsuite/g++.dg/pph/x0structover1.h(revision 0)
@@ -0,0 +1,5 @@
+#ifndef X0STRUCTOVER1_H
+#define X0STRUCTOVER1_H
+#include a0rawstruct.h
+inline int func( S* p ) { if ( p ) return 1; else return 0; }
+#endif
Index: gcc/testsuite/g++.dg/pph/c4vardef.cc
===
--- gcc/testsuite/g++.dg/pph/c4vardef.cc(revision 0)
+++ gcc/testsuite/g++.dg/pph/c4vardef.cc(revision 0)
@@ -0,0 +1,4 @@
+// pph asm xdiff 00553
+
+#include c0vardef1.h
+#include c0vardef2.h
Index: gcc/testsuite/g++.dg/pph/x4structover2.cc
===
--- gcc/testsuite/g++.dg/pph/x4structover2.cc   (revision 0)
+++ gcc/testsuite/g++.dg/pph/x4structover2.cc   (revision 0)
@@ -0,0 +1,6 @@
+#include x0structover2.h
+#include x0structover1.h
+
+int func2() {
+return func( (S*)0 );
+}
Index: gcc/testsuite/g++.dg/pph/x0structover2.h
===
--- gcc/testsuite/g++.dg/pph/x0structover2.h(revision 0)
+++ gcc/testsuite/g++.dg/pph/x0structover2.h(revision 0

Re: [pph] Remove XPASS noise from pph testsuite (issue4967063)

2011-09-12 Thread Lawrence Crowl
And I have confirmed the problem is still here.  I'll be reinserting
the option.

On 9/12/11, Gabriel Charette gcharet...@gmail.com wrote:
 Oops forgot to reply all...

 On Mon, Sep 12, 2011 at 7:40 AM, Diego Novillo dnovi...@google.com wrote:
 This patch removes all the XPASS noise from pph.exp runs by pruning
 the output from the base compiles (thanks Ian for the pointer).  It
 add some comments as well.

 Lawrence, I noticed that we do not seem to need -I. -fno-dwarf2-cfi-asm
 anymore.  So, I removed them.  I'm not sure I remember exactly why you
 had added them, but since removing them produces no changes to the
 results, I just took them out.

 This was a hack because Lawrence was getting different asm checksums
 for the pph asm xdiff because his configuration would output some
 additional dwarf2-cfi assembly. Thus, no single expected diff checksum
 would work for both of us.

 Cheers,
 Gab



-- 
Lawrence Crowl


[pph] Restore -fno-dwarf2-cfi-asm. (issue4992051)

2011-09-12 Thread Lawrence Crowl
Restore compiling the tests with -fno-dwarf2-cfi-asm.  Failure to do
so results in different assembly output on different platforms due to
different assembler support for exceptions.


Index: gcc/testsuite/ChangeLog.pph

2011-09-12   Lawrence Crowl  cr...@google.com

* lib/dg-pph.exp: Restore -fno-dwarf2-cfi-asm option for
stability across platforms.


Index: gcc/testsuite/lib/dg-pph.exp
===
--- gcc/testsuite/lib/dg-pph.exp(revision 178792)
+++ gcc/testsuite/lib/dg-pph.exp(working copy)
@@ -19,10 +19,13 @@
 
 load_lib copy-file.exp
 
+# Options needed for assembly stability across platforms.
+set stable -fno-dwarf2-cfi-asm
+
 # Generate a PPH image from a header file.
 proc dg-pph-hdr { subdir test options mapflag suffix } {
 
-global runtests dg-do-what-default
+global runtests dg-do-what-default stable
 
 # If we're only testing specific files and this isn't one of them, skip it.
 if { ![runtest_file_p $runtests $test] } {
@@ -34,7 +37,7 @@ proc dg-pph-hdr { subdir test options ma
 verbose -log \nTesting $nshort, $options
 
 set dg-do-what-default preparse
-dg-test -keep-output $test -fpph-gen $options $mapflag -I. 
+dg-test -keep-output $test -fpph-gen $options $mapflag $stable 
 
 if { [file_on_host exists $bname.s] } {
file_on_host delete $bname.s
@@ -45,7 +48,7 @@ proc dg-pph-hdr { subdir test options ma
 # as they represent files that are not compatible with PPH.
 proc dg-pph-neg { subdir test options mapflag suffix } {
 
-global runtests dg-do-what-default
+global runtests dg-do-what-default stable
 
 # If we're only testing specific files and this isn't one of them, skip it.
 if { ![runtest_file_p $runtests $test] } {
@@ -57,7 +60,7 @@ proc dg-pph-neg { subdir test options ma
 verbose -log \nTesting $nshort, $options
 
 set dg-do-what-default compile
-dg-test -keep-output $test $options $mapflag -I. -fno-dwarf2-cfi-asm 
+dg-test -keep-output $test $options $mapflag $stable 
 
 if { [file_on_host exists $bname.s] } {
file_on_host delete $bname.s
@@ -71,7 +74,7 @@ proc dg-pph-neg { subdir test options ma
 # assembly outputs are identical.
 proc dg-pph-pos { subdir test options mapflag suffix } {
 
-global runtests dg-do-what-default
+global runtests dg-do-what-default stable
 
 # If we're only testing specific files and this isn't one of them, skip it.
 if { ![runtest_file_p $runtests $test] } {
@@ -109,7 +112,8 @@ proc dg-pph-pos { subdir test options ma
# Now, compile the file but prune the result to avoid considering
# it part of the testsuite.  We just want to compile it to provide
# a base assembly output to compare against.
-   set comp_output [g++-dg-test $test compile $options $other_options]
+set full_options $options $other_options $stable
+   set comp_output [g++-dg-test $test compile $full_options]
set comp_output [g++-dg-prune $target_triplet $comp_output]
 
# Wanted assembly, so quit if it did not compile successfully.
@@ -127,7 +131,7 @@ proc dg-pph-pos { subdir test options ma
 verbose -log 
 
 # Compile a second time using the PPH files.
-dg-test -keep-output $test $options $mapflag 
+dg-test -keep-output $test $options $mapflag $stable 
 
 if { !$is_asm } {
# No assembly means we cannot compare them,

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


[pph] Fix pph_read_tree_header. (issue5050045)

2011-09-17 Thread Lawrence Crowl
Restructure pph_read_tree_header and pph_read_tree to do what their
names say they do.  In particular, generic tree handling from
pph_read_tree_header to pph_read_tree.

Add debugging routines pph_tree_code_text (to avoid out of bounds
indexing on a bad tree code) and pph_dump_min_decl (to dump the
minimal decl information).

Rename the preprocessor lookaside table field pth_debug_level to
debug_level (as PTH is gone).  Adjust thess debug levels to mean
0 == none, 1 == statistics, 2 == verbose.  Adjust the initialization
in pph_init to reflect that.

Tested on x64.


Index: gcc/cp/ChangeLog.pph

2011-09-17   Lawrence Crowl  cr...@google.com

* pph.h (pph_tree_code_text): New.
(pph_dump_min_decl): New.
* pph.c (pph_tree_code_text): New.  Update users of tree_code_name
to call this function instead, here and in other files.
(pph_dump_min_decl): New.
(pph_init): Adjust debug value to preprocessor's value.
* pph-streamer-in.c (pph_read_tree_header): Move work unrelated to
tree headers out of this function.
* (pph_read_tree): Move that work here.
* pt.c (pph_in_spec_entry_htab): Use pph_logfile instead of stderr.
(pph_out_spec_entry_tables): Likewise.
(pph_in_spec_entry_tables): Likewise.

Index: libcpp/ChangeLog.pph

2011-09-17  Lawrence Crowl  cr...@google.com

* internal.h (struct cpp_lookaside): Rename pth_debug_level to
debug_level.
* symtab.c (cpp_lt_create): Likewise.
(cpp_lt_capture): Likewise.
(lt_statistics): Likewise, and change values to 0 == none,
1 == statistics, 2 == verbose.
(lt_query_macro): Likewise.


Index: gcc/cp/pph.c
===
--- gcc/cp/pph.c(revision 178797)
+++ gcc/cp/pph.c(working copy)
@@ -42,6 +42,25 @@ along with GCC; see the file COPYING3.  
-fpph_logfile.  If this flag is not given, stdout is used.  */
 FILE *pph_logfile = NULL;
 
+/* Convert a checked tree_code CODE to a string.  */
+
+const char*
+pph_tree_code_text (enum tree_code code)
+{
+  gcc_assert (code = TEMPLATE_INFO);
+  return tree_code_name[code];
+}
+
+/* Dump identifying information for a minimal DECL to FILE.  */
+
+void
+pph_dump_min_decl (FILE *file, tree decl)
+{
+  expanded_location xloc = expand_location (DECL_SOURCE_LOCATION (decl));
+  print_generic_expr (file, DECL_NAME (decl), 0);
+  print_generic_expr (file, DECL_CONTEXT (decl), 0);
+  fprintf (file, %s:%d, xloc.file, xloc.line);
+}
 
 /* Dump a complicated name for tree T to FILE using FLAGS.
See TDF_* in tree-pass.h for flags.  */
@@ -50,7 +69,7 @@ void
 pph_dump_tree_name (FILE *file, tree t, int flags)
 {
   enum tree_code code = TREE_CODE (t);
-  fprintf (file, %s\t, tree_code_name[code]);
+  fprintf (file, %s\t, pph_tree_code_text (code));
   if (code == FUNCTION_TYPE || code == METHOD_TYPE)
 {
   dump_function_to_file (t, file, flags);
@@ -182,7 +201,7 @@ pph_init (void)
   cb-include = pph_include_handler;
 
   table = cpp_lt_exchange (parse_in,
-   cpp_lt_create (cpp_lt_order, flag_pph_debug));
+   cpp_lt_create (cpp_lt_order, flag_pph_debug/2));
   gcc_assert (table == NULL);
 
   /* If we are generating a PPH file, initialize the writer.  */
Index: gcc/cp/pph.h
===
--- gcc/cp/pph.h(revision 178797)
+++ gcc/cp/pph.h(working copy)
@@ -72,6 +72,8 @@ extern FILE *pph_logfile;
 /* In pph.c  */
 extern void pph_init (void);
 extern void pph_finish (void);
+extern const char *pph_tree_code_text (enum tree_code code);
+extern void pph_dump_min_decl (FILE *file, tree decl);
 extern void pph_dump_tree_name (FILE *file, tree t, int flags);
 extern void pph_dump_namespace (FILE *, tree ns);
 
Index: gcc/cp/pph-streamer-in.c
===
--- gcc/cp/pph-streamer-in.c(revision 178797)
+++ gcc/cp/pph-streamer-in.c(working copy)
@@ -1957,13 +1957,13 @@ pph_read_tree_body (pph_stream *stream, 
 case OPTIMIZATION_NODE:
 case TARGET_OPTION_NODE:
   fatal_error (PPH: unimplemented tree node '%s',
-  tree_code_name[TREE_CODE (expr)]);
+  pph_tree_code_text (TREE_CODE (expr)));
   break;
 
 /* TREES UNRECOGNIZED */
 default:
   fatal_error (PPH: unrecognized tree node '%s',
-   tree_code_name[TREE_CODE (expr)]);
+   pph_tree_code_text (TREE_CODE (expr)));
 }
 }
 
@@ -2007,61 +2007,29 @@ pph_unpack_value_fields (struct bitpack_
 
 
 /* Read a tree header from STREAM and allocate a memory instance for it.
-   Store the new tree in *EXPR_P and write it into the pickle cache at
-   slot IX.
-
-   The return code will indicate whether the caller needs to keep
-   reading the body for *EXPR_P.  Some trees are simple enough that
-   they are completely

[pph] Stream merging information (issue5090041)

2011-09-19 Thread Lawrence Crowl
Prepare for merging symbols.  When writing a cp_binding_level, we emit
this_entity first, so that we can identify the context of the bindings
early.  If this_entity is a namespace, we call alternate routines that
track the namespace.  These ultimately call pph_write_namespace_tree,
which adds additional information needed for decl merging.  Reads take
the corresponding actions.  We do not yet to symbol lookup or merging.

Tested on x64.


Index: gcc/cp/ChangeLog.pph

2011-09-19   Lawrence Crowl  cr...@google.com

* pph-streamer-out.c (pph_out_binding_level_1): Read this_entity first.
Call different routines when it is a namespace.
(pph_write_tree): Move most of body to pph_write_namespace_tree.
(pph_write_namespace_tree): As above.  If there is an enclosing
namespace, write additional information needed for merging.
(pph_out_namespace_tree_vec) New.
(pph_out_namespace_tree_vec_filtered) New.
(pph_write_namespace_chain) New.
(pph_out_namespace_chain_filtered) New.
* pph-streamer-in.c (pph_in_binding_level): Read this_entity first.
Call different routines when it is a namespace.
(pph_read_tree): Move most of body to pph_read_namespace_tree.
(pph_read_namespace_tree): As above.  If there is an enclosing
namespace, read additional information needed for merging.
Merging is currently not done.
(pph_read_namespace_chain): New.
(pph_in_namespace_tree_vec): New.
* pph-streamer.h (pph_write_namespace_tree): New.
(pph_write_namespace_chain): New.
(pph_read_namespace_tree): New.
(pph_read_namespace_chain): New.
(pph_out_namespace_tree_1): New.
(pph_out_namespace_tree): New.
(pph_out_tree_VEC): Deleted, redundant with pph-streamer-out.c.
(pph_out_namespace_chain): New.
(pph_in_namespace_tree): New.
(pph_in_namespace_chain): New.


Index: gcc/cp/pph-streamer-in.c
===
--- gcc/cp/pph-streamer-in.c(revision 178988)
+++ gcc/cp/pph-streamer-in.c(working copy)
@@ -376,6 +376,26 @@ pph_in_tree_vec (pph_stream *stream)
 }
 
 
+/* Read and return a gc VEC of trees in ENCLOSING_NAMESPACE from STREAM.  */
+
+static VEC(tree,gc) *
+pph_in_namespace_tree_vec (pph_stream *stream, tree enclosing_namespace)
+{
+  HOST_WIDE_INT i, num;
+  VEC(tree,gc) *v;
+
+  num = pph_in_hwi (stream);
+  v = NULL;
+  for (i = 0; i  num; i++)
+{
+  tree t = pph_in_namespace_tree (stream, enclosing_namespace);
+  VEC_safe_push (tree, gc, v, t);
+}
+
+  return v;
+}
+
+
 /* Read and return a gc VEC of qualified_typedef_usage_t from STREAM.  */
 
 static VEC(qualified_typedef_usage_t,gc) *
@@ -529,6 +549,7 @@ pph_in_binding_level (pph_stream *stream
   cp_binding_level *bl;
   struct bitpack_d bp;
   enum pph_record_marker marker;
+  tree entity;
 
   marker = pph_in_start_record (stream, image_ix, ix);
   if (marker == PPH_RECORD_END)
@@ -547,13 +568,23 @@ pph_in_binding_level (pph_stream *stream
  ggc_alloc_cleared_cp_binding_level (),
  to_register);
 
-  bl-names = pph_in_chain (stream);
-  bl-namespaces = pph_in_chain (stream);
-
-  bl-static_decls = pph_in_tree_vec (stream);
-
-  bl-usings = pph_in_chain (stream);
-  bl-using_directives = pph_in_chain (stream);
+  entity = bl-this_entity = pph_in_tree (stream);
+  if (NAMESPACE_SCOPE_P (entity))
+{
+  bl-names = pph_in_namespace_chain (stream, entity);
+  bl-namespaces = pph_in_namespace_chain (stream, entity);
+  bl-static_decls = pph_in_namespace_tree_vec (stream, entity);
+  bl-usings = pph_in_namespace_chain (stream, entity);
+  bl-using_directives = pph_in_namespace_chain (stream, entity);
+}
+  else
+{
+  bl-names = pph_in_chain (stream);
+  bl-namespaces = pph_in_chain (stream);
+  bl-static_decls = pph_in_tree_vec (stream);
+  bl-usings = pph_in_chain (stream);
+  bl-using_directives = pph_in_chain (stream);
+}
 
   num = pph_in_uint (stream);
   bl-class_shadowed = NULL;
@@ -574,7 +605,6 @@ pph_in_binding_level (pph_stream *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);
   bl-statement_list = pph_in_chain (stream);
@@ -2042,6 +2072,15 @@ pph_read_tree (struct lto_input_block *i
 {
   /* Find data.  */
   pph_stream *stream = (pph_stream *) root_data_in-sdata;
+  return pph_read_namespace_tree (stream, NULL);
+}
+
+/* Read a tree from the STREAM.  It ENCLOSING_NAMESPACE is not null,
+   the tree may be unified with an existing tree in that namespace.  */
+
+tree
+pph_read_namespace_tree (pph_stream *stream, tree enclosing_namespace)
+{
   struct lto_input_block *ib = stream-encoder.r.ib;
   struct data_in *data_in

[pph] Merge inline function definitions. (issue5677058)

2012-02-15 Thread Lawrence Crowl
This patch merges inline functions where a plain declaration is
read from a pph file after an earlier pph file provides the full
definition.

Making this merge happen required refactoring the several pph
routines.  Ideally, we should have merge versions of the common tree
streamer.  However, we live saving and restoring so as minimize
disruption in the branch.

We add four new tests, x3funcinl12.cc, x3funcinl13.cc, x4funcinl21.cc,
and x4funcinl31.cc to capture the various orders of processing.  The
x3 tests were working.  The x4 tests are now fixed.

Tested on x64.


Index: gcc/testsuite/ChangeLog.pph

2012-02-15   Lawrence Crowl  cr...@google.com

* lib/dg-pph.exp: Clarify kind of test in log file.
* g++.dg/pph/x0funcinl1.h: New.
* g++.dg/pph/x0funcinl2.h: New.
* g++.dg/pph/x0funcinl3.h: New.
* g++.dg/pph/x3funcinl12.cc: New.
* g++.dg/pph/x3funcinl13.cc: New.
* g++.dg/pph/x4funcinl21.cc: New.
* g++.dg/pph/x4funcinl31.cc: New.

Index: gcc/cp/ChangeLog.pph

2012-02-15   Lawrence Crowl  cr...@google.com

* pph-in.c (pph_in_merge_ld_base): Merge odr_used.
(pph_in_lang_indep_tree_body): New, replacing idiom.
(pph_in_merge_lang_indep_tree_body): Decl merge corresponding to above.
(pph_reset_external): New, from refactoring.
(pph_in_tcc_declaration_tail): Moved into pph_in_tcc_declaration.
(pph_in_tcc_declaration): As above.  Factor out pph_reset_external.
(pph_in_nonnull_tree): New.
(pph_in_merge_tcc_declaration): Do serious decl merging.
(pph_in_identifier_bindings): Factor out pph_in_lang_indep_tree_body.
(pph_in_merge_tree_body): Factor out pph_in_lang_indep_tree_body.
Move pph_in_lang_indep_tree_body and TREE_CHAIN save/restore into
pph_in_merge_tcc_declaration.  Do some spacing corrections.


Index: gcc/testsuite/lib/dg-pph.exp
===
--- gcc/testsuite/lib/dg-pph.exp(revision 184170)
+++ gcc/testsuite/lib/dg-pph.exp(working copy)
@@ -34,7 +34,7 @@ proc dg-pph-hdr { subdir test options ma
 
 set nshort $subdir/[file tail $test]
 set bname [file rootname [file tail $nshort]]
-verbose -log \nTesting $nshort, $options
+verbose -log \nTesting header $nshort, $options
 
 set dg-do-what-default preparse
 dg-test -keep-output $test -fpph-gen $options $mapflag $stable 
@@ -57,7 +57,7 @@ proc dg-pph-neg { subdir test options ma
 
 set nshort $subdir/[file tail $test]
 set bname [file rootname [file tail $nshort]]
-verbose -log \nTesting $nshort, $options
+verbose -log \nTesting negative $nshort, $options
 
 set dg-do-what-default compile
 dg-test -keep-output $test $options $mapflag $stable 
@@ -86,7 +86,7 @@ proc dg-pph-pos { subdir test options ma
 set dg-do-what-default compile
 set nshort $subdir/[file tail $test]
 set bname [file rootname [file tail $nshort]]
-verbose -log \nTesting $nshort, $options
+verbose -log \nTesting positive $nshort, $options
 
 # Determine whether this is an assembly comparison test
 set is_exec [llength [grep $test dg-do run]]
Index: gcc/testsuite/g++.dg/pph/x4funcinl21.cc
===
--- gcc/testsuite/g++.dg/pph/x4funcinl21.cc (revision 0)
+++ gcc/testsuite/g++.dg/pph/x4funcinl21.cc (revision 0)
@@ -0,0 +1,7 @@
+#include x0funcinl2.h
+#include x0funcinl1.h
+
+int main()
+{
+return func() + user();
+}
Index: gcc/testsuite/g++.dg/pph/x3funcinl12.cc
===
--- gcc/testsuite/g++.dg/pph/x3funcinl12.cc (revision 0)
+++ gcc/testsuite/g++.dg/pph/x3funcinl12.cc (revision 0)
@@ -0,0 +1,7 @@
+#include x0funcinl1.h
+#include x0funcinl2.h
+
+int main()
+{
+return func() + user();
+}
Index: gcc/testsuite/g++.dg/pph/x0funcinl1.h
===
--- gcc/testsuite/g++.dg/pph/x0funcinl1.h   (revision 0)
+++ gcc/testsuite/g++.dg/pph/x0funcinl1.h   (revision 0)
@@ -0,0 +1,8 @@
+#ifndef X0FUNCINL1_H
+#define X0FUNCINL1_H
+
+inline int func();
+
+extern int user();
+
+#endif
Index: gcc/testsuite/g++.dg/pph/x4funcinl31.cc
===
--- gcc/testsuite/g++.dg/pph/x4funcinl31.cc (revision 0)
+++ gcc/testsuite/g++.dg/pph/x4funcinl31.cc (revision 0)
@@ -0,0 +1,7 @@
+#include x0funcinl3.h
+#include x0funcinl1.h
+
+int main()
+{
+return func() + user();
+}
Index: gcc/testsuite/g++.dg/pph/x0funcinl2.h
===
--- gcc/testsuite/g++.dg/pph/x0funcinl2.h   (revision 0)
+++ gcc/testsuite/g++.dg/pph/x0funcinl2.h   (revision 0)
@@ -0,0 +1,9 @@
+#ifndef X0FUNCINL2_H
+#define X0FUNCINL2_H
+
+inline int func()
+{
+return 3;
+}
+
+#endif
Index: gcc/testsuite/g++.dg/pph/x3funcinl13

Re: [pph] Merge inline function definitions. (issue5677058)

2012-02-16 Thread Lawrence Crowl
On 2/16/12, Diego Novillo dnovi...@google.com wrote:
 With this patch, I'm getting:

 gcc/cp/pph-in.c: In function 'tree_node* pph_in_tree(pph_stream*)':
 gcc/cp/pph-in.c:1694:70: error: 'decl_declared_inline' may be used
 uninitialized in this function
 [-Werror=maybe-uninitialized]gcc/cp/pph-in.c:1644:8: note:
 'decl_declared_inline' was declared here
 gcc/cp/pph-in.c:1683:75: error: 'decl_comdat_group' may be used
 uninitialized in this function
 [-Werror=maybe-uninitialized]gcc/cp/pph-in.c:1643:8: note:
 'decl_comdat_group' was declared here
 gcc/cp/pph-in.c:1682:50: error: 'decl_comdat' may be used
 uninitialized in this function
 [-Werror=maybe-uninitialized]gcc/cp/pph-in.c:1642:8: note:
 'decl_comdat' was declared here
 cc1plus: all warnings being treated as errors
 make: *** [cp/pph-in.o] Error 1

 Could you take a look?

This patch avoids a false used unititalized error by assigning
values soon to be overwritten.

Tested on x64.

Index: gcc/cp/ChangeLog.pph

2012-02-16   Lawrence Crowl  cr...@google.com

* pph-in.c (pph_in_merge_lang_indep_tree_body): Avoid a false used
uninitialized error message.

Index: gcc/cp/pph-in.c
===
--- gcc/cp/pph-in.c (revision 184290)
+++ gcc/cp/pph-in.c (working copy)
@@ -1639,10 +1639,10 @@ static void
 pph_in_merge_lang_indep_tree_body (pph_stream *stream, tree expr)
 {
   enum tree_code code = TREE_CODE (expr);
-  bool decl_comdat;
-  tree decl_comdat_group;
-  bool decl_declared_inline;
-  tree decl_result;
+  bool decl_comdat = false;
+  tree decl_comdat_group = NULL;
+  bool decl_declared_inline = false;
+  tree decl_result = NULL;

   if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS))
 {

-- 
Lawrence Crowl


[pph] Write tree headers for mutated trees (issue5699055)

2012-02-23 Thread Lawrence Crowl
This patch writes the tree header for mutated trees.  This write is
necessary to get updated attribute information from the info bits.
On read, these bits are then merged into the existing tree.

Test x2incomplete4.cc is now generating assembly.  However, it
erroneously generates an inline default constructor.  This error
likely occurs because pph_in_symtab actions are handled after reading
each pph file, rather merged and emitted after all pph files are read.
Diego will address this symtab merge.

Since we are now merging types, this patch includes a fix to more
aggressively trace types.

In addition, there are a couple of fixes to protect against null
pointers.

Tested on x64.


Index: gcc/testsuite/ChangeLog.pph

2012-02-23   Lawrence Crowl  cr...@google.com

* g++.dg/pph/x2incomplete4.cc: Make expected assembley diff.

Index: gcc/cp/ChangeLog.pph

2012-02-23   Lawrence Crowl  cr...@google.com

* pph-core.c (pph_trace_tree): Trace trees as well as decls.
* cp-tree.h (class_of_this_parm): Protect against null type.
* error.c (dump_function_decl): Protect against null type.
* pph-out.c (pph_out_tree): Write tree header for mutated trees.
* pph-in.c (pph_merge_tree_attributes): New.
(pph_in_merge_key_tree): Merge tree attributes.
(pph_in_tree): Read tree header for mutated trees.
Merge their attributes.


Index: gcc/testsuite/g++.dg/pph/x2incomplete4.cc
===
--- gcc/testsuite/g++.dg/pph/x2incomplete4.cc   (revision 184521)
+++ gcc/testsuite/g++.dg/pph/x2incomplete4.cc   (working copy)
@@ -1,5 +1,5 @@
-// { dg-xfail-if ICE { *-*-* } { -fpph-map=pph.map } }
-// { dg-bogus internal compiler error: in import_export_decl, at cp/decl2.c 
 { xfail *-*-* } 0 }
+// pph asm xdiff 21766
+// copies::copies() is wrongly generated
 
 #include x1incomplete3.h
 #include a0incomplete4.cci
Index: gcc/cp/pph-core.c
===
--- gcc/cp/pph-core.c   (revision 184521)
+++ gcc/cp/pph-core.c   (working copy)
@@ -381,7 +381,7 @@ pph_trace_tree (tree t, const char *name
enum pph_trace_end end, enum pph_trace_kind kind)
 {
   char end_char, kind_char, decl_char;
-  bool is_merge, is_decl;
+  bool is_merge, is_decl, is_type;
   bool emit = false;
 
   switch (kind)
@@ -418,6 +418,7 @@ pph_trace_tree (tree t, const char *name
   end_char = end == pph_trace_front ? '{' : '}';
 
   is_decl = DECL_P (t);
+  is_type = TYPE_P (t);
   if (is_decl)
 decl_char = 'D';
   else if (TYPE_P (t))
@@ -425,9 +426,9 @@ pph_trace_tree (tree t, const char *name
   else
 decl_char = '.';
 
-  if (is_merge  is_decl  flag_pph_tracer = 2)
+  if (is_merge  flag_pph_tracer = 2)
 emit = true;
-  else if ((is_merge || is_decl)  flag_pph_tracer = 3)
+  else if ((is_merge || is_decl || is_type)  flag_pph_tracer = 3)
 emit = true;
   else if (!EXPR_P (t)  flag_pph_tracer = 4)
 emit = true;
Index: gcc/cp/error.c
===
--- gcc/cp/error.c  (revision 184521)
+++ gcc/cp/error.c  (working copy)
@@ -1446,8 +1446,13 @@ dump_function_decl (tree t, int flags)
 
   if (TREE_CODE (fntype) == METHOD_TYPE)
{
+ tree type_this = type_of_this_parm (fntype);
+ tree type_class = type_this ? TREE_TYPE (type_this) : NULL;
  pp_base (cxx_pp)-padding = pp_before;
- pp_cxx_cv_qualifier_seq (cxx_pp, class_of_this_parm (fntype));
+ if (type_class)
+   pp_cxx_cv_qualifier_seq (cxx_pp, class_of_this_parm (fntype));
+ else
+   pp_cxx_ws_string (cxx_pp, M_(null));;
}
 
   if (flags  TFF_EXCEPTION_SPECIFICATION)
Index: gcc/cp/pph-out.c
===
--- gcc/cp/pph-out.c(revision 184521)
+++ gcc/cp/pph-out.c(working copy)
@@ -2355,16 +2355,7 @@ pph_out_tree (pph_stream *stream, tree e
 
   if (marker == PPH_RECORD_START || marker == PPH_RECORD_START_MUTATED)
 {
-  /* This is the first time we see EXPR, write it out.  */
-  if (marker == PPH_RECORD_START)
-{
-  /* We only need to write EXPR's header if it needs to be
- re-allocated when reading.  If we are writing the mutated
- state of an existing tree, then we only need to write its
- body.  */
-  pph_out_tree_header (stream, expr);
-}
-
+  pph_out_tree_header (stream, expr);
   pph_out_tree_body (stream, expr);
 }
   else if (marker == PPH_RECORD_START_MERGE_BODY)
Index: gcc/cp/cp-tree.h
===
--- gcc/cp/cp-tree.h(revision 184521)
+++ gcc/cp/cp-tree.h(working copy)
@@ -4836,7 +4836,8 @@ type_of_this_parm (const_tree fntype)
 static inline tree
 class_of_this_parm (const_tree fntype)
 {
-  return TREE_TYPE (type_of_this_parm (fntype));
+  tree

[pph] Merge template specializations. (issue5726044)

2012-03-02 Thread Lawrence Crowl
This patch merges template specializations.

* Factored searching out of pph_in_merge_key_tree via a function
parameter.  Its name is now pph_in_merge_key_tree_with_searcher.  The
decl searching now resides in pph_in_search_key_decl_on_chain and
the type searching now resides in pph_in_search_key_type_in_var.
Added two convenience functions pph_in_merge_key_decl_on_chain and
pph_in_merge_key_type_in_var to enable concise replacement of calls to
pph_in_merge_key_tree..

* Split pph_out/in_global_binding to place the specialization keys
between the global keys and the global bodies.

* Changed the template state in/out functions to be non-specific to
specific tables, but specific to keys or bodies.

* Added strptrmap.h and strptrmap.c for searching for existing
specializations.

* Several routines in pph-out.c and pph-in.c needed for specialization
merging have been made extern for pt.c.


The major test changes are as follows.

* Several ICEs are now gone, most of which are replaced by other
errors.

* More instances of a bogus error on a void atomic intrinsic.

* Unimplemented trait mangling in x6dynarray5.h, which also causes all
includers to fail.

* Test abi/mangle17.C changes behavior.  It emits errors for the an
equivalent but different piece of code.  I will address this problem
later.


Test cleanups are as follows.

* Some compilation failures add a 'documentary' xfail-if.  The syntax
is exactly like dg-xfail-if, but without the dg-.  This change
enables searching for xfail-if.

* Some assembly comparisons add or modify a 'xfail' comment to an
'xfail-if' comment.  This change enables searching for xfail-if.

* The dg-pph.exp test controller now searches for xfail-if rather than
dg-xfail-if to catch expected fails with no exess errors.

* Some tests have had their xfail-if comment string clarified.

* Some tests used dg-excess-errors.  These have been removed in favor
of stating the exact failures.

* Some compilation dg-bogus patterns have been moved to the offending

* Some compilation problems have been isolated to a single line and
statement, which enables the above. line.

* One test has changed trailing include text into a comment.

Tested on x64.


Index: gcc/testsuite/ChangeLog.pph

2012-03-01   Lawrence Crowl  cr...@google.com

* lib/dg-pph.exp: Change search for dg-xfail-if to xfail-if.
* g++.dg/pph/d0include-next.h: Put dg-warning in comment.
* g++.dg/pph/x2incomplete4.cc: Add documentary xfail-if.
* g++.dg/pph/x4incomplete4321.cc: Change documentary to xfail-if.
* g++.dg/pph/x4tmplclass2.cc: Change documentary to xfail-if.
* g++.dg/pph/x4tmplfuncinln.cc: Mark pph asm xokay.
* g++.dg/pph/x4tmplfuncninl.cc: Mark pph asm xokay.
* g++.dg/pph/x5dynarray7.h: Add documentary xfail-if.
* g++.dg/pph/x6dynarray3.cc: Add documentary xfail-if.
* g++.dg/pph/x6dynarray4.cc: Change to xfail on included pph.
* g++.dg/pph/x6dynarray5.h: Change to xfail on included pph.
* g++.dg/pph/x6dynarray6.h: Add documentary xfail-if.
* g++.dg/pph/x6rtti.cc: Remove excess-errors filter.  Add bogus rtti 
mismatch.  Make xfail-if documentary.
* g++.dg/pph/x7dynarray5.cc: Change to xfail on included pph.  (The 
bogus void intrinsic comes fail-over to reading the textual header.)
* g++.dg/pph/x7dynarray6.cc: Change to xfail on bogus void intrinsic.
* g++.dg/pph/x7dynarray7.cc: Remove excess-errors filter.  Add bogus 
void intrinsic.  Change xfail-if message.
* g++.dg/pph/x7rtti.cc: Add documentary xfail-if.  Separate failures to 
separate statements.  Put dg-bogus on offending lines.
* g++.dg/pph/z4nontrivinit.cc: Change documentary to xfail-if.
* g++.dg/pph/z4tmplclass1.cc: Change in failing asm output.  Change 
documentary to xfail-if.
* g++.dg/pph/z4tmplclass2.cc: Change in failing asm output.  Change 
documentary to xfail-if.
* g++.dg/pph/z4tmplfuncinln.cc: Mark pph asm xokay.
* g++.dg/pph/z4tmplfuncninl.cc: Mark pph asm xokay.

Index: gcc/cp/ChangeLog.pph

2012-03-01   Lawrence Crowl  cr...@google.com

* pph-core.c (pph_include_handler): Make warning message a single line.
* Make-lang.in (cp/pt.o): Depend on strptrmap.h.
* pph.h (pph_out_merge_key_tree): Made extern.
(pph_in_string): Made extern.
(typedef pph_merge_searcher): New.
(pph_in_merge_key_tree_with_searcher): Made extern.
(pph_out_pending_templates_list): Removed.
(pph_out_spec_entry_tables): Removed.
(pph_in_pending_templates_list): Removed.
(pph_in_spec_entry_tables): Removed.
(pph_out_merge_key_template_state): New.
(pph_out_merge_body_template_state): New.
(pph_in_merge_key_template_state): New.
(pph_in_merge_body_template_state): New.
* pt.c (#include strptrmap.h): New.
(pph_out_pending_templates_list): Move dump to higher level

[pph] Merge fields and methods, etc. (issue5781061)

2012-03-08 Thread Lawrence Crowl
This patch provides three primary fixes.

* Merge structure fields and methods.

This merging is necessary because a field or method declaration may be
updated with a definition.

Tests x4keyed.cc, x4keyex.cc, and x4keyno.cc expose a problem with
callgraphs and are no longer passing.  Test x7rtti.cc exposes the same
problem, but it was not passing before.

Test x4incomplete4321.cc exposes a problem with gimple expansion, but
it was not passing before.

Test x4incomplete4123.cc newly fails emitting an unneeded function.

Tests x4tmplclass2.cc, z4tmplclass1.cc, and z4tmplclass2.cc newly pass.

* Distinguish template type parameters in error output.

The problem here is that the merge names were the same for different
types.  The change was to add the source location information as a
qualifier to the template parameter name in error pretty printing.
Control this with a TFF flag.

New tests x0dependent.h and x1dependent.cc pass.

* Remove gcc_assert in mangle.c added in the last patch.

We restore this assert mostly to reduce any future client merge
burden.

Test x6dynarray5.cc now fails differently


In addition there are some infrastructure changes.

* Add capability to add notes to the trace output.  This capability is
used to emit merge names into the trace.

* Add functions pph_out_struct_function_for_decl and
pph_out_cgraph_node_for_decl to provide a better debugging handle on
symtab expansion.


Index: gcc/testsuite/ChangeLog.pph

2012-03-07   Lawrence Crowl  cr...@google.com

* g++.dg/pph/x0dependent.h: New.
* g++.dg/pph/x1dependent.cc: New.
* g++.dg/pph/x4incomplete4123.cc: Mark xdiff on extra function.
* g++.dg/pph/x4incomplete4321.cc: Mark ICE on gimple.
* g++.dg/pph/x4keyed.cc: Mark ICE on cgraph.
* g++.dg/pph/x4keyex.cc: Mark ICE on cgraph.
* g++.dg/pph/x4keyno.cc: Mark ICE on cgraph.
* g++.dg/pph/x4tmplclass1.cc: Mark change in labels.
* g++.dg/pph/x4tmplclass2.cc: Mark xokay.
* g++.dg/pph/x6dynarray5.cc: Mark different ICE.
* g++.dg/pph/x7rtti.cc: Mark ICE on cgraph.
* g++.dg/pph/z4tmplclass1.cc: Mark xokay.
* g++.dg/pph/z4tmplclass2.cc: Mark xokay.

Index: gcc/cp/ChangeLog.pph

2012-03-07   Lawrence Crowl  cr...@google.com

* cp-tree.h (TFF_LOC_FOR_TEMPLATE_PARMS): New.
* error.c (dump_location_qualifier): New.
(dump_type): Add source location qualifier to template type parameter
identifiers.
* mangle.c (write_template_arg_literal): Revert to prior code.
* pph-streamer.h (pph_trace_note): New.
* pph-core.c (pph_trace_note): New.
* pph-out.c (pph_out_struct_function_for_decl): New.
(pph_out_cgraph_node_for_decl): New.
(pph_out_symtab): Update to use functions above.
(pph_merge_name): Add TFF_LOC_FOR_TEMPLATE_PARMS for pretty name.
(pph_out_merge_name): Trace merge names.
(pph_out_merge_key_tree): Emit merge keys for class fields and methods.
* pph-in.c (pph_in_merge_key_tree_with_searcher): Merge in keys for
class fields and methods.


Index: gcc/testsuite/g++.dg/pph/x4keyno.cc
===
--- gcc/testsuite/g++.dg/pph/x4keyno.cc (revision 184901)
+++ gcc/testsuite/g++.dg/pph/x4keyno.cc (working copy)
@@ -1,4 +1,7 @@
-// pph asm xokay 32642
+// { dg-xfail-if ICE { *-*-* } { -fpph-map=pph.map } }
+// { dg-bogus x4keyno.cc:13:1: internal compiler error: in 
cgraph_analyze_functions, at cgraphunit.c:1210  { xfail *-*-* } 0 }
+
+// was asm xokay 32642
 
 #include x0keyno1.h
 #include x0keyno2.h
Index: gcc/testsuite/g++.dg/pph/x6dynarray5.h
===
--- gcc/testsuite/g++.dg/pph/x6dynarray5.h  (revision 184901)
+++ gcc/testsuite/g++.dg/pph/x6dynarray5.h  (working copy)
@@ -3,7 +3,7 @@
 // { dg-bogus bits/allocator.h:153:12: sorry, unimplemented: mangling 
trait_expr  { xfail *-*-* } 0 }
 // { dg-bogus bits/stl_construct.h:98:12: sorry, unimplemented: mangling 
trait_expr  { xfail *-*-* } 0 }
 // { dg-bogus bits/stl_tempbuf.h:183:12: sorry, unimplemented: mangling 
trait_expr  { xfail *-*-* } 0 }
-// { dg-bogus bits/cpp_type_traits.h:87:12: internal compiler error: in 
write_template_arg_literal, at cp/mangle.c:2919  { xfail *-*-* } 0 }
+// { dg-bogus bits/cpp_type_traits.h:87:12: internal compiler error: tree 
check: expected integer_cst, have const_decl in tree_int_cst_sgn, at 
tree.c:6567  { xfail *-*-* } 0 }
 
 #ifndef X6DYNARRAY5_H
 #define X6DYNARRAY5_H
Index: gcc/testsuite/g++.dg/pph/x7rtti.cc
===
--- gcc/testsuite/g++.dg/pph/x7rtti.cc  (revision 184901)
+++ gcc/testsuite/g++.dg/pph/x7rtti.cc  (working copy)
@@ -1,7 +1,8 @@
-// {xfail-if UNKNOWN MACRO AND BOGUS RTTI { *-*-* } { 
-fpph-map=pph.map } }
-// { dg-bogus x7rtti.cc:9:0: warning: .__STDC_IEC_559_COMPLEX__. redefined 
 { xfail

[pph] System Headers. Nested Types. (issue5797052)

2012-03-09 Thread Lawrence Crowl
Disable warning when a system header is a primary compilation file.
This change is necessary when creating a PPH file from a system
header.  The change adds and option -fprimary-system-header-okay and
implicitly sets it when a PPH output file is specified.  Added tests
x0sysheader.h and x1sysheader.cc.

Prepare for merging the lang_type in classes to support merging
types nested within classes.  The change adds some merging routines,
but only the bitsets are actually merged, and there is no effect
on existing tests.  Added tests x0neststruct1.h, x0neststruct2.h,
x4neststruct1.cc, and x4neststruct2.cc.  The latter test demonstrates
the problem with a failure.

Tested on x64.


Index: gcc/c-family/ChangeLog.pph

2012-03-09   Lawrence Crowl  cr...@google.com

* c.opt (-fprimary-system-header-okay): New.
* c-opts.c (c_common_handle_option): Add handling for
-fprimary-system-header-okay.  Make PPH output imply this option.

Index: gcc/cp/ChangeLog.pph

2012-03-09   Lawrence Crowl  cr...@google.com

* name-lookup.c (pph_out_binding_table): Correct comment.
(pph_in_binding_table): Correct comment.
* pph-out.c (pph_out_lang_type_class_bits): New.
(pph_out_lang_type_class): Factor out the bitpack writing into
pph_out_lang_type_class_bits.
(pph_out_merge_key_lang_type_class): New.
(pph_out_merge_key_lang_type): New.
(pph_out_merge_key_tree): Also emit merge key for lang_type for classes.
* pph-in.c (typedef merge_toc_entry): Generalize context.
(pph_toc_lookup_add): New.
(pph_merge_into_chain): Factor out TOC lookup and add to
pph_toc_lookup_add.
(pph_in_merge_lang_type_class_bits): New.
(pph_in_lang_type_class): Factor out the bitpack reading into
pph_in_merge_lang_type_class_bits.
(pph_in_merge_key_lang_type_class): New.
(pph_in_merge_key_lang_type): New.
(pph_in_merge_key_tree_with_searcher): Also merge key for lang_type
for classes.

Index: libcpp/ChangeLog.pph

2012-03-09   Lawrence Crowl  cr...@google.com

* include/cpplib.h (struct cpp_options): Add option to supress warning
about a system header as a primary file.
* directives.c (do_pragma_system_header): Implement the effect of the
above option.


Index: gcc/c-family/c.opt
===
--- gcc/c-family/c.opt  (revision 185111)
+++ gcc/c-family/c.opt  (working copy)
@@ -1017,6 +1017,10 @@ fpreprocessed
 C ObjC C++ ObjC++
 Treat the input file as already preprocessed
 
+fprimary-system-header-okay
+C ObjC C++ ObjC++
+Supress warning about compiling a primary system header file.
+
 ftrack-macro-expansion
 C ObjC C++ ObjC++ JoinedOrMissing RejectNegative UInteger
 ; converted into ftrack-macro-expansion=
Index: gcc/c-family/c-opts.c
===
--- gcc/c-family/c-opts.c   (revision 185111)
+++ gcc/c-family/c-opts.c   (working copy)
@@ -385,6 +385,7 @@ c_common_handle_option (size_t scode, co
 
 case OPT__output_pph_:
   pph_out_file = arg;
+  cpp_opts-primary_system_header_okay = true;
   break;
 
 case OPT_A:
@@ -803,6 +804,10 @@ c_common_handle_option (size_t scode, co
   add_pph_include_maps (arg);
   break;
 
+case OPT_fprimary_system_header_okay:
+  cpp_opts-primary_system_header_okay = true;
+  break;
+
 case OPT_idirafter:
   add_path (xstrdup (arg), AFTER, 0, true);
   break;
Index: gcc/cp/pph-out.c
===
--- gcc/cp/pph-out.c(revision 185112)
+++ gcc/cp/pph-out.c(working copy)
@@ -1691,10 +1691,10 @@ pph_out_sorted_fields_type (pph_stream *
 }
 
 
-/* Write all the fields in lang_type_class instance LTC to STREAM.  */
+/* Write all the packed bits in lang_type_class instance LTC to STREAM.  */
 
 static void
-pph_out_lang_type_class (pph_stream *stream, struct lang_type_class *ltc)
+pph_out_lang_type_class_bits (pph_stream *stream, struct lang_type_class *ltc)
 {
   struct bitpack_d bp;
 
@@ -1745,7 +1745,15 @@ pph_out_lang_type_class (pph_stream *str
   bp_pack_value (bp, ltc-has_complex_move_assign, 1);
   bp_pack_value (bp, ltc-has_constexpr_ctor, 1);
   pph_out_bitpack (stream, bp);
+}
+
 
+/* Write all the fields in lang_type_class instance LTC to STREAM.  */
+
+static void
+pph_out_lang_type_class (pph_stream *stream, struct lang_type_class *ltc)
+{
+  pph_out_lang_type_class_bits (stream, ltc);
   pph_out_tree (stream, ltc-primary_base);
   pph_out_tree_pair_vec (stream, ltc-vcall_indices);
   pph_out_tree (stream, ltc-vtables);
@@ -1774,6 +1782,16 @@ pph_out_lang_type_class (pph_stream *str
 }
 
 
+/* Write all the merge key fields in lang_type_class instance LTC to STREAM.  
*/
+
+static void
+pph_out_merge_key_lang_type_class (pph_stream *stream,
+  struct

[pph] add tests and -fpph-check (issue5820069)

2012-03-15 Thread Lawrence Crowl
This patch mostly adds several test cases reduced from full-scale attempts to
use PPH.

  c?anonymous* -- problems handling anonymous/tagless types
  c?features* -- problems with benign macro redefinitions
  x?tmpldfltparm* -- inappropriately merging default template arguments

It also add an option -fpph-check to refine our check for headers compatible
with PPH.  It implies -fprimary-system-header-okay and checks for the main
source file missing a guard.  Generating a pph file implies the same check.

Tested on x64.


Index: gcc/c-family/ChangeLog.pph

2012-03-15   Lawrence Crowl  cr...@google.com

* c.opt (-fpph-check): New.
* c-opts.c (c_common_handle_option): Add OPT_fpph_check.
(case OPT__output_pph_): Also imply -fpph-check.
* c-common.h (bool pph_check_main_missing_guard): New.
* c-common.c (bool pph_check_main_missing_guard): New.
(const char *pph_out_file): Explicitly initialize to NULL.

Index: gcc/testsuite/ChangeLog.pph

2012-03-15   Lawrence Crowl  cr...@google.com

* g++.dg/pph/c0anonymous.h: New.
* g++.dg/pph/c1anonymous1.h: New.
* g++.dg/pph/c1anonymous2.h: New.
* g++.dg/pph/c5features1.h: New.
* g++.dg/pph/c5features2.h: New.
* g++.dg/pph/c7features.cc: New.
* g++.dg/pph/d8dupguard.cc: Add xfail-if comment.
* g++.dg/pph/x0tmpldfltparm.h: New.
* g++.dg/pph/x1tmpldfltparm.cc: New.
* g++.dg/pph/y9overload.cc: Add xfail-if comment.

Index: gcc/cp/ChangeLog.pph

2012-03-15   Lawrence Crowl  cr...@google.com

* pph.h (pph_check_main_guarded): New.
* pph-core.c (pph_check_main_guarded): New.
* pph-out.c (pph_writer_finish): Factor out guard check into
pph_check_main_guarded.
* parser.c (c_parse_file): Add guard check for non-pph compiles.


Index: gcc/c-family/c.opt
===
--- gcc/c-family/c.opt  (revision 185442)
+++ gcc/c-family/c.opt  (working copy)
@@ -981,6 +981,10 @@ fplan9-extensions
 C ObjC Var(flag_plan9_extensions)
 Enable Plan 9 language extensions
 
+fpph-check
+C++
+-fpph-checkCheck a header for minimal compatibility with PPH.
+
 fpph-debug=
 C++ Joined RejectNegative UInteger Var(flag_pph_debug)
 -fpph-debug=N   Enable debugging output at level N from PPH support
Index: gcc/c-family/c-opts.c
===
--- gcc/c-family/c-opts.c   (revision 185442)
+++ gcc/c-family/c-opts.c   (working copy)
@@ -404,6 +404,7 @@ c_common_handle_option (size_t scode, co
 case OPT__output_pph_:
   pph_out_file = arg;
   cpp_opts-primary_system_header_okay = true;
+  pph_check_main_missing_guard = true;
   break;
 
 case OPT_A:
@@ -814,6 +815,11 @@ c_common_handle_option (size_t scode, co
   set_struct_debug_option (global_options, loc, arg);
   break;
 
+case OPT_fpph_check:
+  cpp_opts-primary_system_header_okay = true;
+  pph_check_main_missing_guard = true;
+  break;
+
 case OPT_fpph_hdr_:
   add_pph_header_map (arg);
   break;
Index: gcc/c-family/c-common.c
===
--- gcc/c-family/c-common.c (revision 185442)
+++ gcc/c-family/c-common.c (working copy)
@@ -194,7 +194,11 @@ const char *pch_file;
 /* The file name to which we should write a preparsed header, or
NULL if no header will be written in this compile.  */
 
-const char *pph_out_file;
+const char *pph_out_file = NULL;
+
+/* Whether or not we should check for a guard on the main input file.  */
+
+bool pph_check_main_missing_guard = false;
 
 /* Nonzero if an ISO standard was selected.  It rejects macros in the
user's namespace.  */
Index: gcc/c-family/c-common.h
===
--- gcc/c-family/c-common.h (revision 185442)
+++ gcc/c-family/c-common.h (working copy)
@@ -585,6 +585,10 @@ extern const char *pch_file;
 
 extern const char *pph_out_file;
 
+/* Whether or not we should check for a guard on the main input file.  */
+
+extern bool pph_check_main_missing_guard;
+
 /* Return true if we have any map from INCLUDE to PPH file.  */
 
 extern bool
Index: gcc/testsuite/g++.dg/pph/c1anonymous1.h
===
--- gcc/testsuite/g++.dg/pph/c1anonymous1.h (revision 0)
+++ gcc/testsuite/g++.dg/pph/c1anonymous1.h (revision 0)
@@ -0,0 +1,11 @@
+// {xfail-if ANONYMOUS MERGING { *-*-* } { -fpph-map=pph.map } }
+// { dg-bogus c0anonymous.h:4:16: error: 'anon_t' has a previous declaration 
here  { xfail *-*-* } 0 }
+
+#ifndefC1ANONYMOUS
+#defineC1ANONYMOUS
+
+#include c0anonymous.h
+
+enum { first, second }; // { dg-bogus 'anon_t' referred to as enum  { 
xfail *-*-* } }
+
+#endif
Index: gcc/testsuite/g++.dg/pph/c1anonymous2.h

[pph] Tagless Types; Macro Redefines (issue5846054)

2012-03-16 Thread Lawrence Crowl
This patch addresses two main problems.

(1) We were mishandling tagless types.  The root of the problem was that
tagless types were given tags based on a sequence number.  Two different PPH
files would thus have the same manufactured tag name for different types,
leading to inappropriate collisions in lookup.  The solution is to manufacture
the tag from the source location rather than from a sequence number.  All of
this construction must match the pattern when the name is later strcmp'ed to
see if it is actually tagless.

Tests c1anonymous1.h and c1anonymous2.h are now passing.  Added tests
p0anonretag.h and p1anonretag.cc to ensure that the pattern matcher works.

(2) We were getting macro redefinition errors when two PPH files textually
included the same #defines because each PPH file replays its definitions.
The applied fix is to not do idempotent defines.

Test c7features.cc is now passing.  Test x7rtti.cc does not have as many
errors. 

This patch also addresses a minor problem.

(3) Debugging test x0tmpldfltparm.h was difficult because the same template
parameter identifier was used in different places.  Instead, use unique names.

(4) Some debug/dump/print routines were missing null pointer checks.  Add them.

Tested on x64.


Index: gcc/testsuite/ChangeLog.pph

2012-03-16   Lawrence Crowl  cr...@google.com

* g++.dg/pph/README: Clarify p category.
* g++.dg/pph/c1anonymous1.h: Mark passing.
* g++.dg/pph/c1anonymous2.h: Mark passing.
* g++.dg/pph/c7features.cc: Mark passing.
* g++.dg/pph/p0anonretag.h: New.
* g++.dg/pph/p1anonretag.cc: New.
* g++.dg/pph/x0tmpldfltparm.h: Disambiguate template param names.
* g++.dg/pph/x7rtti.cc: Remove some xfails.

Index: gcc/cp/ChangeLog.pph

2012-03-16   Lawrence Crowl  cr...@google.com

* cp-tree.h (make_anon_name): Add location parameter.
* name-lookup.c (static const char anon_char): New.
(static const char anon_prefix): New.
(edit_anon_name): New.
(make_anon_name): Add location parameter.  Use location in creating
names for anonymous (tagless) types when using PPH.
(make_lambda_name): Fix comment for later.
* class.c (layout_class_type): Pass location to make_anon_name.
* decl.c (start_enum): Pass location to make_anon_name.
* semantics.c (finish_compound_literal): Pass location to
make_anon_name.
(begin_class_definition): Pass location to make_anon_name.
* error.c (dump_type): Protect call against null pointer.
* parser.c (cp_lexer_print_token): Protect against null values.
(cp_parser_enum_specifier): Pass location to make_anon_name.
(cp_parser_class_head): Pass location to make_anon_name.

Index: libcpp/ChangeLog.pph

2012-03-16   Lawrence Crowl  cr...@google.com

* symtab.c (cpp_lt_already_done): New.
(cpp_lt_replay): Avoid idempotent macro defines.


Index: gcc/testsuite/g++.dg/pph/c1anonymous1.h
===
--- gcc/testsuite/g++.dg/pph/c1anonymous1.h (revision 185481)
+++ gcc/testsuite/g++.dg/pph/c1anonymous1.h (working copy)
@@ -1,11 +1,8 @@
-// {xfail-if ANONYMOUS MERGING { *-*-* } { -fpph-map=pph.map } }
-// { dg-bogus c0anonymous.h:4:16: error: 'anon_t' has a previous declaration 
here  { xfail *-*-* } 0 }
-
 #ifndefC1ANONYMOUS
 #defineC1ANONYMOUS
 
 #include c0anonymous.h
 
-enum { first, second }; // { dg-bogus 'anon_t' referred to as enum  { 
xfail *-*-* } }
+enum { first, second };
 
 #endif
Index: gcc/testsuite/g++.dg/pph/c1anonymous2.h
===
--- gcc/testsuite/g++.dg/pph/c1anonymous2.h (revision 185481)
+++ gcc/testsuite/g++.dg/pph/c1anonymous2.h (working copy)
@@ -1,14 +1,11 @@
-// {xfail-if ANONYMOUS MERGING { *-*-* } { -fpph-map=pph.map } }
-// { dg-bogus c0anonymous.h:4:16: error: 'struct anon_t' has a previous 
declaration as 'struct anon_t'  { xfail *-*-* } 0 }
-
 #ifndef C1ANONYMOUS2_H
 #define C1ANONYMOUS2_H
 
 #include c0anonymous.h
 
-typedef struct { // { dg-bogus conflicting declaration 'structanonymous' 
 { xfail *-*-* } }
+typedef struct {
 
 char *field;
-} anon2_t; // { dg-bogus invalid type in declaration before ';' token  { 
xfail *-*-* } }
+} anon2_t;
 
 #endif
Index: gcc/testsuite/g++.dg/pph/README
===
--- gcc/testsuite/g++.dg/pph/README (revision 185481)
+++ gcc/testsuite/g++.dg/pph/README (working copy)
@@ -7,9 +7,10 @@ names.
 c - positive tests for C-level headers and sources
 d - negative tests for C-level headers and sources
 e - C-level tests for non-sharable headers
-p - positive tests for what would be c-level code, but which
-due to C++ standard namespace games are not quite C level
-tests
+p - positive tests for what would be c-level code

Re: [pph] preliminary build support for stdc++.h.pph

2012-03-22 Thread Lawrence Crowl
) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pre_1_source} -o $@

The command line is not a direct replacement for PCH.  Separate rules?


  # Build a precompiled TR1 include, stdtr1c++.h.gch/O2.gch
 -${pch2_output}: ${pch2_source} ${pch1_output}
 +${pch2_output}: ${pre_2_source} ${pch1_output}
   -mkdir -p ${pch2_output_builddir}
 - $(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pch2_source} -o $@
 + $(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pre_2_source} -o $@

  # Build a precompiled extension include, extc++.h.gch/O2.gch
 -${pch3_output}: ${pch3_source} ${pch2_output}
 +${pch3_output}: ${pre_3_source} ${pch2_output}
   -mkdir -p ${pch3_output_builddir}
 - $(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pch3_source} -o $@
 + $(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pre_3_source} -o $@

 +# Build a preprocessed C++ include stdc++.h.pph
 +pph: ${pph_output}
 +${pph_output}: ${allstamped} ${host_builddir}/c++config.h
 ${pre_1_source}
 + $(CXX) $(PPH_GEN_FLAGS) $(AM_CPPFLAGS) -O2 -g ${pre_1_source}
 -o $@ +
  # For robustness sake (in light of junk files or in-source
  # configuration), copy from the build or source tree to the install
  # tree using only the human-maintained file lists and directory
 @@ -1291,7 +1299,7 @@
 $(INSTALL_DATA) $${file} $(DESTDIR)${host_installdir}; done

  # By adding these files here, automake will remove them for 'make
 clean' -CLEANFILES = ${pch_output} ${pch_output_anchors} stamp-host
 +CLEANFILES = ${pch_output} ${pch_output_anchors} ${pph_output}
 stamp-host
  # To remove directories.
  clean-local:

-- 
Lawrence Crowl


[pph] Distinguish template type parameters. (issue5881052)

2012-03-22 Thread Lawrence Crowl
This patch addresses the problem of two template instantiations
appearing to be identical.  They differ in TEMPLATE_PARM_NUM_SIBLINGS,
and so that information needs to be pushed out to the template merge
name.

Test x1tmpldfltparm.cc is now passing the assert, though it has
unneeded functions emitted.

Tested on x64.


Index: gcc/testsuite/ChangeLog.pph

2012-03-22   Lawrence Crowl  cr...@google.com

* g++.dg/pph/x1tmpldfltparm.cc: Failure change from merging to excess
code generation.

Index: gcc/cp/ChangeLog.pph

2012-03-22   Diego Novillo  dnovi...@google.com

* error.c (dump_location_qualifier):  Add qualifier using
TEMPLATE_PARM_NUM_SIBLINGS.  Rename to dump_tmpl_type_parm_qualifier.
(dump_tmpl_type_parm_qualifier): Renamed from above.
(dump_type): Change call of dump_location_qualifier to
dump_tmpl_type_parm_qualifier.
* pt.c (pph_out_pending_templates_list):  Add more debugging output.
(pph_in_pending_templates_list):  Move debugging output.
(pph_out_spec_entry_htab):  Add more debugging output.
* parser.c (cp_debug_parser_where):  Fix comment.
(cp_debug_the_parser_where):  New.
* parser.h (cp_debug_the_parser_where): New.


Index: gcc/testsuite/g++.dg/pph/x1tmpldfltparm.cc
===
--- gcc/testsuite/g++.dg/pph/x1tmpldfltparm.cc  (revision 185539)
+++ gcc/testsuite/g++.dg/pph/x1tmpldfltparm.cc  (working copy)
@@ -1,5 +1,5 @@
-// { dg-xfail-if DEFAULT TEMPLATE ARG MERGING { *-*-* } { 
-fpph-map=pph.map } }
-// { dg-bogus Trying to merge distinct trees from the same PPH image 
x0tmpldfltparm.pph  { xfail *-*-* } 0 }
+// {xfail-if EXCESS FUNCTIONS { *-*-* } { -fpph-map=pph.map } }
+// pph asm xdiff 53613
 
 #include x0tmpldfltparm.h
 
Index: gcc/cp/error.c
===
--- gcc/cp/error.c  (revision 185539)
+++ gcc/cp/error.c  (working copy)
@@ -351,24 +351,30 @@ dump_alias_template_specialization (tree
 }
 
 
-/* Dump a location of a DECL as a qualifier, depending on FLAGS.  */
+/* Dump a discriminating qualifier for a template type parameter,
+   depending on FLAGS.  */
 
 static void
-dump_location_qualifier (tree decl, int flags)
+dump_tmpl_type_parm_qualifier (tree type, int flags)
 {
 if (flags  TFF_LOC_FOR_TEMPLATE_PARMS)
   {
+tree decl = TYPE_NAME (type);
 expanded_location xloc = expand_location (DECL_SOURCE_LOCATION (decl));
-char *buffer = (char*)xmalloc (strlen (xloc.file) + 46);
+char *buffer = (char*)xmalloc (strlen (xloc.file) + 60);
+tree tmv = TYPE_MAIN_VARIANT (type);
+tree tpi = TEMPLATE_TYPE_PARM_INDEX (tmv);
+unsigned int sib = TEMPLATE_PARM_NUM_SIBLINGS (tpi);
 if (xloc.column != 0)
-  sprintf (buffer, `%s:%d:%d`, xloc.file, xloc.line, xloc.column);
+  sprintf (buffer, `%s:%d:%d#%d`, xloc.file, xloc.line, xloc.column, 
sib);
 else
-  sprintf (buffer, `%s:%d`, xloc.file, xloc.line);
+  sprintf (buffer, `%s:%d#%d`, xloc.file, xloc.line, sib);
 pp_cxx_ws_string (cxx_pp, buffer);
 free (buffer);
   }
 }
 
+
 /* Dump a human-readable equivalent of TYPE.  FLAGS controls the
format.  */
 
@@ -488,7 +494,7 @@ dump_type (tree t, int flags)
if (decl)
  {
tree ident = DECL_NAME (decl);
-   dump_location_qualifier (decl, flags);
+   dump_tmpl_type_parm_qualifier (t, flags);
if (ident)
  pp_cxx_tree_identifier (cxx_pp, ident);
else
Index: gcc/cp/pt.c
===
--- gcc/cp/pt.c (revision 185539)
+++ gcc/cp/pt.c (working copy)
@@ -3546,6 +3546,7 @@ reduce_template_parm_level (tree index, 
   return TEMPLATE_PARM_DESCENDANTS (index);
 }
 
+
 /* Process information from new template parameter PARM and append it
to the LIST being built.  This new parameter is a non-type
parameter iff IS_NON_TYPE is true. This new parameter is a
@@ -20728,6 +20729,9 @@ pph_out_pending_templates_list (pph_stre
   for (cur = pending_templates; cur != NULL;  cur = cur-next )
 ++count;
 
+  if (flag_pph_debug = 2)
+fprintf (pph_logfile, PPH: writing %d pending templates\n, count );
+
   /* Now emit them.  */
   pph_out_uint (stream, count);
   for (cur = pending_templates; cur != NULL;  cur = cur-next )
@@ -20740,11 +20744,13 @@ static void
 pph_in_pending_templates_list (pph_stream *stream)
 { 
   unsigned count = pph_in_uint (stream);
+
+  if (flag_pph_debug = 2)
+fprintf (pph_logfile, PPH: loading %d pending templates\n, count );
+
   for (; count  0; --count)
 {
   struct pending_template *pt;
-  if (flag_pph_debug = 2)
-fprintf (pph_logfile, PPH: loading %d pending templates\n, count );
   pt = ggc_alloc_pending_template ();
   pt-next = NULL;
   pt-tinst = pph_in_tinst_level (stream);
@@ -20794,8 +20800,11 @@ pph_out_spec_entry_htab

[pph] Rebuild identifier bindings. (issue5557045)

2012-01-17 Thread Lawrence Crowl
Instead of emitting identifiers with binding information, emit them
without and then patch up that information later.  We switch to this
technique because the cycles in binding info were causing no end of
troubles.

This change requires handling namespaces differently from before.  In
particular, we alway emit all namespaces into the PPH file.  We may
not emit decls within them.

There is an overloading bug in this patch, but I am pushing it up
now to avoid keeping so large a change hanging.


Index: gcc/testsuite/ChangeLog.pph

2011-01-17   Lawrence Crowl  cr...@google.com

* g++.dg/pph/x6dynarray3.cc: Add expected overload failures.
* g++.dg/pph/x4namespace.cc: Remove expected failures.
* g++.dg/pph/x4overset1.cc: Add expected overload asm diff failure.
* g++.dg/pph/x4overset2.cc: Likewise.
* g++.dg/pph/x4overset3.cc: Likewise.
* g++.dg/pph/x4overset4.cc: Likewise.
* g++.dg/pph/x0namespace.h: Add spacing.
* g++.dg/pph/x0namespace2.h: Likewise.

Index: gcc/cp/ChangeLog.pph

2012-01-17   Lawrence Crowl  cr...@google.com

* pph.h (pph_files_read): New.
(chain2vec): Move from static to global.
* pph-streamer.h (pph_dump_namespace): Add message parameter.
* pph-core.c (pph_dump_namespace): Add message parameter.
(pph_trace_marker): Add PPH: label to debugging output.
(pph_cache_insert_at): Remove non-static aggregate initializer.
(pph_loaded): Enable pph_set_global_identifier_bindings().
* pph-out.c (chain2vec): Move from static to global.
(pph_out_merge_key_namespace_decl): New.
(pph_out_merge_body_namespace_decl): New.
(pph_foreach_out_chain): New.
(pph_out_merge_key_binding_level): Handle namespace keys separately.
(pph_out_merge_key_tree): Likewise.
(pph_out_merge_body_binding_level): Handle namespace bodies separately.
(pph_out_identifier_bindings): No longer emit most binding info.
(pph_out_merge_key_namespace_decl): Output record info.
(pph_out_merge_body_namespace_decl): New.
* pph-in.c (pph_in_merge_body_namespace_decl): New.
(pph_in_merge_key_namespace_decl): New.
(pph_in_merge_key_binding_level): Handle namespace separately.
(pph_in_merge_key_tree): Likewise.
(pph_in_merge_body_binding_level_1): Likewise.
(pph_in_identifier_bindings): No longer emit most binding info.
(pph_ensure_namespace_binding_level): New.
(pph_in_merge_key_namespace_decl): Modify chain as needed.
(pph_in_merge_body_namespace_decl): New.
(bool pph_files_were_read): New.
(pph_files_read): New.
(pph_read_file_1): Set pph_files_were_read.
* pt.c (pph_dump_tinst_level): Add PPH: label to debugging output.
(pph_dump_pending_templates_list): Likewise.
(pph_dump_spec_entry_slot): Likewise.
(pph_dump_spec_entry_htab): Likewise.
* parser.h (cp_debug_parser_where): New.
* parser.c (cp_debug_parser_where): New.
(c_parse_file): Conditionalize call to pph_loaded.
* name-lookup.c (pph_debug_binding_action): New.
(pph_debug_binding_inaction): New.
(pph_foreach_on_chain_bl): New.
(pph_set_identifier_bindings): New.
(pph_set_chain_identifier_bindings): Use pph_set_identifier_bindings.
(pph_set_namespace_bindings): New.
(pph_set_chain_namespace_bindings): New.
(pph_foreach_on_chain): New.
(pph_set_namespace_namespace_binding): New.
(pph_set_namespace_namespace_bindings): New.
(pph_set_global_identifier_bindings): Add call to
pph_set_namespace_namespace_bindings.

Index: gcc/ChangeLog.pph

2012-01-17   Lawrence Crowl  cr...@google.com

* langhooks.h (get_lang_hooks): New.
* langhooks.c (get_lang_hooks): New.


Index: gcc/testsuite/g++.dg/pph/x6dynarray3.cc
===
--- gcc/testsuite/g++.dg/pph/x6dynarray3.cc (revision 183260)
+++ gcc/testsuite/g++.dg/pph/x6dynarray3.cc (working copy)
@@ -1,6 +1,8 @@
-// pph asm xdiff 18502
-// xfail BOGUS UNKNOWN
-// Some branches seem to be missing.
+// { dg-bogus a0dynarray-dfn1b.hi:8:13: error: no matching function for call 
to 'operator new  { xfail *-*-* } 0 }
+// { dg-bogus a0dynarray-dfn1b.hi:22:5: error: no suitable 'operator delete 
 { xfail *-*-* } 0 }
+// { dg-bogus a0dynarray-dfn2b.hi:8:13: error: no matching function for call 
to 'operator new  { xfail *-*-* } 0 }
+// { dg-bogus a0dynarray-dfn2b.hi:13:9: error: no suitable 'operator delete 
 { xfail *-*-* } 0 }
+// { dg-bogus a0dynarray-dcl3.hi:11:60: warning: no corresponding 
deallocation function for 'void. operator new  { xfail *-*-* } 0 }
 
 #include x5dynarray3.h
 
Index: gcc/testsuite/g++.dg/pph/x4overset1.cc
===
--- gcc/testsuite/g++.dg/pph/x4overset1.cc

[pph] Correct overloading (issue5555059)

2012-01-20 Thread Lawrence Crowl
Correct construction of bindings for overloaded symbols.


Index: gcc/testsuite/ChangeLog.pph

2011-01-20   Lawrence Crowl  cr...@google.com

* g++.dg/pph/x4overset1.cc: Make passing.
* g++.dg/pph/x4overset2.cc: Make wanted assembly diff.
* g++.dg/pph/x4overset3.cc: Make passing.
* g++.dg/pph/x4overset4.cc: Make wanted assembly diff.
* g++.dg/pph/x6dynarray3.cc: Change xfail signature.

Index: gcc/cp/ChangeLog.pph

2012-01-20   Lawrence Crowl  cr...@google.com

* parser.c (cp_debug_parser_where): Protect against null pointers.
* name-lookup.c (cxx_binding_make_for_name): New.
(binding_for_name): Factor construction into the above.
(modify_binding_for_overload): New.
(push_overloaded_decl_1): Factor out above function.
(pph_foreach_on_chain_bl): Add filter parameter.
(pph_set_identifier_bindings): Likewise.
(pph_set_chain_identifier_bindings): Likewise.
(pph_set_chain_namespace_bindings): Likewise.
(pph_set_namespace_bindings): Likewise.  Correct overloading.
(pph_set_namespace_namespace_bindings): Add filter parameter in calls.
(pph_set_global_identifier_bindings): Likewise.


Index: gcc/testsuite/g++.dg/pph/x6dynarray3.cc
===
--- gcc/testsuite/g++.dg/pph/x6dynarray3.cc (revision 183345)
+++ gcc/testsuite/g++.dg/pph/x6dynarray3.cc (working copy)
@@ -1,8 +1,6 @@
-// { dg-bogus a0dynarray-dfn1b.hi:8:13: error: no matching function for call 
to 'operator new  { xfail *-*-* } 0 }
 // { dg-bogus a0dynarray-dfn1b.hi:22:5: error: no suitable 'operator delete 
 { xfail *-*-* } 0 }
-// { dg-bogus a0dynarray-dfn2b.hi:8:13: error: no matching function for call 
to 'operator new  { xfail *-*-* } 0 }
 // { dg-bogus a0dynarray-dfn2b.hi:13:9: error: no suitable 'operator delete 
 { xfail *-*-* } 0 }
-// { dg-bogus a0dynarray-dcl3.hi:11:60: warning: no corresponding 
deallocation function for 'void. operator new  { xfail *-*-* } 0 }
+// { dg-bogus a0dynarray-dcl3.hi:11:60: error: call of overloaded 'operator 
new  { xfail *-*-* } 0 }
 
 #include x5dynarray3.h
 
Index: gcc/testsuite/g++.dg/pph/x4overset1.cc
===
--- gcc/testsuite/g++.dg/pph/x4overset1.cc  (revision 183345)
+++ gcc/testsuite/g++.dg/pph/x4overset1.cc  (working copy)
@@ -1,5 +1,3 @@
-// pph asm xdiff 56596
-
 #include x1overset1.h
 #include x1overset2.h
 
Index: gcc/testsuite/g++.dg/pph/x4overset2.cc
===
--- gcc/testsuite/g++.dg/pph/x4overset2.cc  (revision 183345)
+++ gcc/testsuite/g++.dg/pph/x4overset2.cc  (working copy)
@@ -1,5 +1,4 @@
-// pph asm xdiff 01525
-// wanted 57625
+// pph asm xwant 19882
 // This test produces overload differences because the declaration and
 // call orders are different between pph and textual parsing.
 
Index: gcc/testsuite/g++.dg/pph/x4overset3.cc
===
--- gcc/testsuite/g++.dg/pph/x4overset3.cc  (revision 183345)
+++ gcc/testsuite/g++.dg/pph/x4overset3.cc  (working copy)
@@ -1,5 +1,3 @@
-// pph asm xdiff 56596
-
 #include x1overset1.h
 #include x1overset2.h
 #include x1overset1.h
Index: gcc/testsuite/g++.dg/pph/x4overset4.cc
===
--- gcc/testsuite/g++.dg/pph/x4overset4.cc  (revision 183345)
+++ gcc/testsuite/g++.dg/pph/x4overset4.cc  (working copy)
@@ -1,5 +1,4 @@
-// pph asm xdiff 01525
-// wanted 57625
+// pph asm xwant 19882
 // This test produces overload differences because the declaration and
 // call orders are different between pph and textual parsing.
 
Index: gcc/cp/parser.c
===
--- gcc/cp/parser.c (revision 183345)
+++ gcc/cp/parser.c (working copy)
@@ -471,12 +471,34 @@ void
 cp_debug_parser_where (FILE *file, cp_parser *parser)
 {
   const size_t window_size = 20;
-  cp_token *token = parser-lexer-next_token;
-  expanded_location eloc = expand_location (token-location);
+  cp_lexer *lexer;
+  cp_token *token;
+  expanded_location eloc;
 
   if (file == NULL)
 file = stderr;
 
+  if (parser == NULL)
+{
+  fprintf (file, No parser available.\n);
+  return;
+}
+
+  lexer = parser-lexer;
+  if (lexer == NULL)
+{
+  fprintf (file, No lexer available.\n);
+  return;
+}
+
+  token = lexer-next_token;
+  if (token == NULL)
+{
+  fprintf (file, No token available.\n);
+  return;
+}
+
+  eloc = expand_location (token-location);
   fprintf (file, %s:%d:%d , eloc.file, eloc.line, eloc.column);
   cp_debug_parser_tokens (file, parser, window_size);
 }
Index: gcc/cp/name-lookup.c
===
--- gcc/cp/name-lookup.c(revision 183345)
+++ gcc/cp/name-lookup.c

[pph] Merge unemitted_tinfo_decls and keyed_classes (issue5575053)

2012-01-24 Thread Lawrence Crowl
Merge unemitted_tinfo_decls and keyed_classes.  We do not have a test
case failing for keyed_classes, so the latter is anticipatory.

Add a 'pph asm xokay' test marker for assembly differences that are
benign.  We would rather have identical assembly, but it is just not
important right now.  These will be treated as passes.

Clarify a few other failures.

Make various debug/trace dump changes.


Index: gcc/testsuite/ChangeLog.pph

2012-01-24   Lawrence Crowl  cr...@google.com

* lib/dg-pph.exp: Add an asm 'xokay' for benign assembly differences.
* g++.dg/pph/x4keyno.cc: Bug fixed, now xokay.
* g++.dg/pph/x4keyed.cc: Bug fixed, now xokay.
* g++.dg/pph/x4keyex.cc: Mark xokay.
* g++.dg/pph/x4tmplclass1.cc: Mark xokay.
* g++.dg/pph/x1tmplclass2.cc: Clarify failure.
* g++.dg/pph/x4tmplclass2.cc: Clarify failure.

Index: gcc/cp/ChangeLog.pph

2012-01-24   Lawrence Crowl  cr...@google.com

* pph-streamer.h (pph_dump_global_state): New.
(pph_dump_namespace): Removed; callers now use pph_dump_global_state.
* pph-core.c (pph_dump_tree_name): Add tree pointer.
(pph_dump_vec_tree): New.
(pph_dump_namespace): Remove message parameter.
(pph_dump_global_state): New.
(pph_loaded): Call pph_dump_global_state instead of pph_dump_namespace.
* pph-out.c (pph_write_file): Call pph_dump_global_state instead of
pph_dump_namespace.
* error.c (dump_decl): Protect against null pointers.
* name-lookup.c (pph_debug_binding_action): Add PPH: output label.
(pph_debug_binding_inaction): Add PPH: output label.
(pph_set_identifier_bindings): Modify debug label.
(pph_debug_overload_binding_action): New.
(pph_set_namespace_bindings): Call pph_debug_overload_binding_action
instead of pph_debug_binding_action.
(pph_add_overload): Remove unused.
* pph-in.c (pph_is_on_chain): New.
(pph_union_into_chain): New.
(pph_read_file_1): Call pph_union_into_chain for keyed_classes.
Call pph_union_into_tree_vec for unemitted_tinfo_decls.
Call pph_dump_global_state instead of pph_dump_namespace.


Index: gcc/testsuite/lib/dg-pph.exp
===
--- gcc/testsuite/lib/dg-pph.exp(revision 183499)
+++ gcc/testsuite/lib/dg-pph.exp(working copy)
@@ -166,9 +166,14 @@ proc dg-pph-pos { subdir test options ma
 
 # The sources mark when they expect the comparison to differ.
 # When marked with xdiff, the difference is a problem.
+# When marked with xokay, the difference is not causing a problem.
 # When marked with xwant, the difference is what we want.
 set xdiff_entry [grep $test pph asm xdiff( )*\[0-9\]*]
+set xokay_entry [grep $test pph asm xokay( )*\[0-9\]*]
 set xwant_entry [grep $test pph asm xwant( )*\[0-9\]*]
+if { $xokay_entry != } {
+   set xwant_entry $xokay_entry
+}
 set xdiff [llength $xdiff_entry]
 set xwant [llength $xwant_entry]
 if { $adiff == 0 } {
Index: gcc/testsuite/g++.dg/pph/x4keyno.cc
===
--- gcc/testsuite/g++.dg/pph/x4keyno.cc (revision 183499)
+++ gcc/testsuite/g++.dg/pph/x4keyno.cc (working copy)
@@ -1,5 +1,4 @@
-// { dg-xfail-if redefinition problems { *-*-* } { -fpph-map=pph.map } }
-// { dg-excess-errors The variable for the typeinfo name for 'keyno' is 
duplicated. }
+// pph asm xokay 32642
 
 #include x0keyno1.h
 #include x0keyno2.h
Index: gcc/testsuite/g++.dg/pph/x1tmplclass2.cc
===
--- gcc/testsuite/g++.dg/pph/x1tmplclass2.cc(revision 183499)
+++ gcc/testsuite/g++.dg/pph/x1tmplclass2.cc(working copy)
@@ -1,4 +1,7 @@
 // pph asm xdiff 37711
-// Soft failure.  Symbols are emitted in different order in pph compile.
+// xfail BOGUS MISSVAR
+// The assembly is missing a template class static member variable
+// basechar::variable instantiated in a prior pph file.
+// Others symbols are emitted in a different order.
 #include x0tmplclass23.h
 #include a0tmplclass2_u.h
Index: gcc/testsuite/g++.dg/pph/x4keyex.cc
===
--- gcc/testsuite/g++.dg/pph/x4keyex.cc (revision 183499)
+++ gcc/testsuite/g++.dg/pph/x4keyex.cc (working copy)
@@ -1,4 +1,4 @@
-// pph asm xdiff 32642
+// pph asm xokay 32642
 //
 // This test case fails to compare because LFB/LFE labels are different.
 //
Index: gcc/testsuite/g++.dg/pph/x4tmplclass1.cc
===
--- gcc/testsuite/g++.dg/pph/x4tmplclass1.cc(revision 183499)
+++ gcc/testsuite/g++.dg/pph/x4tmplclass1.cc(working copy)
@@ -1,4 +1,4 @@
-// pph asm xdiff 63957
+// pph asm xokay 63957
 // Assembly differences seem to be due to the order in which the
 // symbols in the template hash tables are emitted

[pph] Identifier binding fixes. (issue5572065)

2012-01-25 Thread Lawrence Crowl
This change fixes some problems in reconstructing the identifier bindings.
In particular, it removes extra binding creations, handle new bindings better,
identifies already present bindings, and adds some assertions.

Improve debug dump for bindings.

One old test is now passing.  One old test is 2/3 passing.  Two new tests are
passing.  Two old tests are now failing.  These are identical strange failures
with the __sync_fetch_and_add builtin.  The function declaration seems to be
losing its return type.


Index: gcc/testsuite/ChangeLog.pph

* g++.dg/pph/x0samename3.h: New passing.
* g++.dg/pph/x1samename.cc: New passing.
* g++.dg/pph/x4samename.cc: Mark passing.
* g++.dg/pph/x4resolve1.cc: Change passing assembler diff code.
* g++.dg/pph/x4resolve2.cc: Change passing assembler diff code.
* g++.dg/pph/x6dynarray3.cc: Remove two bogus errors.
* g++.dg/pph/x5dynarray7.h: Add one bogus error.
* g++.dg/pph/x6dynarray6.h: Add one bogus error.

2012-01-24   Lawrence Crowl  cr...@google.com

Index: gcc/cp/ChangeLog.pph

2012-01-25   Lawrence Crowl  cr...@google.com

* pph-core.c (pph_dump_tree_name): Refactor.
(pph_dump_overload_names): New.
(pph_dump_one_binding): New.
(pph_dump_bindings_for_id): New.
(pph_dump_bindings_for_decl): New.
(pph_dump_chain): Dump builtins at -fpph-debug=5.  Remove unneeded
'next' variable.
(pph_dump_binding): Likewise.
(pph_loaded): Clarify purpose of global state dump.
* name-lookup.c (pph_debug_binding_inaction): Remove redundant output.
(pph_set_identifier_bindings): Removed.
(pph_set_chain_identifier_bindings): Removed.
(pph_set_namespace_bindings): Removed.
(pph_set_identifier_binding): New.  Refactored from
pph_set_namespace_bindings.  Fixes some identifer binding issues.
(pph_set_namespace_decl_binding): New. Refactored from
pph_set_namespace_bindings.
(pph_set_chain_namespace_bindings): Use pph_set_namespace_decl_binding
instead of pph_set_namespace_bindings.
(pph_set_global_identifier_bindings): Remove bad calls to
pph_set_chain_identifier_bindings.


Index: gcc/testsuite/g++.dg/pph/x4samename.cc
===
--- gcc/testsuite/g++.dg/pph/x4samename.cc  (revision 183499)
+++ gcc/testsuite/g++.dg/pph/x4samename.cc  (working copy)
@@ -1,6 +1,3 @@
-// { dg-bogus x4samename.cc:11:18: error: expected unqualified-id before '=' 
token  { xfail *-*-* } 0 }
-// { dg-bogus x4samename.cc:12:43: error: cannot convert 'const char.' to 
'double' for argument '1' to 'int func.double.'  { xfail *-*-* } 0 }
-
 #include x0samename2.h
 #include x0samename1.h
 
Index: gcc/testsuite/g++.dg/pph/x4resolve1.cc
===
--- gcc/testsuite/g++.dg/pph/x4resolve1.cc  (revision 183499)
+++ gcc/testsuite/g++.dg/pph/x4resolve1.cc  (working copy)
@@ -1,4 +1,4 @@
-// pph asm xwant 03374
+// pph asm xwant 53261
 // This test produces overload differences because the declaration and
 // call orders are different between pph and textual parsing.
 
Index: gcc/testsuite/g++.dg/pph/x6dynarray3.cc
===
--- gcc/testsuite/g++.dg/pph/x6dynarray3.cc (revision 183499)
+++ gcc/testsuite/g++.dg/pph/x6dynarray3.cc (working copy)
@@ -1,5 +1,3 @@
-// { dg-bogus a0dynarray-dfn1b.hi:22:5: error: no suitable 'operator delete 
 { xfail *-*-* } 0 }
-// { dg-bogus a0dynarray-dfn2b.hi:13:9: error: no suitable 'operator delete 
 { xfail *-*-* } 0 }
 // { dg-bogus a0dynarray-dcl3.hi:11:60: error: call of overloaded 'operator 
new  { xfail *-*-* } 0 }
 
 #include x5dynarray3.h
Index: gcc/testsuite/g++.dg/pph/x4resolve2.cc
===
--- gcc/testsuite/g++.dg/pph/x4resolve2.cc  (revision 183499)
+++ gcc/testsuite/g++.dg/pph/x4resolve2.cc  (working copy)
@@ -1,4 +1,4 @@
-// pph asm xwant 37643
+// pph asm xwant 33894
 // This test produces overload differences because the declaration and
 // call orders are different between pph and textual parsing.
 
Index: gcc/testsuite/g++.dg/pph/x6dynarray6.h
===
--- gcc/testsuite/g++.dg/pph/x6dynarray6.h  (revision 183499)
+++ gcc/testsuite/g++.dg/pph/x6dynarray6.h  (working copy)
@@ -1,3 +1,5 @@
+// { dg-bogus atomicity.h:48:45: error: void value not ignored as it ought to 
be  { xfail *-*-* } 0 }
+
 #ifndef X6DYNARRAY6_H
 #define X6DYNARRAY6_H
 
Index: gcc/testsuite/g++.dg/pph/x5dynarray7.h
===
--- gcc/testsuite/g++.dg/pph/x5dynarray7.h  (revision 183499)
+++ gcc/testsuite/g++.dg/pph/x5dynarray7.h  (working copy)
@@ -1,3 +1,5 @@
+// { dg-bogus atomicity.h:48:45: error

[pph] Handle hidden state in cp/decl2.c (issue5577059)

2012-01-26 Thread Lawrence Crowl
Emit some state hidden in cp/decl2.c: pending_statics, deferred_fns, and
no_linkage_decls.

One tests is now passing, two tests are now okay, and three tests have
improved, but are still failing.


Index: gcc/testsuite/ChangeLog.pph

2012-01-26   Lawrence Crowl  cr...@google.com

* g++.dg/pph/x1tmplclass1.cc: Mark passing.
* g++.dg/pph/x1tmplclass2.cc: Mark okay.
* g++.dg/pph/x4tmplclass1.cc: Mark okay.
* g++.dg/pph/x4tmplclass2.cc: Change failure.
* g++.dg/pph/z4tmplclass1.cc: Change failure.
* g++.dg/pph/z4tmplclass2.cc: Change failure.

Index: gcc/cp/ChangeLog.pph

2012-01-26   Lawrence Crowl  cr...@google.com

* decl2.c (#include pph.h): New.
(pph_out_decl2_hidden_state): New.
(pph_in_decl2_hidden_state): New.
(pph_dump_decl2_hidden_state): New.
* Make-lang.in (cp/decl.o): Add dependence on $(CXX_PPH_H)
* pph.h (pph_dump_vec_tree): Externalize.
(pph_out_tree_vec): Externalize.
(pph_in_tree_vec): Externalize.
(pph_union_into_tree_vec): Externalize.
(pph_out_decl2_hidden_state): New.
(pph_in_decl2_hidden_state): New.
(pph_dump_decl2_hidden_state): New.
* pph-core.c (pph_dump_vec_tree): Externalize.
(pph_dump_global_state): Call pph_dump_decl2_hidden_state.
* pph-out.c (pph_out_tree_vec): Externalize.
(pph_write_file): Call pph_out_decl2_hidden_state.
* pph-in.c (pph_in_tree_vec): Externalize.
(pph_union_into_tree_vec): Externalize.
(pph_read_file_1): Call pph_in_decl2_hidden_state.


Index: gcc/testsuite/g++.dg/pph/x1tmplclass1.cc
===
--- gcc/testsuite/g++.dg/pph/x1tmplclass1.cc(revision 183576)
+++ gcc/testsuite/g++.dg/pph/x1tmplclass1.cc(working copy)
@@ -1,7 +1,2 @@
-// pph asm xdiff 11432
-// xfail BOGUS MISSVAR
-// The assembly is missing a template class static member variable
-// basechar::variable instantiated in a prior pph file.
-
 #include x0tmplclass13.h
 #include a0tmplclass1_u.h
Index: gcc/testsuite/g++.dg/pph/x1tmplclass2.cc
===
--- gcc/testsuite/g++.dg/pph/x1tmplclass2.cc(revision 183576)
+++ gcc/testsuite/g++.dg/pph/x1tmplclass2.cc(working copy)
@@ -1,7 +1,5 @@
-// pph asm xdiff 37711
-// xfail BOGUS MISSVAR
-// The assembly is missing a template class static member variable
-// basechar::variable instantiated in a prior pph file.
-// Others symbols are emitted in a different order.
+// pph asm xokay 60608
+// Symbols are emitted in a different order.
+
 #include x0tmplclass23.h
 #include a0tmplclass2_u.h
Index: gcc/testsuite/g++.dg/pph/z4tmplclass1.cc
===
--- gcc/testsuite/g++.dg/pph/z4tmplclass1.cc(revision 183576)
+++ gcc/testsuite/g++.dg/pph/z4tmplclass1.cc(working copy)
@@ -1,5 +1,5 @@
-// pph asm xdiff 65352
-// xfail BOGUS DUPVAR DUPFUNC
+// pph asm xdiff 43522
+// xfail DUPVAR DUPFUNC
 
 #include x0tmplclass13.h
 #include x0tmplclass14.h
Index: gcc/testsuite/g++.dg/pph/z4tmplclass2.cc
===
--- gcc/testsuite/g++.dg/pph/z4tmplclass2.cc(revision 183576)
+++ gcc/testsuite/g++.dg/pph/z4tmplclass2.cc(working copy)
@@ -1,5 +1,5 @@
-// pph asm xdiff 46430
-// xfail BOGUS DUPVAR DUPFUNC
+// pph asm xdiff 26423
+// xfail DUPVAR DUPFUNC
 
 #include x0tmplclass23.h
 #include x0tmplclass24.h
Index: gcc/testsuite/g++.dg/pph/x4tmplclass1.cc
===
--- gcc/testsuite/g++.dg/pph/x4tmplclass1.cc(revision 183576)
+++ gcc/testsuite/g++.dg/pph/x4tmplclass1.cc(working copy)
@@ -1,6 +1,6 @@
-// pph asm xokay 63957
-// Assembly differences seem to be due to the order in which the
-// symbols in the template hash tables are emitted.
+// pph asm xokay 03516
+// Label numbers are different.
+
 #include x0tmplclass11.h
 #include x0tmplclass12.h
 #include a0tmplclass1_u.h
Index: gcc/testsuite/g++.dg/pph/x4tmplclass2.cc
===
--- gcc/testsuite/g++.dg/pph/x4tmplclass2.cc(revision 183576)
+++ gcc/testsuite/g++.dg/pph/x4tmplclass2.cc(working copy)
@@ -1,5 +1,6 @@
-// pph asm xdiff 54639
-// generating different sets of variables
+// pph asm xdiff 51443
+// xfail DUPFUNC
+
 #include x0tmplclass21.h
 #include x0tmplclass22.h
 #include a0tmplclass2_u.h
Index: gcc/cp/pph-core.c
===
--- gcc/cp/pph-core.c   (revision 183576)
+++ gcc/cp/pph-core.c   (working copy)
@@ -273,7 +273,7 @@ pph_dump_binding (FILE *file, cp_binding
 
 /* Dump a tree vec v for PPH.  */
 
-static void
+void
 pph_dump_vec_tree (FILE *file, VEC(tree,gc) *v)
 {
   unsigned i;
@@ -301,6 +301,7 @@ pph_dump_global_state (FILE *file, const
   fprintf (file, \nPPH

[pph] Make tracing more robust. (issue5616043)

2012-02-01 Thread Lawrence Crowl
This patch makes tracing more robust.  It attempts to use type dumping
where possible, use the PPH merge name where possible, and otherwise
use ?. It protects protecting existing type dump machinery against
some unexpected nulls.  It changes tree streaming to write decl
minimal fields first, so that they can be used while reading other
fields.

The patch adds some new tests for the upcoming type merging.

Tested on x64.


Index: gcc/testsuite/ChangeLog.pph

2012-02-01   Lawrence Crowl  cr...@google.com

* g++.dg/pph/c0struct.h: Rename to c0struct2.h.
* g++.dg/pph/c0struct1.h: New.  Has no typedefs.
* g++.dg/pph/c1struct.cc: Rename to c1struct2.cc.
* g++.dg/pph/c1struct1.cc: New.  Has no typedefs.
* g++.dg/pph/x0struct0.h: Rename to x0struct2.h.
* g++.dg/pph/x0struct1.h: New.  Has no typedefs.
* g++.dg/pph/x1struct2.h: Rename to x1struct3.h.
* g++.dg/pph/x1struct1.h: Rename to x1struct2.h.
* g++.dg/pph/x1struct1.h: New.  Has no typedefs.
* g++.dg/pph/x2struct2.cc: Rename to x2struct3.cc.
* g++.dg/pph/x2struct1.cc: Rename to x2struct2.cc.
* g++.dg/pph/x2struct1.cc: New.  Has no typedefs.

Index: gcc/cp/ChangeLog.pph

2012-02-01   Lawrence Crowl  cr...@google.com

* pph-streamer.h (pph_trace_tree):  Add name parameter.  Adjust callers
to match.
* pph-core.c (pph_trace_tree):  Add name parameter to override
pretty-printing the tree.
* error.c (dump_type): Protect against null TYPE_NAME.
(dump_aggr_type): Factor out test for template.
(is_template): New.  Protect against null DECL_TEMPLATE_PARMS.
* pph-out.c (pph_out_merge_body_namespace_decl): Factor out assert for
mergable trees into separate cases.  Merging of types is currently
unexpected and disabled.
* pph-in.c (pph_in_merge_key_namespace_decl): Remove redundant assert
for mergable trees.
(pph_in_merge_key_namespace_decl): Factor out assert for mergable trees
into separate cases.  Merging of types is currently unexpected and
disabled.

Index: gcc/ChangeLog.pph

2012-02-01   Lawrence Crowl  cr...@google.com

* tree-streamer-out.c (streamer_write_tree_body): Write decl minimal
fields first, so that they can be used when reading other fields.
* tree-streamer-in.c (streamer_write_tree_body): Read decl minimal
fields first, so that they can be used when reading other fields.


Index: gcc/testsuite/g++.dg/pph/c0struct2.h
===
--- gcc/testsuite/g++.dg/pph/c0struct2.h(revision 183736)
+++ gcc/testsuite/g++.dg/pph/c0struct2.h(working copy)
@@ -1,5 +1,5 @@
-#ifndef C0STRUCT_H
-#define C0STRUCT_H
+#ifndef C0STRUCT2_H
+#define C0STRUCT2_H
 typedef int type;
 type gbl = 1;
 struct B {
Index: gcc/testsuite/g++.dg/pph/x0struct1.h
===
--- gcc/testsuite/g++.dg/pph/x0struct1.h(revision 0)
+++ gcc/testsuite/g++.dg/pph/x0struct1.h(revision 0)
@@ -0,0 +1,5 @@
+#ifndef X0STRUCT1_H
+#define X0STRUCT1_H
+struct B {
+};
+#endif
Index: gcc/testsuite/g++.dg/pph/c0struct.h
===
--- gcc/testsuite/g++.dg/pph/c0struct.h (revision 183805)
+++ gcc/testsuite/g++.dg/pph/c0struct.h (working copy)
@@ -1,9 +0,0 @@
-#ifndef C0STRUCT_H
-#define C0STRUCT_H
-typedef int type;
-type gbl = 1;
-struct B {
-type fld;
-};
-typedef B thing;
-#endif
Index: gcc/testsuite/g++.dg/pph/x0struct2.h
===
--- gcc/testsuite/g++.dg/pph/x0struct2.h(revision 183736)
+++ gcc/testsuite/g++.dg/pph/x0struct2.h(working copy)
@@ -1,5 +1,5 @@
-#ifndef X0STRUCT0_H
-#define X0STRUCT0_H
+#ifndef X0STRUCT2_H
+#define X0STRUCT2_H
 typedef int type;
 struct B {
 };
Index: gcc/testsuite/g++.dg/pph/c1struct1.cc
===
--- gcc/testsuite/g++.dg/pph/c1struct1.cc   (revision 0)
+++ gcc/testsuite/g++.dg/pph/c1struct1.cc   (revision 0)
@@ -0,0 +1,4 @@
+#include c0struct1.h
+
+B var1;
+B var2 = { 3 };
Index: gcc/testsuite/g++.dg/pph/x2struct1.cc
===
--- gcc/testsuite/g++.dg/pph/x2struct1.cc   (revision 183805)
+++ gcc/testsuite/g++.dg/pph/x2struct1.cc   (working copy)
@@ -1,10 +1,9 @@
 #include x1struct1.h
 
-type D::method()
+int D::method()
 { static int x = 2;
   return fld + mbr; }
 
-type D::mbr = 4;
-typedef D D2;
-D2 var1;
-D2 var2 = var1;
+int D::mbr = 4;
+D var1;
+D var2 = var1;
Index: gcc/testsuite/g++.dg/pph/c1struct.cc
===
--- gcc/testsuite/g++.dg/pph/c1struct.cc(revision 183805)
+++ gcc/testsuite/g++.dg/pph/c1struct.cc(working copy)
@@ -1,4 +0,0 @@
-#include

[pph] Minimal type merging. (issue5620047)

2012-02-01 Thread Lawrence Crowl
This patch adds minimal type merging.  It unifies the existence of
types for a struct decl.  The method is to emit a merge key for the
type when we emit a merge key for the struct decl.

Test x4structover1.cc is now passing.

The next step is to merge struct definitions.  For that we have test
cases x*incomplete*, which progressively add more information to the
classes in different configurations of pph files.

Tested on x64.


Index: gcc/testsuite/ChangeLog.pph

2012-02-01   Lawrence Crowl  cr...@google.com

* g++.dg/pph/x4structover1.cc: Mark fixed.
* g++.dg/pph/a0incomplete2.hi: New.
* g++.dg/pph/a0incomplete3.hi: New.
* g++.dg/pph/a0incomplete4.cci: New.
* g++.dg/pph/x0incomplete1.h: New.
* g++.dg/pph/x0incomplete2.h: New.
* g++.dg/pph/x0incomplete3.h: New.
* g++.dg/pph/x1incomplete3.h: New.
* g++.dg/pph/x1incomplete4.cc: New.
* g++.dg/pph/x2incomplete4.cc: New.
* g++.dg/pph/x3incomplete412.cc: New.
* g++.dg/pph/x3incomplete413.cc: New.
* g++.dg/pph/x4incomplete4123.cc: New.
* g++.dg/pph/x4incomplete4321.cc: New.

Index: gcc/cp/ChangeLog.pph

2012-02-01   Lawrence Crowl  cr...@google.com

* error.c (dump_function_decl):  Add protection against NULL.
* pph-out.c (pph_out_merge_key_tree):  Write merge keys for struct
types, as opposed to decls.
* pph-in.c (pph_in_merge_tree_body):  Save chains in decls only.
(pph_in_merge_key_tree): Read merge keys for struct types.  Split
handling into two phases, cache insertion (which is before the trace
front) and sub-tree reading.


Index: gcc/testsuite/g++.dg/pph/x1incomplete3.h
===
--- gcc/testsuite/g++.dg/pph/x1incomplete3.h(revision 0)
+++ gcc/testsuite/g++.dg/pph/x1incomplete3.h(revision 0)
@@ -0,0 +1,7 @@
+#ifndef X0INCOMPLETE3_H
+#define X0INCOMPLETE3_H
+
+#include x0incomplete2.h
+#include a0incomplete3.hi
+
+#endif
Index: gcc/testsuite/g++.dg/pph/x0incomplete2.h
===
--- gcc/testsuite/g++.dg/pph/x0incomplete2.h(revision 0)
+++ gcc/testsuite/g++.dg/pph/x0incomplete2.h(revision 0)
@@ -0,0 +1,6 @@
+#ifndef X0INCOMPLETE2_H
+#define X0INCOMPLETE2_H
+
+#include a0incomplete2.hi
+
+#endif
Index: gcc/testsuite/g++.dg/pph/x2incomplete4.cc
===
--- gcc/testsuite/g++.dg/pph/x2incomplete4.cc   (revision 0)
+++ gcc/testsuite/g++.dg/pph/x2incomplete4.cc   (revision 0)
@@ -0,0 +1,5 @@
+// { dg-xfail-if ICE { *-*-* } { -fpph-map=pph.map } }
+// { dg-bogus internal compiler error: in import_export_decl, at cp/decl2.c 
 { xfail *-*-* } 0 }
+
+#include x1incomplete3.h
+#include a0incomplete4.cci
Index: gcc/testsuite/g++.dg/pph/x0incomplete3.h
===
--- gcc/testsuite/g++.dg/pph/x0incomplete3.h(revision 0)
+++ gcc/testsuite/g++.dg/pph/x0incomplete3.h(revision 0)
@@ -0,0 +1,7 @@
+#ifndef X0INCOMPLETE3_H
+#define X0INCOMPLETE3_H
+
+#include a0incomplete2.hi
+#include a0incomplete3.hi
+
+#endif
Index: gcc/testsuite/g++.dg/pph/x1incomplete4.cc
===
--- gcc/testsuite/g++.dg/pph/x1incomplete4.cc   (revision 0)
+++ gcc/testsuite/g++.dg/pph/x1incomplete4.cc   (revision 0)
@@ -0,0 +1,2 @@
+#include x0incomplete3.h
+#include a0incomplete4.cci
Index: gcc/testsuite/g++.dg/pph/a0incomplete4.cci
===
--- gcc/testsuite/g++.dg/pph/a0incomplete4.cci  (revision 0)
+++ gcc/testsuite/g++.dg/pph/a0incomplete4.cci  (revision 0)
@@ -0,0 +1,5 @@
+int query( copies arg )
+{
+copies var( arg );
+return var.value();
+}
Index: gcc/testsuite/g++.dg/pph/x4incomplete4123.cc
===
--- gcc/testsuite/g++.dg/pph/x4incomplete4123.cc(revision 0)
+++ gcc/testsuite/g++.dg/pph/x4incomplete4123.cc(revision 0)
@@ -0,0 +1,4 @@
+#include x0incomplete1.h
+#include x0incomplete2.h
+#include x0incomplete3.h
+#include a0incomplete4.cci
Index: gcc/testsuite/g++.dg/pph/x3incomplete412.cc
===
--- gcc/testsuite/g++.dg/pph/x3incomplete412.cc (revision 0)
+++ gcc/testsuite/g++.dg/pph/x3incomplete412.cc (revision 0)
@@ -0,0 +1,4 @@
+#include x0incomplete1.h
+#include x0incomplete2.h
+#include a0incomplete3.hi
+#include a0incomplete4.cci
Index: gcc/testsuite/g++.dg/pph/a0incomplete2.hi
===
--- gcc/testsuite/g++.dg/pph/a0incomplete2.hi   (revision 0)
+++ gcc/testsuite/g++.dg/pph/a0incomplete2.hi   (revision 0)
@@ -0,0 +1,12 @@
+#ifndef A0INCOMPLETE2_HI
+#define A0INCOMPLETE2_HI
+
+struct copies
+{
+copies();
+copies( const copies arg );
+int value

[pph] More C++ Tree Nodes (issue4526083)

2011-05-26 Thread Lawrence Crowl
Oranize the PPH tree switch into tcc_* chunks, in each of four sections:
needs more work, already handled, unimplemented, and unrecognized.

Implement several C++ tree nodes.  These nodes do not get any more tests
to pass, but they do move the failures deeper into the compilation.

Index: gcc/cp/ChangeLog.pph

2011-05-26  Lawrence Crowl  cr...@google.com

* cp-objcp-common.c (cp_tree_size): Add case TREE_BINFO.
* pph.c (pph_read_file): Also log closing of PPH files.
* pph-streamer-in.c (pph_stream_read_tree):
Organize the switch into tcc_* chunks.
Move tcc_statement case STATEMENT_LIST down.
Implement tcc_type cases for BOUND_TEMPLATE_TEMPLATE_PARM,
DECLTYPE_TYPE, TEMPLATE_TEMPLATE_PARM, TEMPLATE_TYPE_PARM,
TYPENAME_TYPE, and TYPEOF_TYPE.
Implement tcc_exceptional case TEMPLATE_PARM_INDEX.
Add tcc_declaration case TRANSLATION_UNIT_DECL to already handled list.
Create a section for unimplemented cases as opposed to unrecognized
cases.
* pph-streamer-out.c (pph_stream_write_tree):
Organize the switch into tcc_* chunks.
Move tcc_statement case STATEMENT_LIST down.
Implement tcc_type cases for BOUND_TEMPLATE_TEMPLATE_PARM,
DECLTYPE_TYPE, TEMPLATE_TEMPLATE_PARM, TEMPLATE_TYPE_PARM,
TYPENAME_TYPE, and TYPEOF_TYPE.
Move tcc_statement case STATEMENT_LIST down.
Implement tcc_exceptional case TEMPLATE_PARM_INDEX.
Add tcc_declaration case TRANSLATION_UNIT_DECL to already handled list.
Create a section for unimplemented cases as opposed to unrecognized
cases.


Index: gcc/cp/pph.c
===
--- gcc/cp/pph.c(revision 174301)
+++ gcc/cp/pph.c(working copy)
@@ -2072,6 +2072,9 @@ pph_read_file (const char *filename)
 {
   pph_read_file_contents (stream);
   pph_stream_close (stream);
+
+  if (flag_pph_debug = 1)
+fprintf (pph_logfile, PPH: Closing %s\n, filename);
 }
   else
 error (Cannot open PPH file for reading: %s: %m, filename);
Index: gcc/cp/pph-streamer-in.c
===
--- gcc/cp/pph-streamer-in.c(revision 174304)
+++ gcc/cp/pph-streamer-in.c(working copy)
@@ -807,6 +807,10 @@ pph_stream_read_tree (struct lto_input_b
 
   switch (TREE_CODE (expr))
 {
+/* TREES NEEDING EXTRA WORK */
+
+/* tcc_declaration */
+
 case DEBUG_EXPR_DECL:
 case IMPORTED_DECL:
 case LABEL_DECL:
@@ -845,16 +849,7 @@ pph_stream_read_tree (struct lto_input_b
   DECL_CONTEXT (expr) = pph_input_tree (stream);
   break;
 
-case STATEMENT_LIST:
-  {
-HOST_WIDE_INT i, num_trees = pph_input_uint (stream);
-for (i = 0; i  num_trees; i++)
- {
-   tree stmt = pph_input_tree (stream);
-   append_to_statement_list (stmt, expr);
- }
-  }
-  break;
+/* tcc_type */
 
 case ARRAY_TYPE:
 case BOOLEAN_TYPE:
@@ -882,6 +877,43 @@ pph_stream_read_tree (struct lto_input_b
   TYPE_BINFO (expr) = pph_input_tree (stream);
   break;
 
+case BOUND_TEMPLATE_TEMPLATE_PARM:
+case DECLTYPE_TYPE:
+case TEMPLATE_TEMPLATE_PARM:
+case TEMPLATE_TYPE_PARM:
+case TYPENAME_TYPE:
+case TYPEOF_TYPE:
+  pph_stream_read_lang_type (stream, expr);
+  TYPE_CACHED_VALUES (expr) = pph_input_tree (stream);
+  /* Note that we are using TYPED_CACHED_VALUES for it access to 
+ the generic .values field of types. */
+  break;
+
+/* tcc_statement */
+
+case STATEMENT_LIST:
+  {
+HOST_WIDE_INT i, num_trees = pph_input_uint (stream);
+for (i = 0; i  num_trees; i++)
+ {
+   tree stmt = pph_input_tree (stream);
+   append_to_statement_list (stmt, expr);
+ }
+  }
+  break;
+
+/* tcc_expression */
+
+/* tcc_unary */
+
+/* tcc_vl_exp */
+
+/* tcc_reference */
+
+/* tcc_constant */
+
+/* tcc_exceptional */
+
 case OVERLOAD:
   OVL_FUNCTION (expr) = pph_input_tree (stream);
   break;
@@ -907,11 +939,127 @@ pph_stream_read_tree (struct lto_input_b
   = pph_stream_read_qual_use_vec (stream);
   break;
 
-case TREE_LIST:
+case TEMPLATE_PARM_INDEX:
+  {
+template_parm_index *p = TEMPLATE_PARM_INDEX_CAST (expr);
+p-index = pph_input_uint (stream);
+p-level = pph_input_uint (stream);
+p-orig_level = pph_input_uint (stream);
+p-num_siblings = pph_input_uint (stream);
+p-decl = pph_input_tree (stream);
+/* FIXME pph: Is TEMPLATE_PARM_PARAMETER_PACK using TREE_LANG_FLAG_0
+   already handled?  */
+  }
+  break;
+
+/* TREES ALREADY HANDLED */
+
+/* tcc_declaration */
+
+case TRANSLATION_UNIT_DECL:
+
+/* tcc_exceptional */
+
 case TREE_BINFO:
-  /* These trees are already fully

Re: [pph] More C++ Tree Nodes (issue4526083)

2011-05-27 Thread Lawrence Crowl
On 5/26/11, Nathan Froyd froy...@codesourcery.com wrote:
 On 05/26/2011 10:24 PM, Lawrence Crowl wrote:
 Index: gcc/cp/cp-objcp-common.c
 ===
 --- gcc/cp/cp-objcp-common.c (revision 174301)
 +++ gcc/cp/cp-objcp-common.c (working copy)
 @@ -99,6 +99,8 @@ cp_tree_size (enum tree_code code)

  case TEMPLATE_INFO: return sizeof (struct
 tree_template_info);

 +case TREE_BINFO:return sizeof (struct tree_binfo);
 +
  default:
gcc_unreachable ();
  }

 This does not look right; TREE_BINFO is a variable-sized structure
 (and is not C++-specific in any event).

I'd forgotten that.

 Maybe you should be using tree_size instead of tree_code_size
 someplace?

Hm.  Possibly.  The PPH system is still mostly C, and so C++ parts
are being dropped, which could cause a different path further
upstream.

-- 
Lawrence Crowl


[pph] Remove case TREE_BINFO in cp_tree_size(). (issue4515156)

2011-05-27 Thread Lawrence Crowl
Remove case TREE_BINFO in cp_tree_size().


Index: gcc/cp/ChangeLog.pph

2011-05-27  Lawrence Crowl  cr...@google.com

* cp-objcp-common.c (cp_tree_size): Remove case TREE_BINFO.


Index: gcc/cp/cp-objcp-common.c
===
--- gcc/cp/cp-objcp-common.c(revision 174345)
+++ gcc/cp/cp-objcp-common.c(working copy)
@@ -99,8 +99,6 @@ cp_tree_size (enum tree_code code)
 
 case TEMPLATE_INFO: return sizeof (struct tree_template_info);
 
-case TREE_BINFO:return sizeof (struct tree_binfo);
-
 default:
   gcc_unreachable ();
 }

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


[pph] TS_COMMON chain and trace edits (issue4564058)

2011-06-05 Thread Lawrence Crowl
We were not streaming the TS_COMMON field change.  This patch adds
a functions to stream TS_COMMON.  It adds calls to them in existing
code that handles trees.  It also implements streaming of other
C++-specific trees that inherit TS_COMMON.  This patch fixes some
ICEs, but the test still fail on later ICEs.

Tests adjusted to reflect new reality.

Tested on x86-64.  Committed.


Index: gcc/testsuite/ChangeLog.pph

2011-06-05  Lawrence Crowl  cr...@google.com

* g++.dg/pph/x1special.cc: Change to new ICE.
* g++.dg/pph/x1template.cc: Change old ICE to new location.
* g++.dg/pph/x1tmplfunc.cc: Change to new ICE.

Index: gcc/cp/ChangeLog.pph

2011-06-05  Lawrence Crowl cr...@google.com

* pph-streamer.c (pph_trace): Clean up trace formatting.
* pph-streamer-in.c (pph_in_tree_common): New for TS_COMMON chain.
(pph_read_tree): Call pph_in_tree_common in existing readers for trees.
Implement readers for C++-specific trees that need pph_in_tree_common.
* pph-streamer-out.c (pph_out_tree_common): New for TS_COMMON chain.
(pph_write_tree): Call pph_out_tree_common in existing writers for
trees.  Implement readers for C++-specific trees that need
pph_out_tree_common.


Index: gcc/testsuite/g++.dg/pph/x1tmplfunc.cc
===
--- gcc/testsuite/g++.dg/pph/x1tmplfunc.cc  (revision 174669)
+++ gcc/testsuite/g++.dg/pph/x1tmplfunc.cc  (working copy)
@@ -1,5 +1,5 @@
 // { dg-xfail-if ICE { *-*-* } { -fpph-map=pph.map } }
-// { dg-bogus x1tmplfunc.h:12:30: internal compiler error: Segmentation 
fault  { xfail *-*-* } 0 }
+// { dg-bogus x1tmplfunc.h:8:16: internal compiler error: Segmentation fault 
 { xfail *-*-* } 0 }
 // { dg-prune-output In file included from  }
 
 #include x1tmplfunc.h
Index: gcc/testsuite/g++.dg/pph/x1special.cc
===
--- gcc/testsuite/g++.dg/pph/x1special.cc   (revision 174669)
+++ gcc/testsuite/g++.dg/pph/x1special.cc   (working copy)
@@ -1,5 +1,5 @@
 // { dg-xfail-if ICE { *-*-* } { -fpph-map=pph.map } }
-// { dg-bogus x1special.h:19:6: internal compiler error: tree check: expected 
tree that contains 'decl minimal' structure, have 'overload' in 
context_for_name_lookup, at cp/search.c:570  { xfail *-*-* } 0 }
+// { dg-bogus x1special.h:10:5: internal compiler error: Segmentation fault 
 { xfail *-*-* } 0 }
 // { dg-prune-output In file included from  }
 
 #include x1special.h
Index: gcc/testsuite/g++.dg/pph/x1template.cc
===
--- gcc/testsuite/g++.dg/pph/x1template.cc  (revision 174669)
+++ gcc/testsuite/g++.dg/pph/x1template.cc  (working copy)
@@ -1,5 +1,5 @@
 // { dg-xfail-if ICE { *-*-* } { -fpph-map=pph.map } }
-// { dg-bogus x1template.h:18:13: internal compiler error: in resume_scope, 
at cp/name-lookup.c:1573  { xfail *-*-* } 0 }
+// { dg-bogus x1template.h:18:13: internal compiler error: in resume_scope, 
at cp/name-lookup.c:1567  { xfail *-*-* } 0 }
 // { dg-prune-output In file included from  }
 
 #include x1template.h
Index: gcc/cp/pph-streamer-in.c
===
--- gcc/cp/pph-streamer-in.c(revision 174669)
+++ gcc/cp/pph-streamer-in.c(working copy)
@@ -484,6 +484,15 @@ pph_in_binding_level (pph_stream *stream
 }
 
 
+/* Read in the tree_common fields.  */
+
+static void
+pph_in_tree_common (pph_stream *stream, tree t)
+{
+  /* The 'struct tree_typed typed' base class is handled in LTO.  */
+  TREE_CHAIN (t) = pph_in_tree (stream);
+}
+
 /* Read and return an instance of struct c_language_function from STREAM.  */
 
 static struct c_language_function *
@@ -1007,6 +1016,7 @@ pph_read_tree (struct lto_input_block *i
 /* tcc_exceptional */
 
 case OVERLOAD:
+  pph_in_tree_common (stream, expr);
   OVL_FUNCTION (expr) = pph_in_tree (stream);
   break;
 
@@ -1021,12 +1031,14 @@ pph_read_tree (struct lto_input_block *i
   break;
 
 case BASELINK:
+  pph_in_tree_common (stream, expr);
   BASELINK_BINFO (expr) = pph_in_tree (stream);
   BASELINK_FUNCTIONS (expr) = pph_in_tree (stream);
   BASELINK_ACCESS_BINFO (expr) = pph_in_tree (stream);
   break;
 
 case TEMPLATE_INFO:
+  pph_in_tree_common (stream, expr);
   TI_TYPEDEFS_NEEDING_ACCESS_CHECKING (expr)
   = pph_in_qual_use_vec (stream);
   break;
@@ -1034,6 +1046,7 @@ pph_read_tree (struct lto_input_block *i
 case TEMPLATE_PARM_INDEX:
   {
 template_parm_index *p = TEMPLATE_PARM_INDEX_CAST (expr);
+pph_in_tree_common (stream, expr);
 p-index = pph_in_uint (stream);
 p-level = pph_in_uint (stream);
 p-orig_level = pph_in_uint (stream);
@@ -1044,6 +1057,56 @@ pph_read_tree (struct lto_input_block *i
   }
   break;
 
+/* tcc_constant */
+
+case PTRMEM_CST

Re: [pph] Clean up PPH tests (issue4572042)

2011-06-06 Thread Lawrence Crowl
On 6/6/11, Diego Novillo dnovi...@google.com wrote:
 So, I'm getting this:

 Running /home/dnovillo/pph/svn/src/gcc/testsuite/g++.dg/pph/pph.exp ...
 XPASS: g++.dg/pph/c120060625-1.cc  -I.  (test for bogus messages, line )
 XPASS: g++.dg/pph/c1eabi1.cc  -I.  (test for bogus messages, line )
 XPASS: g++.dg/pph/x1autometh.cc  -I.  (test for bogus messages, line )
 XPASS: g++.dg/pph/x1functions.cc  -I.  (test for bogus messages, line )
 XPASS: g++.dg/pph/x1functions.cc  -I.  (test for bogus messages, line )
 XPASS: g++.dg/pph/x1special.cc  -I.  (test for bogus messages, line )
 XPASS: g++.dg/pph/x1special.cc  -fpph-map=pph.map -I.  (test for bogus
 messages, line )
 FAIL: g++.dg/pph/x1special.cc  -fpph-map=pph.map -I. (test for excess
 errors)
 XPASS: g++.dg/pph/x1template.cc  -I.  (test for bogus messages, line )
 XPASS: g++.dg/pph/x1template.cc  -fpph-map=pph.map -I.  (test for
 bogus messages, line )
 FAIL: g++.dg/pph/x1template.cc  -fpph-map=pph.map -I. (test for excess
 errors)
 XPASS: g++.dg/pph/x1tmplclass.cc  -I.  (test for bogus messages, line )
 XPASS: g++.dg/pph/x1tmplfunc.cc  -I.  (test for bogus messages, line )
 XPASS: g++.dg/pph/x1tmplfunc.cc  -fpph-map=pph.map -I.  (test for
 bogus messages, line )
 FAIL: g++.dg/pph/x1tmplfunc.cc  -fpph-map=pph.map -I. (test for excess
 errors)
 XPASS: g++.dg/pph/x1typerefs.cc  -I.  (test for bogus messages, line )
 XPASS: g++.dg/pph/x1variables.cc  -I.  (test for bogus messages, line )
 XPASS: g++.dg/pph/x1variables.cc  -I.  (test for bogus messages, line )
 XPASS: g++.dg/pph/x1variables.cc  -fpph-map=pph.map -I.  (test for
 bogus messages, line )
 XPASS: g++.dg/pph/x1variables.cc  -fpph-map=pph.map -I.  (test for
 bogus messages, line )

 === g++ Summary ===

 # of expected passes176
 # of unexpected failures3
 # of unexpected successes   17
 # of expected failures  45

 The three FAILs are expected then?  Those are the ones you mentioned
 can't be easily XFAIL'd?

These are probably changes in the line number of the ICE,
and so the dg-bogus needs updating.

-- 
Lawrence Crowl


[pph] Test cleanup (issue4572050)

2011-06-08 Thread Lawrence Crowl
Update the test suite to reflect recent fixes and merges from trunk.

The following changes happened in this patch.

Conversion of a compilation failure to an assembly diff failure:

remove the dg comments and add the comment // pph asm xdiff

Conversion of a ICE to a BOGUS

change the dg-xfail-if line from ICE to BOGUS
change the dg-bogus line from the ICE message to the BOGUS message
remove the dg-prune-output lines corresponding to the ICE
(dg knows to remove them for errors, but not for ICEs)

Update line numbers from a merge (or other edits to regular sources)
change the line number from old to new as reflected in the test log

The output of make check filtered through the following sed command
should yield no FAIL and no XPASS.

sed -e '
/-fpph-map=pph.map/ ! {
/^XPASS: .*test for bogus messages/ d
/^XPASS: .*test for excess errors/  d
}

/^#/p
/^ERROR: /  p
/^XFAIL: /  p
/^XPASS: /  p
/^FAIL: /   p

d
'

The same command works to filter the log file to its essential record
of pass/fail.  In particular, it enables listing XFAILs that need work.


Index: gcc/testsuite/ChangeLog.pph

2011-06-08  Lawrence Crowl cr...@google.com

* lib/dg-pph.exp (dg-pph-pos): Stop redundantly reporting a missing
pph assembly as an xfail when its compile xfails.
* g++.dg/pph/x1typerefs.cc: Replace ICE xfail with a bogus error xfail.
* g++.dg/pph/x1tmplclass.cc: Likewise.
* g++.dg/pph/x1autometh.cc: Replace ICE xfail with an assembly diff
xfail.
* g++.dg/pph/x1special.cc: Remove ICE xfail.
* g++.dg/pph/x1functions.cc: Correct xfail to BOGUS rather than ERROR.
Remove leftover pruning from previous ICE.
* g++.dg/pph/x1template.cc: Update line number of ICE.
* g++.dg/pph/x1variables.cc: Update line number of BOGUS.


Index: gcc/testsuite/lib/dg-pph.exp
===
--- gcc/testsuite/lib/dg-pph.exp(revision 174789)
+++ gcc/testsuite/lib/dg-pph.exp(working copy)
@@ -94,9 +94,7 @@ proc dg-pph-pos { subdir test options ma
 # Quit if it did not compile successfully.
 if { ![file_on_host exists $bname.s] } {
# Expect assembly to be missing when the compile is an expected fail.
-   if { [llength [grep $test dg-xfail-if.*-fpph-map]] } {
-   xfail $nshort $options (pph assembly missing)
-   } else {
+   if { ![llength [grep $test dg-xfail-if.*-fpph-map]] } {
fail $nshort $options (pph assembly missing)
}
return
Index: gcc/testsuite/g++.dg/pph/x1typerefs.cc
===
--- gcc/testsuite/g++.dg/pph/x1typerefs.cc  (revision 174789)
+++ gcc/testsuite/g++.dg/pph/x1typerefs.cc  (working copy)
@@ -1,6 +1,5 @@
-// { dg-xfail-if ICE { *-*-* } { -fpph-map=pph.map } }
-// { dg-bogus c1typerefs.h:11:18: internal compiler error: Segmentation 
fault  { xfail *-*-* } 0 }
-// { dg-prune-output In file included from  }
+// { dg-xfail-if BOGUS { *-*-* } { -fpph-map=pph.map } }
+// { dg-bogus c1typerefs.h:11:18: error: cannot convert 'const 
std::type_info.' to 'const std::type_info.' in initialization  { xfail *-*-* 
} 0 }
 
 #include x1typerefs.h
 
Index: gcc/testsuite/g++.dg/pph/x1autometh.cc
===
--- gcc/testsuite/g++.dg/pph/x1autometh.cc  (revision 174789)
+++ gcc/testsuite/g++.dg/pph/x1autometh.cc  (working copy)
@@ -1,6 +1,4 @@
-// { dg-xfail-if ICE { *-*-* } { -fpph-map=pph.map } }
-// { dg-bogus x1autometh.h:8:1: internal compiler error: Segmentation fault 
 { xfail *-*-* } 0 }
-// { dg-prune-output In file included from  }
+// pph asm xdiff
 
 #include x1autometh.h
 
Index: gcc/testsuite/g++.dg/pph/x1special.cc
===
--- gcc/testsuite/g++.dg/pph/x1special.cc   (revision 174789)
+++ gcc/testsuite/g++.dg/pph/x1special.cc   (working copy)
@@ -1,7 +1,3 @@
-// { dg-xfail-if ICE { *-*-* } { -fpph-map=pph.map } }
-// { dg-bogus x1special.h:10:5: internal compiler error: Segmentation fault 
 { xfail *-*-* } 0 }
-// { dg-prune-output In file included from  }
-
 #include x1special.h
 
 B b(1);
Index: gcc/testsuite/g++.dg/pph/x1functions.cc
===
--- gcc/testsuite/g++.dg/pph/x1functions.cc (revision 174789)
+++ gcc/testsuite/g++.dg/pph/x1functions.cc (working copy)
@@ -1,8 +1,5 @@
-// { dg-xfail-if ERROR { *-*-* } { -fpph-map=pph.map } }
+// { dg-xfail-if BOGUS { *-*-* } { -fpph-map=pph.map } }
 // { dg-bogus 'mbr_decl_inline' was not declared in this scope  { xfail 
*-*-* } 0 }
-// { dg-prune-output In file included from  }
-// { dg-prune-output In member function  }
-// { dg-prune-output At global scope

Re: [pph] Clean up PPH tests (issue4572042)

2011-06-08 Thread Lawrence Crowl
On 6/7/11, Diego Novillo dnovi...@google.com wrote:
 After getting new failures due to an unrelated fix, I think this will
 be more trouble than it's worth.

 First, we can't get rid of the XPASSes, so those will always be noisy.

Remove all the noise with:

sed -e '
/-fpph-map=pph.map/ ! {
/^XPASS: .*test for bogus messages/ d
/^XPASS: .*test for excess errors/  d
}

/^#/p
/^ERROR: /  p
/^XFAIL: /  p
/^XPASS: /  p
/^FAIL: /   p

d
'


 Second, some XPASSes will need to be unmarked because we just fixed
 the underlying problem.

That is how we know that what progress we have made.  These should
be reflected in the work list.


 Third, we are at such an early stage, that fixes to a test case will
 generally expose failures in other already failing tests, but these
 failures will be in a different place.  So more noise.

That is now we expose remaining tasks.  These should be reflected
in the work list.


 I really think that for now the easiest way to keep track of this is
 to have a clean build to compare against.

But the clean build isn't a decent comparison.  The existing tools
only compare against whether or not tests fail.  They fail to
report that a test failed for different reasons.  Given that there
are only twelve tests for which there is a concern, I think we are
better off know where we are.

-- 
Lawrence Crowl


[pph] Front-end builtin macros (issue4575055)

2011-06-08 Thread Lawrence Crowl
Some builtin macros are more builtin than others.  In particular, front-end
builtin macros are weaker than libcpp builtin macros, and should not be
processed with the libcpp builtin tools.


Index: gcc/testsuite/ChangeLog.pph

2011-06-08  Lawrence Crowl cr...@google.com

* g++.dg/pph/c120060625-1.h: Make expected pass.
* g++.dg/pph/c120060625-1.cc: Make expected pass.

Index: libcpp/ChangeLog.pph

2011-06-08  Lawrence Crowl  cr...@google.com

* symtab.c (lt_query_macro): Querying user builtin macros should not
call _cpp_builtin_macro_text.  Instead, call regular query, but first
let the front end define the value.


Index: gcc/testsuite/g++.dg/pph/c120060625-1.cc
===
--- gcc/testsuite/g++.dg/pph/c120060625-1.cc(revision 174789)
+++ gcc/testsuite/g++.dg/pph/c120060625-1.cc(working copy)
@@ -1,5 +1 @@
-// { dg-xfail-if ICE { *-*-* } { -fpph-map=pph.map } }
-// { dg-bogus c120060625-1.h:14:22: internal compiler error: invalid built-in 
macro .__FLT_MAX__.  { xfail *-*-* } 0 }
-// { dg-prune-output In file included from  }
-
 #include c120060625-1.h
Index: gcc/testsuite/g++.dg/pph/c120060625-1.h
===
--- gcc/testsuite/g++.dg/pph/c120060625-1.h (revision 174789)
+++ gcc/testsuite/g++.dg/pph/c120060625-1.h (working copy)
@@ -1,6 +1,3 @@
-// { dg-xfail-if ICE { *-*-* } { -fpph-map=pph.map } }
-// { dg-bogus c120060625-1.h:14:22: internal compiler error: invalid built-in 
macro .__FLT_MAX__.  { xfail *-*-* } 0 }
-
 #ifndef __PPH_GUARD_H
 #define __PPH_GUARD_H
 
Index: libcpp/symtab.c
===
--- libcpp/symtab.c (revision 174789)
+++ libcpp/symtab.c (working copy)
@@ -494,7 +494,8 @@ static const char *
 lt_query_macro (cpp_reader *reader, cpp_hashnode *cpp_node)
 {
   const char *definition = NULL;
-  if (cpp_node-flags  NODE_BUILTIN)
+  if ((cpp_node-flags  NODE_BUILTIN)
+   cpp_node-value.builtin  BT_FIRST_USER)
 {
   const char *str = (const char *)cpp_node-ident.str;
   if (   strcmp(str, __DATE__) == 0
@@ -527,6 +528,8 @@ lt_query_macro (cpp_reader *reader, cpp_
   else
 {
   char c;
+  if ((cpp_node-flags  NODE_BUILTIN)  reader-cb.user_builtin_macro)
+reader-cb.user_builtin_macro (reader, cpp_node);
   definition = (const char *) cpp_macro_definition (reader, cpp_node);
   /* Skip over the macro name within the definition.  */
   c = *definition;

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


Re: [pph] New script to reproduce failures from a .log file (issue4601050)

2011-06-09 Thread Lawrence Crowl
On 6/9/11, Diego Novillo dnovi...@google.com wrote:
 This small script searches for the spawn line corresponding to a given
 grep pattern inside a dejagnu log file.  If it finds the spawn line,
 it executes it with any other arguments provided on the command line.

 It's generally useful for cutting and pasting failed test cases.  I did
 not find anything close to it in gcc/contrib, so I will be adding it
 to trunk shortly.

 Gab, Lawrence, this ought to simplify reproducing pph failures from
 g++.log.  Feel free to add more functionality to it, or use it to
 find writer and reader pairs in the log file and execute them separately.


 Diego.


   * repro_fail: New.

 diff --git a/contrib/repro_fail b/contrib/repro_fail
 new file mode 100755
 index 000..d5bce04
 --- /dev/null
 +++ b/contrib/repro_fail
 @@ -0,0 +1,49 @@
 +#!/bin/bash
 +#
 +# Script to reproduce a test failure from a dejagnu .log file
 +#
 +# Contributed by Diego Novillo dnovi...@google.com
 +#
 +# Copyright (C) 2011 Free Software Foundation, Inc.
 +#
 +# This file is part of GCC.
 +#
 +# GCC is free software; you can redistribute it and/or modify
 +# it under the terms of the GNU General Public License as published by
 +# the Free Software Foundation; either version 3, or (at your option)
 +# any later version.
 +#
 +# GCC is distributed in the hope that it will be useful,
 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 +# GNU General Public License for more details.
 +#
 +# You should have received a copy of the GNU General Public License
 +# along with GCC; see the file COPYING.  If not, write to
 +# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
 +# Boston, MA 02110-1301, USA.
 +
 +if [ $# -lt 2 ] ; then
 +echo usage: $0 pattern file.log [additional-args]
 +echo
 +echo Finds the 'spawn' line matching PATTERN in FILE.LOG and executes
 +echo the command with any arguments in ADDITIONAL-ARGS.
 +echo
 +exit 1
 +fi
 +
 +set -e
 +pattern=$1
 +logf=$2
 +shift 2
 +args=$@
 +line=$(grep ^spawn .*$pattern $logf | sed -e s:^spawn ::)

line=$(sed -e /^spawn .*$pattern/ ! d ; s/^spawn // $logf)

Has one fewer process and one fewer pipe.  Sed is your friend.

I think this code fails when multiple lines match the pattern.
Pipe through head?

 +
 +if [ $line =  ] ; then
 +echo Could not find a spawn command for pattern $1
 +exit 1
 +fi
 +
 +set -x +e
 +$line $args
 +exit $?

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



-- 
Lawrence Crowl


Re: [pph] New test (issue4629075)

2011-06-27 Thread Lawrence Crowl
On 6/27/11, Diego Novillo dnovi...@google.com wrote:
 On Jun 27, 2011 Gabriel Charette gch...@google.com wrote:
  Just wondering why you're naming x finishing by an underscore
  x_, this is a valid name, but just thinking it's tricky syntax,
  does this test anything more? or is it just a preference for
  private members?

 No real reason.  Just a quick hack I was trying to compile with
 pph enabled.

There is a convention in Google (and elsewhere) to mark data member
fields with a trailing underscore in their name.  This convention
makes it easy to identify field accesses, which helps avoid
performance problems (unnecessary reloads) and correctness problems
(missing reloads in the presence of aliasing).

-- 
Lawrence Crowl


Re: [pph] Add header files to pph.map (issue4639073)

2011-06-27 Thread Lawrence Crowl
On 6/27/11, Gabriel Charette gch...@google.com wrote:
 On Jun 27, 2011 Diego Novillo dnovi...@google.com wrote:
  On Jun 27, 2011 Gabriel Charette gch...@google.com wrote:
   Couldn't we have headers look for their corresponding .pph
   file by default when -fpph-map is on? (especially since
   pph.map is only temporary for the implementation phase)
 
  The problem is with headers that include other headers.
  We want to limit the generation of images to specific headers.
  Given that we are in this initial implementation phase, the
  simplest approach is to remember to update pph.map.

 Well in what I'm proposing we only use the pph file if it was
 actually generated before (we don't generate it if it's not
 there). Are there any situations where we have a corresponding
 pph file, but don't actually want to use it when the fpph-map
 flag is on? Seems unlikely as we put all the pph files in the
 pph map for now anyways...

For a shortcut, you can add the option

-fpph-hdr=base-name   A mapping from base-name.h to base-name.pph

In general, the pph files won't live in the same directory as the
header file.  This will cause problems when two headers have the same
name.  I would rather not get into complicated search rules just yet.

-- 
Lawrence Crowl


[pph] Update Tests (issue4636066)

2011-06-27 Thread Lawrence Crowl
Add missing mappings in pph.map.  These new mappings result in changes
to assembly difference expectations.

Remove namespace issues from x1template test.  Copy that test to a new
test x1namespace.

Add a new test x1dynarray, which is executable, when existing failures
get fixed.


Index: gcc/testsuite/ChangeLog.pph

2011-06-27  Lawrence Crowl  cr...@google.com

* g++.dg/pph/pph.map: Add missing PPH mappings.
* g++.dg/pph/c1funcstatic.cc: Add expected asm diff.
* g++.dg/pph/c1eabi1.cc: Add xfail-if; remove expected asm diff.
* g++.dg/pph/c2builtin2.cc: Add expected asm diff.
* g++.dg/pph/x1funcstatic.cc: Add expected asm diff.
* g++.dg/pph/x1template.h: Remove use of namespace.
* g++.dg/pph/x1template.cc: Remove use of namespace; now passing.
* g++.dg/pph/x1namespace.h: New, copy of old x1template.h.
* g++.dg/pph/x1namespace.cc: New, copy of old x1template.cc.
* g++.dg/pph/x1dynarray1.h: New executable program, but it fails.
* g++.dg/pph/x1dynarray1.cc: New executable program, but it fails.


Index: gcc/testsuite/g++.dg/pph/c1funcstatic.cc
===
--- gcc/testsuite/g++.dg/pph/c1funcstatic.cc(revision 175566)
+++ gcc/testsuite/g++.dg/pph/c1funcstatic.cc(working copy)
@@ -1,2 +1,3 @@
+// pph asm xdiff
 #include c1funcstatic.h
 int g() { return f(); }
Index: gcc/testsuite/g++.dg/pph/x1namespace.h
===
--- gcc/testsuite/g++.dg/pph/x1namespace.h  (revision 0)
+++ gcc/testsuite/g++.dg/pph/x1namespace.h  (revision 0)
@@ -0,0 +1,22 @@
+#ifndef X1NAMESPACE_H
+#define X1NAMESPACE_H
+namespace A {
+extern int x;
+struct B;
+template typename T 
+struct C {
+T* b;
+int method();
+int another()
+{ return *b; }
+};
+template typename T 
+int C T ::method()
+{ return x; }
+} // namespace A
+struct D : A::C int  {
+int method();
+int another()
+{ return *b; }
+};
+#endif
Index: gcc/testsuite/g++.dg/pph/x1template.h
===
--- gcc/testsuite/g++.dg/pph/x1template.h   (revision 175566)
+++ gcc/testsuite/g++.dg/pph/x1template.h   (working copy)
@@ -1,6 +1,5 @@
 #ifndef X1TEMPLATE_H
 #define X1TEMPLATE_H
-namespace A {
 extern int x;
 struct B;
 template typename T 
@@ -13,8 +12,7 @@ struct C {
 template typename T 
 int C T ::method()
 { return x; }
-} // namespace A
-struct D : A::C int  {
+struct D : C int  {
 int method();
 int another()
 { return *b; }
Index: gcc/testsuite/g++.dg/pph/c1eabi1.cc
===
--- gcc/testsuite/g++.dg/pph/c1eabi1.cc (revision 175566)
+++ gcc/testsuite/g++.dg/pph/c1eabi1.cc (working copy)
@@ -1,5 +1,5 @@
 // { dg-timeout 2 { target *-*-* } }
+// { dg-xfail-if INFINITE { *-*-* } { -fpph-map=pph.map } }
 // { dg-options -w -fpermissive }
-// pph asm xdiff
 
 #include c1eabi1.h
Index: gcc/testsuite/g++.dg/pph/c2builtin2.cc
===
--- gcc/testsuite/g++.dg/pph/c2builtin2.cc  (revision 175566)
+++ gcc/testsuite/g++.dg/pph/c2builtin2.cc  (working copy)
@@ -1,3 +1,4 @@
+// pph asm xdiff
 #include a2builtin4.h
 #include c2builtin5.h
 #include c2builtin6.h
Index: gcc/testsuite/g++.dg/pph/pph.map
===
--- gcc/testsuite/g++.dg/pph/pph.map(revision 175566)
+++ gcc/testsuite/g++.dg/pph/pph.map(working copy)
@@ -6,9 +6,11 @@ c1builtin-integral-1.h c1builtin-integra
 c1builtin-object-size-2.h  c1builtin-object-size-2.pph
 c1chained1.h   c1chained1.pph
 c1chained2.h   c1chained2.pph
+c1eabi1.h  c1eabi1.pph
 c1empty.h  c1empty.pph
 c1field.h  c1field.pph
 c1funcmac.hc1funcmac.pph
+c1funcstatic.h c1funcstatic.pph
 c1functions.h  c1functions.pph
 c1guarded1.h   c1guarded1.pph
 c1guarded2.h   c1guarded2.pph
@@ -28,6 +30,8 @@ c1variables.h c1variables.pph
 c2builtin1.h   c2builtin1.pph
 c2builtin2.h   c2builtin2.pph
 c2builtin3.h   c2builtin3.pph
+c2builtin5.h   c2builtin5.pph
+c2builtin6.h   c2builtin6.pph
 c2dupguard1.h  c2dupguard1.pph
 c2dupguard2.h  c2dupguard2.pph
 c2paste.h  c2paste.pph
@@ -38,10 +42,12 @@ stdlib.hstdlib.pph
 string.h   string.pph
 sys/types.htypes.pph
 x1autometh.h   x1autometh.pph
+x1dynarray1.h  x1dynarray1.pph
 x1funcstatic.h x1funcstatic.pph
 x1functions.h  x1functions.pph
 x1globalref.h  x1globalref.pph
 x1hardlookup.h x1hardlookup.pph
+x1namespace.h  x1namespace.pph
 x1special.hx1special.pph
 x1struct0.hx1struct0.pph
 x1struct1.hx1struct1.pph
@@ -53,6 +59,6 @@ x1tmplfunc.h  x1tmplfunc.pph
 x1typerefs.h   x1typerefs.pph
 x1variables.h  x1variables.pph
 x2nontrivinit.hx2nontrivinit.pph
-y2overload1.h  y2overload1.pph
-y2overload2.h  y2overload2.pph
-y2overload3.h  y2overload3.pph
+x2overload1.h  x2overload1

[pph] Correct executable testing. Factor x1dynarray1. (issue4667050)

2011-06-29 Thread Lawrence Crowl
Fix dg-pph.exp to execute both normal and pph executable tests and to avoid
false new/disappeared reports.

Break x1dynarray1 into three levels of tests.

Remove ICE failure in x1dynarray1.  We now get bogus warnings, but we cannot
seem to mark them with dg-bogus without also getting xfails.


Index: gcc/testsuite/ChangeLog.pph

2011-06-29  Lawrence Crowl  cr...@google.com

* lib/dg-pph.exp: Run pph executables when normal executables run.
Change (assembly identical) and (assembly mismatch) to (assembly
comparison) to avoid false disappeared test
reports.
* g++.dg/pph/x1dynarray1.h: Simplfy test to avoid more complicated
language features: namespaces, exceptions, placement new, and explicit
destructor calls.
* g++.dg/pph/x1dynarray1.cc: Strip out namespaces.
* g++.dg/pph/x1dynarray0.cc: New.  An even simpler use.
* g++.dg/pph/x1dynarray2.h: New.  Add back the full test.
* g++.dg/pph/x1dynarray2.cc: New.  Add back the full test.


Index: gcc/testsuite/lib/dg-pph.exp
===
--- gcc/testsuite/lib/dg-pph.exp(revision 175673)
+++ gcc/testsuite/lib/dg-pph.exp(working copy)
@@ -74,29 +74,35 @@ proc dg-pph-pos { subdir test options ma
 set dg-do-what-default compile
 dg-test -keep-output $test $options -I. 
 
-# Quit if it did not compile successfully.
-if { ![file_on_host exists $bname.s] } {
-   # All regular compiles should pass.
-   fail $nshort $options (regular assembly missing)
-   return
+# Executables do not generate assembly.
+if { ![string compare dg-do-what run] } {
+   # Not executable, so quit if it did not compile successfully.
+   if { ![file_on_host exists $bname.s] } {
+   fail $nshort $options (regular assembly missing)
+   return
+   }
+   # Rename the .s file into .s-pph to compare it after the second build.
+   remote_upload host $bname.s $bname.s-pph
+   remote_download host $bname.s-pph
+   file_on_host delete $bname.s
 }
 
-# Rename the .s file into .s-pph to compare it after the second build.
-remote_upload host $bname.s $bname.s-pph
-remote_download host $bname.s-pph
-file_on_host delete $bname.s
-
 verbose -log 
 
 # Compile a second time using the pph files.
 dg-test -keep-output $test $options $mapflag -I. 
 
+# Executables do not generate assembly,
+if { [string compare dg-do-what run] } {
+   # and so we are done testing.
+   return
+}
+
 # Quit if it did not compile successfully.
 if { ![file_on_host exists $bname.s] } {
# Expect assembly to be missing when the compile is an
-   # expected fail or when this was an executable test.
-   if { ![string compare dg-do-what run] \
- ![llength [grep $test dg-xfail-if.*-fpph-map]] } {
+   # expected fail.
+   if { ![llength [grep $test dg-xfail-if.*-fpph-map]] } {
fail $nshort $options (pph assembly missing)
}
return
@@ -117,17 +123,17 @@ proc dg-pph-pos { subdir test options ma
fail $nshort $options comparison failure
 } elseif { $adiff == 1 } {
if { $xdiff } {
-   xpass $nshort $options (assembly identical)
+   xpass $nshort $options (assembly comparison)
} else {
-   pass $nshort $options (assembly identical)
+   pass $nshort $options (assembly comparison)
}
file_on_host delete $bname.s-pph
file_on_host delete $bname.s+pph
 } else {
if { $xdiff } {
-   xfail $nshort $options (assembly mismatch)
+   xfail $nshort $options (assembly comparison)
} else {
-   fail $nshort $options (assembly mismatch)
+   fail $nshort $options (assembly comparison)
}
 }
 }
Index: gcc/testsuite/g++.dg/pph/x1dynarray2.h
===
--- gcc/testsuite/g++.dg/pph/x1dynarray2.h  (revision 0)
+++ gcc/testsuite/g++.dg/pph/x1dynarray2.h  (revision 0)
@@ -0,0 +1,111 @@
+// { dg-xfail-if BOGUS { *-*-* } { -fpph-map=pph.map } }
+// { dg-bogus wchar.h:1:0: error: PPH file stdio.pph fails macro validation, 
_WCHAR_H is  { xfail *-*-* } 0 }
+// { dg-bogus unistd.h:1144:34: error: declaration of .* has a different 
exception specifier  { xfail *-*-* } 0 }
+#ifndef X1DYNARRAY2_H
+#define X1DYNARRAY2_H
+
+#include stddef.h
+#include stdexcept
+#include memory
+#include new
+#include iterator
+
+#define DefaultConstructible typename
+#define CPP0X( ignore )
+
+namespace std {
+
+template DefaultConstructible T 
+struct dynarray
+{
+// types:
+typedef   T   value_type;
+typedef   T  reference;
+typedef const T  const_reference;
+typedef   T*  iterator;
+typedef

Re: [pph] Fix executable test detection (issue4635087)

2011-07-01 Thread Lawrence Crowl
LGTM

On 7/1/11, Gabriel Charette gch...@google.com wrote:
 [string compare dg-do-what run] which was used before would always
 return true.

 Thus the tests would no longer even get to the asm diff section...

 Me and Lawrence tried to find a way to get the content of the dg-do-what
 variable, but couldn't.

 We decided to revert to this quick hack fix for now (better then not running
 the asm diffs...)

 (I also added an unrelated re-ordering to the order of the pph asm xdiff
 comment in c1varoder.cc)

 2011-07-01  Gabriel Charette  gch...@google.com

   * g++.dg/pph/c1varorder.cc: Moved pph asm xdiff comment to top.
   * lib/dg-pph.exp (proc): Fixed executable test detection.

 diff --git a/gcc/testsuite/g++.dg/pph/c1varorder.cc
 b/gcc/testsuite/g++.dg/pph/c1varorder.cc
 index 2db8209..a7a65ec 100644
 --- a/gcc/testsuite/g++.dg/pph/c1varorder.cc
 +++ b/gcc/testsuite/g++.dg/pph/c1varorder.cc
 @@ -1,6 +1,7 @@
 -#include c1varorder.h
  // pph asm xdiff

 +#include c1varorder.h
 +
  int foo(void)
  {
return var1 - var2;
 diff --git a/gcc/testsuite/lib/dg-pph.exp b/gcc/testsuite/lib/dg-pph.exp
 index b701ce2..e34bd63 100644
 --- a/gcc/testsuite/lib/dg-pph.exp
 +++ b/gcc/testsuite/lib/dg-pph.exp
 @@ -74,8 +74,11 @@ proc dg-pph-pos { subdir test options mapflag suffix } {
  set dg-do-what-default compile
  dg-test -keep-output $test $options -I. 

 +# Determine whether this is an executable test
 +set is_exec [llength [grep $test dg-do run]]
 +
  # Executables do not generate assembly.
 -if { ![string compare dg-do-what run] } {
 +if { !$is_exec } {
   # Not executable, so quit if it did not compile successfully.
   if { ![file_on_host exists $bname.s] } {
   fail $nshort $options (regular assembly missing)
 @@ -93,7 +96,7 @@ proc dg-pph-pos { subdir test options mapflag suffix } {
  dg-test -keep-output $test $options $mapflag -I. 

  # Executables do not generate assembly,
 -if { [string compare dg-do-what run] } {
 +if { $is_exec } {
   # and so we are done testing.
   return
  }

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



-- 
Lawrence Crowl


Re: [pph] Test cleanup (issue4572050)

2011-07-01 Thread Lawrence Crowl
On 7/1/11, Gabriel Charette gch...@google.com wrote:
 One problem now though: `// pph asm xdiff`, only flags for asm diffs,
 but those could be different diffs after a change (for the better or
 worse) and this won't be caught. It's probably hard to get something
 precise on this, but maybe we could simply add the # of lines of diff
 expected, e.g. `// pph asm xdiff 32`. Then we XFAIL if the number of
 expected lines in the diff match, but actually fail if the number of
 lines in the diff is now different.

 I'm not very familiar with dg.. Is that doable? Would be very helpful
 at this stage.

That looks easy enough.  I need to finish the current test stuff
before I get to that though.

-- 
Lawrence Crowl


[pph] Graduated Application Test (issue4661067)

2011-07-02 Thread Lawrence Crowl
This patch replaces the existing x1dynarray* tests with new versions.
These versions test more in finer grades.

x1dynarray1.cc  : basic template data structure of PODs
x1dynarray2a.cc + wrapped in namespace; accessed with using directive
x1dynarray2b.cc | wrapped in namespace; accessed with qualifier
x1dynarray3.cc  + simple std headers; non-POD; uses exceptions
x1dynarray4.cc  + leading nested PPH; conflicting std header
x1dynarray5.cc  + doubly included PPH; uses iostreams
x1dynarray6.cc  + std headers first; uses stdexception in PPH
x1dynarray7.cc  + reverse iterators (more std header conflict)

The latter test is not an artificial testcase.


Index: gcc/testsuite/ChangeLog.pph

2011-07-01  Lawrence Crowl  cr...@google.com

* g++.dg/pph/a1dynarray-dcl1.hi: New.
* g++.dg/pph/a1dynarray-dcl2a.hi: New.
* g++.dg/pph/a1dynarray-dcl2b.hi: New.
* g++.dg/pph/a1dynarray-dcl3.hi: New.
* g++.dg/pph/a1dynarray-dcl4.hi: New.
* g++.dg/pph/a1dynarray-dfn1a.hi: New.
* g++.dg/pph/a1dynarray-dfn1b.hi: New.
* g++.dg/pph/a1dynarray-dfn2a.hi: New.
* g++.dg/pph/a1dynarray-dfn2b.hi: New.
* g++.dg/pph/a1dynarray-dfn2c.hi: New.
* g++.dg/pph/a1dynarray-dfn3a.hi: New.
* g++.dg/pph/a1dynarray-dfn3b.hi: New.
* g++.dg/pph/a1dynarray-dfn3c.hi: New.
* g++.dg/pph/a1dynarray-hlp1.cci: New.
* g++.dg/pph/a1dynarray-use1.cci: New.
* g++.dg/pph/a1dynarray-use2.cci: New.
* g++.dg/pph/a1dynarray-use3a.cci: New.
* g++.dg/pph/a1dynarray-use3b.cci: New.
* g++.dg/pph/a1dynarray-use4a.cci: New.
* g++.dg/pph/a1dynarray-use4b.cci: New.
* g++.dg/pph/a1integer.h: New.
* g++.dg/pph/x1dynarray0.cc: Removed.
* g++.dg/pph/x1dynarray1.cc: Removed.
* g++.dg/pph/x1dynarray1.h: Removed.
* g++.dg/pph/x1dynarray2.cc: Removed.
* g++.dg/pph/x1dynarray2.h: Removed.
* g++.dg/pph/x1dynarray1.cc: New. (Name reused.)
* g++.dg/pph/x1dynarray1.h: New. (Name reused.)
* g++.dg/pph/x1dynarray2.h: New. (Name reused.)
* g++.dg/pph/x1dynarray2a.cc: New.
* g++.dg/pph/x1dynarray2b.cc: New.
* g++.dg/pph/x1dynarray3.cc: New.
* g++.dg/pph/x1dynarray3.h: New.
* g++.dg/pph/x1dynarray4.cc: New.
* g++.dg/pph/x1dynarray4.h: New.
* g++.dg/pph/x1dynarray5.cc: New.
* g++.dg/pph/x1dynarray5.h: New.
* g++.dg/pph/x1dynarray6.cc: New.
* g++.dg/pph/x1dynarray6.h: New.
* g++.dg/pph/x1dynarray7.cc: New.
* g++.dg/pph/x1dynarray7.h: New.


Index: gcc/testsuite/g++.dg/pph/a1dynarray-dfn2a.hi
===
--- gcc/testsuite/g++.dg/pph/a1dynarray-dfn2a.hi(revision 0)
+++ gcc/testsuite/g++.dg/pph/a1dynarray-dfn2a.hi(revision 0)
@@ -0,0 +1,4 @@
+template typename T 
+dynarrayT::dynarray(const dynarray d)
+: store( alloc( d.count ) ), count( d.count )
+{ memcpy( store, d.store, count * sizeof(T) ); }
Index: gcc/testsuite/g++.dg/pph/x1dynarray2.h
===
--- gcc/testsuite/g++.dg/pph/x1dynarray2.h  (revision 175776)
+++ gcc/testsuite/g++.dg/pph/x1dynarray2.h  (working copy)
@@ -1,111 +1,23 @@
-// { dg-xfail-if BOGUS { *-*-* } { -fpph-map=pph.map } }
-// { dg-bogus wchar.h:1:0: error: PPH file stdio.pph fails macro validation, 
_WCHAR_H is  { xfail *-*-* } 0 }
-// { dg-bogus unistd.h:1144:34: error: declaration of .* has a different 
exception specifier  { xfail *-*-* } 0 }
 #ifndef X1DYNARRAY2_H
 #define X1DYNARRAY2_H
 
-#include stddef.h
-#include stdexcept
-#include memory
-#include new
-#include iterator
-
-#define DefaultConstructible typename
-#define CPP0X( ignore )
+extern C void *memcpy(void *dest, const void *src, unsigned long n);
+extern C void exit(int) throw();
 
-namespace std {
+namespace tst {
 
-template DefaultConstructible T 
+template typename T 
 struct dynarray
 {
-// types:
-typedef   T   value_type;
-typedef   T  reference;
-typedef const T  const_reference;
-typedef   T*  iterator;
-typedef const T*  const_iterator;
-typedef std::reverse_iteratoriterator   reverse_iterator;
-typedef std::reverse_iteratorconst_iterator const_reverse_iterator;
-typedef size_tsize_type;
-typedef ptrdiff_t difference_type;
-
-// fields:
-private:
-T*store;
-size_type count;
-
-// helper functions:
-void check(size_type n)
-{ if ( n = count ) throw out_of_range(dynarray); }
-T* alloc(size_type n)
-{ return reinterpret_castT*( new char[ n*sizeof(T) ] ); }
-
-public:
-// construct and destruct:
-dynarray() CPP0X( = delete ) ;
-const

Change hash_table for separate comparator, documentation, cleanups...

2012-10-25 Thread Lawrence Crowl
Change hash_table to support a comparator type different from the
value type stored in the hash table.  The 'find' functions now may
take a different type from the value type.  This requires introducing
a second typedef into the Descriptor conceptual type.  Change the
Descriptor concept to use typedefs value_type and compare_type instead
of T.  Change all users to match.

Add usage documentation to hash-table.h.

Tested on x86-64.

Okay for trunk?


Index: gcc/ChangeLog

2012-10-25  Lawrence Crowl  cr...@google.com

* hash-table.h: Add usage documentation.
(template struct typed_free_remove): Clarify documentation.
Rename template parameter.
(struct typed_noop_remove): Likewise.
(descriptor concept): Change typedef T to value_type.
Add typedef compare_type.  Use more precise template parameter name,
Descriptor instead of Descr.  Update users to match.
(struct hash_table): Change 'find' parameters to use compare_type
instead of the value type.


Index: gcc/tree-ssa-tail-merge.c
===
--- gcc/tree-ssa-tail-merge.c   (revision 192820)
+++ gcc/tree-ssa-tail-merge.c   (working copy)
@@ -226,10 +226,11 @@ struct same_succ_def
   hashval_t hashval;

   /* hash_table support.  */
-  typedef same_succ_def T;
-  static inline hashval_t hash (const same_succ_def *);
-  static int equal (const same_succ_def *, const same_succ_def *);
-  static void remove (same_succ_def *);
+  typedef same_succ_def value_type;
+  typedef same_succ_def compare_type;
+  static inline hashval_t hash (const value_type *);
+  static int equal (const value_type *, const compare_type *);
+  static void remove (value_type *);
 };
 typedef struct same_succ_def *same_succ;
 typedef const struct same_succ_def *const_same_succ;
@@ -237,7 +238,7 @@ typedef const struct same_succ_def *cons
 /* hash routine for hash_table support, returns hashval of E.  */

 inline hashval_t
-same_succ_def::hash (const same_succ_def *e)
+same_succ_def::hash (const value_type *e)
 {
   return e-hashval;
 }
@@ -528,7 +529,7 @@ inverse_flags (const_same_succ e1, const
 /* Compares SAME_SUCCs E1 and E2.  */

 int
-same_succ_def::equal (const_same_succ e1, const_same_succ e2)
+same_succ_def::equal (const value_type *e1, const compare_type *e2)
 {
   unsigned int i, first1, first2;
   gimple_stmt_iterator gsi1, gsi2;
Index: gcc/tree-ssa-threadupdate.c
===
--- gcc/tree-ssa-threadupdate.c (revision 192820)
+++ gcc/tree-ssa-threadupdate.c (working copy)
@@ -127,20 +127,21 @@ struct redirection_data : typed_free_rem
   struct el *incoming_edges;

   /* hash_table support.  */
-  typedef redirection_data T;
-  static inline hashval_t hash (const redirection_data *);
-  static inline int equal (const redirection_data *, const redirection_data
*);
+  typedef redirection_data value_type;
+  typedef redirection_data compare_type;
+  static inline hashval_t hash (const value_type *);
+  static inline int equal (const value_type *, const compare_type *);
 };

 inline hashval_t
-redirection_data::hash (const redirection_data *p)
+redirection_data::hash (const value_type *p)
 {
   edge e = p-outgoing_edge;
   return e-dest-index;
 }

 inline int
-redirection_data::equal (const redirection_data *p1, const
redirection_data *p2)
+redirection_data::equal (const value_type *p1, const compare_type *p2)
 {
   edge e1 = p1-outgoing_edge;
   edge e2 = p2-outgoing_edge;
Index: gcc/java/jcf-io.c
===
--- gcc/java/jcf-io.c   (revision 192820)
+++ gcc/java/jcf-io.c   (working copy)
@@ -276,19 +276,21 @@ find_classfile (char *filename, JCF *jcf

 struct charstar_hash : typed_noop_remove char
 {
-  typedef const char T;
-  static inline hashval_t hash (const T *candidate);
-  static inline bool equal (const T *existing, const T *candidate);
+  typedef const char value_type;
+  typedef const char compare_type;
+  static inline hashval_t hash (const value_type *candidate);
+  static inline bool equal (const value_type *existing,
+   const compare_type *candidate);
 };

 inline hashval_t
-charstar_hash::hash (const T *candidate)
+charstar_hash::hash (const value_type *candidate)
 {
   return htab_hash_string (candidate);
 }

 inline bool
-charstar_hash::equal (const T *existing, const T *candidate)
+charstar_hash::equal (const value_type *existing, const compare_type
*candidate)
 {
   return strcmp (existing, candidate) == 0;
 }
Index: gcc/valtrack.h
===
--- gcc/valtrack.h  (revision 192820)
+++ gcc/valtrack.h  (working copy)
@@ -46,32 +46,33 @@ struct dead_debug_global_entry
 struct dead_debug_hash_descr
 {
   /* The hash table contains pointers to entries of this type.  */
-  typedef struct dead_debug_global_entry T;
+  typedef struct

Re: Change hash_table for separate comparator, documentation, cleanups...

2012-10-26 Thread Lawrence Crowl
On 10/26/12, Richard Biener richard.guent...@gmail.com wrote:
 On Oct 25, 2012 Lawrence Crowl cr...@googlers.com wrote:
  Change hash_table to support a comparator type different from the
  value type stored in the hash table.  The 'find' functions now
  may take a different type from the value type.  This requires
  introducing a second typedef into the Descriptor conceptual type.
  Change the Descriptor concept to use typedefs value_type and
  compare_type instead of T.  Change all users to match.
 
  Add usage documentation to hash-table.h.
 
  Tested on x86-64.
 
  Okay for trunk?

 Can you elaborate on why this is needed?

There are several uses of htab_t that have a different type for
the comparator than from the values in the table.  I also got a
question asking how to make that happen.  So, to enable handling
the existing cases and the question, I added the capability.

-- 
Lawrence Crowl


[patch] Apply conditional down cast to cgraph.h et.al.

2012-10-26 Thread Lawrence Crowl
This patch implements generic type query and conversion functions,
and applies them to the use of cgraph_node, varpool_node, and symtab_node.

The functions are:

bool is_a TYPE (pointer)
  Tests whether the pointer actually points to a more derived TYPE.

TYPE *as_a TYPE (pointer)
  Converts pointer to a TYPE*.

TYPE *dyn_cast TYPE (pointer)
  Converts pointer to TYPE* if and only if is_a TYPE pointer.
  Otherwise, returns NULL.
  This function is essentially a checked down cast.

These functions reduce compile time and increase type safety when treating a
generic item as a more specific item.  In essence, the code change is from

  if (symtab_function_p (node))
{
  struct cgraph_node *cnode = cgraph (node);
  
}

to

  if (cgraph_node *cnode = dyn_cast cgraph_node (node))
{
  
}

The necessary conditional test defines a variable that holds a known good
pointer to the specific item and avoids subsequent conversion calls and
the assertion checks that may come with them.

When, the property test is embedded within a larger condition, the variable
declaration gets pulled out of the condition.  (This leaves some room for
using the variable inappropriately.)

  if (symtab_variable_p (node)
   varpool (node)-finalized)
varpool_analyze_node (varpool (node));

becomes

  varpool_node *vnode = dyn_cast varpool_node (node);
  if (vnode  vnode-finalized)
varpool_analyze_node (vnode);

Note that we have converted two sets of assertions in the calls to varpool
into safe and efficient use of a variable.


There are remaining calls to symtab_function_p and symtab_variable_p that
do not involve a pointer to a more specific type.  These have been converted
to calls to a functions is_a cgraph_node and is_a varpool_node.  The
original predicate functions have been removed.

The cgraph.h header defined both a struct and a function with the name
varpool_node.  This name overloading can cause some unintuitive error messages
when, as is common in C++, one omits the struct keyword when using the type.
I have renamed the function to varpool_node_for_decl.

Tested on x86_64.

Okay for trunk?


Index: gcc/ChangeLog

2012-10-26  Lawrence Crowl  cr...@google.com

* is-a.h: New.
(is_a T (U*)): New.  Test for is-a relationship.
(as_a T (U*)): New.  Treat as a derived type.
(dyn_cast T (U*)): New.  Conditionally cast based on is_a.
* cgraph.h (varpool_node): Rename to varpool_node_for_decl.
Adjust callers to match.
(is_a_helper cgraph_node::test (symtab_node_def *)): New.
(is_a_helper varpool_node::test (symtab_node_def *)): New.
(symtab_node_def::try_function): New.  Change most calls to
symtab_function_p with calls to dyn_cast cgraph_node (p).
(symtab_node_def::try_variable): New.  Change most calls to
symtab_variable_p with calls to dyn_cast varpool_node (p).
(symtab_function_p): Remove.  Change callers to use
is_a cgraph_node (p) instead.
(symtab_variable_p): Remove.  Change callers to use
is_a varpool_node (p) instead.
* cgraph.c (cgraph_node_for_asm): Remove redundant call to
symtab_node_for_asm.
* cgraphunit.c (symbol_finalized_and_needed): New.
(symbol_finalized): New.
(cgraph_analyze_functions): Split complicated conditionals out into
above new functions.
* Makefile.in (CGRAPH_H): Add is-a.h as used by cgraph.h.

Index: gcc/lto-symtab.c
===
--- gcc/lto-symtab.c(revision 192862)
+++ gcc/lto-symtab.c(working copy)
@@ -532,11 +532,11 @@ lto_symtab_merge_cgraph_nodes_1 (symtab_

   if (!symtab_real_symbol_p (e))
continue;
-  if (symtab_function_p (e)
-  !DECL_BUILT_IN (e-symbol.decl))
-   lto_cgraph_replace_node (cgraph (e), cgraph (prevailing));
-  if (symtab_variable_p (e))
-   lto_varpool_replace_node (varpool (e), varpool (prevailing));
+  cgraph_node *ce = dyn_cast cgraph_node (e);
+  if (ce  !DECL_BUILT_IN (e-symbol.decl))
+   lto_cgraph_replace_node (ce, cgraph (prevailing));
+  if (varpool_node *ve = dyn_cast varpool_node (e))
+   lto_varpool_replace_node (ve, varpool (prevailing));
 }

   return;
Index: gcc/cgraphbuild.c
===
--- gcc/cgraphbuild.c   (revision 192862)
+++ gcc/cgraphbuild.c   (working copy)
@@ -84,7 +84,7 @@ record_reference (tree *tp, int *walk_su

   if (TREE_CODE (decl) == VAR_DECL)
{
- struct varpool_node *vnode = varpool_node (decl);
+ struct varpool_node *vnode = varpool_node_for_decl (decl);
  ipa_record_reference ((symtab_node)ctx-varpool_node,
(symtab_node)vnode,
IPA_REF_ADDR, NULL);
@@ -123,7 +123,7 @@ record_type_list (struct cgraph_node *no
  type = TREE_OPERAND (type, 0

Re: [patch] Unify bitmap interface.

2012-10-26 Thread Lawrence Crowl
On 10/25/12, Lawrence Crowl cr...@googlers.com wrote:
 This patch implements the unification of the *bitmap interfaces as
 discussed.
 Essentially, we rename ebitmap and sbitmap functions to use the same names
 as the bitmap functions.  This rename works because we can now overload
 on the bitmap type.  Some macros now become inline functions to enable
 that overloading.

 The sbitmap non-bool returning bitwise operations have been merged with
 the bool versions.  Sometimes this merge involved modifying the non-bool
 version to compute the bool value, and sometimes modifying bool version to
 add additional work from the non-bool version.  The redundant routines have
 been ifdef'd out.  I will remove the ifdef'd out code later.

 The allocation functions have not been renamed, because we often do not
 have an argument on which to overload.  The cardinality functions have not
 been renamed, because they have different parameters, and are thus not
 interchangable.  The iteration functions have not been renamed, because
 they are functionally different.

 Tested on x86_64.  Config testing in progress.

Config testing has only 3 failures, all unrelated.

-- 
Lawrence Crowl


Re: [patch] Unify bitmap interface.

2012-10-29 Thread Lawrence Crowl
On 10/29/12, Richard Biener richard.guent...@gmail.com wrote:
 On Oct 29, 2012 Diego Novillo dnovi...@google.com wrote:
  On Oct 25, 2012 Lawrence Crowl cr...@googlers.com wrote:
   The sbitmap non-bool returning bitwise operations have been
   merged with the bool versions.  Sometimes this merge involved
   modifying the non-bool version to compute the bool value,
   and sometimes modifying bool version to add additional work
   from the non-bool version.  The redundant routines have been
   ifdef'd out.  I will remove the ifdef'd out code later.
 
  No #if 0 code, please.  Let's just remove them.

Okay, but I point out that there is an awful lot of #if 0 code
out there.  I would rather have done such removal in a followup
patch.

   The allocation functions have not been renamed, because we
   often do not have an argument on which to overload.
 
  Would it work if we made the first argument a reference to the
  bitmap being allocated?  I suppose this shouldn't be a big deal.

 It's definitely good to at least in one place see what kind of
 bitmap is actually being used ... ;)

The parameters to the allocation functions are different.  So even
if they had the same name, they are not interchangable.

   The cardinality functions have not been renamed, because they
   have different parameters, and are thus not interchangable.
 
  Why not change the parameters then?

 Agree, as a followup maybe.

The sbitmap popcount function is only used in ebitmap, which is
itself not used.  If we do anything, removing them might be the
thing to do.

   The iteration functions have not been renamed, because they
   are functionally different.
 
  Functionally different?  How?

The bitmap.h iterators set and the sbitmap.h iterator set intersect
in one element.  I would rather treat the iterator conversion as
a separate patch.

  It seems like the patch only goes skin deep.  I would rather
  make a true unification.  If the only thing that remains the
  different are the allocation functions, that's not a big deal.
  But the point was to make everything else the same.

 Indeed.

It's not quite skin deep as it removes the distinction between the
value returning and non-value returning functions.  The intent here
is to change the skin.

Richard said in an earlier mail, I'd rather not mix this with
any kind of further C++-ification (that is introduction of member
functions or operator overloads).  So, exactly what are you
all after?

  I also notice that the patch does not rename any of the SET_BIT,
  RESET_BIT functions in sbitmap.c.

 They should go - a followup is fine though.

That was the intent.

   Tested on x86_64.  Config testing in progress.
 
  You will also want to test on a couple other architecture on
  the farm.  By config testing, do you mean contrib/config-list.mk?

Yes, I meant that.  There are no functional changes here.  Why is
contrib/config-list.mk not sufficient?

-- 
Lawrence Crowl


Re: [patch] Apply conditional down cast to cgraph.h et.al.

2012-10-29 Thread Lawrence Crowl
On 10/27/12, Marc Glisse marc.gli...@inria.fr wrote:
 On Fri, 26 Oct 2012, Lawrence Crowl wrote:
  2012-10-26  Lawrence Crowl  cr...@google.com

 missing ''

Fixed.

  * is-a.h: New.
  (is_a T (U*)): New.  Test for is-a relationship.
  (as_a T (U*)): New.  Treat as a derived type.
  (dyn_cast T (U*)): New.  Conditionally cast based on is_a.

 I can't find this file in the patch...

I forgot to svn add.  Updated patch here.


This patch implements generic type query and conversion functions,
and applies them to the use of cgraph_node, varpool_node, and symtab_node.

The functions are:

bool is_a TYPE (pointer)
  Tests whether the pointer actually points to a more derived TYPE.

TYPE *as_a TYPE (pointer)
  Converts pointer to a TYPE*.

TYPE *dyn_cast TYPE (pointer)
  Converts pointer to TYPE* if and only if is_a TYPE pointer.
  Otherwise, returns NULL.
  This function is essentially a checked down cast.

These functions reduce compile time and increase type safety when treating a
generic item as a more specific item.  In essence, the code change is from

  if (symtab_function_p (node))
{
  struct cgraph_node *cnode = cgraph (node);
  
}

to

  if (cgraph_node *cnode = dyn_cast cgraph_node (node))
{
  
}

The necessary conditional test defines a variable that holds a known good
pointer to the specific item and avoids subsequent conversion calls and
the assertion checks that may come with them.

When, the property test is embedded within a larger condition, the variable
declaration gets pulled out of the condition.  (This leaves some room for
using the variable inappropriately.)

  if (symtab_variable_p (node)
   varpool (node)-finalized)
varpool_analyze_node (varpool (node));

becomes

  varpool_node *vnode = dyn_cast varpool_node (node);
  if (vnode  vnode-finalized)
varpool_analyze_node (vnode);

Note that we have converted two sets of assertions in the calls to varpool
into safe and efficient use of a variable.


There are remaining calls to symtab_function_p and symtab_variable_p that
do not involve a pointer to a more specific type.  These have been converted
to calls to a functions is_a cgraph_node and is_a varpool_node.  The
original predicate functions have been removed.

The cgraph.h header defined both a struct and a function with the name
varpool_node.  This name overloading can cause some unintuitive error messages
when, as is common in C++, one omits the struct keyword when using the type.
I have renamed the function to varpool_node_for_decl.

Tested on x86_64.


Okay for trunk?
Index: gcc/ChangeLog

2012-10-29  Lawrence Crowl  cr...@google.com

* is-a.h: New.
(is_a T (U*)): New.  Test for is-a relationship.
(as_a T (U*)): New.  Treat as a derived type.
(dyn_cast T (U*)): New.  Conditionally cast based on is_a.
* cgraph.h (varpool_node): Rename to varpool_node_for_decl.
Adjust callers to match.
(is_a_helper cgraph_node::test (symtab_node_def *)): New.
(is_a_helper varpool_node::test (symtab_node_def *)): New.
(symtab_node_def::try_function): New.  Change most calls to
symtab_function_p with calls to dyn_cast cgraph_node (p).
(symtab_node_def::try_variable): New.  Change most calls to
symtab_variable_p with calls to dyn_cast varpool_node (p).
(symtab_function_p): Remove.  Change callers to use
is_a cgraph_node (p) instead.
(symtab_variable_p): Remove.  Change callers to use
is_a varpool_node (p) instead.
* cgraph.c (cgraph_node_for_asm): Remove redundant call to
symtab_node_for_asm.
* cgraphunit.c (symbol_finalized_and_needed): New.
(symbol_finalized): New.
(cgraph_analyze_functions): Split complicated conditionals out into
above new functions.
* Makefile.in (CGRAPH_H): Add is-a.h as used by cgraph.h.

Index: gcc/is-a.h
===
--- gcc/is-a.h  (revision 0)
+++ gcc/is-a.h  (revision 0)
@@ -0,0 +1,118 @@
+/* Dynamic testing for abstract is-a relationships.
+   Copyright (C) 2012 Free Software Foundation, Inc.
+   Contributed by Lawrence Crowl.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+http://www.gnu.org/licenses/.  */
+
+
+/*
+
+Suppose you have a symtab_node_def *ptr, AKA symtab_node ptr.  You can
+test whether it points to a 'derived

Re: [patch] Unify bitmap interface.

2012-10-29 Thread Lawrence Crowl
On 10/29/12, Diego Novillo dnovi...@google.com wrote:
 On Oct 29, 2012 Lawrence Crowl cr...@googlers.com wrote:
  The sbitmap popcount function is only used in ebitmap, which is
  itself not used.  If we do anything, removing them might be the
  thing to do.

 Yes, please.

Separate patch, please.

  The bitmap.h iterators set and the sbitmap.h iterator set
  intersect in one element.  I would rather treat the iterator
  conversion as a separate patch.

 OK, but this would be for 4.8, right?

Yes, depending on when stage one closes.

  Richard said in an earlier mail, I'd rather not mix this with
  any kind of further C++-ification (that is introduction of
  member functions or operator overloads).  So, exactly what
  are you all after?

 I'm after full unification.  The patch seemed to stop short of
 doing that.  If you are going to do follow-up patches, that would
 be fine.  But stage 1 is closing, and I'd like to have this done
 for 4.8.  I want to minimize partial transitions.  We have too
 many of those already.

The intent is for follow-up patches.

  Yes, I meant that.  There are no functional changes here.
  Why is contrib/config-list.mk not sufficient?

 Just to make sure.  Testing on ppc should be fast, for example.

Okay.

-- 
Lawrence Crowl


Re: [patch] Unify bitmap interface.

2012-10-30 Thread Lawrence Crowl
On 10/30/12, Diego Novillo dnovi...@google.com wrote:
 On Oct 30, 2012 Bin.Cheng amker.ch...@gmail.com wrote:
  Just one question: Should we change the name of functions
  sbitmap_intersection_of_succs/sbitmap_intersection_of_preds/
  sbitmap_union_of_succs/sbitmap_union_of_preds too? It might
  be a little confusing that sbitmap_* is used among bitmap_*.

 Yes.  Lawrence is proceeding with this unification in stages.
 The next few patches should rename these.

Actually, I didn't know about them because they are auxillary
routines declared outside of the bitmap files.  I've gone ahead
and changed them as well.

 The only two sets of functions that will remain separate for
 now are the iterators and the bitmap creation routines, I think.
 Lawrence?

The iterator functions have been unified, but not the iterator
type names.

-- 
Lawrence Crowl


<    1   2   3   >