Merge branch 'duplicate'
authorJustin Seyster <jseyster@cs.sunysb.edu>
Fri, 13 Aug 2010 23:03:36 +0000 (19:03 -0400)
committerJustin Seyster <jseyster@cs.sunysb.edu>
Fri, 13 Aug 2010 23:03:36 +0000 (19:03 -0400)
Conflicts:
src/aop-pc-assign.c
src/aop-pc-entry.c
src/aop-pc-exit.c
src/aop-pc-fun-call.c
src/aop-pointcut.c
src/aop-pointcut.h

1  2 
src/aop-pc-assign.c
src/aop-pc-entry.c
src/aop-pc-exit.c
src/aop-pc-fun-call.c
src/aop-pointcut.c
src/aop-pointcut.h
src/aop.h

index 03801cffe0f6cf2a9998026f83db0226997bdd74,5964704629bdc76f9531f4700e750653ca4b221a..0c8cdf21702e15ba1791ffd705b4c41d25207cc1
@@@ -301,6 -301,24 +301,26 @@@ stmt_matches_pointcut (struct aop_point
      }
  }
  
 -        init_joinpoint (&jp, &gsi, pc, stmt);
+ static void join_on_bb_assign (basic_block bb, struct aop_pointcut *pc,
+                              join_callback cb, void *callback_param)
+ {
+   gimple_stmt_iterator gsi;
++  expanded_location xloc;
+   for (gsi = gsi_start_bb (bb) ; !gsi_end_p (gsi) ; gsi_next (&gsi))
+     {
+       gimple stmt = gsi_stmt (gsi);
+       if (stmt_matches_pointcut (pc, stmt))
+       {
+         struct aop_joinpoint jp;
++        xloc = expand_location (gimple_location (stmt));
++        init_joinpoint (&jp, &gsi, pc, stmt, xloc.line, xloc.file);
+         cb (&jp, callback_param);
+       }
+     }
+ }
  static void
  op_join_on_assign (struct aop_pointcut *pc, join_callback cb,
                   void *callback_param)
index faf7ee8f562db75e372a9c58ffe7dd3836dfa00f,cd1179a788bbe62c8e17ec9cc3fd95e443651536..a828a9ebed5151d73ef88291d611422db57df82a
  #include <basic-block.h>
  #include <gimple.h>
  #include <string.h>
 +#include <tree-flow.h>
  
  #include "aop.h"
+ #include "aop-duplicate.h"
  #include "aop-pointcut.h"
  #include "aop-type.h"
  
   * \{
   */
  
 +static expanded_location
 +get_function_entry_xloc()
 +{
 +  basic_block bb;
 +  expanded_location xloc;
 +  
 +  bb = ENTRY_BLOCK_PTR_FOR_FUNCTION (cfun);
 +  xloc = expand_location (gimple_location (first_stmt (bb->next_bb)));
 +  return xloc;
 +}
 +
+ /* Function have only one entry.  Return true if that entry matches
+    the pointcut's filtering criteria. */
+ static bool
+ is_function_entry_matching (struct aop_pointcut *pc)
+ {
+   /* Filter by name. */
+   if(pc->pc_entry.function_name == NULL)
+     {
+       /* No name filter in place. */
+       return true;
+     }
+   else
+     {
+       const char *func_name =
+       IDENTIFIER_POINTER (DECL_NAME (current_function_decl));
+       return (strcmp (func_name, pc->pc_entry.function_name) == 0);
+     }  
+ }
  
+ /* We represent the function's entry as a control-flow graph edge.
+    That edge is the only thing necessary to join on the pointcut's one
+    join point. */
  static void
op_join_on_function_entry (struct aop_pointcut *pc, join_callback cb,
-                          void *callback_param)
join_on_entry_edge (struct aop_pointcut *pc, edge in_edge, join_callback cb,
+                   void *callback_param)
  {
    struct aop_joinpoint jp;
    gimple_stmt_iterator gsi;
 +  expanded_location xloc;
  
-   aop_assert (pc->kind == ATP_ENTRY);
-   /* Filter this pointcut by function name if necessary. */
-   if(pc->pc_entry.function_name != NULL)
-     {
-       const char *func_name =
-       IDENTIFIER_POINTER (DECL_NAME (current_function_decl));
-       if (strcmp (func_name, pc->pc_entry.function_name) != 0)
-       return;
-     }
    /* Note that the gimple iterator gets initialized by
       op_prepare_entry when it is time to insert advice.  (We poison it
       just to make sure that initialization is getting called.)*/
    memset (&gsi, 0xfa, sizeof (gimple_stmt_iterator));
 -  init_joinpoint (&jp, &gsi, pc, NULL);
 +  xloc = get_function_entry_xloc ();
 +  init_joinpoint (&jp, &gsi, pc, NULL, xloc.line, xloc.file);
+   jp.in_edge = in_edge;
    cb (&jp, callback_param);
  }
  
index cf1caf048b8c5882679c1313943de043b0e654ce,e7be410c722812bd3d4cc125ed351b91fb4bc345..5e1c17ede74ed7f8cae72f8fab06b8dd4d5146c1
   * \{
   */
  
 -        init_joinpoint (&jp, &gsi, pc, stmt);
+ static void
+ join_on_bb_function_exit (basic_block bb, struct aop_pointcut *pc,
+                         join_callback cb, void *callback_param)
+ {
+   gimple_stmt_iterator gsi;
++  expanded_location xloc;
+   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;
++        xloc = expand_location (gimple_location (stmt)); 
++        init_joinpoint (&jp, &gsi, pc, stmt, xloc.line, xloc.file);
+         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;
-   expanded_location xloc;
++
    aop_assert (pc->kind == ATP_EXIT);
    
    FOR_EACH_BB(bb)
index 7293ab7894f6d4346ceec324ec29d5eb269f2769,96f4f3e273e990424f09481d9786c28103b75d88..04834a5be1575a7c2b3ded3da60d76cff7269d24
@@@ -131,35 -132,26 +132,28 @@@ call_matches (struct aop_pointcut *pc, 
  }
  
  static void
op_join_on_function_call (struct aop_pointcut *pc, join_callback cb,
-                         void *callback_param)
join_on_bb_function_call (basic_block bb, struct aop_pointcut *pc,
+                         join_callback cb, void *callback_param)
  {
-   basic_block my_basic_block;
    gimple_stmt_iterator gsi;
 +  expanded_location xloc;
  
-   aop_assert (pc->kind == ATP_CALL);
-   FOR_EACH_BB(my_basic_block)
+   for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) 
      {
-       for (gsi = gsi_start_bb (my_basic_block) ; !gsi_end_p (gsi) ;
-          gsi_next (&gsi))
+       gimple stmt = gsi_stmt (gsi);
+       /* At this stage, there should be no GIMPLE statements with
+        sub-statements. */
+       gcc_assert(!gimple_has_substatements (stmt));
+       if (gimple_code (stmt) == GIMPLE_CALL)
        {
-         gimple stmt = gsi_stmt (gsi);
-         /* At this stage, there should be no GIMPLE statements with
-            sub-statements. */
-         gcc_assert(!gimple_has_substatements (stmt));
-         if (gimple_code (stmt) == GIMPLE_CALL)
-           {
-             if (call_matches (pc, stmt))
-               {                       
-                 struct aop_joinpoint jp;
-                 xloc = expand_location (gimple_location (stmt));
-                 init_joinpoint (&jp, &gsi, pc, stmt, xloc.line, xloc.file);
-                 cb (&jp, callback_param);             
-               }
+         if (call_matches (pc, stmt))
+           {                   
+             struct aop_joinpoint jp;
 -            init_joinpoint (&jp, &gsi, pc, stmt);
++            xloc = expand_location (gimple_location (stmt));
++            init_joinpoint (&jp, &gsi, pc, stmt, xloc.line, xloc.file);
+             cb (&jp, callback_param);         
            }
        }
      }
index 4c4727f5a4499406653ea375c8e395570837ed94,086feefc10bf90c726e0ccf60396a18844470c24..36636666fa4c7bdb9cb7393297aebc7eec2733f8
@@@ -60,20 -59,6 +60,21 @@@ init_joinpoint (struct aop_joinpoint *j
    jp->pc = pc;
    jp->gsi = gsi;
    jp->stmt = stmt;
 +  jp->line = line;
 +  jp->file = file;
+   jp->in_edge = NULL;
    jp->is_prepared = false;
 +  
 +}
 +
 +int
 +aop_capture_lineno (struct aop_joinpoint *jp)
 +{
 +  return jp->line;
 +}
 +
 +const char *
 +aop_capture_file_name (struct aop_joinpoint *jp)
 +{
 +  return jp->file;
  }
index 7f6a338d35094eb7e098afbef193a01296267863,c86fc2dc3a547a0db5479521fee21ee18228aee7..1cd103c6c45736ffee4ebe4ebf4b232ab6a9ea3d
@@@ -68,9 -68,10 +68,10 @@@ struct aop_pointcut 
    enum aop_pckind kind;
  
    void (*join_on) (struct aop_pointcut *, join_callback, void *);
+   void (*join_on_copy) (struct aop_pointcut *, int copy, join_callback, void *);
    insert_callback insert_before;
    insert_callback insert_after;
 -  
 +
    /* prepare_for_weave() gets called once for each joinpoint before
       any advice gets inserted at that joinpoint.  */
    void (*prepare_for_weave) (struct aop_joinpoint *);
diff --cc src/aop.h
Simple merge