summaryrefslogtreecommitdiff
path: root/gcc/fortran/frontend-passes.c
diff options
context:
space:
mode:
authortkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4>2011-04-08 21:46:08 +0000
committertkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4>2011-04-08 21:46:08 +0000
commit10b2bb30426070c8b2e4f0d2db382805a94a4913 (patch)
treedead53cd1d4f1c204f3597d9701bfc77638335b5 /gcc/fortran/frontend-passes.c
parent713209080e93abe21e7e913145e20aab60ad1ecb (diff)
downloadgcc-10b2bb30426070c8b2e4f0d2db382805a94a4913.tar.gz
2011-04-08 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/48448 * gfortran.h (gfc_option_t): Add warn_function_elimination and flag_frontend_optimize. * lang.opt (Wfunction-elimination): Add. (ffrontend-optimize): Add. * invoke.texi: Add documentation for -Wfunction-elimination and -ffrontend-optimize. Add -faggressive-function-elimination to list of code generation options. * frontend-passes.c (gfc_run_passes): Run optimizations if flag_frontend_optimize is set. (warn_function_elimination): New function. (cfe_expr_0): Call it if requested to do so. * options.c (gfc_init_options): Initiate warn_function_elimination and flag_frontend_optimize. (gfc_post_options): Set flag_frontend_optimize if not specified by user, depending on the optimization level. (gfc_handle_option): Handle -Wfunction-elimination and -ffrontend-optimize. 2011-04-08 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/48448 * gfortran.dg/function_optimize_5.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@172215 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/frontend-passes.c')
-rw-r--r--gcc/fortran/frontend-passes.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c
index b6f6b4cd020..cabfd285586 100644
--- a/gcc/fortran/frontend-passes.c
+++ b/gcc/fortran/frontend-passes.c
@@ -62,7 +62,7 @@ gfc_namespace *current_ns;
void
gfc_run_passes (gfc_namespace *ns)
{
- if (optimize)
+ if (gfc_option.flag_frontend_optimize)
{
expr_size = 20;
expr_array = XNEWVEC(gfc_expr **, expr_size);
@@ -283,6 +283,20 @@ create_var (gfc_expr * e)
return result;
}
+/* Warn about function elimination. */
+
+static void
+warn_function_elimination (gfc_expr *e)
+{
+ if (e->expr_type != EXPR_FUNCTION)
+ return;
+ if (e->value.function.esym)
+ gfc_warning ("Removing call to function '%s' at %L",
+ e->value.function.esym->name, &(e->where));
+ else if (e->value.function.isym)
+ gfc_warning ("Removing call to function '%s' at %L",
+ e->value.function.isym->name, &(e->where));
+}
/* Callback function for the code walker for doing common function
elimination. This builds up the list of functions in the expression
and goes through them to detect duplicates, which it then replaces
@@ -315,6 +329,10 @@ cfe_expr_0 (gfc_expr **e, int *walk_subtrees,
{
if (newvar == NULL)
newvar = create_var (*(expr_array[i]));
+
+ if (gfc_option.warn_function_elimination)
+ warn_function_elimination (*(expr_array[j]));
+
gfc_free (*(expr_array[j]));
*(expr_array[j]) = gfc_copy_expr (newvar);
}