#define INITIAL_PAIRS 10
-/* TODO: This needs to be garbage collected. */
DEF_VEC_O(label_pair);
DEF_VEC_ALLOC_O(label_pair, heap);
-#define FOR_EACH_BB_PAIR(pairs, index, pair) \
- for ((index)=0; VEC_iterate(bb_pair, pairs, index, pair); (index)++)
-
#define FOR_EACH_LABEL_PAIR(pairs, index, pair) \
- for ((index)=0; VEC_iterate(label_pair, pairs, index, pair); (index)++)
+ for ((index) = 0; VEC_iterate (label_pair, pairs, index, pair); (index)++)
+
+/* The last function duplicated. Used to make sure we never try to
+ access duplicated basic blocks from an older function. */
+static struct function *duplicated_function = NULL;
+
+/* The distributor basic block for the current function (assuming that
+ the current function has been duplicated). */
+basic_block distributor_bb;
+
+/* The duplicated basic blocks for the current function (assuming that
+ the current function has been duplicated). */
+VEC(bb_pair, gc) *bb_pairs;
+
+bool
+is_current_func_duplicated ()
+{
+ return (cfun == duplicated_function);
+}
static basic_block
new_bb_for_old(VEC(bb_pair, gc) *bb_pairs, basic_block old)
duty to further populate the distributor block.
*/
void
-duplicate_function_body (VEC(bb_pair, gc) **bb_pairs_ptr,
- basic_block *distributor_bb_ptr,
- const char *tmpvar_name, gimple call)
+duplicate_function_body (const char *tmpvar_name, gimple call)
{
- VEC(bb_pair, gc) *bb_pairs;
VEC(label_pair, heap) *label_pairs;
unsigned int pair_index;
basic_block old_first_bb;
basic_block new_first_bb;
- basic_block distributor_bb;
tree old_label;
tree new_label;
remove_edge(single_succ_edge(distributor_bb));
make_edge(distributor_bb, old_first_bb, EDGE_FALSE_VALUE);
make_edge(distributor_bb, new_first_bb, EDGE_TRUE_VALUE);
-
- *distributor_bb_ptr = distributor_bb;
}
- *bb_pairs_ptr = bb_pairs;
-
free_original_copy_tables();
VEC_free (label_pair, heap, label_pairs);
- return;
+
+ /* Make a note that this function was duplicated. */
+ duplicated_function = cfun;
}
DEF_VEC_O(bb_pair);
DEF_VEC_ALLOC_O(bb_pair, gc);
-extern void duplicate_function_body (VEC(bb_pair, gc) **bb_pairs_ptr,
- basic_block *distributor_bb_ptr,
- const char *tmpvar_name, gimple call);
+#define FOR_EACH_BB_PAIR(pairs, index, pair) \
+ for ((index) = 0; VEC_iterate (bb_pair, pairs, index, pair); (index)++)
+
+extern basic_block distributor_bb;
+extern VEC(bb_pair, gc) *bb_pairs;
+
+extern bool is_current_func_duplicated ();
+extern void duplicate_function_body (const char *tmpvar_name, gimple call);
#endif