From: Ketan Dixit Date: Mon, 5 Jul 2010 20:52:24 +0000 (-0400) Subject: Added regimplification for assignment ptcut X-Git-Tag: release-v1.0~89^2~1 X-Git-Url: https://git.fsl.cs.stonybrook.edu/?a=commitdiff_plain;h=179400f8c49a6248daf2b962a67f0ac25838cd79;p=interaspect.git Added regimplification for assignment ptcut --- diff --git a/src/aop-main.c b/src/aop-main.c index 4cd0a33..9b6a563 100644 --- a/src/aop-main.c +++ b/src/aop-main.c @@ -56,6 +56,24 @@ 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 diff --git a/src/aop-pc-assign.c b/src/aop-pc-assign.c index 6600437..07a43c5 100644 --- a/src/aop-pc-assign.c +++ b/src/aop-pc-assign.c @@ -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; } diff --git a/src/aop-pc-entry.c b/src/aop-pc-entry.c index b24bd02..66145d5 100644 --- a/src/aop-pc-entry.c +++ b/src/aop-pc-entry.c @@ -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; diff --git a/src/aop-pc-exit.c b/src/aop-pc-exit.c index 3dbe43b..2869fa6 100644 --- a/src/aop-pc-exit.c +++ b/src/aop-pc-exit.c @@ -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; } diff --git a/src/aop-pc-fun-call.c b/src/aop-pc-fun-call.c index ff5c846..199bae1 100644 --- a/src/aop-pc-fun-call.c +++ b/src/aop-pc-fun-call.c @@ -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; } diff --git a/src/aop-pointcut.h b/src/aop-pointcut.h index f5014ef..ca23946 100644 --- a/src/aop-pointcut.h +++ b/src/aop-pointcut.h @@ -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