aop_join_on_copy() support for function exit pointcuts.
authorJustin Seyster <jseyster@cs.sunysb.edu>
Thu, 12 Aug 2010 23:23:46 +0000 (19:23 -0400)
committerJustin Seyster <jseyster@cs.sunysb.edu>
Thu, 12 Aug 2010 23:23:46 +0000 (19:23 -0400)
src/aop-pc-exit.c

index 9f6f9e366e3b8f5af3be8c1fb7a96bd1de1aec52..e7be410c722812bd3d4cc125ed351b91fb4bc345 100644 (file)
@@ -34,6 +34,7 @@
 #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);
     } 
 }
 
@@ -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.