@@ -1177,6 +1177,10 @@ fdump-internal-locations
Common Var(flag_dump_locations) Init(0)
Dump detailed information on GCC's internal representation of source code locations
+fdump-metadata
+Common Var(flag_dump_metadata) Init(1)
+Include metadata about the relevant pass at the start and end of dumpfiles
+
fdump-passes
Common Var(flag_dump_passes) Init(0)
Dump optimization passes
@@ -324,6 +324,7 @@ Objective-C and Objective-C++ Dialects}.
-fdump-translation-unit@r{[}-@var{n}@r{]} @gol
-fdump-class-hierarchy@r{[}-@var{n}@r{]} @gol
-fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline @gol
+-fno-dump-metadata @gol
-fdump-passes @gol
-fdump-statistics @gol
-fdump-tree-all @gol
@@ -6863,6 +6864,26 @@ Dump after function inlining.
Dump the list of optimization passes that are turned on and off by
the current command-line options.
+@item -fno-dump-metadata
+@opindex fno-dump-metadata
+By default, gcc dump files contain header lines of the form:
+
+@smallexample
+
+; start of dump from pass_forwprop (../../src/gcc/tree-ssa-forwprop.c:2103)
+
+(dump goes here)
+
+; end of dump from pass_forwprop (../../src/gcc/tree-ssa-forwprop.c:2103)
+
+@end smallexample
+
+at the top and bottom, identifying the C++ class implementing the
+pass, and its location within GCC's source tree.
+
+This option suppresses these metadata lines, for use by gcc's testsuite
+when looking for regexes in the dump files.
+
@item -fdump-statistics-@var{option}
@opindex fdump-statistics
Enable and control dumping of pass statistics in a separate file. The
@@ -2114,6 +2114,9 @@ pass_init_dump_file (opt_pass *pass)
!dumps->dump_initialized_p (pass->static_pass_number);
dump_file_name = dumps->get_dump_file_name (pass->static_pass_number);
dumps->dump_start (pass->static_pass_number, &dump_flags);
+ if (dump_file && flag_dump_metadata)
+ fprintf (dump_file, "; start of dump from %s (%s:%i)\n",
+ pass->classname, pass->filename, pass->line_num);
if (dump_file && current_function_decl)
dump_function_header (dump_file, current_function_decl, dump_flags);
if (initializing_dump
@@ -2138,6 +2141,10 @@ pass_fini_dump_file (opt_pass *pass)
{
timevar_push (TV_DUMP);
+ if (dump_file && flag_dump_metadata)
+ fprintf (dump_file, "; end of dump from %s (%s:%i)\n",
+ pass->classname, pass->filename, pass->line_num);
+
/* Flush and close dump file. */
if (dump_file_name)
{
@@ -278,6 +278,24 @@ proc gcc-dg-test-1 { target_compile prog do_what extra_tool_flags } {
}
}
+ # Determine if any { dg-final { scan-tree-dump-times } } actions were
+ # registered.
+ set will_scan_dump 0
+ foreach x [split $finalcode "\n"] {
+ set finalcmd [lindex $x 0]
+ if { ${finalcmd} == "scan-tree-dump-times" } {
+ set will_scan_dump 1
+ }
+ }
+ # If so, add -fno-dump-metadata to the options to prevent the dumpfiles
+ # from containing lines like:
+ # ; start of dump from pass_forwprop (../../src/gcc/tree-ssa-forwprop.c:2103)
+ # which could potentially match a regexp (e.g. if the path to the
+ # source tree contains strings of interest).
+ if { ${will_scan_dump} } {
+ lappend extra_tool_flags "-fno-dump-metadata"
+ }
+
append finalcode [schedule-cleanups "$options $extra_tool_flags"]
if { $extra_tool_flags != "" } {
lappend options "additional_flags=$extra_tool_flags"