aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-inline.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree-inline.c')
-rw-r--r--gcc/tree-inline.c61
1 files changed, 60 insertions, 1 deletions
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 7fa0245..c358cbe 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -47,6 +47,7 @@ along with GCC; see the file COPYING3. If not see
#include "value-prof.h"
#include "tree-pass.h"
#include "target.h"
+#include "cfgloop.h"
#include "rtl.h" /* FIXME: For asm_str_count. */
@@ -2088,7 +2089,7 @@ initialize_cfun (tree new_fndecl, tree callee_fndecl, gcov_type count)
cfun->static_chain_decl = src_cfun->static_chain_decl;
cfun->nonlocal_goto_save_area = src_cfun->nonlocal_goto_save_area;
cfun->function_end_locus = src_cfun->function_end_locus;
- cfun->curr_properties = src_cfun->curr_properties & ~PROP_loops;
+ cfun->curr_properties = src_cfun->curr_properties;
cfun->last_verified = src_cfun->last_verified;
cfun->va_list_gpr_size = src_cfun->va_list_gpr_size;
cfun->va_list_fpr_size = src_cfun->va_list_fpr_size;
@@ -2193,6 +2194,45 @@ maybe_move_debug_stmts_to_successors (copy_body_data *id, basic_block new_bb)
}
}
+/* Make a copy of the sub-loops of SRC_PARENT and place them
+ as siblings of DEST_PARENT. */
+
+static void
+copy_loops (bitmap blocks_to_copy,
+ struct loop *dest_parent, struct loop *src_parent)
+{
+ struct loop *src_loop = src_parent->inner;
+ while (src_loop)
+ {
+ if (!blocks_to_copy
+ || bitmap_bit_p (blocks_to_copy, src_loop->header->index))
+ {
+ struct loop *dest_loop = alloc_loop ();
+
+ /* Assign the new loop its header and latch and associate
+ those with the new loop. */
+ dest_loop->header = (basic_block)src_loop->header->aux;
+ dest_loop->header->loop_father = dest_loop;
+ if (src_loop->latch != NULL)
+ {
+ dest_loop->latch = (basic_block)src_loop->latch->aux;
+ dest_loop->latch->loop_father = dest_loop;
+ }
+
+ /* Copy loop meta-data. */
+ copy_loop_info (src_loop, dest_loop);
+
+ /* Finally place it into the loop array and the loop tree. */
+ place_new_loop (dest_loop);
+ flow_loop_tree_node_add (dest_parent, dest_loop);
+
+ /* Recurse. */
+ copy_loops (blocks_to_copy, dest_loop, src_loop);
+ }
+ src_loop = src_loop->next;
+ }
+}
+
/* Make a copy of the body of FN so that it can be inserted inline in
another function. Walks FN via CFG, returns new fndecl. */
@@ -2270,6 +2310,7 @@ copy_cfg_body (copy_body_data * id, gcov_type count, int frequency_scale,
basic_block new_bb = copy_bb (id, bb, frequency_scale, count_scale);
bb->aux = new_bb;
new_bb->aux = bb;
+ new_bb->loop_father = entry_block_map->loop_father;
}
last = last_basic_block;
@@ -2290,6 +2331,16 @@ copy_cfg_body (copy_body_data * id, gcov_type count, int frequency_scale,
e->count = incoming_count;
}
+ /* Duplicate the loop tree, if available and wanted. */
+ if (id->src_cfun->x_current_loops != NULL
+ && current_loops != NULL)
+ {
+ copy_loops (blocks_to_copy, entry_block_map->loop_father,
+ id->src_cfun->x_current_loops->tree_root);
+ /* Defer to cfgcleanup to update loop-father fields of basic-blocks. */
+ loops_state_set (LOOPS_NEED_FIXUP);
+ }
+
if (gimple_in_ssa_p (cfun))
FOR_ALL_BB_FN (bb, cfun_to_copy)
if (!blocks_to_copy
@@ -5147,6 +5198,14 @@ tree_function_versioning (tree old_decl, tree new_decl,
}
}
+ /* Set up the destination functions loop tree. */
+ if (DECL_STRUCT_FUNCTION (old_decl)->x_current_loops)
+ {
+ cfun->curr_properties &= ~PROP_loops;
+ loop_optimizer_init (AVOID_CFG_MODIFICATIONS);
+ cfun->curr_properties |= PROP_loops;
+ }
+
/* Copy the Function's body. */
copy_body (&id, old_entry_block->count, REG_BR_PROB_BASE,
ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, blocks_to_copy, new_entry);