From: Justin Seyster Date: Thu, 12 Aug 2010 19:30:38 +0000 (-0400) Subject: The two copies of a duplicated function are now available for joining. X-Git-Tag: release-v1.0~73^2~6 X-Git-Url: https://git.fsl.cs.stonybrook.edu/?a=commitdiff_plain;h=596b540abdd9d56271084869cec2d13ad2bea326;p=interaspect.git The two copies of a duplicated function are now available for joining. The basic block pairs are now stored in globally accessible place and are set up to get garbage collected when the pass ends. --- diff --git a/src/aop-duplicate.c b/src/aop-duplicate.c index b7d19bd..30723d9 100644 --- a/src/aop-duplicate.c +++ b/src/aop-duplicate.c @@ -44,15 +44,29 @@ typedef struct label_pair { #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) @@ -117,11 +131,8 @@ fix_labels(tree *label, int *walk_subtrees, void *arg) 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; @@ -228,7 +239,6 @@ duplicate_function_body (VEC(bb_pair, gc) **bb_pairs_ptr, basic_block old_first_bb; basic_block new_first_bb; - basic_block distributor_bb; tree old_label; tree new_label; @@ -296,13 +306,11 @@ duplicate_function_body (VEC(bb_pair, gc) **bb_pairs_ptr, 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; } diff --git a/src/aop-duplicate.h b/src/aop-duplicate.h index 878a549..c87093b 100644 --- a/src/aop-duplicate.h +++ b/src/aop-duplicate.h @@ -26,8 +26,13 @@ typedef struct bb_pair { 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 diff --git a/src/aop-weave.c b/src/aop-weave.c index 2f84133..19088d8 100644 --- a/src/aop-weave.c +++ b/src/aop-weave.c @@ -271,9 +271,6 @@ aop_duplicate (struct aop_joinpoint *jp, const char *func_name, ...) gimple func_call; struct aop_pointcut *pc; - VEC(bb_pair, gc) *bb_pairs; - basic_block distributor; - pc = jp->pc; if (pc->kind != ATP_ENTRY) @@ -288,5 +285,5 @@ aop_duplicate (struct aop_joinpoint *jp, const char *func_name, ...) argp); va_end (argp); - duplicate_function_body (&bb_pairs, &distributor, "ia_body_index", func_call); + duplicate_function_body ("ia_body_index", func_call); }