Commit bdde878c by Alexandre Oliva Committed by Alexandre Oliva

gcc.c (report_times_to_file): New.

* gcc.c (report_times_to_file): New.
(execute): Implement it.
(process_command): Support -time=.
* doc/invoke.texi: Document it.

From-SVN: r148162
parent 2ce59df7
2009-06-04 Alexandre Oliva <aoliva@redhat.com> 2009-06-04 Alexandre Oliva <aoliva@redhat.com>
* gcc.c (report_times_to_file): New.
(execute): Implement it.
(process_command): Support -time=.
* doc/invoke.texi: Document it.
2009-06-04 Alexandre Oliva <aoliva@redhat.com>
* tree-ssa-live.c (remove_unused_scope_block_p): Keep variables * tree-ssa-live.c (remove_unused_scope_block_p): Keep variables
that have value exprs. that have value exprs.
......
...@@ -318,7 +318,7 @@ Objective-C and Objective-C++ Dialects}. ...@@ -318,7 +318,7 @@ Objective-C and Objective-C++ Dialects}.
-print-multi-directory -print-multi-lib @gol -print-multi-directory -print-multi-lib @gol
-print-prog-name=@var{program} -print-search-dirs -Q @gol -print-prog-name=@var{program} -print-search-dirs -Q @gol
-print-sysroot -print-sysroot-headers-suffix @gol -print-sysroot -print-sysroot-headers-suffix @gol
-save-temps -save-temps=cwd -save-temps=obj -time} -save-temps -save-temps=cwd -save-temps=obj -time@r{[}=@var{file}@r{]}}
@item Optimization Options @item Optimization Options
@xref{Optimize Options,,Options that Control Optimization}. @xref{Optimize Options,,Options that Control Optimization}.
...@@ -5287,11 +5287,13 @@ would create @file{foo.i}, @file{foo.s}, @file{dir/xbar.i}, ...@@ -5287,11 +5287,13 @@ would create @file{foo.i}, @file{foo.s}, @file{dir/xbar.i},
@file{dir/xbar.s}, @file{dir2/yfoobar.i}, @file{dir2/yfoobar.s}, and @file{dir/xbar.s}, @file{dir2/yfoobar.i}, @file{dir2/yfoobar.s}, and
@file{dir2/yfoobar.o}. @file{dir2/yfoobar.o}.
@item -time @item -time@r{[}=@var{file}@r{]}
@opindex time @opindex time
Report the CPU time taken by each subprocess in the compilation Report the CPU time taken by each subprocess in the compilation
sequence. For C source files, this is the compiler proper and assembler sequence. For C source files, this is the compiler proper and assembler
(plus the linker if linking is done). The output looks like this: (plus the linker if linking is done).
Without the specification of an output file, the output looks like this:
@smallexample @smallexample
# cc1 0.12 0.01 # cc1 0.12 0.01
...@@ -5303,6 +5305,18 @@ executing the program itself. The second number is ``system time'', ...@@ -5303,6 +5305,18 @@ executing the program itself. The second number is ``system time'',
time spent executing operating system routines on behalf of the program. time spent executing operating system routines on behalf of the program.
Both numbers are in seconds. Both numbers are in seconds.
With the specification of an output file, the output is appended to the
named file, and it looks like this:
@smallexample
0.12 0.01 cc1 @var{options}
0.00 0.01 as @var{options}
@end smallexample
The ``user time'' and the ``system time'' are moved before the program
name, and the options passed to the program are displayed, so that one
can later tell what file was being compiled, and with which options.
@item -fvar-tracking @item -fvar-tracking
@opindex fvar-tracking @opindex fvar-tracking
Run variable tracking pass. It computes where variables are stored at each Run variable tracking pass. It computes where variables are stored at each
......
...@@ -198,6 +198,10 @@ static int print_subprocess_help; ...@@ -198,6 +198,10 @@ static int print_subprocess_help;
static int report_times; static int report_times;
/* Whether we should report subprocess execution times to a file. */
FILE *report_times_to_file = NULL;
/* Nonzero means place this string before uses of /, so that include /* Nonzero means place this string before uses of /, so that include
and library files can be found in an alternate location. */ and library files can be found in an alternate location. */
...@@ -3017,7 +3021,8 @@ execute (void) ...@@ -3017,7 +3021,8 @@ execute (void)
/* Run each piped subprocess. */ /* Run each piped subprocess. */
pex = pex_init (PEX_USE_PIPES | (report_times ? PEX_RECORD_TIMES : 0), pex = pex_init (PEX_USE_PIPES | ((report_times || report_times_to_file)
? PEX_RECORD_TIMES : 0),
programname, temp_filename); programname, temp_filename);
if (pex == NULL) if (pex == NULL)
pfatal_with_name (_("pex_init failed")); pfatal_with_name (_("pex_init failed"));
...@@ -3061,7 +3066,7 @@ execute (void) ...@@ -3061,7 +3066,7 @@ execute (void)
if (!pex_get_status (pex, n_commands, statuses)) if (!pex_get_status (pex, n_commands, statuses))
pfatal_with_name (_("failed to get exit status")); pfatal_with_name (_("failed to get exit status"));
if (report_times) if (report_times || report_times_to_file)
{ {
times = (struct pex_time *) alloca (n_commands * sizeof (struct pex_time)); times = (struct pex_time *) alloca (n_commands * sizeof (struct pex_time));
if (!pex_get_times (pex, n_commands, times)) if (!pex_get_times (pex, n_commands, times))
...@@ -3106,7 +3111,7 @@ See %s for instructions.", ...@@ -3106,7 +3111,7 @@ See %s for instructions.",
ret_code = -1; ret_code = -1;
} }
if (report_times) if (report_times || report_times_to_file)
{ {
struct pex_time *pt = &times[i]; struct pex_time *pt = &times[i];
double ut, st; double ut, st;
...@@ -3117,7 +3122,43 @@ See %s for instructions.", ...@@ -3117,7 +3122,43 @@ See %s for instructions.",
+ (double) pt->system_microseconds / 1.0e6); + (double) pt->system_microseconds / 1.0e6);
if (ut + st != 0) if (ut + st != 0)
notice ("# %s %.2f %.2f\n", commands[i].prog, ut, st); {
if (report_times)
notice ("# %s %.2f %.2f\n", commands[i].prog, ut, st);
if (report_times_to_file)
{
int c = 0;
const char *const *j;
fprintf (report_times_to_file, "%g %g", ut, st);
for (j = &commands[i].prog; *j; j = &commands[i].argv[++c])
{
const char *p;
for (p = *j; *p; ++p)
if (*p == '"' || *p == '\\' || *p == '$'
|| ISSPACE (*p))
break;
if (*p)
{
fprintf (report_times_to_file, " \"");
for (p = *j; *p; ++p)
{
if (*p == '"' || *p == '\\' || *p == '$')
fputc ('\\', report_times_to_file);
fputc (*p, report_times_to_file);
}
fputc ('"', report_times_to_file);
}
else
fprintf (report_times_to_file, " %s", *j);
}
fputc ('\n', report_times_to_file);
}
}
} }
} }
...@@ -3876,6 +3917,12 @@ process_command (int argc, const char **argv) ...@@ -3876,6 +3917,12 @@ process_command (int argc, const char **argv)
} }
else if (strcmp (argv[i], "-time") == 0) else if (strcmp (argv[i], "-time") == 0)
report_times = 1; report_times = 1;
else if (strncmp (argv[i], "-time=", sizeof ("-time=") - 1) == 0)
{
if (report_times_to_file)
fclose (report_times_to_file);
report_times_to_file = fopen (argv[i] + sizeof ("-time=") - 1, "a");
}
else if (strcmp (argv[i], "-pipe") == 0) else if (strcmp (argv[i], "-pipe") == 0)
{ {
/* -pipe has to go into the switches array as well as /* -pipe has to go into the switches array as well as
...@@ -4288,6 +4335,8 @@ process_command (int argc, const char **argv) ...@@ -4288,6 +4335,8 @@ process_command (int argc, const char **argv)
; ;
else if (strcmp (argv[i], "-time") == 0) else if (strcmp (argv[i], "-time") == 0)
; ;
else if (strncmp (argv[i], "-time=", sizeof ("-time=") - 1) == 0)
;
else if (strcmp (argv[i], "-###") == 0) else if (strcmp (argv[i], "-###") == 0)
; ;
else if (argv[i][0] == '-' && argv[i][1] != 0) else if (argv[i][0] == '-' && argv[i][1] != 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment