gcc.git
10 years agoAdd new xfail manifest for grtev3.heads/pph
Diego Novillo [Thu, 26 Apr 2012 14:10:12 +0000 (26 10:10 -0400)]
Add new xfail manifest for grtev3.

From-SVN: r186876

10 years agoMerged revisions 184819-184823,184825-184830,184837,184844,184849,184852,184854,18485...
Diego Novillo [Wed, 25 Apr 2012 22:57:54 +0000 (25 18:57 -0400)]
Merged revisions 184819-184823,184825-184830,184837,184844,184849,184852,184854,184856,184858-184860,184862-184867,184872-184877,184879-184880,184882-184884,184887,184891,184893-184894,184896-184901,184903-184904,184910-184911,184913-184914,184918-184919,184923,184925-184927,184930,184932-184933,184935-184937,184939-184941,184944-184949,184952-184953,184955,184957-184966,184971,184975,184981-184983,184985-184988,184990,184997,185000,185007,185010-185011,185013,185015,185019,185024-185033,185035-185036,185042-185053,185055-185060,185065-185067,185070,185072-185076,185079-185082,185088-185089,185092,185094,185100-185101,185103,185105-185106,185109,185111,185115,185120,185123-185129,185131-185134,185136-185137,185139-185143,185146,185148-185149,185152,185160,185165,185167-185168,185174-185175,185177,185179,185181-185184,185190,185192-185198,185200-185202,185207-185208,185211,185213-185215,185218-185219,185221-185224,185226,185229-185233,185235,185240,185242,185244-185247,185249-185250,185253-185256,185259-185261,185264-185265,185268,185276,185278,185320-185325,185327-185330,185334-185337,185341,185343,185346,185350-185358,185361-185363,185365,185371,185374-185376,185378-185382,185384-185385,185389-185392,185394-185397,185403-185404,185406,185409-185413,185415-185422,185424,185426-185431,185433,185436-185439,185442-185444,185446-185447,185451,185453-185456,185458-185466,185468-185470,185474,185476,185481,185485-185489,185498-185499,185505,185507-185508,185514,185517,185520,185522,185524-185529,185531,185534-185536,185540-185542,185544-185545,185548,185552,185555,185561-185565,185567-185570,185573,185577-185580,185582-185584,185586-185588,185593,185595-185596,185598-185599,185601-185603,185605,185613-185622,185627,185676-185678,185680,185687-185689,185691-185694,185698-185700,185702,185707,185709,185712,185716,185721-185722,185725,185727-185728,185734-185735,185737,185741,185744-185746,185752,185756,185764-185765,185767-185768,185772-185773,185776-185780,185782,185786-185789,185791-185793,185795,185799-185800,185806-185807,185811-185813,185825,185829,185845,185850-185852,185855,185857,185865,185867,185876,185878,185882-185883,185887,185889-185891,185893-185895,185897,185902-185904,185907,185910,185913-185915,185917,185919,185924-185925,185927-185928,185930-185931,185933,185935,185937-185938,185943,185945-185946,185950-185951,185955-185958,185962-185963,185965-185966,185968,185971,185977-185978,185982-185983,185988,185990,185993-185994,185996-186006,186008-186013,186015-186020,186023-186024,186026,186028-186029,186034-186035,186038,186045,186047,186049-186050,186054-186055,186057-186058,186062-186067,186069-186074,186076-186077,186079-186082,186085,186087,186091-186092,186097,186099-186102,186104,186106,186109-186110,186112,186114,186116,186122-186123,186128,186131,186133-186135,186139-186140,186142,186144,186147,186153,186156,186158-186167,186169-186170,186174,186176-186177,186179,186183-186187,186194,186199-186200,186202,186208-186213,186216-186217,186222-186223,186225-186226,186229,186233-186234,186237,186241,186243,186252,186256-186261,186265,186268-186269,186272,186274,186276,186278,186283-186287,186301,186303-186314,186318-186321,186324-186328,186330,186338-186339,186342-186347,186350-186355,186358,186361-186366,186371-186375,186378,186381,186384,186387-186389,186391,186393,186397,186402-186403,186405-186408,186410-186411,186413-186416,186418-186422,186426-186429,186432-186434,186444-186445,186447-186448,186450-186456,186460,186464-186466,186468-186469,186474,186478-186480,186486,186488,186490-186499,186501-186503,186506-186507,186511,186516,186519-186530,186534,186539-186542,186545-186549,186553,186557,186559-186568,186572,186575-186576,186578-186580,186584-186588,186590-186594,186596-186597,186599-186600,186604-186605,186607,186609-186610,186614-186629,186631,186633,186635,186637,186640,186642,186644,186649,186652-186655,186657-186658,186662,186667-186670,186672-186673,186675-186676,186678,186681,186683,186685,186687,186692-186694,186696-186697,186700-186702,186704,186707,186709-186710,186715,186718,186721-186722,186725-186727,186729-186730,186734,186737,186739,186741-186742,186744,186747-186750,186753-186754,186757,186759-186761,186763-186764,186766,186768-186769,186771-186772,186774,186776 via svnmerge from
svn+ssh://gcc.gnu.org/svn/gcc/trunk

From-SVN: r186846

10 years agoAdd more PPH timers and stats.
Diego Novillo [Tue, 27 Mar 2012 19:35:48 +0000 (27 15:35 -0400)]
Add more PPH timers and stats.

We are spending too much time inside the reading of template bodies.
This patch adds more timers that pinpoint the problem to be the
hashing of specialization tables.  We spend roughly 50% of PPH reading
inside the hashing code.

2012-03-27   Diego Novillo  <dnovillo@google.com>

cp/ChangeLog.pph
* pph-core.c (pph_dump_stats): Print pph_stats.num_spec_entry_elems.
* pph.h (struct pph_stats_s): Add field num_spec_entry_elems.
* pt.c (pph_out_spec_entry_htab): Update pph_stats.num_spec_entry_elems.
(pph_in_bodies_spec_entry_htab): Likewise.
Add timer TV_PPH_SPECIALIZATION_HASH around hashing operations.

ChangeLog.pph
* timevar.def (TV_PPH_SPECIALIZATION_HASH): New timer.
(TV_PPH_OUT_MERGE_KEYS, TV_PPH_OUT_MERGE_BODIES, TV_PPH_IN_MERGE_KEYS,
TV_PPH_IN_MERGE_BODIES): Remove.
(TV_PPH_OUT_BL_K): New.  Update previous users of TV_PPH_OUT_MERGE_KEYS.
(TV_PPH_OUT_BL_B): New.  Update previous users of
TV_PPH_OUT_MERGE_BODIES.
(TV_PPH_OUT_TMPL_K): New.  Update previous users of
TV_PPH_OUT_MERGE_KEYS.
(TV_PPH_OUT_TMPL_B): New.  Update previous users of
TV_PPH_OUT_MERGE_BODIES.
(TV_PPH_IN_BL_K): New.  Update previous users of TV_PPH_OUT_MERGE_KEYS.
(TV_PPH_IN_BL_B): New.  Update previous users of
TV_PPH_OUT_MERGE_BODIES.
(TV_PPH_IN_TMPL_K): New.  Update previous users of
TV_PPH_OUT_MERGE_KEYS.
(TV_PPH_IN_TMPL_B): New.  Update previous users of
TV_PPH_OUT_MERGE_BODIES.

From-SVN: r185892

10 years agoAdd PPH statistics.
Diego Novillo [Tue, 27 Mar 2012 16:59:44 +0000 (27 12:59 -0400)]
Add PPH statistics.

Adds a new flag -fpph-statistics.  When used, it shows various collected
stats at the end of PPH processing.

2012-03-27   Diego Novillo  <dnovillo@google.com>

c-family/ChangeLog.pph
* c.opt (fpph-stats): Add flag.

cp/ChangeLog.pph
* pph-core.c (pph_stats): Declare.
(pph_init): Initialize.
(pph_cache_lookup): Update pph_stats.cache_lookups and
pph_stats.cache_hits.
(pph_dump_stats): New.
(pph_streamer_finish): Call it.
* pph-in.c (pph_in_record_marker): Update
pph_stats.num_records_by_marker and
pph_stats.num_records_by_tag.
* pph.h (enum pph_record_marker): Add value
PPH_NUM_RECORD_MARKERS.
(struct pph_stats_s): Declare.
(pph_stats_t): Declare.

From-SVN: r185886

10 years agoAdjust expected patterns in some tests.
Diego Novillo [Mon, 26 Mar 2012 17:29:12 +0000 (26 13:29 -0400)]
Adjust expected patterns in some tests.

After the mangling adjustments I made earlier, these tests are
now passing and or failing in a different way.  Adjusted.

2012-03-26   Diego Novillo  <dnovillo@google.com>

* g++.dg/pph/x6dynarray4.cc: Adjust expected patterns.
* g++.dg/pph/x6dynarray5.h: Likewise.
* g++.dg/pph/x7dynarray5.cc: Likewise.

From-SVN: r185814

10 years agoAdd timers for PPH actions.
Diego Novillo [Mon, 26 Mar 2012 15:59:30 +0000 (26 11:59 -0400)]
Add timers for PPH actions.

This initial set of timers measures time spent in the major phases of
PPH processing.  We may want to add/remove timers as we measure
performance.

2012-03-26   Diego Novillo  <dnovillo@google.com>

cp/ChangeLog.pph
* pph-core.c (pph_include_handler): Use timer TV_PPH.
(pph_init): Likewise.
(pph_finish): Likewise.
* pph-in.c (pph_in_line_table_and_includes): Use timer
TV_PPH_RESTORE_LINE_TABLE.
(pph_in_replay): Use timer TV_PPH_RESTORE_REPLAY.
(pph_in_identifiers): Use timer TV_PPH_RESTORE_IDENTIFIERS.
(pph_in_global_binding_keys): Use timer
TV_PPH_RESTORE_MERGE_KEYS.
(pph_in_global_binding_bodies): Use timer
TV_PPH_RESTORE_MERGE_BODIES.
(pph_read_file_1): Use timer TV_PPH_RESTORE_MISC and timer
TV_PPH_VALIDATE_IDENTIFIERS.
(pph_read_file): Use timer TV_PPH_RESTORE.
* pph-out.c (pph_writer_init): Use timer TV_PPH_SAVE.
(pph_out_line_table_and_includes): Use timer
TV_PPH_SAVE_LINE_TABLE.
(pph_out_replay): Use timer TV_PPH_SAVE_REPLAY.
(pph_out_identifiers): Use timer TV_PPH_SAVE_IDENTIFIERS.
(pph_out_global_binding_keys): Use timer TV_PPH_SAVE_MERGE_KEYS.
(pph_out_global_binding_bodies): Use timer TV_PPH_SAVE_MERGE_BODIES.
(pph_write_file): Use timer TV_PPH_SAVE_MISC.
(pph_writer_finish): Use timer TV_PPH_SAVE.
* pt.c (pph_in_bodies_spec_entry_htab): Use timer
TV_PPH_RESTORE_MERGE_BODIES.
(pph_out_merge_key_template_state): Use timer TV_PPH_SAVE_MERGE_KEYS.
(pph_out_merge_body_template_state): Use timer TV_PPH_SAVE_MERGE_BODIES.
(pph_in_merge_key_template_state): Use timer TV_PPH_RESTORE_MERGE_KEYS.
(pph_in_merge_body_template_state): Use timer
TV_PPH_RESTORE_MERGE_BODIES.

ChangeLog.pph
* timevar.def (TV_PPH): New timer.
(TV_PPH_VALIDATE_IDENTIFIERS): New timer.
(TV_PPH_SAVE): New timer.
(TV_PPH_SAVE_LINE_TABLE): New timer.
(TV_PPH_SAVE_IDENTIFIERS): New timer.
(TV_PPH_SAVE_MERGE_KEYS): New timer.
(TV_PPH_SAVE_MERGE_BODIES): New timer.
(TV_PPH_SAVE_MISC): New timer.
(TV_PPH_SAVE_REPLAY): New timer.
(TV_PPH_RESTORE): New timer.
(TV_PPH_RESTORE_LINE_TABLE): New timer.
(TV_PPH_RESTORE_IDENTIFIERS): New timer.
(TV_PPH_RESTORE_MERGE_KEYS): New timer.
(TV_PPH_RESTORE_MERGE_BODIES): New timer.
(TV_PPH_RESTORE_MISC): New timer.
(TV_PPH_RESTORE_REPLAY): New timer.

From-SVN: r185810

10 years agoFix check for empty statement list.
Diego Novillo [Mon, 26 Mar 2012 15:59:12 +0000 (26 11:59 -0400)]
Fix check for empty statement list.

We do some sanity checks before starting to write a PPH image.  The
check was inconsistent: for the VEC scope_chain->x_stmt_tree.x_cur_stmt_list
we were asserting that it was NULL *and* empty.

We just need it to be empty.  It doesn't matter if it was allocated.

2012-03-25   Diego Novillo  <dnovillo@google.com>

* pph-out.c (pph_out_global_binding_keys): Fix check for empty
statement list.

From-SVN: r185809

10 years agoMangle TRAIT_EXPR and CONST_DECLs in template parameters.
Diego Novillo [Mon, 26 Mar 2012 15:58:55 +0000 (26 11:58 -0400)]
Mangle TRAIT_EXPR and CONST_DECLs in template parameters.

We use the mangler to generate unique strings to represent types and symbols
that need to be merged.  However, the C++ mangler does not handle all
possible combinations.  This patch works around this problem by using
a combination of the pretty printer and the mangler.  This only works
when a PPH image is being generated, so it does not affect the
standard mangler.

2012-03-25   Diego Novillo  <dnovillo@google.com>

* mangle.c (write_expression): Handle TRAIT_EXPR when PPH is enabled.
(write_template_arg_literal): Handle CONST_DECLs that do not have
a constant DECL_INITIAL when PPH is enabled.

From-SVN: r185808

10 years agoFix bindings for using declarations.
Diego Novillo [Fri, 23 Mar 2012 19:48:02 +0000 (23 15:48 -0400)]
Fix bindings for using declarations.

When an identifier is declared in a using declaration, we were
registering the USING_DECL object in the corresponding binding.

This was wrong, and at the time I hacked around it by simply ignoring
USING_DECLs when setting bindings.  That was wrong too.  What we
actually need to do is discover what is the USING_DECL pointing to and
register that.

I traced the regular parser, and I'm mimicking the lookup of the
associated TYPE_DECL by calling do_nonmember_using_decl.

The only issue I have with this is that I'm not sure where to get the
scope from. In the testcase I'm fixing, the USING_DECL's type has the
namespace_decl where the search should be done.

I'll test in the internal codebase and see if this is always the case.

2012-03-23   Diego Novillo  <dnovillo@google.com>

cp/ChangeLog.pph
* name-lookup.c (pph_set_identifier_binding): If DECL is a USING_DECL,
register the TYPE_DECL it is referring to.
(pph_set_namespace_decl_binding): Remove previous hack that skipped
USING_DECLs.

testsuite/ChangeLog.pph
* g++.dg/pph/x1mbstate_t.h: Mark fixed.

From-SVN: r185750

10 years agox1mbstate_t.h: Adjust failure pattern.
Diego Novillo [Fri, 23 Mar 2012 13:07:50 +0000 (23 09:07 -0400)]
x1mbstate_t.h: Adjust failure pattern.

2012-03-23   Diego Novillo  <dnovillo@google.com>

* g++.dg/pph/x1mbstate_t.h: Adjust failure pattern.

From-SVN: r185736

10 years agoThis patch addresses the problem of two template instantiations appearing to be ident...
Lawrence Crowl [Thu, 22 Mar 2012 23:58:32 +0000 (22 23:58 +0000)]
This patch addresses the problem of two template instantiations appearing to be identical.

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  <crowl@google.com>

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

Index: gcc/cp/ChangeLog.pph

2012-03-22   Lawrence Crowl  <crowl@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.

From-SVN: r185715

10 years agoAdd expected error in x1mbstate_t.h.
Diego Novillo [Wed, 21 Mar 2012 17:39:06 +0000 (21 13:39 -0400)]
Add expected error in x1mbstate_t.h.

The fix in http://gcc.gnu.org/ml/gcc-patches/2012-03/msg01441.html did not
address the bogus error message that we are now getting.

2012-03-21   Diego Novillo  <dnovillo@google.com>

        * gcc/testsuite/g++.dg/pph/x1mbstate_t.h: Add expected error.

From-SVN: r185608

10 years agoFix x1mbstate_t.h.
Diego Novillo [Wed, 21 Mar 2012 17:31:24 +0000 (21 13:31 -0400)]
Fix x1mbstate_t.h.

This patch fixes the parser segmentation fault caused by a name
lookup failure (details in
http://gcc.gnu.org/ml/gcc-patches/2012-03/msg01369.html).

I am not 100% sure that this is the right fix, but Jason seems to
think that the theory behind this is fine (parser does no allow a
USING_DECL to be set in the bindings of an identifier).  I left a
FIXME note to help future debugging.

2012-03-21   Diego Novillo  <dnovillo@google.com>

cp/ChangeLog.pph
* name-lookup.c (pph_set_namespace_decl_binding): Ignore
USING_DECLs.

testsuite/ChangeLog.pph
* g++.dg/pph/x1mbstate_t.h: Mark fixed.

From-SVN: r185607

10 years agoAdd reduced test case for a common lookup failure.
Diego Novillo [Tue, 20 Mar 2012 17:08:31 +0000 (20 13:08 -0400)]
Add reduced test case for a common lookup failure.

This is reduced from the standard library.  The type mbstate_t is
declared in the global scope and then incorporated into 'std' via
using.

When the header doing this is converted into a PPH image, the lookup
for identifier 'mbstate_t' produces the USING_DECL instead of the
TYPE_DECL in the global scope.

This causes the parser to segfault while parsing 'typedef
std::mbstate_t state_type' in the user of that PPH image.

Working on a fix shortly.

2012-03-20   Diego Novillo  <dnovillo@google.com>

* g++.dg/pph/x0mbstate_t.h: New.
* g++.dg/pph/x1mbstate_t.h: New.

From-SVN: r185581

10 years agoThis patch renames pph_symtab...
Diego Novillo [Mon, 19 Mar 2012 19:18:46 +0000 (19 15:18 -0400)]
This patch renames pph_symtab...

This patch renames pph_symtab, pph_symtab_entry and pph_symtab_action
into pph_replay* to better reflects the semantics of this table.

No functional changes, just a rename.

2012-03-19   Diego Novillo  <dnovillo@google.com>

* pph-streamer.h (struct pph_replay_entry): Rename from
pph_symtab_entry.
Rename field DECL to TO_REPLAY.
Update all users.
(struct pph_replay): Rename from pph_symtab.
(enum pph_replay_action): Rename from pph_symtab_action.

From-SVN: r185539

10 years agoparser.c (cp_lexer_print_token): Protect against NULL values in CPP_NAME tokens.
Diego Novillo [Mon, 19 Mar 2012 19:18:31 +0000 (19 15:18 -0400)]
parser.c (cp_lexer_print_token): Protect against NULL values in CPP_NAME tokens.

2012-03-17   Diego Novillo  <dnovillo@google.com>

* parser.c (cp_lexer_print_token): Protect against NULL
values in CPP_NAME tokens.

From-SVN: r185538

10 years agoAdd support to re-play actions on types as well as symbols.
Diego Novillo [Mon, 19 Mar 2012 19:18:14 +0000 (19 15:18 -0400)]
Add support to re-play actions on types as well as symbols.

When declaring class types, the parser calls finish_struct_methods to perform
things like sorting the method vector for the class.  This needs
to be done at reading time, because the sorting is done based on
the pointer values of the entries in the method vector.

We were eagerly doing this for *all* class types we read from PPH
images, but this is not applicable to all class types.  Using the
symtab to replay this action allows us to do it exactly on the
same classes done during the original parse.

The symbol table needs renaming now.  Done in a subsequent patch.

2012-03-19   Diego Novillo  <dnovillo@google.com>

* Make-lang.in (cp/class.o): Add dependency on PPH_H.
* class.c (finish_struct_methods): If pph_writer_enabled_p
returns true, call pph_add_type_to_symtab.
* pph-in.c (pph_in_tcc_type): Do not call finish_struct_methods.
(pph_in_symtab_action): Handle PPH_SYMTAB_FINISH_STRUCT_METHODS.
(pph_in_symtab): Likewise.
* pph-out.c (pph_out_symtab_action): Likewise.
(pph_add_type_to_symtab): New.
* pph.h (enum pph_symtab_action): Add PPH_SYMTAB_FINISH_STRUCT_METHODS.
(pph_add_type_to_symtab): Declare.

From-SVN: r185537

10 years agoThis patch addresses two main problems.
Lawrence Crowl [Sat, 17 Mar 2012 02:09:40 +0000 (17 02:09 +0000)]
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  <crowl@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  <crowl@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  <crowl@google.com>

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

From-SVN: r185482

10 years agoThis patch mostly adds several test cases reduced from full-scale attempts to
Lawrence Crowl [Thu, 15 Mar 2012 22:08:12 +0000 (15 22:08 +0000)]
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  <crowl@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  <crowl@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  <crowl@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.

From-SVN: r185445

10 years agoAdd a GC root for the lexer.
Diego Novillo [Wed, 14 Mar 2012 23:55:30 +0000 (14 19:55 -0400)]
Add a GC root for the lexer.

This GC root is required to support running the garbage collector
during lexing.  This happens when the lexer loads pre-parsed headers.
Loading these headers calls into the middle-end, which may run the
garbage collector.

This was triggering in some of the bigger translation units that cause
a lot of GC activity.

2012-03-14   Diego Novillo  <dnovillo@google.com>

* parser.c (the_lexer): Declare.
(cp_lexer_new_main): Initialize.
(c_parse_file): Set to NULL.

From-SVN: r185399

10 years agoDetect one class of invalid merges.
Diego Novillo [Wed, 14 Mar 2012 23:48:05 +0000 (14 19:48 -0400)]
Detect one class of invalid merges.

When merging two different EXPRs, we are currently merging some trees
that should not be merged.  This patch tries to identify one case
where we can certainly detect that a bad merge is about to happen.

This fixes no tests, but diagnoses quite a few bad merges in our
internal testing.

2012-03-14   Diego Novillo  <dnovillo@google.com>

* pph-in.c (pph_in_merge_key_tree_with_searcher): Detect and
diagnose attempts to merge two distinct trees from the same
PPH image.

From-SVN: r185398

10 years agoRemove callgraph nodes from PPH images.
Diego Novillo [Tue, 13 Mar 2012 16:56:42 +0000 (13 12:56 -0400)]
Remove callgraph nodes from PPH images.

This patch fixes several failures by refusing to generat code while
writing PPH images.  Instead, the writer saves state information for
the reader to expand and declare symbols via rest_of_decl_compilation
and expand_or_defer_fn/expand_or_defer_fn_1.

In the process, I had to deal with some global state that is used
during expansion.  The idea is that during generation, calls to any of
the above functions are cut short.  The symbol being expanded is added
to the PPH symbol table, together with all the state needed to re-play
the action during reading.

This slims down the data we save on PPH images and makes the writer
slightly faster by not doing any code generation actions (similarly to
how LTO operates in WPA mode).

I still need to cleanup the flags used to recognize if PPH is enabled.
PPH is a C++-only feature, but we are accessing its flags from
toplev.c.  In a subsequent pass, I'll move those flags to common code
and mark it as a C++-exclusive feature.

This change also required merging the DECL_NOT_REALLY_EXTERN.  It was
being clobbered during merging, and it's used by the expansion code.
Not merging it properly was causing several failures because
FUNCTION_DECLs were being dropped out of the cgraph.

We were also mis-merging DECL_RESULT and DECL_ARGUMENTS.  When a
function decl F already had a body, we do not want to take the result
and arguments from the decl that we are merging in.  This causes
trouble later during RTL expansion because the pointers used in the
body are different than those stored in DECL_RESULT and
DECL_ARGUMENTS.

2012-03-13   Diego Novillo  <dnovillo@google.com>

c-family/ChangeLog.pph
* c-common.h (pph_writer_enabled_p): Declare.
(pph_enabled_p): Declare.
* c-opts.c (pph_writer_enabled_p): New.
(pph_enabled_p): New.
* c.opt (fpph-gen): Add Var(flag_pph_gen).

cp/ChangeLog.pph
* decl.c (cp_rest_of_decl_compilation): When generating a PPH
file, call pph_add_decl_to_symtab and return.
* pph-core.c (tag_strings): Remove "PPH_cgraph_node".
* pph-in.c (pph_in_merge_ld_base): Merge
ldb->not_really_extern with |=.
(pph_in_merge_lang_indep_tree_body): Preserve existing
DECL_ARGUMENTS for a FUNCTION_DECL only if the decl already
has a DECL_SAVED_TREE.
(pph_reset_external): Remove.  Update all users.
(pph_in_nonnull_tree): Overwrite *FIELD only if it is
currently NULL.
(pph_in_cgraph_node): Remove.  Update all users.
(pph_node_already_emitted): Remove.  Update all users.
(pph_fn_already_expanded): New.
(pph_in_symtab): Call it.
Read all new fields in pph_symtab_entry.
Handle PPH_SYMTAB_EXPAND and PPH_SYMTAB_EXPAND_1 actions.
* pph-out.c (pph_out_struct_function_for_decl): Remove.
(pph_out_symtab_action): Assert that the action is in the set
of known action.
(pph_out_cgraph_node): Remove.  Update all users.
(pph_out_cgraph_node_for_decl): Remove.  Update all users.
(pph_add_decl_to_symtab): Capture global state required to
re-play symtab actions in the reader.
(pph_out_symtab): Write all new fields from pph_symtab_entry.
* pph-streamer.h (struct pph_symtab_entry): Add fields AT_EOF,
X_PROCESSING_TEMPLATE_DECL and FUNCTION_DEPTH.
* pph.h (enum pph_symtab_action): Add value PPH_SYMTAB_EXPAND_1.
(enum pph_tag): Remove value PPH_cgraph_node.  Update all
users.
(pph_writer_enabled_p): Move to c-family/c-opts.c.
(pph_enabled_p): Likewise.
* cp/semantics.c (expand_or_defer_fn_1): If we are generating
a PPH file, add it to the symbol table and return.
(expand_or_defer_fn): Likewise.
* toplev.c (compile_file): If -fpph-gen is used, do not
generate code.

testsuite/ChangeLog.pph
* g++.dg/pph/x2incomplete4.cc: Mark fixed.
* g++.dg/pph/x4incomplete4123.cc: Likewise.
* g++.dg/pph/x4incomplete4321.cc: Likewise.
* g++.dg/pph/x4keyed.cc: Likewise.
* g++.dg/pph/x4keyex.cc: Likewise.
* g++.dg/pph/x4keyno.cc: Likewise.
* g++.dg/pph/x6dynarray5.h: Update expected failure patterns.
* g++.dg/pph/x7dynarray6.cc: Likewise.
* g++.dg/pph/x7rtti.cc: Likewise.

From-SVN: r185345

10 years agoThis patch adds more trees to the preloaded tree cache.
Diego Novillo [Tue, 13 Mar 2012 16:56:21 +0000 (13 12:56 -0400)]
This patch adds more trees to the preloaded tree cache.

This patch adds more trees to the preloaded tree cache.  This avoids
common trees, built at compiler initialization time, to be streamed
out to PPH images.

These trees are in:

- type_hash_table: The private hash table used in tree.c to
  record canonical types.  To avoid exposing this table out of
  tree.c, I added a traversal routine with a callback argument
  (type_hash_table_traverse).

- Builtin types registered with record_builtin_type.  I added
  a routine pph_register_builtin_type that is called for every
  builtin type.  We later record those types in
  pph_cache_preload.

Another piece of private state that needs to be written out is
canonical_template_parms and nonstandard_integer_type_cache.  I added
writer and reader routines to pt.c to do deal with
canonical_template_parms and traversal+callback iterators in tree.c to
deal with nonstandard_integer_type_cache (to avoid middle-end routines
to have to know about PPH).

2012-03-13   Diego Novillo  <dnovillo@google.com>

cp/ChangeLog.pph
* decl.c (record_builtin_type): Call pph_register_builtin_type.
* pph-core.c (pph_cache_add_full_tree_r): New.
(pph_cache_add_full_tree): New.
(nitc_callback): New.
(pph_builtin_types): Declare.
(pph_register_builtin_type): New.
(pph_cache_add_builtin_types): New.
(pph_cache_add_canonical_type): New.
(pph_cache_preload): Call pph_cache_add_full_tree instead of
pph_cache_add.
Call traverse_nonstandard_integer_type_cache with nitc_callback.
Call pph_cache_add_builtin_types.
Call type_hash_table_traverse.
* pph-in.c (pph_in_tcc_type): Read TYP_NEXT_PTR_TO for
POINTER_TYPE types.
(pph_read_file_1): Call pph_in_canonical_template_parms.
* pph-out.c (pph_out_tcc_type): Write TYPE_NEXT_PTR_TO for
POINTER_TYPE types.
(pph_write_file): Call pph_out_canonical_template_parms.
* pph.h (pph_register_builtin_type): Declare.
(pph_out_canonical_template_parms): Declare.
(pph_in_canonical_template_parms): Declare.
* pt.c (pph_out_canonical_template_parms): New.
(pph_in_canonical_template_parms): New.

ChangeLog.pph
* tree.c (type_hash_traverse): Declare.
(type_hash_table_retrieve_entry): New.
(type_hash_table_traverse): New.
(type_hash_table_length): New.
(CACHED_PREC_LEN): Factor out of ...
(nonstandard_integer_type_cache): ... here.
(traverse_nonstandard_integer_type_cache): New.
* tree.h (type_hash_table_traverse): Declare.
(type_hash_table_length): Declare.
(traverse_nonstandard_integer_type_cache): Declare.

From-SVN: r185344

10 years agoDisable warning when a system header is a primary compilation file.
Lawrence Crowl [Sat, 10 Mar 2012 01:30:43 +0000 (10 01:30 +0000)]
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  <crowl@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  <crowl@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  <crowl@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.

From-SVN: r185166

10 years agoThis patch provides three primary fixes.
Lawrence Crowl [Thu, 8 Mar 2012 20:57:10 +0000 (8 20:57 +0000)]
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  <crowl@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  <crowl@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.

From-SVN: r185112

10 years agoMerged revisions 183974,183976-183985,183987,183991,183993-183995,183997-184001,18400...
Diego Novillo [Sun, 4 Mar 2012 18:24:44 +0000 (4 13:24 -0500)]
Merged revisions 183974,183976-183985,183987,183991,183993-183995,183997-184001,184003-184007,184009-184011,184015-184017,184021-184028,184032-184037,184041-184043,184045,184065,184075,184079-184080,184083,184086,184088-184089,184092,184096,184098-184100,184102-184103,184107-184108,184110-184113,184115-184117,184121-184124,184126-184130,184134-184145,184150-184152,184155-184161,184165,184167-184169,184171,184174,184177,184180-184181,184185,184187-184188,184192-184193,184196,184198-184203,184210-184212,184214,184217-184224,184227,184229,184232-184234,184236-184238,184245-184246,184250-184255,184257-184259,184264-184265,184269,184272,184274,184276-184277,184279-184282,184284,184286-184287,184289,184291,184293,184297-184303,184305-184306,184310,184313-184314,184316-184320,184322,184327-184343,184345,184347-184353,184355-184357,184362-184365,184367,184372-184373,184377,184379-184381,184385,184388,184390-184394,184396,184398-184406,184409,184414,184416-184417,184421-184422,184426,184428-184430,184433-184437,184439-184440,184442,184445-184448,184451,184453,184458,184461-184464,184466-184467,184471-184475,184477-184478,184480-184481,184485,184488,184490,184500-184501,184503,184506-184509,184511,184519,184522,184526-184527,184530-184531,184540,184542-184549,184552,184555,184557-184560,184564,184568-184569,184571-184572,184576,184581-184585,184589-184590,184592-184594,184596-184607,184613-184630,184632-184634,184636,184638-184642,184645,184649,184651-184654,184656-184662,184664-184669,184672,184674-184676,184680-184681,184684,184686,184688,184692,184739,184743,184746,184748,184750-184757,184760-184761,184763-184766,184770,184772-184776,184778,184780-184785,184789-184790,184792,184796,184798-184799,184802-184803,184805-184806,184811,184813,184815-184816 via svnmerge from
svn+ssh://gcc.gnu.org/svn/gcc/trunk

Merge from trunk rev 184817.

BASE-VER: Update to 4.8.0-pph.

From-SVN: r184890

10 years agoThis patch merges template specializations.
Lawrence Crowl [Fri, 2 Mar 2012 18:45:05 +0000 (2 18:45 +0000)]
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  <crowl@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  <crowl@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_in_pending_templates_list): Make static.
(pph_out_key_spec_entry_slot): New.
(pph_out_spec_entry_slot): Renamed to pph_out_body_spec_entry_slot.
(pph_out_spec_entry_htab): Make slot function a parameter.
(pph_in_search_key_spec): New.
(pph_in_keys_spec_entry_htab): New.
(pph_in_spec_entry_htab): Rename to pph_in_bodies_spec_entry_htab.
(pph_out_merge_key_template_state): New.
(pph_out_spec_entry_tables): Rename to
pph_out_merge_body_template_state.  Pass search functions.  Add call
to pph_out_pending_templates_list.  Move dumping here.
(static strptrmap_t *decl_spec_tbl): New.
(static strptrmap_t *type_spec_tbl): New.
(pph_in_merge_key_template_state): New.
(pph_in_spec_entry_tables): Rename to pph_in_merge_body_template_state.
Add call to pph_in_pending_templates_list.  Move dumping here.
* pph-out.c (pph_out_merge_key_tree): Made extern.  Added bool
parameter to force merge name emission, which is used for template
type specialization merging.
(pph_out_global_binding): Split into pph_out_global_binding_keys and
pph_out_global_binding_bodies.
(pph_write_file): Change calls for emitting global bindings and
template state.
* pph-in.c (pph_in_string): Make extern.
(pph_in_merge_key_tree): Factor out searching into function parameter.
Rename to pph_in_merge_key_tree_with_searcher.  Always merge trees
when a match is found.  Make extern.
(pph_in_search_key_decl_on_chain): New.
(pph_in_merge_key_decl_on_chain): New.
(pph_in_search_key_type_in_field): New.
(pph_in_merge_key_type_in_field): New.
(pph_in_global_binding): Split into pph_in_global_binding_keys and
pph_in_global_binding_bodies.
(pph_read_file_1): Change calls for emitting global bindings and
        template state.

Index: gcc/ChangeLog.pph

2012-03-01   Lawrence Crowl  <crowl@google.com>

* strptrmap.h: New.
* strptrmap.c: New.
* Makefile.in: Added entries for strptrmap.h and strptrmap.c.

From-SVN: r184814

10 years agoThis patch writes the tree header for mutated trees.
Lawrence Crowl [Thu, 23 Feb 2012 22:19:24 +0000 (23 22:19 +0000)]
This patch writes the tree header for mutated trees.

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  <crowl@google.com>

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

Index: gcc/cp/ChangeLog.pph

2012-02-23   Lawrence Crowl  <crowl@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.

From-SVN: r184532

10 years ago* pph-core.c (pph_init): Use stderr for -fpph-tracer.
Diego Novillo [Mon, 20 Feb 2012 21:27:00 +0000 (20 16:27 -0500)]
* pph-core.c (pph_init): Use stderr for -fpph-tracer.

From-SVN: r184407

10 years agoThis patch avoids a false "used unititalized" error by assigning
Lawrence Crowl [Thu, 16 Feb 2012 23:57:50 +0000 (16 23:57 +0000)]
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  <crowl@google.com>

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

From-SVN: r184321

10 years agoThis patch merges inline functions where a plain declaration is read from a pph...
Lawrence Crowl [Wed, 15 Feb 2012 22:51:28 +0000 (15 22:51 +0000)]
This patch merges inline functions where a plain declaration is read from a pph...

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  <crowl@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  <crowl@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.

From-SVN: r184290

10 years agoThis patch re-writes the streaming of binding levels to guarantee that the...
Diego Novillo [Mon, 13 Feb 2012 21:05:55 +0000 (13 16:05 -0500)]
This patch re-writes the streaming of binding levels to guarantee that the...

This patch re-writes the streaming of binding levels to guarantee that
the whole tree of binding levels in each file is written and merged-in
before anything else.

With this re-factoring, we now write all the binding levels, the merge
keys for symbols/types and their other contents at the start of the
PPH image.  Additionally, we do not skip any namespaces when
traversing the binding level tree (we used to skip over builtin
namespaces, which causes problems when looking up things like
std::ptrdiff_t).

After all the binding levels have been merged-in, every other read of
a binding level is expected to be read as a reference (so that we
don't materialize a new binding level that has not been merged in).

With this change, I get significantly fewer name lookup failures in
our internal code base.  But this is still incomplete.  In chasing
down other failures, I found out that we should be also writing out
the table of canonical types (type_hash_table).  I'm getting a new
ICE, because two different types that compare the same fail the
TYPE_CANONICAL identity test.

Lawrence, to avoid too many merge conflicts with the patch you are
working with, I will be fixing this new failure in a subsequent patch.

Most of this patch is moving code around.  The old
pph_out/in_binding_level is now simply expecting a reference to a
binding level.

The merging into existing binding levels (e.g., the global binding
scope or binding levels for already existing namespaces) is done by
pph_in_binding_level_start.  This routine will take an existing
binding level as parameter and use it in two ways:

   1- If the record read from STREAM is a reference, the binding level
      in that reference must be identical to EXISTING_BL.

   2- If the record read from STREAM is a new instance, the binding
      level given in EXISTING_BL is registered in the cache at the
      slot location given by this record.  This way, subsesequent
      internal references to EXISTING_BL will resolve to EXISTING_BL.
      This is used for binding levels that are already set in the
      compilation (e.g., scope_chain->bindings).

2012-02-13   Diego Novillo  <dnovillo@google.com>

cp/ChangeLog.pph
* pph-in.c (pph_in_binding_level_start): Move earlier into the
file.
Change return type to cp_binding_level *.
Add argument EXISTING_BL and EXISTED_P.
If EXISTING_BL is given, and a reference is read from STREAM,
the reference read should be the same as EXISTING_BL.
If EXISTING_BL is given and a new reference is started,
do not allocate a new instance.  Rather, register EXISTING_BL
in the cache.
(pph_in_binding_level_ref): Rename from pph_in_binding_level.
Assert that it always reads a reference record.
Update all users.
(pph_in_binding_level_1): Move body inside
pph_in_merge_body_binding_level.
(pph_in_merge_key_binding_level): Move earlier in the file.
(pph_in_merge_body_binding_level): Move earlier in the file.
(pph_in_merge_body_binding_level_1): Move body into
pph_in_merge_body_binding_level.
(pph_in_ld_ns): Call pph_in_binding_level_ref.
(pph_ensure_namespace_binding_level): Move body into
pph_in_merge_key_namespace_decl.  Update all users.
(pph_in_merge_key_namespace_decl): Fix comment.
(pph_in_global_binding): Call pph_in_binding_level_start.
* pph-out.c (pph_out_tree_vec_unchain): Remove.
(pph_out_chain_filtered): Remove.
(pph_out_binding_level_ref): Rename from
pph_out_binding_level.  Always expect to write a reference
record.  Update all users.
(pph_out_cxx_binding_1): Embed inside pph_out_merge_body_binding_level.
Update all users.
(pph_out_merge_key_binding_level): Do not filter
BL->NAMESPACES.
(pph_out_merge_body_binding_level): Likewise.

testsuite/ChangeLog.pph
* g++.dg/pph/x7dynarray5.cc: Add expected failure due to
type canonical mismatch.

From-SVN: r184170

10 years agoMerged revisions 184097 via svnmerge from
Diego Novillo [Fri, 10 Feb 2012 17:24:11 +0000 (10 12:24 -0500)]
Merged revisions 184097 via svnmerge from

svn+ssh://gcc.gnu.org/svn/gcc/trunk

........
  r184097 | dnovillo | 2012-02-10 10:52:03 -0500 (Fri, 10 Feb 2012) | 8 lines

  This patch adds two common shortcuts to the failure reproducer
  script.

  Committed to trunk.

  2012-02-10   Diego Novillo  <dnovillo@google.com>

   * repro_fail: Add --debug and --debug-tui flags.
........

From-SVN: r184106

10 years agoAdd merge ChangeLog entry.
Diego Novillo [Wed, 8 Feb 2012 21:14:11 +0000 (8 16:14 -0500)]
Add merge ChangeLog entry.

From-SVN: r184019

10 years agoMerged revisions 182920-182926,182928-182932,182935,182937-182938,182942-182943,18294...
Diego Novillo [Wed, 8 Feb 2012 20:05:21 +0000 (8 15:05 -0500)]
Merged revisions 182920-182926,182928-182932,182935,182937-182938,182942-182943,182947,182950-182954,182959,182963,182965,182967-182975,182979,182981-182984,182988-182995,182999,183002-183003,183005,183007-183008,183010-183013,183015-183018,183020,183024-183025,183028-183030,183032-183034,183038-183039,183043,183047-183067,183069-183070,183072,183085,183087-183090,183092-183109,183111-183112,183117-183124,183126,183129-183130,183132-183133,183136-183137,183141,183144,183148-183151,183153-183156,183158-183159,183161-183162,183164-183169,183171-183173,183177-183180,183182-183183,183185-183186,183190,183192,183194-183197,183204,183207,183210,183213-183214,183216-183222,183228,183233,183235-183238,183242-183243,183245-183249,183251-183254,183261-183264,183268,183270-183273,183277,183281,183285-183288,183290,183295-183297,183299-183301,183303-183307,183310,183312-183313,183317,183324-183326,183328-183330,183335-183336,183338-183342,183344-183345,183348-183352,183355-183356,183358-183359,183363,183365,183368,183370-183371,183374,183376,183378-183379,183381,183385,183388-183390,183396,183402,183406-183414,183416-183425,183427,183429-183436,183438-183439,183441-183446,183450-183455,183457-183458,183462-183468,183470,183472-183476,183478-183483,183485-183494,183496-183497,183499-183500,183502-183503,183507,183509-183510,183512-183516,183518-183519,183521-183522,183524,183527-183542,183547,183549,183552,183555-183557,183559-183561,183566-183567,183570,183577,183579-183585,183588,183591,183593,183598-183599,183601-183611,183613-183616,183620-183622,183624-183625,183627-183630,183632-183635,183637-183638,183641-183644,183648,183650-183652,183655,183660-183661,183663,183667-183670,183674-183688,183692-183694,183696-183708,183710-183711,183713-183715,183717-183726,183728,183730,183732-183733,183737,183739,183741,183743-183745,183749,183751-183759,183763,183765-183766,183768-183771,183773-183775,183782,183787-183788,183791-183794,183796,183798,183800,183802,183806-183808,183810-183812,183814-183816,183821,183825-183826,183829-183830,183832-183833,183836,183840-183841,183843,183846-183849,183851-183853,183859-183860,183862,183865,183867,183869-183870,183873,183875,183878,183887,183889,183891,183894-183895,183900,183902,183904-183918,183920,183925-183926,183928,183932-183934,183936-183937,183940-183945,183951,183953-183956,183962,183964,183966,183968,183970-183972 via svnmerge from
svn+ssh://gcc.gnu.org/svn/gcc/trunk

From-SVN: r184018

10 years agoWhen we re-play the symbol table for a PPH image, we are executing from libcpp's...
Diego Novillo [Tue, 7 Feb 2012 01:09:29 +0000 (6 20:09 -0500)]
When we re-play the symbol table for a PPH image, we are executing from libcpp's #include handler.

When we re-play the symbol table for a PPH image, we are executing
from libcpp's #include handler.  This means that the lexer thinks that
it is inside the #include directive.

This alters the lexer behaviour in subtle ways.  In this test case,
for example, the parsing of the escaped quotes inside the asm()
instruction makes the lexer think that the string has ended before it
actually does.

This cascades into a lexing or syntax error later on because the
string got truncated.

This patch saves and restores the lexer state as we re-play the symbol
table.  Initially, I was trying to do this after we return from the
table are needed while we read the PPH file.

2012-02-06   Diego Novillo  <dnovillo@google.com>

libcpp/ChangeLog.pph
* directives.c (_cpp_clear_directive_state): New.
(end_directive): Call it.
(_cpp_save_directive_state): New.
(_cpp_restore_directive_state): New.
* internal.h (_cpp_clear_directive_state): Declare.
(_cpp_save_directive_state): Declare.
(_cpp_restore_directive_state): Declare.
* symtab.c (cpp_lt_replay): Call
_cpp_clear_directive_state, _cpp_save_directive_state and
_cpp_restore_directive_state.

gcc/testsuite/ChangeLog.pph
* g++.dg/pph/x0string-escapes.h: New.
* g++.dg/pph/x1string-escapes.h: New.
* g++.dg/pph/x2string-escapes.cc: New.

From-SVN: r183952

10 years ago* error.c (dump_function_decl): Add missing ';'.
Diego Novillo [Thu, 2 Feb 2012 02:58:18 +0000 (1 21:58 -0500)]
* error.c (dump_function_decl): Add missing ';'.

From-SVN: r183824

10 years agoThis patch extends the hack I added in...
Diego Novillo [Thu, 2 Feb 2012 02:57:59 +0000 (1 21:57 -0500)]
This patch extends the hack I added in...

This patch extends the hack I added in
http://gcc.gnu.org/ml/gcc-patches/2012-01/msg01031.html to pacify the
garbage collector.

I have to keep using the same fake GC root because these trees are
added to structures that I can't seem to get properly annotated for
GC.  In particular, I'm having trouble with 'FILE' pointers.  I will
try to figure this out at some point, but we've got bigger issues to
address at the moment.

The specific problem this time was that bitsizetype was being
GC'd out while we were reading a PPH image.  This was causing
ICEs when we were trying to read many PPH images.

2012-02-01   Diego Novillo  <dnovillo@google.com>

* config-lang.in (gtfiles): Remove pph-out.c.  Add pph-core.c.
* pph-core.c: Include gt-cp-pph-core.h.
(pph_cached_trees): Declare.
(pph_cache_insert_at): If adding a tree to the cache, also
add it to pph_cached_trees.
(pph_streamer_init): Set pph_cached_trees to NULL.
(pph_streamer_finish): Likewise.
Call ggc_collect.
* pph-out.c (pph_decls_in_symtab): Remove.  Update all users.

From-SVN: r183823

10 years agoThis patch adds minimal type merging.
Lawrence Crowl [Thu, 2 Feb 2012 02:47:50 +0000 (2 02:47 +0000)]
This patch adds minimal type merging.

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  <crowl@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  <crowl@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.

From-SVN: r183822

10 years agoThis patch makes tracing more robust.
Lawrence Crowl [Wed, 1 Feb 2012 19:25:15 +0000 (1 19:25 +0000)]
This patch makes tracing more robust.

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  <crowl@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  <crowl@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  <crowl@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.

From-SVN: r183809

10 years agoThis patch fixes a problem with streaming of symbols and types that
Diego Novillo [Wed, 1 Feb 2012 01:31:30 +0000 (31 20:31 -0500)]
This patch fixes a problem with streaming of symbols and types that
have mutated from one PPH to another.

--- parent.h -----------------------------------------------------------------
struct C1 {
    int field1;
    float field2;
};
-----------------------------------------------------------------------------

--- child.h -----------------------------------------------------------------
struct C1;
-----------------------------------------------------------------------------

When we read child.pph from parent.pph, we will notice that struct C1
has mutated, so we read its body again (which fills in the fields,
etc).  However, the TYPE_LANG_DECL structure for C1 is also present in
the pickle cache for child.pph, and we were using it unmodified.

In this case, one of the fields in TYPE_LANG_DECL was
CLASSTYPE_LAZY_DEFAULT_CTOR, which had not been set in child.pph, so
when we tried to use the default ctor from struct C1 during code
generation, we were never finding it.  This was causing the failure in
x1namespace-alias2.cc and two other ICEs in the dynarray tests.

What the patch does is to never insert in the pickle cache any
structures that are embedded in structures that are already inside
other structures that get put in the cache.  We now always write out
the contents of these structures (using the PPH_RECORD_START_NO_CACHE
marker).  This includes the structures: PPH_binding_table,
PPH_function, PPH_lang_decl, PPH_lang_type, PPH_language_function and
PPH_sorted_fields_type.

Since these structures are always embedded in structures that are
already shared, they are never read and allocated more than once,
unless the parent structure is pickled.

Additionally, this simplifies the logic in the reader, since it never
needs to worry about adding these structures to the cache.

cp/ChangeLog.pph
* name-lookup.c (pph_out_binding_table): Use
PPH_RECORD_START_NO_CACHE records.
(pph_in_binding_table): Likewise.
* pph-in.c (pph_in_language_function): Remove caching code,
assume that the structure is always in a
PPH_RECORD_START_NO_CACHE.
(pph_in_struct_function): Likewise.
(pph_in_lang_decl): Likewise.
(pph_in_sorted_fields_type): Likewise.
(pph_in_lang_type_class): Likewise.
(pph_in_lang_type): Likewise.
(pph_in_lang_decl_start): Remove.
* pph-out.c (pph_get_marker_for): Always return
PPH_RECORD_START_NO_CACHE for PPH_binding_table, PPH_function,
PPH_lang_decl, PPH_lang_type, PPH_language_function and
PPH_sorted_fields_type.
(pph_out_start_record): Do not write IX for
PPH_RECORD_START_NO_CACHE.
(pph_out_language_function): Only support
PPH_RECORD_START_NO_CACHE or PPH_RECORD_END.
(pph_out_struct_function): Likewise.
(pph_out_lang_decl): Likewise.
(pph_out_sorted_fields_type): Likewise.
(pph_out_lang_type_class): Likewise.
(pph_out_lang_type): Likewise.

testsuite/ChangeLog.pph
* g++.dg/pph/x1namespace-alias2.cc: Mark fixed.
* g++.dg/pph/x6dynarray4.cc: Remove expected ICE.
* g++.dg/pph/x7dynarray5.cc: Remove expected ICE.

From-SVN: r183790

10 years agoThis patch adds support for disabling PPH reads.
Diego Novillo [Fri, 27 Jan 2012 20:29:23 +0000 (27 15:29 -0500)]
This patch adds support for disabling PPH reads.

This patch adds support for disabling PPH reads.  It uses the new
support to disable PPH reading when we disable PPH writing.  This is
to avoid confusion in the PPH registration code that will have some
stale content after the output file has been removed.

Lawrence suggests that we should just fail hard when we cannot
generate a PPH image.  We are currently only emitting a warning.  I
think I will just rip out this support in the near future.  For now,
it was easier to just disable the reader.  For now, I'm leaving it in
just in case we have another need for this.

2012-01-27   Diego Novillo  <dnovillo@google.com>

c-family/ChangeLog.pph
* c-common.h (pph_disable_reader): Declare.
* c-opts.c (pph_disable_reader): New.

cp/ChangeLog.pph
* pph-core.c (pph_include_handler): If PPH has been disabled,
process the file as a regular text include.
* pph-out.c (pph_disable_output): Also disable the reader.

From-SVN: r183645

10 years agoWhen generating PPH images...
Diego Novillo [Fri, 27 Jan 2012 18:51:28 +0000 (27 13:51 -0500)]
When generating PPH images...

When generating PPH images, circular #includes cannot be handled using
the usual double-guard inclusion in the pre-processor.  This happens
because we generate PPH images in separate compilations.  So, even
with properly double-guarded headers, each header will include the
other in its image:

1.h

2.h

When compiling 1.h, we will try open 2.pph, which in turn includes
1.h, which is being generated.  To avoid this situation, we simply
force the inclusion of 1.h to proceed as a text inclusion.

When adding a test for this, I ran into trouble with the testing
harness.  The test would fail depending on which PPH images were
already present in the build directory.  So, I modified pph.exp to
remove all the PPH images before starting the main test loop.  I think
this will not work in a remote test setting, but I will deal with that
later.

2012-01-27   Diego Novillo  <dnovillo@google.com>

cp/ChangeLog.pph
* pph-core.c (pph_stream_open): If STREAM exists and its mode
is different than the mode in which it was originally opened,
return NULL.

testsuite/ChangeLog.pph
* g++.dg/pph/pph.exp: Remove PPH images before running the tests.
* g++.dg/pph/x1circular.h: New.
* g++.dg/pph/x2circular.h: New.
* g++.dg/pph/x3circular.cc: New.

From-SVN: r183640

10 years agoEmit some state hidden in cp/decl2.c: pending_statics, deferred_fns, and
Lawrence Crowl [Fri, 27 Jan 2012 02:16:12 +0000 (27 02:16 +0000)]
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  <crowl@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  <crowl@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.

From-SVN: r183600

10 years agopph-core.c (pph_loaded): Tidy.
Diego Novillo [Thu, 26 Jan 2012 22:57:29 +0000 (26 17:57 -0500)]
pph-core.c (pph_loaded): Tidy.

2012-01-26   Diego Novillo  <dnovillo@google.com>

* pph-core.c (pph_loaded): Tidy.

From-SVN: r183587

10 years agoNoticed while going through build logs.
Diego Novillo [Thu, 26 Jan 2012 22:43:05 +0000 (26 17:43 -0500)]
Noticed while going through build logs.

2012-01-26   Diego Novillo  <dnovillo@google.com>

* pph-core.c (pph_include_handler): Tidy warning message.
* pph-out.c (pph_disable_output): Add tracing output.

From-SVN: r183586

10 years agoA small fixlet to deal with files that have errors in them.
Diego Novillo [Thu, 26 Jan 2012 20:41:12 +0000 (26 15:41 -0500)]
A small fixlet to deal with files that have errors in them.

A small fixlet to deal with files that have errors in them.  When we
are about to generate PPH output, we check if there have been errors
emitted for the file.  If so, we disable PPH generation.

Testing this, I found that we were not clearing pph_out_stream
when disabling PPH.  Fixed.

2012-01-26   Diego Novillo  <dnovillo@google.com>

* pph-core.c (pph_stream_close_1): Add a newline to fprintf call.
(pph_finish): If there were errors during compilation,
disable PPH generation.
* pph-out.c (pph_disable_output): Also set pph_out_stream to
NULL.

From-SVN: r183578

10 years agoAdd forgotten ChangeLog entry.
Diego Novillo [Thu, 26 Jan 2012 17:01:34 +0000 (26 12:01 -0500)]
Add forgotten ChangeLog entry.

From-SVN: r183574

10 years ago* pph-in.c (pph_read_file): Remove leftover debugging code.
Diego Novillo [Thu, 26 Jan 2012 17:00:31 +0000 (26 12:00 -0500)]
* pph-in.c (pph_read_file): Remove leftover debugging code.

From-SVN: r183573

10 years agoThis patch fixes a bug in the handling of #include files in PPH files.
Diego Novillo [Thu, 26 Jan 2012 17:00:14 +0000 (26 12:00 -0500)]
This patch fixes a bug in the handling of #include files in PPH files.

The bug is a bit convoluted, so an example is easier.  Given the files

foo.h

1.h

Assume that all the files are properly double-guarded, and that we are
generating PPH images for all the headers.  The contents of 2.h and
3.h are not important.

When we are generating foo.pph, we read 1.pph, which adds 1.pph and
2.pph to the #include table of foo.pph.  When we finish reading 1.pph,
the include handler is presented with #include "2.h", which it
resolves to 2.pph, which it then reads and adds to the #include table
*again*.

So, when we generated foo.pph, we had 2.pph in the #include table
twice.  This means that 3.pph ends up in the 4th slot of the #include
table.  All the external references to 3.pph are written to address
into that slot.

However, when we are reading foo.pph, the include hanlder is not
active for the files it includes, so 2.pph is only added once to the
table.  Meaning that external references going to 3.pph are looked up
from the wrong slot in the #include table.

All this, because we were allowing duplicate entries in the #include
table.  So, this patch reworks the #include table to only allow a
single entry.

In generating the test case, I found a second bug.  When we have
function bodies inside a header file, we were adding call graph nodes
for the functions, but we were not resetting the DECL_EXTERNAL field
for the FUNCTION_DECL.  These functions were being dropped by IPA
later on (in function_and_variable_visibility).

2012-01-26   Diego Novillo  <dnovillo@google.com>

cp/ChangeLog.pph
* pph-core.c (pph_include_handler): Call pph_writer_get_stream.
(pph_add_include): Move to pph-in.c
(pph_stream_open): Initialize STREAM->INCLUDES.M.
(pph_stream_close_1): Free STREAM->INCLUDES.M.
* pph-in.c (pph_in_symtab): For functions we are going to
expand, set DECL_EXTERNAL to false.
(pph_add_include_1): New.
(pph_add_include): Move from pph-core.c.  Call pph_add_include_1.
(pph_read_file): Add argument PARENT.  Update all callers.
If PARENT is given, add STREAM to PARENT's #include table.
* pph-out.c (pph_writer_get_stream): New.
* pph-streamer.h (struct pph_stream): Change field INCLUDES to
be a structure with two fields V and M.  Update all users.
(pph_add_include): Remove.
(pph_writer_add_include): Remove.
(pph_read_file): Add second argument.

testsuite/ChangeLog.pph
* x0multiple-include.h: New.
* x1multiple-include.h: New.
* x2multiple-include.h: New.
* x3multiple-include.h: New.
* x4multiple-include.cc: New.

From-SVN: r183572

10 years agoThis patch adds a new debug dumping routine to show the #include table
Diego Novillo [Thu, 26 Jan 2012 16:59:56 +0000 (26 11:59 -0500)]
This patch adds a new debug dumping routine to show the #include table
for a given stream.

2012-01-25   Diego Novillo  <dnovillo@google.com>

* pph-core.c (pph_dump_includes): New.
* pph.h (pph_dump_includes): Declare.

From-SVN: r183571

10 years agoThis change fixes some problems in reconstructing the identifier bindings.
Lawrence Crowl [Thu, 26 Jan 2012 05:15:42 +0000 (26 05:15 +0000)]
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  <crowl@google.com>

Index: gcc/cp/ChangeLog.pph

2012-01-25   Lawrence Crowl  <crowl@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.

From-SVN: r183551

10 years agoFix some warnings.
Diego Novillo [Wed, 25 Jan 2012 16:30:51 +0000 (25 11:30 -0500)]
Fix some warnings.

2012-01-25   Diego Novillo  <dnovillo@google.com>

* pph-core.c (pph_dump_binding): Declare static.
(pph_dump_vec_tree): Likewise.

From-SVN: r183525

10 years agopph-core.c: Fix copyright and contribution data.
Diego Novillo [Wed, 25 Jan 2012 13:00:19 +0000 (25 08:00 -0500)]
pph-core.c: Fix copyright and contribution data.

* pph-core.c: Fix copyright and contribution data.
* pph-in.c: Likewise.
* pph-out.c: Likewise.
* pph-streamer.h: Likewise.
* pph.h: Likewise.

From-SVN: r183517

10 years agobackport: case failing for keyed_classes, so the latter is anticipatory.
Lawrence Crowl [Tue, 24 Jan 2012 23:32:07 +0000 (24 23:32 +0000)]
backport: case failing for keyed_classes, so the latter is anticipatory.

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  <crowl@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  <crowl@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.

From-SVN: r183501

10 years agoThis patch factors out some code, which was making debugging
Diego Novillo [Tue, 24 Jan 2012 19:50:57 +0000 (24 14:50 -0500)]
This patch factors out some code, which was making debugging
unnecessarily confusing.

When we read the header of a tree, we first read an LTO tag marker to
identify what kind of tree we are reading.  However, we were doing
this *outside* of pph_in_tree_header, which resulted in code
duplication in the several callers we have for it.

The patch also removes some unnecessary code:

- In pph_out_tree, we will never have an IDENTIFIER_NODE when writing
  a builtin.  Similarly, in pph_in_tree.

- There was some code commented out in
  pph_in_merge_body_namespace_decl that is really not needed anymore.
  We are now treating mutated trees as XREFs, instead of trying to add
  them on the internal cache.

2012-01-24   Diego Novillo  <dnovillo@google.com>

* pph-in.c (pph_in_tree_header): Add argument FULLY_READ_P.
Remove argument TAG.  Update all callers.
Move LTO tag reading code from ...
(pph_in_tree): ... here.
(pph_in_merge_body_namespace_decl): Remove unused code.
* pph-out.c (pph_out_tree): Remove check for IDENTIFIER_NODE.

From-SVN: r183495

10 years agoThis patch fixes an ICE in build_int_cst_wide.
Diego Novillo [Sat, 21 Jan 2012 00:28:49 +0000 (20 19:28 -0500)]
This patch fixes an ICE in build_int_cst_wide.

This patch fixes an ICE in build_int_cst_wide.  We were not writing
out TYPE_MODE for types, causing RTL generation to try to emit an
offset using VOIDmode.

This is not the only problem in this test case.  We are also failing
to mark something needed, because with PPH enabled, a whole function
is optimized out.  I'm not quite sure why yet.  I will fix this in a
subsequent patch.

2012-01-20   Diego Novillo  <dnovillo@google.com>

cp/ChangeLog.pph
* pph-in.c (pph_in_machine_mode): New.
(pph_in_tcc_type): Call it.
* pph-out.c (pph_out_machine_mode): New.
(pph_out_tcc_type): Call it.

testsuite/ChangeLog.pph
* g++.dg/pph/x1namespace-alias2.cc: Remove expected ICE.
Document assembly difference.

From-SVN: r183364

10 years agoThis is a bit of a hack.
Diego Novillo [Fri, 20 Jan 2012 22:30:12 +0000 (20 17:30 -0500)]
This is a bit of a hack.

This is a bit of a hack.  All the PPH data is short-lived, and
explicitly managed on the heap.  However, we store some GC'd objects
in them and the parser will sometimes run garbage collection.

This was causing problems when we tried to write out the symbol table.
Some trees in it had been GC'd out because the symbol table is not a
GC root (it's in the heap).

What we should really do is realize when these trees are discarded, so
they can be removed from the symbol table.  But, the simplest approach
here is to put them in a GC root vector until we are done with PPH
(thanks Tom for the suggestion).

* config-lang.in (gtfiles): Remove pph.h and pph-core.c.
Add pph-out.c
* pph-out.c: Include gt-cp-pph-out.h.
(pph_decls_in_symtab): Declare.
(pph_writer_init): Initialize.
(pph_add_decl_to_symtab): Add DECL to pph_decls_in_symtab.
(pph_writer_finish): Set pph_decls_in_symtab and call
ggc_collect.

From-SVN: r183357

10 years agoCorrect construction of bindings for overloaded symbols.
Lawrence Crowl [Fri, 20 Jan 2012 18:46:12 +0000 (20 18:46 +0000)]
Correct construction of bindings for overloaded symbols.

Index: gcc/testsuite/ChangeLog.pph

2011-01-20   Lawrence Crowl  <crowl@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  <crowl@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.

From-SVN: r183347

10 years agoWhen we read a tree from the cache of an external PPH file and the tree is mutated...
Diego Novillo [Thu, 19 Jan 2012 20:28:56 +0000 (19 15:28 -0500)]
When we read a tree from the cache of an external PPH file and the tree is mutated in the current file...

When we read a tree from the cache of an external PPH file and the
tree is mutated in the current file, we need to re-sign the tree to
reflect the changes.

The problem was, that the signing code was assuming that the tree had
come from the *current* file, so it was trying to sign a cache entry
for the internal cache, which would ICE if the internal cache is
smaller than the external one.

I have not yet been able to produce a small test case for this, but it
fixes several thousand ICEs in our internal code.  I will add a test
case as soon as I get one reduced.

* pph-in.c (pph_in_tree): Sign EXPR from the cache it was
taken from.
* pph-streamer.h (pph_cache_select): Handle PPH_RECORD_START,
PPH_RECORD_START_MERGE_BODY, PPH_RECORD_START_MERGE_KEY
and PPH_RECORD_START_MUTATED.

From-SVN: r183311

10 years agoThis patch adds a check for #include_next and refuses to generate a
Diego Novillo [Wed, 18 Jan 2012 22:24:28 +0000 (18 17:24 -0500)]
This patch adds a check for #include_next and refuses to generate a
PPH image for files that use it.

Since the discovery of #include_next comes well into the
pre-processing stage (after we've initialized PPH data), we need to
undo what we did and disable PPH.  To do that, there is a new function
pph_disable_output() which closes and unlinks the output file.  This
needed changes to pph_stream_close() to not bother writing the
encoding buffers.

To decide whether we see the #include_next command in the primary
source file, I exported the function cpp_in_primary_file() from
libcpp.

Finally, the patch adds checks to avoid getting into an infinite loop
when processing includes.  Some system files include each other and if
we produce PPH images for both files, we were getting into an infinite
mutually-referential cycle.

2012-01-18   Diego Novillo  <dnovillo@google.com>
libcpp/ChangeLog.pph

* internal.h (cpp_in_primary_file): Move ...
* files.c (cpp_in_primary_file): ... here.
* include/cpplib.h (cpp_in_primary_file): Declare.

gcc/cp/ChangeLog.pph
* pph-core.c (pph_include_handler): If the primary file
uses #include_next, emit a warning and call
pph_disable_output.
(pph_stream_close_1): Factor out of ...
(pph_stream_close): ... here.
(pph_stream_close_no_flush): New.
(pph_streamer_finish): Call pph_writer_finish if
pph_writer_enabled_p returns true.
Call pph_reader_finish if pph_reader_enabled_p returns
true.
* pph-in.c (pph_in_include): Assert that we are not
trying to read STREAM from STREAM.
* pph-out.c (pph_out_line_table_and_includes): Do not
emit a line table reference to STREAM.
(pph_disable_output): New.
* pph-streamer.h (pph_stream_close_no_flush): Declare.
(pph_disable_output): Declare.

gcc/testsuite/ChangeLog.pph
* g++.dg/pph/d0include-next.h: New.

From-SVN: r183291

10 years agoAdd forgotten ChangeLog entry.
Diego Novillo [Wed, 18 Jan 2012 17:10:52 +0000 (18 12:10 -0500)]
Add forgotten ChangeLog entry.

From-SVN: r183275

10 years agoInstead of emitting identifiers with binding information, emit them without and then...
Lawrence Crowl [Wed, 18 Jan 2012 03:21:27 +0000 (18 03:21 +0000)]
Instead of emitting identifiers with binding information, emit them without and then patch up that information later.

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  <crowl@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  <crowl@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  <crowl@google.com>

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

From-SVN: r183269

10 years agoThis patch changes the representation of mutated trees to avoid creating...
Diego Novillo [Tue, 17 Jan 2012 18:04:16 +0000 (17 13:04 -0500)]
This patch changes the representation of mutated trees to avoid creating...

This patch changes the representation of mutated trees to avoid
creating unnecessary (and ultimately confusing) cache entries.

Mutated trees are those that we read initially from an external PPH
image and get changed during parsing.  The most common case is when
the external PPH image has a declaration which is converted into a
full definition in the current file.

When we initially read these trees, we compute a checksum of its body.
So, when we write it out in the second file, we decide whether the
tree has mutated by re-computing its checksum.  If it did, we write a
special record (PPH_RECORD_START_MUTATED) which indicates to the
reader that this is a tree that exists in an external file, but its
body should be re-read.

Before this patch, we would also insert the tree into the cache of the
current file.  This converted further references to the tree into
internal references.

This is unnecessary, since the tree is already present in the external
cache.  Additionally, the new merging code that Lawrence is working on
gets confused by it, as it expects to always find the tree in the
external cache.

This patch changes that.  We now write the mutated reference to the
external cache.  But instead of adding the tree to the internal cache
of the current file, we re-sign the tree.

This way, subsequent references to the tree will resolve as regular
external references (PPH_RECORD_XREF).

* pph-in.c (pph_in_tree): Do not expect an internal reference
when reading a mutated tree.
Only add the tree to the cache for PPH_RECORD_START markers.
* pph-out.c (pph_out_start_tree_record): Do not add mutated
trees to the internal cache.
Re-sign mutated trees.
Do not write an internal reference.

From-SVN: r183259

10 years agoMy previous patch moved the in_memory marker to the wrong place.
Diego Novillo [Tue, 17 Jan 2012 16:33:52 +0000 (17 11:33 -0500)]
My previous patch moved the in_memory marker to the wrong place.

We need to prevent a file from being re-read by an #include from one
of its included children images.  This is common in system headers.

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

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

From-SVN: r183256

10 years agoWe were marking STREAM in-memory too late.
Diego Novillo [Tue, 17 Jan 2012 15:11:03 +0000 (17 10:11 -0500)]
We were marking STREAM in-memory too late.

We were marking STREAM in-memory too late.  This was causing repeated
attempts to open the same PPH stream more than once.  Leading to
confusion.

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

From-SVN: r183250

10 years agoVarious fixes to avoid C syntax errors during stage 1.
Diego Novillo [Tue, 17 Jan 2012 04:18:29 +0000 (16 23:18 -0500)]
Various fixes to avoid C syntax errors during stage 1.

* name-lookup.c (pph_set_global_identifier_bindings): Make
parameter list void.
* pph.h (pph_set_global_identifier_bindings): Likewise.
* pph-core.c (pph_stream_registry_add_name): Fix use of struct
pph_name_stream_map.

From-SVN: r183232

10 years agoThis patch changes pph_out_line_table_and_includes to use the registry when...
Diego Novillo [Tue, 17 Jan 2012 04:18:06 +0000 (16 23:18 -0500)]
This patch changes pph_out_line_table_and_includes to use the registry when...

This patch changes pph_out_line_table_and_includes to use the registry
when deciding whether an LC_ENTER linemap is entering a PPH image.

We used to keep track of entered images by using a "next" index on the
table of read PPH files.  The problem with this is that this table
contains the transitive closure of all the read images and the loop in
pph_out_line_table_and_includes skips over all the entries of PPH
images.

So, if a PPH file includes another, we would miss the second one and
ICE at the end of the loop.

With the new registry, we simply examine all the LC_ENTER linemaps
after PPH_NUM_IGNORED_LINE_TABLE_ENTRIES.  If the file being entered
is in the registry, then we are entering a PPH image and we have to
skip all the linemaps until we leave that file (because those will be
processed when we read that image).

This fixes the test failures in the first patch of this series.

* pph-core.c (pph_stream_register): Move later in the file.
(pph_stream_unregister): Likewise.
(pph_stream_registry_ix_for): Fix comparison to !=.
(pph_stream_registry_add_name): Make extern.
Allocate a new slot in the table.
(pph_stream_set_header_name): New.
(pph_stream_registry_lookup): Fix computation of SLOT_IX.
(pph_stream_open): Call pph_stream_register earlier.
* pph-in.c (pph_in_line_table_and_includes): Call
pph_stream_set_header_name.
* pph-out.c (pph_init_write): Likewise.
(pph_get_next_include): Remove.  Update all users.
(pph_out_line_table_and_includes): Call
pph_stream_registry_lookup to determine if the file being
entered is a PPH image.
* pph-streamer.h (pph_stream_registry_lookup): Declare.
(pph_stream_set_header_name): Declare.

From-SVN: r183231

10 years agoThis patch adds a centralized registry for all open PPH images.
Diego Novillo [Tue, 17 Jan 2012 04:17:47 +0000 (16 23:17 -0500)]
This patch adds a centralized registry for all open PPH images.

This patch adds a centralized registry for all open PPH images.  This
has three different uses:

   1- To associate header pathnames (HEADER_NAME field in
      pph_stream) and images.  Used for looking up PPH streams from
      header names (e.g., pph_out_line_table_and_includes).

   2- To associate PPH file names (NAME field in pph_stream) and
      images.  Used for deciding whether a PPH file has been
      opened already (e.g., pph_stream_open).

   3- To look for symbols and types in the pickle cache of opened
      PPH streams (e.g., pph_cache_lookup_in_includes).

We used to have a simple VEC array that we would always traverse
looking for an image.  But this is slow and we sometimes need to
lookup PPH images by the full path name of the original header file or
by the full path name of the PPH file itself.

This patch simply introduces the new registry.  It does not yet uses
it for looking up header files during line table emission.  That comes
in the next patch.

* pph-core.c (struct pph_name_stream_map): Declare.
(struct pph_stream_registry_d): Declare.
(pph_stream_registry): New.
(pph_read_images): Remove.  Update all users.
(pph_find_stream_for): Remove.  Update all users.
(pph_mark_stream_read): Remove.  Update all users.
(pph_stream_register): New.
(pph_stream_unregister): New
(pph_stream_registry_ix_for): New.
(pph_stream_registered_p): New.
(pph_stream_registry_add_name): New.
(pph_stream_registry_lookup): New.
(pph_stream_open): Call it.
Call pph_stream_register.
(pph_stream_close): Call pph_stream_unregister.
(pph_header_image_hash): New.
(pph_header_image_eq): New.
(pph_init): Initialize pph_stream_registry.
(pph_streamer_finish): Free memory used by pph_stream_registry.
* pph-in.c (pph_read_file_1): Do not call pph_mark_stream_read.
Set STREAM->IN_MEMORY_P to true.
* pph-streamer.h (pph_mark_stream_read): Remove.

From-SVN: r183230

10 years agoIn a line map entry...
Diego Novillo [Tue, 17 Jan 2012 04:17:27 +0000 (16 23:17 -0500)]
In a line map entry...

In a line map entry, there is a field 'included_from' which is
the index into the line table corresponding to the file that is
including the current line map entry.

This index is an absolute value, but given that PPH images may be
loaded in different order from different TUs, absolute values
cannot be used.

Instead, we save an offset from the entry back to its includer.
The problem we were having is that I had messed up the
reconstruction of the value.  I switched the order of the
subtraction operands, so we were computing negative absolute
values.  Produces various failures in larger tests.

* pph-in.c (pph_in_line_table_and_includes): Fix computation of
includer file index relocation.
* pph-out.c (pph_out_line_map_ordinary): Add documentation.

From-SVN: r183229

10 years agoMerged revisions 182208,182210-182212,182217-182221,182224-182235,182237-182242,18224...
Diego Novillo [Fri, 6 Jan 2012 18:29:28 +0000 (6 13:29 -0500)]
Merged revisions 182208,182210-182212,182217-182221,182224-182235,182237-182242,182244,182246-182247,182249-182252,182256-182258,182262-182266,182270-182271,182275-182276,182278-182302,182306-182310,182313-182315,182319-182322,182324,182326-182332,182336-182338,182342-182343,182345-182347,182352-182353,182355-182360,182362-182372,182374-182382,182384-182392,182398,182401-182411,182414-182415,182419-182420,182424,182428-182433,182435,182441-182442,182445,182451-182453,182455-182457,182460,182462,182466,182470-182471,182474-182475,182477-182485,182487,182489,182491-182502,182504-182506,182508,182510,182512,182516,182520-182524,182526-182528,182532-182540,182542,182545-182546,182548-182556,182560-182564,182567-182568,182570-182571,182573-182578,182581-182595,182599,182602,182604-182605,182607-182609,182613,182615-182621,182623-182628,182630-182633,182636-182640,182644-182653,182655-182663,182665-182669,182673-182676,182680,182684-182686,182690,182692-182698,182702-182706,182708-182711,182713,182717,182719-182728,182731,182734,182738,182740,182742-182747,182751,182754-182757,182760-182761,182765,182767-182769,182771-182776,182780-182781,182783,182785-182789,182791-182798,182800-182806,182809-182810,182819-182821,182825-182826,182828-182833,182835-182839,182844-182845,182849,182851,182854-182858,182860,182864-182865,182868-182869,182871-182882,182884-182886,182889,182895,182897,182899-182900,182902-182904,182907-182909,182911-182915,182917,182919 via svnmerge from
svn+ssh://gcc.gnu.org/svn/gcc/trunk

From-SVN: r182961

10 years agoMerged revisions 181626-181629,181631,181633-181634,181638-181640,181642-181643,18164...
Diego Novillo [Wed, 14 Dec 2011 16:12:34 +0000 (14 11:12 -0500)]
Merged revisions 181626-181629,181631,181633-181634,181638-181640,181642-181643,181648,181653-181670,181674-181677,181683-181685,181690-181691,181694,181696-181698,181700-181702,181706-181707,181709,181713,181715,181718,181721-181725,181727-181728,181730-181731,181735,181738-181750,181754-181766,181770-181773,181775,181778-181779,181782,181784-181789,181793-181816,181818-181819,181821,181823-181825,181829-181833,181836-181837,181842-181843,181848-181849,181851-181857,181859-181863,181867-181870,181872,181874-181877,181879-181887,181889-181897,181901-181902,181906,181908,181912-181920,181922,181924,181926-181933,181937-181939,181949,181951,181955,181959,181964-181968,181970-181975,181979-181987,181990-181995,181999-182002,182004-182017,182020-182021,182023-182031,182033,182037-182039,182041-182045,182048-182056,182058-182061,182063-182068,182072-182077,182082-182086,182088-182092,182096-182097,182100,182102,182105,182107-182110,182115-182117,182119,182121,182123,182127,182131-182134,182136,182140-182144,182148,182151-182152,182154-182156,182158-182170,182174-182175,182177-182179,182183-182194,182198-182206 via svnmerge from
svn+ssh://gcc.gnu.org/svn/gcc/trunk

From-SVN: r182341

10 years agopph-core.c (pph_include_handler): Use LOC instead of INPUT_LOCATION.
Diego Novillo [Fri, 9 Dec 2011 19:25:30 +0000 (9 14:25 -0500)]
pph-core.c (pph_include_handler): Use LOC instead of INPUT_LOCATION.

cp/ChangeLog.pph

* pph-core.c (pph_include_handler): Use LOC instead of
INPUT_LOCATION.

testsuite/ChangeLog.pph

* g++.dg/pph/d1symnotinc.cc: Expect warning.
* g++.dg/pph/y8inc-nmspc.cc: Likewise.

From-SVN: r182173

10 years agoc.opt (Winvalid-pph, [...]): New flags.
Diego Novillo [Fri, 9 Dec 2011 18:37:33 +0000 (9 13:37 -0500)]
c.opt (Winvalid-pph, [...]): New flags.

c-family/ChangeLog.pph

* c.opt (Winvalid-pph, Wmissing-pph): New flags.

cp/ChangeLog.pph

* pph-core.c (pph_is_valid_here): Call warning_at instead of
error_at.
(pph_include_handler): If pph_read_file returns NULL, emit
warning and proceed with textual header parsing.
* pph-in.c (pph_read_file): Do not call fatal_error if
FILENAME is not found.

From-SVN: r182171

10 years agopph-streamer.h (struct pph_stream): Add field HEADER_NAME.
Diego Novillo [Thu, 8 Dec 2011 21:22:54 +0000 (8 16:22 -0500)]
pph-streamer.h (struct pph_stream): Add field HEADER_NAME.

* pph-streamer.h (struct pph_stream): Add field HEADER_NAME.
* pph-in.c (pph_in_line_table_and_includes): Read it.
* pph-out.c (pph_init_write): Initialize it from input_filename.
(pph_filename_eq_ignoring_path): Remove.
(pph_out_line_table_and_includes): Write STREAM->HEADER_NAME.
Compare the file name in LM against STREAM->HEADER_NAME to
decide whether to write a reference to an external PPH.

From-SVN: r182139

10 years agopph-in.c (pph_in_merge_key_binding_level): Support NULL values of BL.
Diego Novillo [Mon, 5 Dec 2011 19:00:24 +0000 (5 14:00 -0500)]
pph-in.c (pph_in_merge_key_binding_level): Support NULL values of BL.

cp/ChangeLog.pph
* cp/pph-in.c (pph_in_merge_key_binding_level): Support NULL values
of BL.
(pph_in_merge_key_namespace_decl): If DECL does not have
DECL_LANG_SPECIFIC set, use a NULL binding level.
(pph_in_merge_key_tree): Support NULL values of CHAIN.

testsuite/ChangeLog.pph
* g++.dg/pph/x1namespace-alias1.cc: Rename from x1namespace-alias.cc
* g++.dg/pph/x1namespace-alias1.h: New.
* g++.dg/pph/x1namespace-alias2.cc: New.
* g++.dg/pph/x1namespace-alias2.h: New.

From-SVN: r182019

10 years agopph-out.c (pph_out_tcc_declaration): Write DECL_ABSTRACT_ORIGIN.
Diego Novillo [Mon, 5 Dec 2011 18:59:09 +0000 (5 13:59 -0500)]
pph-out.c (pph_out_tcc_declaration): Write DECL_ABSTRACT_ORIGIN.

cp/ChangeLog.pph
* pph-out.c (pph_out_tcc_declaration): Write DECL_ABSTRACT_ORIGIN.
* pph-in.c (pph_in_tcc_declaration_tail): Read DECL_ABSTRACT_ORIGIN.
(pph_in_merge_key_namespace_decl): Remove argument DECL.
Update all users.
Create an empty binding level to read all merge keys into.

testsuite/ChangeLog.pph
g++.dg/pph/x0namespace-alias.h: New.
g++.dg/pph/x1namespace-alias.cc: New.

From-SVN: r182018

10 years agopph-in.c (pph_in_lang_decl_start): Rename from pph_in_ref_lang_decl.
Diego Novillo [Fri, 2 Dec 2011 22:44:47 +0000 (2 17:44 -0500)]
pph-in.c (pph_in_lang_decl_start): Rename from pph_in_ref_lang_decl.

* pph-in.c (pph_in_lang_decl_start): Rename from pph_in_ref_lang_decl.
Handle PPH_RECORD_START_MERGE_BODY records.
Add argument IS_MERGE_P.  Set it to true if the caller should do
a merge read.
Update all users.
(pph_in_lang_decl): Call pph_in_merge_ld_base when reading
a merge record.
(pph_in_merge_lang_decl): Remove.  Update all users.

From-SVN: r181952

10 years agopph-in.c (pph_in_cxx_binding_1): Assert that we are not reading a merge record.
Diego Novillo [Fri, 2 Dec 2011 18:58:11 +0000 (2 13:58 -0500)]
pph-in.c (pph_in_cxx_binding_1): Assert that we are not reading a merge record.

* pph-in.c (pph_in_cxx_binding_1): Assert that we are not
reading a merge record.
(pph_in_class_binding): Likewise.
(pph_in_label_binding): Likewise.
(pph_in_language_function): Likewise.
(pph_in_struct_function): Likewise.
(pph_in_sorted_fields_type): Likewise.
(pph_in_lang_type_class): Likewise.
(pph_in_lang_type): Likewise.
(pph_in_merge_key_binding_level): Rename from pph_in_binding_merge_keys.
(pph_in_merge_body_binding_level_1): Rename from
pph_in_binding_merge_bodies_1.  Update all users.
(pph_in_merge_body_binding_level): Rename from
pph_in_binding_merge_bodies.  Update all users.
(pph_in_ref_lang_decl): Rename from pph_in_ref_lang_specific.
Update all users.
Assert that we are not reading a merge record.
(pph_in_lang_decl): Rename from pph_in_lang_specific.  Update all users.
(pph_in_merge_lang_decl): Rename from pph_in_merge_lang_specific.
* pph-out.c (pph_out_reference_record): Support
PPH_RECORD_START_MERGE_BODY records.
Return the written marker instead of a boolean value.
Update all users.
(pph_out_start_merge_key_record): Accept a void * instead of
tree.  Add pph_tag argument.  Update all users.
(pph_out_start_merge_key_tree_record): New.
(pph_out_merge_key_binding_level): Rename from
pph_out_binding_merge_keys.
(pph_out_merge_body_binding_level): Rneame from
pph_out_binding_merge_bodies.
(pph_out_cxx_binding_1): Assert that we are not writing a
merge record.
(pph_out_cxx_binding): Likewise.
(pph_out_class_binding): Likewise.
(pph_out_label_binding): Likewise.
(pph_out_language_function): Likewise.
(pph_out_struct_function): Likewise.
(pph_out_ld_parm): Likewise.
(pph_out_lang_decl): Likewise.
(pph_out_sorted_fields_type): Likewise.
(pph_out_lang_type_class): Likewise.
(pph_out_lang_type): Likewise.
(pph_out_cgraph_node): Likewise.
(pph_out_tree): Call pph_is_reference_or_end_marker.
* pph-streamer.h (pph_is_reference_or_end_marker): New.

From-SVN: r181935

10 years agopph-in.c (pph_in_bool): New.
Diego Novillo [Fri, 2 Dec 2011 18:57:14 +0000 (2 13:57 -0500)]
pph-in.c (pph_in_bool): New.

* pph-in.c (pph_in_bool): New.
(pph_in_merge_key_namespace_decl): Factor out of ...
(pph_in_merge_key_tree): ... here.
Handle namespace aliases.
* pph-out.c (pph_out_bool): New.
(pph_out_merge_key_namespace_decl): Factor out of ...
(pph_out_merge_key_tree): ... here.
Handle namespace aliases.

From-SVN: r181934

10 years agopph-out.c (pph_out_global_binding): Fix empty test for scope_chain->x_stmt_tree.x_cur...
Diego Novillo [Thu, 1 Dec 2011 18:05:53 +0000 (1 13:05 -0500)]
pph-out.c (pph_out_global_binding): Fix empty test for scope_chain->x_stmt_tree.x_cur_stmt_list.

* pph-out.c (pph_out_global_binding): Fix empty test
for scope_chain->x_stmt_tree.x_cur_stmt_list.

From-SVN: r181888

10 years agoThe identifier bindings are causing trouble in merging.
Lawrence Crowl [Thu, 1 Dec 2011 05:04:02 +0000 (1 05:04 +0000)]
The identifier bindings are causing trouble in merging.

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  <crowl@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  <crowl@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.

From-SVN: r181871

10 years agoMerge pph.c and pph-streamer.c into pph-core.c.
Lawrence Crowl [Wed, 30 Nov 2011 05:20:50 +0000 (30 05:20 +0000)]
Merge pph.c and pph-streamer.c into pph-core.c.

Shorten pph-streamer-in.c to pph-in.c.
Shorten pph-streamer-out.c to pph-out.c.
Reduce redundancies in make dependences.

Index: gcc/cp/ChangeLog.pph

2011-11-29   Lawrence Crowl  <crowl@google.com>

* pph-streamer.c: Renamed pph-core.c.
* pph.c: Contents moved into pph-core.c.
(pph_dump_min_decl): Removed unused.
(flatten_name): Rename pph_flatten_name.
* pph-streamer-in.c: Renamed pph-in.c.
* pph-streamer-out.c: Renamed pph-out.c.
* pph-streamer.h: Adjust to reflect above.  Remove unneeded decls.
* pph.h: Adjust to reflect above.
* config-lang.in: Adjust to reflect above.
* Make-lang.in: Adjust to reflect above.
(CXX_PPH_STREAMER_H): Remove redundancies.
(CXX_PPH_COMMON_H): New.
(CXX_PPH_COMMON_H): New.
(cp/pph-core.o): Remove redundancies.
(cp/pph-in.o): Remove redundancies.
(cp/pph-out.o): Remove redundancies.
(cp/pt.o): Add depndence on CXX_PPH_H.
* pt.c: Remove redundant #include "pph-streamer.h".

From-SVN: r181835

10 years agogimple.c (gimple_call_set_cannot_inline): Move from gimple.h.
Diego Novillo [Thu, 24 Nov 2011 14:52:03 +0000 (24 09:52 -0500)]
gimple.c (gimple_call_set_cannot_inline): Move from gimple.h.

* gimple.c (gimple_call_set_cannot_inline): Move from gimple.h.
Update field call_stmt_cannot_inline_p from call graph edge, if
needed.
* gimple.h (gimple_call_set_cannot_inline): Move to gimple.c.

From-SVN: r181693

10 years agoRevert
Diego Novillo [Thu, 24 Nov 2011 14:50:56 +0000 (24 09:50 -0500)]
Revert

PR bootstrap/50709
* ipa-inline.c (inline_small_functions):
Fix checking code to not make effect on fibheap stability.

From-SVN: r181692

10 years agobackport: dg-pph.exp: Set dg-final-code to "".
Diego Novillo [Tue, 22 Nov 2011 19:33:09 +0000 (22 14:33 -0500)]
backport: dg-pph.exp: Set dg-final-code to "".

ChangeLog.pph

Merge from trunk rev 181625.

testsuite/ChangeLog.pph

* lib/dg-pph.exp: Set dg-final-code to "".

The dg-pph.exp fix was needed to prevent a missing symbol error that
the new merge was causing when executing g++-dg-test.

From-SVN: r181630

10 years agobackport: pph-streamer-in.c (pph_in_int): New.
Diego Novillo [Tue, 22 Nov 2011 15:38:11 +0000 (22 10:38 -0500)]
backport: pph-streamer-in.c (pph_in_int): New.

gcc/ChangeLog.pph
Merge from trunk rev 180687.

gcc/cp/ChangeLog.pph
* pph-streamer-in.c (pph_in_int): New.
(pph_in_line_map_ordinary): New.
(pph_in_line_map): Call it.
(pph_in_line_table_and_includes): Re-write to account for
new macro location changes.
(pph_prepend_to_chain): Fix warnings.
* pph-streamer-out.c (pph_out_int): New.
(pph_out_line_map_ordinary): New.
(pph_out_line_map): Call it.
(pph_out_line_table_and_includes): Re-write to account for
new macro location changes.
(pph_out_location): Likewise.
* pph.c (pph_file_change_handler): Likewise.

libcpp/ChangeLog.pph
* include/line-map.h (linemap_dump): Declare.
(line_table_dump): Declare.
* line-map.c (linemap_dump): New.
(line_table_dump): New.

From-SVN: r181622

10 years ago* testsuite-management/x86_64-unknown-linux-gnu.xfail: Update.
Diego Novillo [Wed, 16 Nov 2011 16:01:32 +0000 (16 11:01 -0500)]
* testsuite-management/x86_64-unknown-linux-gnu.xfail: Update.

From-SVN: r181415

10 years agoc.opt (fpph-include-tree): New.
Diego Novillo [Mon, 14 Nov 2011 16:45:23 +0000 (14 11:45 -0500)]
c.opt (fpph-include-tree): New.

c-family/ChangeLog.pph
2011-11-13   Diego Novillo  <dnovillo@google.com>

* c.opt (fpph-include-tree): New.
(fpph-logfile, fpph-map): Tidy.

cp/ChangeLog.pph

* parser.c (c_parse_file): Call pph_init_include_tree.
* pph.c (pph_init_include_tree): New.
(flatten_name): New.
(pph_file_change_handler): New.
(pph_include_handler_for_map): New.
(pph_init_map_file): New.
(pph_finish_map_file): New.
* pph.h (pph_init_include_tree): New.

From-SVN: r181354

10 years agoAdd merging of namespaces.
Lawrence Crowl [Mon, 7 Nov 2011 21:58:47 +0000 (7 21:58 +0000)]
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  <crowl@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  <crowl@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.

From-SVN: r181123

10 years agoAdd merging of static_decls in bindings.
Lawrence Crowl [Wed, 2 Nov 2011 03:23:59 +0000 (2 03:23 +0000)]
Add merging of static_decls in bindings.

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  <crowl@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.

From-SVN: r180759

10 years agoUndo unnecessary changes against trunk.
Diego Novillo [Sat, 29 Oct 2011 19:03:50 +0000 (29 15:03 -0400)]
Undo unnecessary changes against trunk.

From-SVN: r180661

10 years agopph-streamer-in.c (pph_node_already_emitted): New.
Diego Novillo [Sat, 29 Oct 2011 18:24:00 +0000 (29 14:24 -0400)]
pph-streamer-in.c (pph_node_already_emitted): New.

cp/ChangeLog.pph

* pph-streamer-in.c (pph_node_already_emitted): New.
(pph_in_symtab): Call it.

testsuite/ChangeLog.pph

* g++.dg/pph/x1keyed.cc: Mark fixed.
* g++.dg/pph/x1keyno.cc: Likewise.
* g++.dg/pph/x6rtti.cc: Remove ICE failure.  Document operator match
problem.
* g++.dg/pph/x7rtti.cc: Likewise.
* g++.dg/pph/x1tmplclass2.cc: Document asm diff to out-of-order diff.
* g++.dg/pph/z4tmplclass2.cc: Likewise.
* g++.dg/pph/x4keyex.cc: Likewise.
* g++.dg/pph/x4keyed.cc: Change failure to typeinfo redefinition.
* g++.dg/pph/x4keyno.cc: Likewise.

From-SVN: r180658

10 years agoAdd namespace merging.
Lawrence Crowl [Fri, 28 Oct 2011 17:58:07 +0000 (28 17:58 +0000)]
Add namespace merging.

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  <crowl@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.

From-SVN: r180621

10 years agocp-tree.h (get_mangled_id): Declare.
Diego Novillo [Wed, 26 Oct 2011 23:28:47 +0000 (26 19:28 -0400)]
cp-tree.h (get_mangled_id): Declare.

* cp-tree.h (get_mangled_id): Declare.
* mangle.c (get_mangled_id): Factor out of ...
(mangle_decl): ... here.
* pph-streamer-in.c
(pph_get_include_path_hash): Remove.  Update all users.
* pph-streamer-out.c (pph_merge_name): Move from pph-streamer.c.
Change return type to char *.
Call get_mangled_id and decl_as_string.
Update users.

testsuite/ChangeLog.pph

* g++.dg/pph/c4inline.cc: Mark fixed.
* g++.dg/pph/x4tmplclass1.cc: Likewise.
* g++.dg/pph/x4tmplclass2.cc: Likewise.
* g++.dg/pph/z4tmplclass1.cc: Likewise.
* g++.dg/pph/z4tmplclass2.cc: Likewise.
* g++.dg/pph/x4tmplfuncinln.cc: Change expected failure.
* g++.dg/pph/x4tmplfuncninl.cc: Likewise.
* g++.dg/pph/z4tmplfuncinln.cc: Likewise.
* g++.dg/pph/z4tmplfuncninl.cc: Likewise.

From-SVN: r180548

10 years agopph-streamer-in.c (pph_in_merge_key_chain): Add new argument IPATH_HASH.
Diego Novillo [Sat, 22 Oct 2011 15:43:07 +0000 (22 11:43 -0400)]
pph-streamer-in.c (pph_in_merge_key_chain): Add new argument IPATH_HASH.

* pph-streamer-in.c (pph_in_merge_key_chain): Add new argument
IPATH_HASH.  Update all users.
(pph_match_to_overload): Remove.
(pph_match_to_function): Remove.
(pph_match_to_link): Remove.
(pph_search_in_chain): Remove.
(merge_toc): Declare.
(merge_toc_entry): Declare.
(htab_merge_key_hash): New.
(htab_merge_key_eq): New.
(pph_toc_lookup): New.
(pph_toc_add): New.
(pph_prepend_to_chain): Add argument IPATH_HASH.  Update all users.
Call pph_toc_lookup and pph_toc_add.
(pph_in_merge_key_tree): Add argument IPATH_HASH.  Update all users.
Call pph_in_string.
(pph_get_include_path_hash): New.
(pph_in_merge_keys): Call it.
(pph_reader_init): New.
(pph_reader_finish): New.
* pph-streamer-out.c (pph_out_merge_key_tree): Do not call
pph_out_location.
* pph-streamer.c (pph_streamer_finish): Call pph_reader_finish.
(pph_add_include): Update INCLUDE->PARENT.
* pph-streamer.h (struct pph_stream): Add field PARENT.
(pph_reader_init): Declare.
(pph_reader_finish): Declare.
* pph.c (pph_init): Call pph_reader_init.

testsuite/ChangeLog.pph

* g++.dg/pph/c1limits-externalid.cc: Mark fixed.

From-SVN: r180326

10 years agopph-streamer-in.c (ALLOC_AND_REGISTER_ALTERNATE): Remove.
Diego Novillo [Fri, 21 Oct 2011 02:42:32 +0000 (20 22:42 -0400)]
pph-streamer-in.c (ALLOC_AND_REGISTER_ALTERNATE): Remove.

* pph-streamer-in.c (ALLOC_AND_REGISTER_ALTERNATE): Remove.
(pph_in_tree_1): Remove.
(pph_in_tree): Rename from pph_in_tree_1.
(pph_in_chain): Call streamer_read_chain.
(pph_in_merge_key_chain): New.
(pph_in_merge_body_chain): Rename from pph_in_mergeable_chain.
(pph_in_binding_level_1): Switch the order of the arguments.
Update all users.
Read fields this_entity and static_decls.
(pph_in_mergeable_binding_level): Remove.
(pph_in_merge_key_tree): New.
(pph_in_tree): Handle PPH_RECORD_START_MERGE_BODY.
(pph_in_merge_keys): New.
(pph_in_global_binding): New.
(pph_read_file_1): Call it.
* pph-streamer-out.c (pph_get_marker_for):
(pph_out_start_tree_record): Handle PPH_RECORD_START_MERGE_BODY.
(pph_out_start_merge_key_record): New.
(pph_out_tree_1): Remove.
(pph_out_tree): Rename from pph_out_tree_1.
Handle PPH_RECORD_START_MERGE_BODY.
(pph_out_merge_key_vec): Rename from pph_out_mergeable_tree_vec.
Call pph_out_merge_key_tree.
(pph_out_merge_key_chain): Rename from pph_out_mergeable_chain_filtered.
(pph_out_binding_level_1): Handle fields this_entity and static_decls.
(pph_out_mergeable_binding_level): Remove.
(pph_out_merge_key_tree): New.
(pph_out_merge_keys): New.
(pph_out_global_binding): Call pph_out_merge_keys.
* pph-streamer.c (pph_cache_insert_at): Return the inserted entry.
Update all users.
(pph_cache_add): Likewise.
(pph_cache_lookup): Return the found entry.  Update all users.
(pph_cache_lookup_in_includes): Likewise.
(pph_merge_name): Ignore EXPRs with no lang-specific info.
* pph-streamer.h (pph_cache_entry): Add field needs_merge_body.
Update all users.
(pph_tag_to_tree_code): Remove.
(pph_tree_is_mergeable): New.
* pph.h (enum pph_record_marker): Add values PPH_RECORD_START_MERGE_KEY
and PPH_RECORD_START_MERGE_BODY.

From-SVN: r180286

10 years agoMerge revision 180136 from trunk (cp_debug_parser).
Diego Novillo [Tue, 18 Oct 2011 17:53:09 +0000 (18 13:53 -0400)]
Merge revision 180136 from trunk (cp_debug_parser).

From-SVN: r180161

10 years agoMerge from trunk rev 180072.
Diego Novillo [Mon, 17 Oct 2011 19:55:11 +0000 (17 15:55 -0400)]
Merge from trunk rev 180072.

From-SVN: r180108

10 years agoAdd function merging. First, let function mangled names match.
Lawrence Crowl [Mon, 17 Oct 2011 06:20:02 +0000 (17 06:20 +0000)]
Add function merging.  First, let function mangled names match.

Second, overwrite existing struct functions for merged functions.
Third, add filtering for already emitted functions.

The result is ICEs in the call graph code.

Add tests for overload sets with more than one member.

Bootstrapped on x64.

2011-10-16   Lawrence Crowl  <crowl@google.com>

Index: gcc/testsuite/ChangeLog.pph

* g++.dg/pph/c4inline.cc: Change to ICE in cgraph.
* g++.dg/pph/x1keyed.cc: Likewise.
* g++.dg/pph/x1keyno.cc: Likewise.
* g++.dg/pph/x4keyed.cc: Likewise.
* g++.dg/pph/x4keyex.cc: Likewise.
* g++.dg/pph/x4keyno.cc: Likewise.
* g++.dg/pph/x4tmplclass1.cc: Likewise.
* g++.dg/pph/x4tmplclass2.cc: Likewise.
* g++.dg/pph/x4tmplfuncinln.cc: Likewise.
* g++.dg/pph/x4tmplfuncninl.cc: Likewise.
* g++.dg/pph/x6rtti.cc: Likewise.
* g++.dg/pph/x7rtti.cc: Likewise.
* g++.dg/pph/z4tmplclass1.cc: Likewise.
* g++.dg/pph/z4tmplclass2.cc: Likewise.
* g++.dg/pph/z4tmplfuncinln.cc: Likewise.
* g++.dg/pph/z4tmplfuncninl.cc: Likewise.
* g++.dg/pph/x1tmplclass2.cc: Change to missing function.

Index: gcc/cp/ChangeLog.pph

2011-10-16   Lawrence Crowl  <crowl@google.com>

* pph-streamer-in.c (pph_match_to_overload): Comment on overloading.
(pph_match_to_function): Allow functions to match for merging.
Comment on overloading.
(pph_match_to_link): Comment on overloading.
(pph_in_struct_function): Implement overwriting a struct function
when merging.
(pph_in_symtab): Add filtering for already emitted functions.
* pph-streamer.h (pph_trace_tree): Add a boolean parameter specifying
whether or not the tree was actually merged.
* pph-streamer.c (pph_trace_tree): Add a boolean parameter specifying
whether or not the tree was actually merged.  Change output to
correspond.  Update callers.

From-SVN: r180074