aboutsummaryrefslogtreecommitdiff
path: root/gcc/lto-streamer-in.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/lto-streamer-in.c')
-rw-r--r--gcc/lto-streamer-in.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c
index c4daa30..f5789c0 100644
--- a/gcc/lto-streamer-in.c
+++ b/gcc/lto-streamer-in.c
@@ -48,6 +48,8 @@ along with GCC; see the file COPYING3. If not see
#include "tree-streamer.h"
#include "tree-pass.h"
#include "streamer-hooks.h"
+#include "cfgloop.h"
+
struct freeing_string_slot_hasher : string_slot_hasher
{
@@ -660,6 +662,58 @@ input_cfg (struct lto_input_block *ib, struct function *fn,
p_bb = bb;
index = streamer_read_hwi (ib);
}
+
+ /* ??? The cfgloop interface is tied to cfun. */
+ gcc_assert (cfun == fn);
+
+ /* Input the loop tree. */
+ unsigned n_loops = streamer_read_uhwi (ib);
+ if (n_loops == 0)
+ return;
+
+ struct loops *loops = ggc_alloc_cleared_loops ();
+ init_loops_structure (fn, loops, n_loops);
+
+ /* Input each loop and associate it with its loop header so
+ flow_loops_find can rebuild the loop tree. */
+ for (unsigned i = 1; i < n_loops; ++i)
+ {
+ int header_index = streamer_read_hwi (ib);
+ if (header_index == -1)
+ {
+ loops->larray->quick_push (NULL);
+ continue;
+ }
+
+ struct loop *loop = alloc_loop ();
+ loop->num = loops->larray->length ();
+ loop->header = BASIC_BLOCK_FOR_FUNCTION (fn, header_index);
+ loop->header->loop_father = loop;
+
+ /* Read everything copy_loop_info copies. */
+ loop->estimate_state = streamer_read_enum (ib, loop_estimation, EST_LAST);
+ loop->any_upper_bound = streamer_read_hwi (ib);
+ if (loop->any_upper_bound)
+ {
+ loop->nb_iterations_upper_bound.low = streamer_read_uhwi (ib);
+ loop->nb_iterations_upper_bound.high = streamer_read_hwi (ib);
+ }
+ loop->any_estimate = streamer_read_hwi (ib);
+ if (loop->any_estimate)
+ {
+ loop->nb_iterations_estimate.low = streamer_read_uhwi (ib);
+ loop->nb_iterations_estimate.high = streamer_read_hwi (ib);
+ }
+
+ loops->larray->quick_push (loop);
+
+ /* flow_loops_find doesn't like loops not in the tree, hook them
+ all as siblings of the tree root temporarily. */
+ flow_loop_tree_node_add (loops->tree_root, loop);
+ }
+
+ /* Rebuild the loop tree. */
+ fn->x_current_loops = flow_loops_find (loops);
}