aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/frontend-passes.c
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2011-04-08 21:46:08 +0000
committerThomas Koenig <tkoenig@gcc.gnu.org>2011-04-08 21:46:08 +0000
commit51a30b323dd59079cf039341d16e95c6136f31cb (patch)
treedead53cd1d4f1c204f3597d9701bfc77638335b5 /gcc/fortran/frontend-passes.c
parent041e059f264744313dc38f2223098409f8d86c29 (diff)
downloadgcc-51a30b323dd59079cf039341d16e95c6136f31cb.zip
gcc-51a30b323dd59079cf039341d16e95c6136f31cb.tar.gz
gcc-51a30b323dd59079cf039341d16e95c6136f31cb.tar.bz2
re PR fortran/48448 (Implement -f(no-)frontend-optimization)
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. From-SVN: r172215
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 b6f6b4c..cabfd28 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);
}