From cec34ee582db1c7990d6f871e953862fe4fb7ca1 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Tue, 30 Jun 2015 21:05:02 +0000 Subject: [PATCH] lto-streamer-out.c (class DFS): Adjust hash_scc method. * lto-streamer-out.c (class DFS): Adjust hash_scc method. (DFS::DFS): Pass this_ref_p and ref_p to hash_scc. (hash_scc): Add this_ref_p and ref_p parameters and pass them to the inner DFS walk. From-SVN: r225212 --- gcc/ChangeLog | 7 +++++++ gcc/lto-streamer-out.c | 34 +++++++++++++++++++++------------ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gnat.dg/lto17.adb | 12 ++++++++++++ gcc/testsuite/gnat.dg/lto17.ads | 20 +++++++++++++++++++ 5 files changed, 65 insertions(+), 12 deletions(-) create mode 100644 gcc/testsuite/gnat.dg/lto17.adb create mode 100644 gcc/testsuite/gnat.dg/lto17.ads diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 91e7e4a51af..fc23abd6c2d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2015-06-30 Eric Botcazou + + * lto-streamer-out.c (class DFS): Adjust hash_scc method. + (DFS::DFS): Pass this_ref_p and ref_p to hash_scc. + (hash_scc): Add this_ref_p and ref_p parameters and pass them + to the inner DFS walk. + 2015-06-30 Richard Sandiford * target-insns.def (jump): New targetm instruction pattern. diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c index 15f5933d34f..254d7ba50b7 100644 --- a/gcc/lto-streamer-out.c +++ b/gcc/lto-streamer-out.c @@ -411,9 +411,9 @@ lto_write_tree (struct output_block *ob, tree expr, bool ref_p) streamer_write_zero (ob); } -/* Emit the physical representation of tree node EXPR to output block - OB. If THIS_REF_P is true, the leaves of EXPR are emitted as references - via lto_output_tree_ref. REF_P is used for streaming siblings of EXPR. */ +/* Emit the physical representation of tree node EXPR to output block OB, + If THIS_REF_P is true, the leaves of EXPR are emitted as references via + lto_output_tree_ref. REF_P is used for streaming siblings of EXPR. */ static void lto_output_tree_1 (struct output_block *ob, tree expr, hashval_t hash, @@ -490,13 +490,20 @@ private: tree expr, bool ref_p, bool this_ref_p); hashval_t - hash_scc (struct output_block *ob, unsigned first, unsigned size); + hash_scc (struct output_block *ob, unsigned first, unsigned size, + bool ref_p, bool this_ref_p); hash_map sccstate; vec worklist_vec; struct obstack sccstate_obstack; }; +/* Emit the physical representation of tree node EXPR to output block OB, + using depth-first search on the subgraph. If THIS_REF_P is true, the + leaves of EXPR are emitted as references via lto_output_tree_ref. + REF_P is used for streaming siblings of EXPR. If SINGLE_P is true, + this is for a rewalk of a single leaf SCC. */ + DFS::DFS (struct output_block *ob, tree expr, bool ref_p, bool this_ref_p, bool single_p) { @@ -564,7 +571,7 @@ DFS::DFS (struct output_block *ob, tree expr, bool ref_p, bool this_ref_p, unsigned first, size; tree x; - /* If we are re-walking a single leaf-SCC just pop it, + /* If we are re-walking a single leaf SCC just pop it, let earlier worklist item access the sccstack. */ if (single_p) { @@ -587,7 +594,7 @@ DFS::DFS (struct output_block *ob, tree expr, bool ref_p, bool this_ref_p, unsigned scc_entry_len = 0; if (!flag_wpa) { - scc_hash = hash_scc (ob, first, size); + scc_hash = hash_scc (ob, first, size, ref_p, this_ref_p); /* Put the entries with the least number of collisions first. */ unsigned entry_start = 0; @@ -1362,10 +1369,12 @@ DFS::scc_entry_compare (const void *p1_, const void *p2_) return 0; } -/* Return a hash value for the SCC on the SCC stack from FIRST with SIZE. */ +/* Return a hash value for the SCC on the SCC stack from FIRST with SIZE. + THIS_REF_P and REF_P are as passed to lto_output_tree for FIRST. */ hashval_t -DFS::hash_scc (struct output_block *ob, unsigned first, unsigned size) +DFS::hash_scc (struct output_block *ob, unsigned first, unsigned size, + bool ref_p, bool this_ref_p) { unsigned int last_classes = 0, iterations = 0; @@ -1441,7 +1450,8 @@ DFS::hash_scc (struct output_block *ob, unsigned first, unsigned size) for (unsigned i = 0; i < size; ++i) map.put (sccstack[first+i].t, sccstack[first+i].hash); - DFS again (ob, sccstack[first+firstunique].t, false, false, true); + DFS again (ob, sccstack[first+firstunique].t, ref_p, this_ref_p, + true); gcc_assert (again.sccstack.length () == size); memcpy (sccstack.address () + first, @@ -1539,9 +1549,9 @@ DFS::DFS_write_tree (struct output_block *ob, sccs *from_state, } -/* Emit the physical representation of tree node EXPR to output block - OB. If THIS_REF_P is true, the leaves of EXPR are emitted as references - via lto_output_tree_ref. REF_P is used for streaming siblings of EXPR. */ +/* Emit the physical representation of tree node EXPR to output block OB. + If THIS_REF_P is true, the leaves of EXPR are emitted as references via + lto_output_tree_ref. REF_P is used for streaming siblings of EXPR. */ void lto_output_tree (struct output_block *ob, tree expr, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 80be58e6e58..8fc634abefd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2015-06-30 Eric Botcazou + + * gnat.dg/lto17.ad[sb]: New test. + 2015-06-30 David Malcolm * jit.dg/all-non-failing-tests.h: Add test-switch.c. diff --git a/gcc/testsuite/gnat.dg/lto17.adb b/gcc/testsuite/gnat.dg/lto17.adb new file mode 100644 index 00000000000..af42e8d85d8 --- /dev/null +++ b/gcc/testsuite/gnat.dg/lto17.adb @@ -0,0 +1,12 @@ +-- { dg-do compile } +-- { dg-options "-flto" } +-- { dg-require-effective-target lto } + +package body Lto17 is + + function To_Chunk_List(C : Chunk) return Chunk_List is + begin + return new Chunk_List_Element'(C.Size, C, null); + end; + +end Lto17; diff --git a/gcc/testsuite/gnat.dg/lto17.ads b/gcc/testsuite/gnat.dg/lto17.ads new file mode 100644 index 00000000000..19b8a9c7c16 --- /dev/null +++ b/gcc/testsuite/gnat.dg/lto17.ads @@ -0,0 +1,20 @@ +package Lto17 is + + type Chunk_List_Element; + type Chunk_List is access Chunk_List_Element; + + type Arr is array (Natural range <>) of Integer; + + type Chunk(Size : Natural) is record + Data : Arr(1 .. Size); + Where : Natural; + end record; + + type Chunk_List_Element(Size : Natural) is record + Chnk : Chunk(Size); + Link : Chunk_List; + end record; + + function To_Chunk_List(C : Chunk) return Chunk_List; + +end Lto17; -- 2.30.2