Patchwork [fortran] Introducing -fdump-optimized-tree

login
register
mail settings
Submitter Thomas Koenig
Date Oct. 24, 2010, 9:40 p.m.
Message ID <1287956428.26284.8.camel@linux-fd1f.site>
Download mbox | patch
Permalink /patch/69055/
State New
Headers show

Comments

Thomas Koenig - Oct. 24, 2010, 9:40 p.m.
Hello world,

here's a patch for dumping the optimized tree after front-end
optimization.  Regression-tested (not that I expected to find anything
there...).  Tested with 'make dvi' and 'make info'. OK for trunk?

	Thomas

2010-10-24  Thomas Koenig  <tkoenig@gcc.gnu.org>

	* gfortran.h (gfc_option_t):  Add dump_optimized_tree.
	* lang.opt:  Add fdump-optimized-tree.
	* gfortran.texi:  Adjust description of fdump-parse-tree to
	the presence of fdump-optimized-tree.  Add description of
	fdump-optimized-tree.
	* frontend-passes.c (gfc_run_passes):  If optimizing and
	if fdump-optimized-tree is set, dump the parse tree after
	optimization.
	* options.c (gfc_init_options):  Initialize dump_optimized_tree.
	(gfc_handle_option):  Handle dump_optimized_tree.
Diego Novillo - Oct. 25, 2010, 2:02 a.m.
This looks

On Sun, Oct 24, 2010 at 17:40, Thomas Koenig <tkoenig@netcologne.de> wrote:
> Hello world,
>
> here's a patch for dumping the optimized tree after front-end
> optimization.  Regression-tested (not that I expected to find anything
> there...).  Tested with 'make dvi' and 'make info'. OK for trunk?
>
>        Thomas
>
> 2010-10-24  Thomas Koenig  <tkoenig@gcc.gnu.org>
>
>        * gfortran.h (gfc_option_t):  Add dump_optimized_tree.
>        * lang.opt:  Add fdump-optimized-tree.

Could we name this differently?  It looks too similar to
fdump-tree-optimized.  It's confusing.

fdump-fortran-xxx?  Or perhaps have an umbrella fdump=...


Diego.
Thomas Koenig - Oct. 26, 2010, 4:43 a.m.
Diego Novillo wrote:

> fdump-fortran-xxx?  Or perhaps have an umbrella fdump=...

fdump-fortran-original and fdump-fortran-optimized sounds good to me.

Should we keep fdump-parse-tree around as an alias for 4.6, then remove
it for 4.7?

	Thomas
Tobias Burnus - Oct. 27, 2010, 8:01 a.m.
Thomas,

I think the patch is OK; however, I agree with Diego that the name is 
confusing.

On 10/26/2010 06:43 AM, Thomas Koenig wrote:
> Diego Novillo wrote:
>> fdump-fortran-xxx?  Or perhaps have an umbrella fdump=...
> fdump-fortran-original and fdump-fortran-optimized sounds good to me.

Looks also fine to me.

> Should we keep fdump-parse-tree around as an alias for 4.6, then remove
> it for 4.7?

Well, in principle one should really avoid removing flags; thus, we can 
deprecate it, but I am not sure that we should already remove it in 4.7. 
(On the other hand, -fdump-parse-tree is presumably extremely rarely 
used by users and also I hardly every use it - thus, it does not matter 
as much as removing -fbounds-check in favour of -fcheck=bounds would do.)

Tobias

Patch

Index: gfortran.h
===================================================================
--- gfortran.h	(Revision 165903)
+++ gfortran.h	(Arbeitskopie)
@@ -2179,6 +2179,7 @@  typedef struct
   int max_continue_free;
   int max_identifier_length;
   int dump_parse_tree;
+  int dump_optimized_tree;
 
   int warn_aliasing;
   int warn_ampersand;
Index: lang.opt
===================================================================
--- lang.opt	(Revision 165903)
+++ lang.opt	(Arbeitskopie)
@@ -362,6 +362,10 @@  fdump-parse-tree
 Fortran
 Display the code tree after parsing
 
+fdump-optimized-tree
+Fortran
+Display the code tree after front end optimization
+
 fexternal-blas
 Fortran
 Specify that an external BLAS library should be used for matmul calls on large-size arrays
Index: invoke.texi
===================================================================
--- invoke.texi	(Revision 165903)
+++ invoke.texi	(Arbeitskopie)
@@ -143,8 +143,8 @@  and warnings}.
 
 @item Debugging Options
 @xref{Debugging Options,,Options for debugging your program or GNU Fortran}.
-@gccoptlist{-fdump-parse-tree  -ffpe-trap=@var{list} @gol
--fdump-core -fbacktrace}
+@gccoptlist{-fdump-parse-tree  -fdump-optimized-tree @gol
+-ffpe-trap=@var{list}  -fdump-core -fbacktrace}
 
 @item Directory Options
 @xref{Directory Options,,Options for directory search}.
@@ -881,9 +881,15 @@  either your program or the GNU Fortran compiler.
 @table @gcctabopt
 @item -fdump-parse-tree
 @opindex @code{fdump-parse-tree}
-Output the internal parse tree before starting code generation.  Only
-really useful for debugging the GNU Fortran compiler itself.
+Output the internal parse tree after translating the source program
+into internal representation.  Only really useful for debugging the
+GNU Fortran compiler itself.
 
+@item -fdump-optimized-tree
+@opindex @code{fdump-optimized-tree}
+Output the parse tree after front-end optimization.  Only really
+useful for debugging the GNU Fortran compiler itself.
+
 @item -ffpe-trap=@var{list}
 @opindex @code{ffpe-trap=}@var{list}
 Specify a list of IEEE exceptions when a Floating Point Exception
Index: frontend-passes.c
===================================================================
--- frontend-passes.c	(Revision 165903)
+++ frontend-passes.c	(Arbeitskopie)
@@ -42,7 +42,11 @@  void
 gfc_run_passes (gfc_namespace *ns)
 {
   if (optimize)
-    optimize_namespace (ns);
+    {
+      optimize_namespace (ns);
+      if (gfc_option.dump_optimized_tree)
+	gfc_dump_parse_tree (ns, stdout);
+    }
 }
 
 /* Callback for each gfc_code node invoked through gfc_code_walker
Index: options.c
===================================================================
--- options.c	(Revision 165903)
+++ options.c	(Arbeitskopie)
@@ -91,6 +91,7 @@  gfc_init_options (unsigned int decoded_options_cou
   gfc_option.convert = GFC_CONVERT_NATIVE;
   gfc_option.record_marker = 0;
   gfc_option.dump_parse_tree = 0;
+  gfc_option.dump_optimized_tree = 0;
 
   gfc_option.warn_aliasing = 0;
   gfc_option.warn_ampersand = 0;
@@ -690,6 +691,10 @@  gfc_handle_option (size_t scode, const char *arg,
       gfc_option.dump_parse_tree = value;
       break;
 
+    case OPT_fdump_optimized_tree:
+      gfc_option.dump_optimized_tree = value;
+      break;
+
     case OPT_ffixed_form:
       gfc_option.source_form = FORM_FIXED;
       break;