Added regimplification for assignment ptcut
authorKetan Dixit <ketan.dixit@gmail.com>
Mon, 5 Jul 2010 20:52:24 +0000 (16:52 -0400)
committerJustin Seyster <jseyster@cs.sunysb.edu>
Tue, 6 Jul 2010 22:21:40 +0000 (18:21 -0400)
src/aop-main.c
src/aop-pc-assign.c
src/aop-pc-entry.c
src/aop-pc-exit.c
src/aop-pc-fun-call.c
src/aop-pointcut.h

index 4cd0a33e917a9fd6c2a98dc4cbcde4de54b78d32..9b6a56354152275fe8119068cea16e6126650f6c 100644 (file)
 
 static const char *aop_plugin_name;
 
+/* This code regimplifies the current function. Regimplification
+   fixes broken GIMPLE invariants. */
+static void
+regimplify ()
+{
+  basic_block bb;
+  FOR_EACH_BB(bb)
+    {
+      gimple_stmt_iterator gsi;
+      
+      for (gsi = gsi_start_bb (bb) ; !gsi_end_p (gsi) ; gsi_next (&gsi))
+       {
+         gimple stmt = gsi_stmt (gsi);
+         gimple_regimplify_operands(stmt, &gsi);
+       }
+    }
+}
+
 void
 aop_join_on (struct aop_pointcut *pc, join_callback callback, 
             void *callback_param)
@@ -63,6 +81,12 @@ aop_join_on (struct aop_pointcut *pc, join_callback callback,
   aop_assert (pc != NULL && pc->join_on != NULL);
 
   pc->join_on (pc, callback, callback_param);
+
+  /* Call regimplification only if the pointcut needs it */
+  if (pc->need_regimplification) {
+    regimplify();
+    pc->need_regimplification = false;
+  }  
 }
 
 /* Store a list of all struct opt_pass objects we create so that we
index 66004377745a9ea051098953bf4a049ac6343b57..07a43c59bc1b09f7aa91ed43eadcb09162e4fd50 100644 (file)
@@ -173,6 +173,8 @@ aop_capture_lhs_addr (struct aop_joinpoint *jp)
   dv->jp = jp;
   dv->get_dynval = op_get_lhs_addr;
 
+  jp->pc->need_regimplification = true;
+
   return dv;
 }
 
@@ -353,10 +355,12 @@ aop_match_assignment_by_type (const struct aop_type *type)
   pc->kind = ATP_ASSIGN;
   pc->join_on = op_join_on_assign;
   pc->insert_before = op_default_insert_before;
+  pc->insert_after = op_default_insert_after;
   pc->prepare_for_weave = op_prepare_assign;
 
   pc->pc_assign.type = type;
   pc->pc_assign.include_temp_vars = false;
+  pc->need_regimplification = false;
 
   return pc;
 }
index b24bd02848f6e6a49d39e5812d9cd2b0100e7eed..66145d56e91ba6b4cb564206c1be836dd5015259 100644 (file)
@@ -74,6 +74,8 @@ aop_match_function_entry ()
   struct aop_pointcut *pc;
   pc = ggc_alloc (sizeof (struct aop_pointcut));
   pc->kind = ATP_ENTRY;
+  pc->need_regimplification = false;
+
   pc->join_on = op_join_on_function_entry;
   pc->insert_before = op_default_insert_before;
   pc->prepare_for_weave = op_default_prepare_for_weave;
index 3dbe43b717c3efc0f45048d3853087c17c9fcaf7..2869fa66f0f3e0ec4cab9602b17fbe657c5d400e 100644 (file)
@@ -70,8 +70,11 @@ aop_match_function_exit ()
   struct aop_pointcut *pc;  
   pc = ggc_alloc (sizeof (struct aop_pointcut));
   pc->kind = ATP_EXIT;
+  pc->need_regimplification = false;
+
   pc->join_on = op_join_on_function_exit;
   pc->insert_before = op_default_insert_before;
   pc->prepare_for_weave = op_default_prepare_for_weave;
+
   return pc;
 }
index ff5c8467fb747803d0b798679c5c582966a30d05..199bae1538a0c5d3eb9e3bd3f4cf504adfc80db9 100644 (file)
@@ -119,6 +119,8 @@ aop_match_function_call ()
 
   pc = ggc_alloc (sizeof (struct aop_pointcut));
   pc->kind = ATP_CALL;
+  pc->need_regimplification = false;
+
   pc->join_on = op_join_on_function_call;
   pc->insert_after = op_default_insert_after;
   pc->insert_before = op_default_insert_before;
@@ -126,6 +128,7 @@ aop_match_function_call ()
 
   /* Initialize the list to NULL */
   pc->pc_call.param_list_head = NULL;
+
   return pc;
 }
 
index f5014efbf04550d12e6978ef5f47af80bb26d6ee..ca23946098fbe5d38ebe09d315603e34df6f7e37 100644 (file)
@@ -78,6 +78,9 @@ struct aop_pointcut {
     struct aop_pc_entry pc_entry;
     struct aop_pc_fun_call pc_call;
   };
+
+  /* True if the pointcut needs regimplification after join_on */
+  bool need_regimplification;
 };
 
 /* An AOP joinpoint represents a specific location in the code where