#include <gimple.h>
#include "aop.h"
+#include "aop-duplicate.h"
#include "aop-pointcut.h"
#include "aop-type.h"
* \{
*/
+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);
}
}
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.