aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2016-10-11 07:38:08 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2016-10-11 07:38:08 +0000
commitec1db2a9949e828d4b65757c8a3de2bde37ef493 (patch)
tree389f2ee21069cd3fbc3717a0d83c00f200c8a926
parent038b5cc0d5f5e5df2be06844d9f53e9c08fc985a (diff)
downloadgcc-ec1db2a9949e828d4b65757c8a3de2bde37ef493.zip
gcc-ec1db2a9949e828d4b65757c8a3de2bde37ef493.tar.gz
gcc-ec1db2a9949e828d4b65757c8a3de2bde37ef493.tar.bz2
lto-streamer-out.c (collect_block_tree_leafs): New helper.
2016-10-11 Richard Biener <rguenther@suse.de> * lto-streamer-out.c (collect_block_tree_leafs): New helper. (output_function): Properly stream the whole block tree. * lto-streamer-in.c (input_function): Likewise. From-SVN: r240964
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/lto-streamer-in.c3
-rw-r--r--gcc/lto-streamer-out.c24
3 files changed, 30 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f2f1a15..61d94b8 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2016-10-11 Richard Biener <rguenther@suse.de>
+
+ * lto-streamer-out.c (collect_block_tree_leafs): New helper.
+ (output_function): Properly stream the whole block tree.
+ * lto-streamer-in.c (input_function): Likewise.
+
2016-10-11 Marek Polacek <polacek@redhat.com>
* Makefile.in (C_COMMON_OBJS): Add c-family/c-warn.o.
diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c
index 5075b56..f852bf9 100644
--- a/gcc/lto-streamer-in.c
+++ b/gcc/lto-streamer-in.c
@@ -1036,6 +1036,9 @@ input_function (tree fn_decl, struct data_in *data_in,
/* Read the tree of lexical scopes for the function. */
DECL_INITIAL (fn_decl) = stream_read_tree (ib, data_in);
+ unsigned block_leaf_count = streamer_read_uhwi (ib);
+ while (block_leaf_count--)
+ stream_read_tree (ib, data_in);
if (!streamer_read_uhwi (ib))
return;
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index 2bb0c504..22c4140 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -2016,6 +2016,18 @@ output_struct_function_base (struct output_block *ob, struct function *fn)
}
+/* Collect all leaf BLOCKs beyond ROOT into LEAFS. */
+
+static void
+collect_block_tree_leafs (tree root, vec<tree> &leafs)
+{
+ for (root = BLOCK_SUBBLOCKS (root); root; root = BLOCK_CHAIN (root))
+ if (! BLOCK_SUBBLOCKS (root))
+ leafs.safe_push (root);
+ else
+ collect_block_tree_leafs (BLOCK_SUBBLOCKS (root), leafs);
+}
+
/* Output the body of function NODE->DECL. */
static void
@@ -2048,10 +2060,16 @@ output_function (struct cgraph_node *node)
streamer_write_chain (ob, DECL_ARGUMENTS (function), true);
/* Output DECL_INITIAL for the function, which contains the tree of
- lexical scopes.
- ??? This only streams the outermost block because we do not
- recurse into BLOCK_SUBBLOCKS but re-build those on stream-in. */
+ lexical scopes. */
stream_write_tree (ob, DECL_INITIAL (function), true);
+ /* As we do not recurse into BLOCK_SUBBLOCKS but only BLOCK_SUPERCONTEXT
+ collect block tree leafs and stream those. */
+ auto_vec<tree> block_tree_leafs;
+ if (DECL_INITIAL (function))
+ collect_block_tree_leafs (DECL_INITIAL (function), block_tree_leafs);
+ streamer_write_uhwi (ob, block_tree_leafs.length ());
+ for (unsigned i = 0; i < block_tree_leafs.length (); ++i)
+ stream_write_tree (ob, block_tree_leafs[i], true);
/* We also stream abstract functions where we stream only stuff needed for
debug info. */