From: Justin Seyster Date: Thu, 12 Aug 2010 23:23:46 +0000 (-0400) Subject: aop_join_on_copy() support for function exit pointcuts. X-Git-Tag: release-v1.0~73^2~2 X-Git-Url: https://git.fsl.cs.stonybrook.edu/?a=commitdiff_plain;h=0f2f59929c8598c6dd0547eac23db2013c19c3c6;p=interaspect.git aop_join_on_copy() support for function exit pointcuts. --- diff --git a/src/aop-pc-exit.c b/src/aop-pc-exit.c index 9f6f9e3..e7be410 100644 --- a/src/aop-pc-exit.c +++ b/src/aop-pc-exit.c @@ -34,6 +34,7 @@ #include #include "aop.h" +#include "aop-duplicate.h" #include "aop-pointcut.h" #include "aop-type.h" @@ -42,35 +43,41 @@ * \{ */ +static void +join_on_bb_function_exit (basic_block bb, struct aop_pointcut *pc, + join_callback cb, void *callback_param) +{ + gimple_stmt_iterator gsi; + + for (gsi = gsi_start_bb (bb) ; !gsi_end_p (gsi) ; gsi_next (&gsi)) + { + gimple stmt = gsi_stmt (gsi); + + if (gimple_code (stmt) == GIMPLE_RETURN) + { + struct aop_joinpoint jp; + init_joinpoint (&jp, &gsi, pc, stmt); + cb (&jp, callback_param); + + /* It's possible that gsi is no longer a valid iterator if + the callback inserted advice. Anyway, that's fine + because there shouldn't be any statements in the basic + block after the return! On to the next basic block. */ + break; + } + } +} + static void op_join_on_function_exit (struct aop_pointcut *pc, join_callback cb, void *callback_param) { basic_block bb; - gimple stmt; aop_assert (pc->kind == ATP_EXIT); FOR_EACH_BB(bb) { - gimple_stmt_iterator gsi; - for (gsi = gsi_start_bb (bb) ; !gsi_end_p (gsi) ; gsi_next (&gsi)) - { - stmt = gsi_stmt (gsi); - - if (gimple_code (stmt) == GIMPLE_RETURN) - { - struct aop_joinpoint jp; - init_joinpoint (&jp, &gsi, pc, stmt); - cb (&jp, callback_param); - - /* It's possible that gsi is no longer a valid iterator - if the callback inserted advice. Anyway, that's fine - because there shouldn't be any statements in the - basic block after the return! On to the next basic - block. */ - break; - } - } + join_on_bb_function_exit (bb, pc, cb, callback_param); } } @@ -78,8 +85,18 @@ static void op_join_on_copy_function_exit (struct aop_pointcut *pc, int copy, join_callback cb, void *callback_param) { - /* Not yet supported. */ - aop_assert(0); + unsigned int pair_index; + bb_pair *pair; + + aop_assert (pc->kind == ATP_EXIT); + aop_assert (is_current_func_duplicated ()); + + FOR_EACH_BB_PAIR (bb_pairs, pair_index, pair) + { + basic_block bb = (copy == 0) ? pair->old : pair->new; + + join_on_bb_function_exit (bb, pc, cb, callback_param); + } } /* Prepare for an insert at a function entry join point.